1
1
// Start as WiFi station
2
2
3
- bool startWifiStation (){
3
+ bool startWifiStation (bool stopble , bool startwebserver ){
4
4
5
5
Serial .printf ("[INFO]: Connecting to %s" , wificonfig .ssid );
6
6
if (String (WiFi .SSID ()) != String (wificonfig .ssid ))
@@ -22,30 +22,32 @@ bool startWifiStation(){
22
22
23
23
}
24
24
}
25
-
26
- // Delete the task bleKeyboard had create to free memory and to not interfere with AsyncWebServer
27
- bleKeyboard .end ();
28
-
29
- // Stop BLE from interfering with our WIFI signal
30
- btStop ();
31
- esp_bt_controller_disable ();
32
- esp_bt_controller_deinit ();
33
- esp_bt_controller_mem_release (ESP_BT_MODE_BTDM );
34
-
35
- Serial .println ("" );
36
- Serial .println ("[INFO]: BLE Stopped" );
25
+ if (stopble ){
26
+ // Delete the task bleKeyboard had create to free memory and to not interfere with AsyncWebServer
27
+ bleKeyboard .end ();
28
+
29
+ // Stop BLE from interfering with our WIFI signal
30
+ btStop ();
31
+ esp_bt_controller_disable ();
32
+ esp_bt_controller_deinit ();
33
+ esp_bt_controller_mem_release (ESP_BT_MODE_BTDM );
34
+
35
+ Serial .println ("" );
36
+ Serial .println ("[INFO]: BLE Stopped" );
37
+ // Set pageNum to 7 so no buttons are displayed and touches are ignored
38
+ pageNum = 7 ;
39
+ }
37
40
Serial .print ("[INFO]: Connected! IP address: " );
38
41
Serial .println (WiFi .localIP ());
39
-
40
- MDNS .begin (wificonfig .hostname );
41
- MDNS .addService ("http" , "tcp" , 80 );
42
-
43
- // Set pageNum to 7 so no buttons are displayed and touches are ignored
44
- pageNum = 7 ;
45
42
46
- // Start the webserver
47
- webserver .begin ();
48
- Serial .println ("[INFO]: Webserver started" );
43
+ if (startwebserver ){
44
+ // Open port 80
45
+ MDNS .begin (wificonfig .hostname );
46
+ MDNS .addService ("http" , "tcp" , 80 );
47
+ // Start the webserver
48
+ webserver .begin ();
49
+ Serial .println ("[INFO]: Webserver started" );
50
+ }
49
51
return true;
50
52
}
51
53
@@ -170,7 +172,7 @@ void configmode()
170
172
171
173
if (strcmp (wificonfig .wifimode , "WIFI_STA" ) == 0 )
172
174
{
173
- if (!startWifiStation ()){
175
+ if (!startWifiStation (true, true )){
174
176
startDefaultAP ();
175
177
Serial .println ("[WARNING]: Could not connect to AP, so started as AP." );
176
178
tft .println ("Started as AP because WiFi connection failed." );
0 commit comments