Skip to content

Commit

Permalink
WITH_AP_BUTTON => Turn on the WiFi AP only when user button is presse…
Browse files Browse the repository at this point in the history
…d during startup
  • Loading branch information
pjalocha committed Apr 4, 2021
1 parent 08b6b99 commit dcd97b1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions main/hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ void LED_RX_Flash(uint8_t Time=100);

void LED_TimerCheck(uint8_t Ticks=1);

bool Button_isPressed(void);
// extern bool Button_SleepRequest;
int32_t Button_TimerCheck(uint8_t Ticks=1);

Expand Down
6 changes: 5 additions & 1 deletion main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ void app_main(void)
xTaskCreate(vTaskSTX, "STX", 4000, 0, tskIDLE_PRIORITY+3, 0);
#endif
#ifdef WITH_AP
if(Parameters.APname[0])
#ifdef WITH_AP_BUTTON
if(Button_isPressed() && Parameters.APname[0]) // start WiFi AP when button pressed during startup and APname non-empty
#else
if(Parameters.APname[0]) // start WiFi AP when APname non-empty
#endif
xTaskCreate(vTaskAP, "AP", 4000, 0, tskIDLE_PRIORITY+3, 0);
#endif
#if defined(WITH_OLED) || defined(WITH_U8G2_OLED) || defined(WITH_ST7789) || defined(WITH_ILI9341)
Expand Down
2 changes: 1 addition & 1 deletion main/wifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ esp_err_t WIFI_StartAP(const char *SSID, const char *Pass, int MaxConnections)
// IP4_ADDR(&IPinfo.gw, 192,168,1,1);
// IP4_ADDR(&IPinfo.netmask, 255,255,255,0);
// tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_AP, &IPinfo);
Err = esp_wifi_set_mode(WIFI_MODE_AP); if(Err!=ESP_OK) return Err; // which one should come first: set_mode or set_config ?
Err = esp_wifi_set_config(ESP_IF_WIFI_AP, &WIFI_Config); if(Err!=ESP_OK) return Err;
Err = esp_wifi_set_mode(WIFI_MODE_AP); if(Err!=ESP_OK) return Err;
Err = esp_wifi_start();
return Err; }

Expand Down

0 comments on commit dcd97b1

Please sign in to comment.