Skip to content

Commit 8b05d3d

Browse files
committed
Changed startWifiStation()
to have the option to keep the BLE keyboard running and not starting the webserver. Trying to add API calls support.
1 parent 033e9fe commit 8b05d3d

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

ConfigHelper.h

+25-23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Start as WiFi station
22

3-
bool startWifiStation(){
3+
bool startWifiStation(bool stopble, bool startwebserver){
44

55
Serial.printf("[INFO]: Connecting to %s", wificonfig.ssid);
66
if (String(WiFi.SSID()) != String(wificonfig.ssid))
@@ -22,30 +22,32 @@ bool startWifiStation(){
2222

2323
}
2424
}
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+
}
3740
Serial.print("[INFO]: Connected! IP address: ");
3841
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;
4542

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+
}
4951
return true;
5052
}
5153

@@ -170,7 +172,7 @@ void configmode()
170172

171173
if (strcmp(wificonfig.wifimode, "WIFI_STA") == 0)
172174
{
173-
if(!startWifiStation()){
175+
if(!startWifiStation(true, true)){
174176
startDefaultAP();
175177
Serial.println("[WARNING]: Could not connect to AP, so started as AP.");
176178
tft.println("Started as AP because WiFi connection failed.");

FreeTouchDeck.ino

+4
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ const char *versionnumber = "0.9.18a";
7373

7474
/* Version 0.9.18a.
7575
*
76+
* Added option to start WiFi, without stopping BLE and starting webserver
77+
* startWifiStation(false, false) will keep Keyboard in combination with WiFi
78+
* this is to try and add API calls together with BLE Keyboard. For this, use
79+
* the original T-vK BLE Keyboard library.
7680
* Adding ESP32-S3 support
7781
* Trying to add LitteFS Support
7882
* Fix #89

0 commit comments

Comments
 (0)