@@ -145,8 +145,10 @@ void wifiStartAP()
145145#define WIFI_PASSWORD " parachutes"
146146 WiFi.mode (WIFI_STA);
147147
148+ #ifdef COMPILE_ESPNOW
148149 // Return protocol to default settings (no WIFI_PROTOCOL_LR for ESP NOW)
149150 esp_wifi_set_protocol (WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N);
151+ #endif
150152
151153 WiFi.begin (WIFI_SSID, WIFI_PASSWORD);
152154 Serial.print (" Wi-Fi connecting to" );
@@ -161,8 +163,10 @@ void wifiStartAP()
161163 // Start in AP mode
162164 WiFi.mode (WIFI_AP);
163165
166+ #ifdef COMPILE_ESPNOW
164167 // Return protocol to default settings (no WIFI_PROTOCOL_LR for ESP NOW)
165168 esp_wifi_set_protocol (WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N);
169+ #endif
166170
167171 IPAddress local_IP (192 , 168 , 4 , 1 );
168172 IPAddress gateway (192 , 168 , 1 , 1 );
@@ -203,12 +207,20 @@ void wifiStart(char* ssid, char* pw)
203207#ifdef COMPILE_WIFI
204208 if ((wifiState == WIFI_OFF) || (wifiState == WIFI_ON))
205209 {
210+ #ifdef COMPILE_ESPNOW
206211 // If ESP-Now is active, reconfigure protocols
207212 if (espnowState > ESPNOW_OFF)
208213 {
214+ Serial.println (" Mixing WiFi into ESPNOW setup" );
209215 // Enable WiFi + ESP-Now
210216 esp_wifi_set_protocol (WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N | WIFI_PROTOCOL_LR);
211217 }
218+ else
219+ {
220+ // Radio is off, turn it on
221+ WiFi.mode (WIFI_STA);
222+ }
223+ #endif
212224
213225 Serial.printf (" Wi-Fi connecting to %s\r\n " , ssid);
214226 WiFi.begin (ssid, pw);
@@ -233,6 +245,8 @@ void wifiStop()
233245 {
234246 // Do nothing
235247 }
248+
249+ #ifdef COMPILE_ESPNOW
236250 // If WiFi is on but ESP NOW is off, then turn off radio entirely
237251 else if (espnowState == ESPNOW_OFF)
238252 {
@@ -252,6 +266,12 @@ void wifiStop()
252266
253267 Serial.println (" Wi-Fi disabled, ESP-Now left in place" );
254268 }
269+ #else
270+ // Turn off radio
271+ WiFi.mode (WIFI_OFF);
272+ wifiSetState (WIFI_OFF);
273+ Serial.println (" Wi-Fi Stopped" );
274+ #endif
255275
256276 // Display the heap state
257277 reportHeapNow ();
0 commit comments