add BLE to all ESP32-S3 based AP's (default disabled; enable in the config screen if needed)

This commit is contained in:
Nic Limper
2024-02-24 14:01:27 +01:00
parent c0e59dadb4
commit 9137c5acb1
8 changed files with 30 additions and 1 deletions

View File

@@ -67,6 +67,7 @@ struct Config {
char timeZone[52];
uint8_t sleepTime1;
uint8_t sleepTime2;
uint8_t ble;
String repo;
String env;
};

View File

@@ -137,6 +137,7 @@ build_flags =
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
-D POWER_RAMPING
-D POWER_HIGH_SIDE_DRIVER
-D HAS_BLE_WRITER
-D FLASHER_AP_SS=4
-D FLASHER_AP_CLK=5
-D FLASHER_AP_MOSI=7
@@ -225,6 +226,7 @@ build_flags =
-D POWER_NO_SOFT_POWER
-D BOARD_HAS_PSRAM
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
-D HAS_BLE_WRITER
-D FLASHER_AP_SS=-1
-D FLASHER_AP_CLK=-1
-D FLASHER_AP_MOSI=-1
@@ -385,6 +387,7 @@ build_flags =
-D POWER_RAMPING
-D POWER_HIGH_SIDE_DRIVER
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
-D HAS_BLE_WRITER
-D FLASHER_AP_SS=-1
-D FLASHER_AP_CLK=-1
-D FLASHER_AP_MOSI=-1

View File

@@ -147,6 +147,7 @@ void BLE_startScan(uint32_t timeout) {
void BLETask(void* parameter) {
vTaskDelay(5000 / portTICK_PERIOD_MS);
Serial.println("BLE task started");
BLEDevice::init("");
while (1) {
switch (ble_main_state) {

View File

@@ -139,7 +139,9 @@ void setup() {
vTaskDelay(10 / portTICK_PERIOD_MS);
#ifdef HAS_BLE_WRITER
xTaskCreate(BLETask, "BLE Writer", 12000, NULL, 5, NULL);
if (config.ble) {
xTaskCreate(BLETask, "BLE Writer", 12000, NULL, 5, NULL);
}
#endif
#ifdef HAS_USB

View File

@@ -325,6 +325,7 @@ void initAPconfig() {
config.lock = APconfig.containsKey("lock") ? APconfig["lock"] : 0;
config.sleepTime1 = APconfig.containsKey("sleeptime1") ? APconfig["sleeptime1"] : 0;
config.sleepTime2 = APconfig.containsKey("sleeptime2") ? APconfig["sleeptime2"] : 0;
config.ble = APconfig.containsKey("ble") ? APconfig["ble"] : 0;
// default wifi power 8.5 dbM
// see https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFiGeneric.h#L111
config.wifiPower = APconfig.containsKey("wifipower") ? APconfig["wifipower"] : 34;
@@ -354,6 +355,7 @@ void saveAPconfig() {
APconfig["timezone"] = config.timeZone;
APconfig["sleeptime1"] = config.sleepTime1;
APconfig["sleeptime2"] = config.sleepTime2;
APconfig["ble"] = config.ble;
APconfig["repo"] = config.repo;
APconfig["env"] = config.env;
serializeJsonPretty(APconfig, configFile);

View File

@@ -503,6 +503,11 @@ void init_web() {
response->print("\"hasFlasher\": \"1\", ");
#else
response->print("\"hasFlasher\": \"0\", ");
#endif
#ifdef HAS_BLE_WRITER
response->print("\"hasBLE\": \"1\", ");
#else
response->print("\"hasBLE\": \"0\", ");
#endif
response->print("\"apstate\": \"" + String(apInfo.state) + "\"");
@@ -561,6 +566,9 @@ void init_web() {
if (request->hasParam("lock", true)) {
config.lock = static_cast<uint8_t>(request->getParam("lock", true)->value().toInt());
}
if (request->hasParam("ble", true)) {
config.ble = static_cast<uint8_t>(request->getParam("ble", true)->value().toInt());
}
if (request->hasParam("sleeptime1", true)) {
config.sleepTime1 = static_cast<uint8_t>(request->getParam("sleeptime1", true)->value().toInt());
config.sleepTime2 = static_cast<uint8_t>(request->getParam("sleeptime2", true)->value().toInt());

View File

@@ -289,6 +289,13 @@ options:
<option value="27">27</option>
</select>
</p>
<p title="Enable Bluetooth (BLE) support. Only enable this if you have BLE capable tags. Changing this value requires a reboot to take effect.">
<label for="apcfgble">Bluetooth</label>
<select id="apcfgble">
<option value="1">enabled</option>
<option value="0" selected>disabled</option>
</select>
</p>
<p>
<label for="apcfgledbrightness">RGB LED brightness</label>
<select id="apcfgledbrightness">

View File

@@ -61,6 +61,9 @@ window.addEventListener("loadConfig", function () {
if (data.hasFlasher) {
$('[data-target="flashtab"]').style.display = 'block';
}
if (data.hasBLE == 0) {
$("#apcfgble").parentNode.style.display = 'none';
}
if (data.savespace) {
}
if (data.apstate) {
@@ -727,6 +730,7 @@ document.addEventListener("loadTab", function (event) {
apConfig = data;
$('#apcfgalias').value = data.alias;
$('#apcfgchid').value = data.channel;
$('#apcfgble').value = data.ble;
$("#apcfgledbrightness").value = data.led;
$("#apcfgtftbrightness").value = data.tft;
$("#apcfglanguage").value = data.language;
@@ -761,6 +765,7 @@ $('#apcfgsave').onclick = function () {
let formData = new FormData();
formData.append("alias", $('#apcfgalias').value);
formData.append("channel", $('#apcfgchid').value);
formData.append('ble', $('#apcfgble').value);
formData.append('led', $('#apcfgledbrightness').value);
formData.append('tft', $('#apcfgtftbrightness').value);
formData.append('language', $('#apcfglanguage').value);