Skip to content

Commit

Permalink
ESP32C3: don't kick connected BLE devices off if reset() is called
Browse files Browse the repository at this point in the history
ESP32C3: disable warnings about "BT_BTM: BTM_GetSecurityFlags false"
  • Loading branch information
gfwilliams committed Oct 16, 2024
1 parent 70e8f9e commit 990adf4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
Bangle.js2: DFU update from flash now retries if CRC doesn't match
Bangle.js2: Bootloader now shows 'Hold button to turn on' to avoid users assuming it is dead when it's not
Bangle.js2: Bootloader now 'Hold BTN to reboot' not 'BTN1 = REBOOT'/etc
ESP32C3: don't kick connected BLE devices off if reset() is called
ESP32C3: disable warnings about "BT_BTM: BTM_GetSecurityFlags false"

2v24 : Bangle.js2: Add 'Bangle.touchRd()', 'Bangle.touchWr()'
Bangle.js2: After Bangle.showTestScreen, put Bangle.js into a hard off state (not soft off)
Expand Down
9 changes: 6 additions & 3 deletions targets/esp32/BLE/esp32_gatts_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,10 @@ static void gatts_disconnect_handler(esp_gatts_cb_event_t event, esp_gatt_if_t g
}
void gatts_reg_app(){
esp_err_t r;
if(ble_service_pos < ble_service_cnt){
if(ble_service_pos < ble_service_cnt) {
r = esp_ble_gatts_app_register(ble_service_pos);
if(r) jsWarn("app_register error:%d\n",r);
}
else{
} else {
bluetooth_gap_startAdvertising(true);
jshSetDeviceInitialised(EV_BLUETOOTH, true);
}
Expand Down Expand Up @@ -649,6 +648,10 @@ void gatts_set_services(JsVar *data){
jsvUnLock(options);
}
void gatts_reset(bool removeValues){
if (!removeValues && gatts_if_connected()) {
jsWarn("Not removing services for reset() as connected");
return;
}
esp_err_t r;
_removeValues = removeValues;
if(ble_service_cnt > 0){
Expand Down
5 changes: 4 additions & 1 deletion targets/esp32/bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ uint32_t jsble_set_rssi_scan(bool enabled){
void jsble_set_services(JsVar *data){
if(!ESP32_Get_NVS_Status(ESP_NETWORK_BLE))
return; // ESP32.enableBLE(false)

if (jsble_has_peripheral_connection()) {
jsWarn("Skip jsble_set_services as connected");
return;
}
gatts_set_services(data);
}

Expand Down
4 changes: 3 additions & 1 deletion targets/esp32/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ char* romdata_jscode=0;
*/
int app_main(void)
{
esp_log_level_set("*", ESP_LOG_ERROR); // set all components to ERROR level - suppress Wifi Info
esp_log_level_set("*", ESP_LOG_VERBOSE); // set all components to ERROR level - suppress Wifi Info
esp_log_level_set("BT_BTM", ESP_LOG_NONE); // Kill "BT_BTM: BTM_GetSecurityFlags false" BLE errors

esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
Expand Down

0 comments on commit 990adf4

Please sign in to comment.