@@ -95,14 +95,16 @@ int ESPHostLwIP::disconnectEventCb(CCtrlMsgWrapper *resp) {
95
95
}
96
96
97
97
bool ESPHostLwIP::initHW () {
98
- if (wifiHwInitialized)
98
+ if (wifiHwInitialized) {
99
99
return true ;
100
+ }
100
101
instance = this ;
101
102
102
103
CEspControl::getInstance ().listenForStationDisconnectEvent (disconnectEventCb);
103
104
CEspControl::getInstance ().listenForInitEvent (initEventCb);
104
- if (CEspControl::getInstance ().initSpiDriver () != 0 )
105
+ if (CEspControl::getInstance ().initSpiDriver () != 0 ) {
105
106
return false ;
107
+ }
106
108
107
109
uint32_t start = millis ();
108
110
while (!wifiHwInitialized && (millis () - start < timeout)) {
@@ -117,8 +119,9 @@ bool ESPHostLwIP::initHW() {
117
119
}
118
120
119
121
bool ESPHostLwIP::begin () {
120
- if (!initHW ())
122
+ if (!initHW ()) {
121
123
return false ;
124
+ }
122
125
ethernet_arch_lwip_begin ();
123
126
if (!apMode) {
124
127
CEspControl::getInstance ().setWifiMode (WIFI_MODE_STA);
@@ -131,7 +134,7 @@ bool ESPHostLwIP::begin() {
131
134
} else {
132
135
CEspControl::getInstance ().setWifiMode (WIFI_MODE_AP);
133
136
if (softAP.channel == 0 || softAP.channel > MAX_CHNL_NO) {
134
- softAP.channel = 1 ;
137
+ softAP.channel = 1 ;
135
138
}
136
139
softAP.max_connections = MAX_SOFTAP_CONNECTION_DEF;
137
140
softAP.encryption_mode = softAP.pwd [0 ] == 0 ? WIFI_AUTH_OPEN : WIFI_AUTH_WPA_WPA2_PSK;
@@ -198,8 +201,9 @@ uint8_t ESPHostLwIP::status() {
198
201
}
199
202
200
203
uint8_t * ESPHostLwIP::macAddress (bool apMode, uint8_t *mac) {
201
- if (!initHW ())
204
+ if (!initHW ()) {
202
205
return mac;
206
+ }
203
207
WifiMac_t MAC;
204
208
MAC.mode = apMode ? WIFI_MODE_AP : WIFI_MODE_STA;
205
209
ethernet_arch_lwip_begin ();
@@ -220,8 +224,9 @@ int ESPHostLwIP::channel() {
220
224
}
221
225
222
226
int32_t ESPHostLwIP::RSSI () {
223
- if (!joined)
227
+ if (!joined) {
224
228
return 0 ;
229
+ }
225
230
ethernet_arch_lwip_begin ();
226
231
CEspControl::getInstance ().getAccessPointConfig (ap);
227
232
ethernet_arch_lwip_end ();
@@ -254,15 +259,18 @@ uint8_t ESPHostLwIP::encryptionType() {
254
259
}
255
260
256
261
int8_t ESPHostLwIP::scanNetworks (bool async) {
262
+ (void ) async;
257
263
accessPoints.clear ();
258
- if (!initHW ())
264
+ if (!initHW ()) {
259
265
return -1 ;
266
+ }
260
267
ethernet_arch_lwip_begin ();
261
268
int res = CEspControl::getInstance ().getAccessPointScanList (accessPoints);
262
269
ethernet_arch_lwip_end ();
263
270
wifiStatus = WL_SCAN_COMPLETED;
264
- if (res != ESP_CONTROL_OK)
271
+ if (res != ESP_CONTROL_OK) {
265
272
return -1 ;
273
+ }
266
274
return accessPoints.size ();
267
275
}
268
276
@@ -310,8 +318,9 @@ int32_t ESPHostLwIP::RSSI(uint8_t networkItem) {
310
318
}
311
319
312
320
void ESPHostLwIP::lowPowerMode () {
313
- if (!initHW ())
321
+ if (!initHW ()) {
314
322
return ;
323
+ }
315
324
ethernet_arch_lwip_begin ();
316
325
CEspControl::getInstance ().setPowerSaveMode (1 );
317
326
ethernet_arch_lwip_end ();
0 commit comments