【已解决】BLE蓝牙掉电绑定信息消失的问题求助
【已解决】BLE蓝牙掉电绑定信息消失的问题求助
开发环境:ESP IDF 4.4.2 开发板:ESP32-S3-DevKitC-1 v1.1 PC:win11 在编译测试gatt_security_server这个工程的时候,使用BLE4.2.在测试手机连接后,重启ESP32S3,板子上的绑定信息就丢失了。还有我添加到白名单的地址也会随着重启消失。白名单我可以通过NVS记录,但是绑定的密钥信息我无法存储。我查阅了BLE的接口文档,没有看到保存绑定信息的接口。请教一下我应该怎么搞。
Last edited by xinhaojie on Sat Sep 03, 2022 1:48 pm, edited 1 time in total.
Re: BLE蓝牙掉电绑定信息消失的问题求助
还有一个问题,就是我在使用BLE调试助手这个APP在连接esp32s3时每次都需要让我确认两次配对信息。使用手机里面蓝牙设置页面第一次连接时只需要确认配对一次就行了。这是我什么地方没有设置好吗?
Re: BLE蓝牙掉电绑定信息消失的问题求助
我这边使用 esp32s3 开发板测试ESP IDF 4.4.2下的 gatt_security_server 示例没有遇到这个问题; 重启esp32s3, 手机再次与之相连,绑定地址是之前配对手机的,绑定设备数目也是 1 个 在 gatt_security_server 中这个 remove_all_bonded_devices() https://github.com/espressif/esp-idf/bl ... emo.c#L581 API 是可以删除绑定设备信息的,但是这部分代码是默认屏蔽的
Re: BLE蓝牙掉电绑定信息消失的问题求助
你看下我得操作步骤:
1、用示例工程生成一个ble4.2的server工程
2、在main_app函数中加上show_bonded_devices(); 3、设置ble地址为固定地址,防止每次都产生一个新的蓝牙记录。 4、然后编译烧写后,第一次打开用手机系统的蓝牙设置连接一下。
5、重启设备,先不用手机连接,观察show_bonded_devices() 函数的打印信息。
-------------------------------------------------一下是日志----------------------------------------------------
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x18 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
Octal Flash Mode Enabled
For OPI Flash, Use Default Flash Boot Mode
mode:SLOW_RD, clock div:1
load:0x3fce3808,len:0x1654
load:0x403c9700,len:0xbb8
load:0x403cc700,len:0x2f88
SHA-256 comparison failed:
Calculated: b7ce2f7693df2d6f0d0090eeaf59e9d7f3dc2aa28824f5729293528e3c41f764
Expected: 1d9205207d8d1080d6f0cfe002218a5b76dfac59ac50890fc374c07311e16718
Attempting to boot anyway...
entry 0x403c9954
I (50) boot: ESP-IDF v4.4.2-dirty 2nd stage bootloader
I (51) boot: compile time 18:00:25
I (51) boot: chip revision: 0
I (53) boot.esp32s3: Boot SPI Speed : 80MHz
I (58) boot.esp32s3: SPI Mode : SLOW READ
I (63) boot.esp32s3: SPI Flash Size : 4MB
I (67) boot: Enabling RNG early entropy source...
I (73) boot: Partition Table:
I (76) boot: ## Label Usage Type ST Offset Length
I (84) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (91) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (99) boot: 2 factory factory app 00 00 00010000 00100000
I (106) boot: End of partition table
I (110) esp_image: segment 0: paddr=00010020 vaddr=3c080020 size=1c7ach (116652) map
I (146) esp_image: segment 1: paddr=0002c7d4 vaddr=3fc945b0 size=03844h ( 14404) load
I (150) esp_image: segment 2: paddr=00030020 vaddr=42000020 size=713b0h (463792) map
I (261) esp_image: segment 3: paddr=000a13d8 vaddr=3fc97df4 size=000d8h ( 216) load
I (262) esp_image: segment 4: paddr=000a14b8 vaddr=40374000 size=105b0h ( 66992) load
I (285) esp_image: segment 5: paddr=000b1a70 vaddr=50000000 size=00010h ( 16) load
I (292) boot: Loaded app from partition at offset 0x10000
I (292) boot: Disabling RNG early entropy source...
I (306) cpu_start: Pro cpu up.
I (306) cpu_start: Starting app cpu, entry point is 0x40375194
0x40375194: call_start_cpu1 at D:/software/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/port/cpu_start.c:160
I (0) cpu_start: App cpu up.
I (320) cpu_start: Pro cpu start user code
I (320) cpu_start: cpu freq: 160000000
I (320) cpu_start: Application information:
I (322) cpu_start: Project name: sec_gatts_demo
I (328) cpu_start: App version: 1
I (332) cpu_start: Compile time: Sep 1 2022 18:00:04
I (339) cpu_start: ELF file SHA256: 0bb7ff711e029e97...
I (345) cpu_start: ESP-IDF: v4.4.2-dirty
I (350) heap_init: Initializing. RAM available for dynamic allocation:
I (357) heap_init: At 3FC9BD40 len 000442C0 (272 KiB): D/IRAM
I (364) heap_init: At 3FCE0000 len 0000EE34 (59 KiB): STACK/DRAM
I (370) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (377) spi_flash: detected chip: mxic
W (381) spi_flash: Detected flash size > 16 MB, but access beyond 16 MB is not supported for this flash model yet.
I (392) spi_flash: flash io: dio
W (396) spi_flash: Detected size(32768k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
I (410) sleep: Configure to isolate all GPIO pins in sleep state
I (416) sleep: Enable automatic switching of GPIO sleep configuration
I (423) coexist: coexist rom version e7ae62f
I (428) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
W (469) BT_INIT: esp_bt_controller_mem_release not implemented, return OK
I (469) BT_INIT: BT controller compile version [05195c9]
I (469) phy_init: phy_version 503,13653eb,Jun 1 2022,17:47:08
W (479) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
I (529) system_api: Base MAC address is not set
I (529) system_api: read default base MAC address from EFUSE
I (529) BT_INIT: Bluetooth MAC: 7c:df:a1:e1:10:c6
I (539) SEC_GATTS_DEMO: app_main init bluetooth
I (579) SEC_GATTS_DEMO: The number handle = 8
I (589) SEC_GATTS_DEMO: advertising start success
I (589) SEC_GATTS_DEMO: Bonded devices number : 0
I (589) SEC_GATTS_DEMO: Bonded devices list : 0
I (4129) SEC_GATTS_DEMO: ESP_GATTS_CONNECT_EVT
W (5619) BT_SMP: FOR LE SC LTK IS USED INSTEAD OF STK
I (5749) SEC_GATTS_DEMO: key type = ESP_LE_KEY_LENC
I (5749) SEC_GATTS_DEMO: key type = ESP_LE_KEY_PENC
I (5749) SEC_GATTS_DEMO: key type = ESP_LE_KEY_LID
I (5849) SEC_GATTS_DEMO: key type = ESP_LE_KEY_PID
I (5879) SEC_GATTS_DEMO: remote BD_ADDR: 579159b80052
I (5879) SEC_GATTS_DEMO: address type = 1
I (5879) SEC_GATTS_DEMO: pair status = success
I (5879) SEC_GATTS_DEMO: auth mode = ESP_LE_AUTH_REQ_SC_BOND
I (5889) SEC_GATTS_DEMO: Bonded devices number : 1
I (5889) SEC_GATTS_DEMO: Bonded devices list : 1
I (5899) SEC_GATTS_DEMO: 57 91 59 b8 00 52
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x18 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
Octal Flash Mode Enabled
For OPI Flash, Use Default Flash Boot Mode
mode:SLOW_RD, clock div:1
load:0x3fce3808,len:0x1654
load:0x403c9700,len:0xbb8
load:0x403cc700,len:0x2f88
SHA-256 comparison failed:
Calculated: b7ce2f7693df2d6f0d0090eeaf59e9d7f3dc2aa28824f5729293528e3c41f764
Expected: 1d9205207d8d1080d6f0cfe002218a5b76dfac59ac50890fc374c07311e16718
Attempting to boot anyway...
entry 0x403c9954
I (50) boot: ESP-IDF v4.4.2-dirty 2nd stage bootloader
I (51) boot: compile time 18:00:25
I (51) boot: chip revision: 0
I (53) boot.esp32s3: Boot SPI Speed : 80MHz
I (58) boot.esp32s3: SPI Mode : SLOW READ
I (63) boot.esp32s3: SPI Flash Size : 4MB
I (67) boot: Enabling RNG early entropy source...
I (73) boot: Partition Table:
I (76) boot: ## Label Usage Type ST Offset Length
I (84) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (91) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (99) boot: 2 factory factory app 00 00 00010000 00100000
I (106) boot: End of partition table
I (110) esp_image: segment 0: paddr=00010020 vaddr=3c080020 size=1c7ach (116652) map
I (146) esp_image: segment 1: paddr=0002c7d4 vaddr=3fc945b0 size=03844h ( 14404) load
I (150) esp_image: segment 2: paddr=00030020 vaddr=42000020 size=713b0h (463792) map
I (261) esp_image: segment 3: paddr=000a13d8 vaddr=3fc97df4 size=000d8h ( 216) load
I (262) esp_image: segment 4: paddr=000a14b8 vaddr=40374000 size=105b0h ( 66992) load
I (285) esp_image: segment 5: paddr=000b1a70 vaddr=50000000 size=00010h ( 16) load
I (292) boot: Loaded app from partition at offset 0x10000
I (292) boot: Disabling RNG early entropy source...
I (306) cpu_start: Pro cpu up.
I (306) cpu_start: Starting app cpu, entry point is 0x40375194
0x40375194: call_start_cpu1 at D:/software/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/port/cpu_start.c:160
I (0) cpu_start: App cpu up.
I (320) cpu_start: Pro cpu start user code
I (320) cpu_start: cpu freq: 160000000
I (320) cpu_start: Application information:
I (322) cpu_start: Project name: sec_gatts_demo
I (328) cpu_start: App version: 1
I (332) cpu_start: Compile time: Sep 1 2022 18:00:04
I (339) cpu_start: ELF file SHA256: 0bb7ff711e029e97...
I (345) cpu_start: ESP-IDF: v4.4.2-dirty
I (350) heap_init: Initializing. RAM available for dynamic allocation:
I (357) heap_init: At 3FC9BD40 len 000442C0 (272 KiB): D/IRAM
I (364) heap_init: At 3FCE0000 len 0000EE34 (59 KiB): STACK/DRAM
I (370) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (377) spi_flash: detected chip: mxic
W (381) spi_flash: Detected flash size > 16 MB, but access beyond 16 MB is not supported for this flash model yet.
I (392) spi_flash: flash io: dio
W (396) spi_flash: Detected size(32768k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
I (410) sleep: Configure to isolate all GPIO pins in sleep state
I (416) sleep: Enable automatic switching of GPIO sleep configuration
I (423) coexist: coexist rom version e7ae62f
I (428) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
W (469) BT_INIT: esp_bt_controller_mem_release not implemented, return OK
I (469) BT_INIT: BT controller compile version [05195c9]
I (469) phy_init: phy_version 503,13653eb,Jun 1 2022,17:47:08
W (479) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
I (529) system_api: Base MAC address is not set
I (529) system_api: read default base MAC address from EFUSE
I (529) BT_INIT: Bluetooth MAC: 7c:df:a1:e1:10:c6
I (529) SEC_GATTS_DEMO: app_main init bluetooth
I (579) SEC_GATTS_DEMO: The number handle = 8
I (589) SEC_GATTS_DEMO: advertising start success
I (589) SEC_GATTS_DEMO: Bonded devices number : 0
I (589) SEC_GATTS_DEMO: Bonded devices list : 0
--------------------------------------以上是日志------------------------------------------------
1、用示例工程生成一个ble4.2的server工程
2、在main_app函数中加上show_bonded_devices(); 3、设置ble地址为固定地址,防止每次都产生一个新的蓝牙记录。 4、然后编译烧写后,第一次打开用手机系统的蓝牙设置连接一下。
5、重启设备,先不用手机连接,观察show_bonded_devices() 函数的打印信息。
-------------------------------------------------一下是日志----------------------------------------------------
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x18 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
Octal Flash Mode Enabled
For OPI Flash, Use Default Flash Boot Mode
mode:SLOW_RD, clock div:1
load:0x3fce3808,len:0x1654
load:0x403c9700,len:0xbb8
load:0x403cc700,len:0x2f88
SHA-256 comparison failed:
Calculated: b7ce2f7693df2d6f0d0090eeaf59e9d7f3dc2aa28824f5729293528e3c41f764
Expected: 1d9205207d8d1080d6f0cfe002218a5b76dfac59ac50890fc374c07311e16718
Attempting to boot anyway...
entry 0x403c9954
I (50) boot: ESP-IDF v4.4.2-dirty 2nd stage bootloader
I (51) boot: compile time 18:00:25
I (51) boot: chip revision: 0
I (53) boot.esp32s3: Boot SPI Speed : 80MHz
I (58) boot.esp32s3: SPI Mode : SLOW READ
I (63) boot.esp32s3: SPI Flash Size : 4MB
I (67) boot: Enabling RNG early entropy source...
I (73) boot: Partition Table:
I (76) boot: ## Label Usage Type ST Offset Length
I (84) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (91) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (99) boot: 2 factory factory app 00 00 00010000 00100000
I (106) boot: End of partition table
I (110) esp_image: segment 0: paddr=00010020 vaddr=3c080020 size=1c7ach (116652) map
I (146) esp_image: segment 1: paddr=0002c7d4 vaddr=3fc945b0 size=03844h ( 14404) load
I (150) esp_image: segment 2: paddr=00030020 vaddr=42000020 size=713b0h (463792) map
I (261) esp_image: segment 3: paddr=000a13d8 vaddr=3fc97df4 size=000d8h ( 216) load
I (262) esp_image: segment 4: paddr=000a14b8 vaddr=40374000 size=105b0h ( 66992) load
I (285) esp_image: segment 5: paddr=000b1a70 vaddr=50000000 size=00010h ( 16) load
I (292) boot: Loaded app from partition at offset 0x10000
I (292) boot: Disabling RNG early entropy source...
I (306) cpu_start: Pro cpu up.
I (306) cpu_start: Starting app cpu, entry point is 0x40375194
0x40375194: call_start_cpu1 at D:/software/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/port/cpu_start.c:160
I (0) cpu_start: App cpu up.
I (320) cpu_start: Pro cpu start user code
I (320) cpu_start: cpu freq: 160000000
I (320) cpu_start: Application information:
I (322) cpu_start: Project name: sec_gatts_demo
I (328) cpu_start: App version: 1
I (332) cpu_start: Compile time: Sep 1 2022 18:00:04
I (339) cpu_start: ELF file SHA256: 0bb7ff711e029e97...
I (345) cpu_start: ESP-IDF: v4.4.2-dirty
I (350) heap_init: Initializing. RAM available for dynamic allocation:
I (357) heap_init: At 3FC9BD40 len 000442C0 (272 KiB): D/IRAM
I (364) heap_init: At 3FCE0000 len 0000EE34 (59 KiB): STACK/DRAM
I (370) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (377) spi_flash: detected chip: mxic
W (381) spi_flash: Detected flash size > 16 MB, but access beyond 16 MB is not supported for this flash model yet.
I (392) spi_flash: flash io: dio
W (396) spi_flash: Detected size(32768k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
I (410) sleep: Configure to isolate all GPIO pins in sleep state
I (416) sleep: Enable automatic switching of GPIO sleep configuration
I (423) coexist: coexist rom version e7ae62f
I (428) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
W (469) BT_INIT: esp_bt_controller_mem_release not implemented, return OK
I (469) BT_INIT: BT controller compile version [05195c9]
I (469) phy_init: phy_version 503,13653eb,Jun 1 2022,17:47:08
W (479) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
I (529) system_api: Base MAC address is not set
I (529) system_api: read default base MAC address from EFUSE
I (529) BT_INIT: Bluetooth MAC: 7c:df:a1:e1:10:c6
I (539) SEC_GATTS_DEMO: app_main init bluetooth
I (579) SEC_GATTS_DEMO: The number handle = 8
I (589) SEC_GATTS_DEMO: advertising start success
I (589) SEC_GATTS_DEMO: Bonded devices number : 0
I (589) SEC_GATTS_DEMO: Bonded devices list : 0
I (4129) SEC_GATTS_DEMO: ESP_GATTS_CONNECT_EVT
W (5619) BT_SMP: FOR LE SC LTK IS USED INSTEAD OF STK
I (5749) SEC_GATTS_DEMO: key type = ESP_LE_KEY_LENC
I (5749) SEC_GATTS_DEMO: key type = ESP_LE_KEY_PENC
I (5749) SEC_GATTS_DEMO: key type = ESP_LE_KEY_LID
I (5849) SEC_GATTS_DEMO: key type = ESP_LE_KEY_PID
I (5879) SEC_GATTS_DEMO: remote BD_ADDR: 579159b80052
I (5879) SEC_GATTS_DEMO: address type = 1
I (5879) SEC_GATTS_DEMO: pair status = success
I (5879) SEC_GATTS_DEMO: auth mode = ESP_LE_AUTH_REQ_SC_BOND
I (5889) SEC_GATTS_DEMO: Bonded devices number : 1
I (5889) SEC_GATTS_DEMO: Bonded devices list : 1
I (5899) SEC_GATTS_DEMO: 57 91 59 b8 00 52
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x18 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
Octal Flash Mode Enabled
For OPI Flash, Use Default Flash Boot Mode
mode:SLOW_RD, clock div:1
load:0x3fce3808,len:0x1654
load:0x403c9700,len:0xbb8
load:0x403cc700,len:0x2f88
SHA-256 comparison failed:
Calculated: b7ce2f7693df2d6f0d0090eeaf59e9d7f3dc2aa28824f5729293528e3c41f764
Expected: 1d9205207d8d1080d6f0cfe002218a5b76dfac59ac50890fc374c07311e16718
Attempting to boot anyway...
entry 0x403c9954
I (50) boot: ESP-IDF v4.4.2-dirty 2nd stage bootloader
I (51) boot: compile time 18:00:25
I (51) boot: chip revision: 0
I (53) boot.esp32s3: Boot SPI Speed : 80MHz
I (58) boot.esp32s3: SPI Mode : SLOW READ
I (63) boot.esp32s3: SPI Flash Size : 4MB
I (67) boot: Enabling RNG early entropy source...
I (73) boot: Partition Table:
I (76) boot: ## Label Usage Type ST Offset Length
I (84) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (91) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (99) boot: 2 factory factory app 00 00 00010000 00100000
I (106) boot: End of partition table
I (110) esp_image: segment 0: paddr=00010020 vaddr=3c080020 size=1c7ach (116652) map
I (146) esp_image: segment 1: paddr=0002c7d4 vaddr=3fc945b0 size=03844h ( 14404) load
I (150) esp_image: segment 2: paddr=00030020 vaddr=42000020 size=713b0h (463792) map
I (261) esp_image: segment 3: paddr=000a13d8 vaddr=3fc97df4 size=000d8h ( 216) load
I (262) esp_image: segment 4: paddr=000a14b8 vaddr=40374000 size=105b0h ( 66992) load
I (285) esp_image: segment 5: paddr=000b1a70 vaddr=50000000 size=00010h ( 16) load
I (292) boot: Loaded app from partition at offset 0x10000
I (292) boot: Disabling RNG early entropy source...
I (306) cpu_start: Pro cpu up.
I (306) cpu_start: Starting app cpu, entry point is 0x40375194
0x40375194: call_start_cpu1 at D:/software/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/port/cpu_start.c:160
I (0) cpu_start: App cpu up.
I (320) cpu_start: Pro cpu start user code
I (320) cpu_start: cpu freq: 160000000
I (320) cpu_start: Application information:
I (322) cpu_start: Project name: sec_gatts_demo
I (328) cpu_start: App version: 1
I (332) cpu_start: Compile time: Sep 1 2022 18:00:04
I (339) cpu_start: ELF file SHA256: 0bb7ff711e029e97...
I (345) cpu_start: ESP-IDF: v4.4.2-dirty
I (350) heap_init: Initializing. RAM available for dynamic allocation:
I (357) heap_init: At 3FC9BD40 len 000442C0 (272 KiB): D/IRAM
I (364) heap_init: At 3FCE0000 len 0000EE34 (59 KiB): STACK/DRAM
I (370) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (377) spi_flash: detected chip: mxic
W (381) spi_flash: Detected flash size > 16 MB, but access beyond 16 MB is not supported for this flash model yet.
I (392) spi_flash: flash io: dio
W (396) spi_flash: Detected size(32768k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
I (410) sleep: Configure to isolate all GPIO pins in sleep state
I (416) sleep: Enable automatic switching of GPIO sleep configuration
I (423) coexist: coexist rom version e7ae62f
I (428) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
W (469) BT_INIT: esp_bt_controller_mem_release not implemented, return OK
I (469) BT_INIT: BT controller compile version [05195c9]
I (469) phy_init: phy_version 503,13653eb,Jun 1 2022,17:47:08
W (479) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
I (529) system_api: Base MAC address is not set
I (529) system_api: read default base MAC address from EFUSE
I (529) BT_INIT: Bluetooth MAC: 7c:df:a1:e1:10:c6
I (529) SEC_GATTS_DEMO: app_main init bluetooth
I (579) SEC_GATTS_DEMO: The number handle = 8
I (589) SEC_GATTS_DEMO: advertising start success
I (589) SEC_GATTS_DEMO: Bonded devices number : 0
I (589) SEC_GATTS_DEMO: Bonded devices list : 0
--------------------------------------以上是日志------------------------------------------------
ESP_XuLZ wrote: ↑Wed Aug 31, 2022 3:28 am我这边使用 esp32s3 开发板测试ESP IDF 4.4.2下的 gatt_security_server 示例没有遇到这个问题; 重启esp32s3, 手机再次与之相连,绑定地址是之前配对手机的,绑定设备数目也是 1 个
企业微信截图_20220831111453.png
企业微信截图_20220831111721.png
在 gatt_security_server 中这个 remove_all_bonded_devices() https://github.com/espressif/esp-idf/bl ... emo.c#L581 API 是可以删除绑定设备信息的,但是这部分代码是默认屏蔽的
Re: BLE蓝牙掉电绑定信息消失的问题求助
弹出两次这个应该是蓝牙APP的问题,我用的那个测试APP的问题。但是我确实遇到了使用测试APP在ESP32S3重启之后,在APP上再次连接会报错然后重新再让我认证的问题。
Re: BLE蓝牙掉电绑定信息消失的问题求助
下面是出现重启之后让我重新绑定的操作过程:(备注,也是官方例程只改了公开地址,和隐私那个false)
1、开启蓝牙,然后使用蓝牙调试软件 BLE调试宝 这个APP连接esp32s3 app显示两次确认连接的对话框。
日志---------------------------------------
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x18 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
Octal Flash Mode Enabled
For OPI Flash, Use Default Flash Boot Mode
mode:SLOW_RD, clock div:1
load:0x3fce3808,len:0x1654
load:0x403c9700,len:0xbb8
load:0x403cc700,len:0x2f88
SHA-256 comparison failed:
Calculated: b7ce2f7693df2d6f0d0090eeaf59e9d7f3dc2aa28824f5729293528e3c41f764
Expected: 1d9205207d8d1080d6f0cfe002218a5b76dfac59ac50890fc374c07311e16718
Attempting to boot anyway...
entry 0x403c9954
I (50) boot: ESP-IDF v4.4.2-dirty 2nd stage bootloader
I (51) boot: compile time 18:00:25
I (51) boot: chip revision: 0
I (53) boot.esp32s3: Boot SPI Speed : 80MHz
I (58) boot.esp32s3: SPI Mode : SLOW READ
I (63) boot.esp32s3: SPI Flash Size : 4MB
I (67) boot: Enabling RNG early entropy source...
I (73) boot: Partition Table:
I (76) boot: ## Label Usage Type ST Offset Length
I (84) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (91) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (99) boot: 2 factory factory app 00 00 00010000 00100000
I (106) boot: End of partition table
I (110) esp_image: segment 0: paddr=00010020 vaddr=3c080020 size=1c7ach (116652) map
I (146) esp_image: segment 1: paddr=0002c7d4 vaddr=3fc945b0 size=03844h ( 14404) load
I (150) esp_image: segment 2: paddr=00030020 vaddr=42000020 size=713b0h (463792) map
I (261) esp_image: segment 3: paddr=000a13d8 vaddr=3fc97df4 size=000d8h ( 216) load
I (262) esp_image: segment 4: paddr=000a14b8 vaddr=40374000 size=105b0h ( 66992) load
I (285) esp_image: segment 5: paddr=000b1a70 vaddr=50000000 size=00010h ( 16) load
I (292) boot: Loaded app from partition at offset 0x10000
I (292) boot: Disabling RNG early entropy source...
I (306) cpu_start: Pro cpu up.
I (306) cpu_start: Starting app cpu, entry point is 0x40375194
0x40375194: call_start_cpu1 at D:/software/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/port/cpu_start.c:160
I (0) cpu_start: App cpu up.
I (320) cpu_start: Pro cpu start user code
I (320) cpu_start: cpu freq: 160000000
I (320) cpu_start: Application information:
I (323) cpu_start: Project name: sec_gatts_demo
I (328) cpu_start: App version: 1
I (332) cpu_start: Compile time: Sep 1 2022 18:00:04
I (339) cpu_start: ELF file SHA256: 0bb7ff711e029e97...
I (345) cpu_start: ESP-IDF: v4.4.2-dirty
I (350) heap_init: Initializing. RAM available for dynamic allocation:
I (357) heap_init: At 3FC9BD40 len 000442C0 (272 KiB): D/IRAM
I (364) heap_init: At 3FCE0000 len 0000EE34 (59 KiB): STACK/DRAM
I (370) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (377) spi_flash: detected chip: mxic
W (381) spi_flash: Detected flash size > 16 MB, but access beyond 16 MB is not supported for this flash model yet.
I (392) spi_flash: flash io: dio
W (396) spi_flash: Detected size(32768k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
I (410) sleep: Configure to isolate all GPIO pins in sleep state
I (416) sleep: Enable automatic switching of GPIO sleep configuration
I (423) coexist: coexist rom version e7ae62f
I (428) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
W (469) BT_INIT: esp_bt_controller_mem_release not implemented, return OK
I (469) BT_INIT: BT controller compile version [05195c9]
I (469) phy_init: phy_version 503,13653eb,Jun 1 2022,17:47:08
W (479) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
I (519) system_api: Base MAC address is not set
I (519) system_api: read default base MAC address from EFUSE
I (519) BT_INIT: Bluetooth MAC: 7c:df:a1:e1:10:c6
I (529) SEC_GATTS_DEMO: app_main init bluetooth
I (579) SEC_GATTS_DEMO: The number handle = 8
I (589) SEC_GATTS_DEMO: advertising start success
I (589) SEC_GATTS_DEMO: Bonded devices number : 0
I (589) SEC_GATTS_DEMO: Bonded devices list : 0
I (6979) SEC_GATTS_DEMO: ESP_GATTS_CONNECT_EVT
W (9449) BT_SMP: FOR LE SC LTK IS USED INSTEAD OF STK
I (9499) SEC_GATTS_DEMO: key type = ESP_LE_KEY_LENC
I (9499) SEC_GATTS_DEMO: key type = ESP_LE_KEY_PENC
I (9499) SEC_GATTS_DEMO: key type = ESP_LE_KEY_LID
I (9549) SEC_GATTS_DEMO: key type = ESP_LE_KEY_PID
I (9579) SEC_GATTS_DEMO: remote BD_ADDR: 501d1a9eb399
I (9579) SEC_GATTS_DEMO: address type = 1
I (9579) SEC_GATTS_DEMO: pair status = success
I (9579) SEC_GATTS_DEMO: auth mode = ESP_LE_AUTH_REQ_SC_BOND
I (9589) SEC_GATTS_DEMO: Bonded devices number : 1
I (9589) SEC_GATTS_DEMO: Bonded devices list : 1
I (9599) SEC_GATTS_DEMO: 50 1d 1a 9e b3 99
日志----------------------------------------------------------------
2、先断开app连接然后重启esp32s3,然后因为手机已经显示已绑定,直接在APP上连接
日志----------------------------------------
I (0) cpu_start: App cpu up.
I (320) cpu_start: Pro cpu start user code
I (320) cpu_start: cpu freq: 160000000
I (320) cpu_start: Application information:
I (322) cpu_start: Project name: sec_gatts_demo
I (328) cpu_start: App version: 1
I (332) cpu_start: Compile time: Sep 1 2022 18:00:04
I (339) cpu_start: ELF file SHA256: 0bb7ff711e029e97...
I (345) cpu_start: ESP-IDF: v4.4.2-dirty
I (350) heap_init: Initializing. RAM available for dynamic allocation:
I (357) heap_init: At 3FC9BD40 len 000442C0 (272 KiB): D/IRAM
I (364) heap_init: At 3FCE0000 len 0000EE34 (59 KiB): STACK/DRAM
I (370) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (377) spi_flash: detected chip: mxic
W (381) spi_flash: Detected flash size > 16 MB, but access beyond 16 MB is not supported for this flash model yet.
I (392) spi_flash: flash io: dio
W (396) spi_flash: Detected size(32768k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
I (410) sleep: Configure to isolate all GPIO pins in sleep state
I (416) sleep: Enable automatic switching of GPIO sleep configuration
I (423) coexist: coexist rom version e7ae62f
I (428) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
W (469) BT_INIT: esp_bt_controller_mem_release not implemented, return OK
I (469) BT_INIT: BT controller compile version [05195c9]
I (469) phy_init: phy_version 503,13653eb,Jun 1 2022,17:47:08
W (479) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
I (529) system_api: Base MAC address is not set
I (529) system_api: read default base MAC address from EFUSE
I (529) BT_INIT: Bluetooth MAC: 7c:df:a1:e1:10:c6
I (529) SEC_GATTS_DEMO: app_main init bluetooth
I (579) SEC_GATTS_DEMO: The number handle = 8
I (589) SEC_GATTS_DEMO: advertising start success
I (589) SEC_GATTS_DEMO: Bonded devices number : 0
I (589) SEC_GATTS_DEMO: Bonded devices list : 0
I (4959) SEC_GATTS_DEMO: ESP_GATTS_CONNECT_EVT
日志此处经过较长时间等待,预计有十几秒。
I (34969) SEC_GATTS_DEMO: remote BD_ADDR: 57819b836c7b
I (34969) SEC_GATTS_DEMO: address type = 1
I (34969) SEC_GATTS_DEMO: pair status = fail
I (34979) SEC_GATTS_DEMO: fail reason = 0x63
I (34979) SEC_GATTS_DEMO: Bonded devices number : 0
I (34989) SEC_GATTS_DEMO: Bonded devices list : 0
W (37969) BT_HCI: hci cmd send: disconnect: hdl 0x1, rsn:0x13
W (37969) BT_BTM: btm_sec_clr_temp_auth_service() - no dev CB
I (37969) SEC_GATTS_DEMO: ESP_GATTS_DISCONNECT_EVT, disconnect reason 0x16
W (37969) BT_HCI: hcif disc complete: hdl 0x1, rsn 0x16
E (37979) BT_BTM: Device not found
I (37989) SEC_GATTS_DEMO: advertising start success
日志------------------------------
3、这时候第二次连接刚开始显示连接了,但是过一会儿会自动断开,然后esp32s3会报错。我需要重新连接这个时候连接的时候还是需要两次确认配对。
日志-------------------------------
I (105939) SEC_GATTS_DEMO: ESP_GATTS_CONNECT_EVT
W (111009) BT_SMP: FOR LE SC LTK IS USED INSTEAD OF STK
I (111049) SEC_GATTS_DEMO: key type = ESP_LE_KEY_LENC
I (111059) SEC_GATTS_DEMO: key type = ESP_LE_KEY_PENC
I (111059) SEC_GATTS_DEMO: key type = ESP_LE_KEY_LID
I (111089) SEC_GATTS_DEMO: key type = ESP_LE_KEY_PID
I (111119) SEC_GATTS_DEMO: remote BD_ADDR: 501d1a9eb399
I (111119) SEC_GATTS_DEMO: address type = 1
I (111119) SEC_GATTS_DEMO: pair status = success
I (111119) SEC_GATTS_DEMO: auth mode = ESP_LE_AUTH_REQ_SC_BOND
I (111129) SEC_GATTS_DEMO: Bonded devices number : 1
I (111129) SEC_GATTS_DEMO: Bonded devices list : 1
I (111139) SEC_GATTS_DEMO: 50 1d 1a 9e b3 99
日志-------------------------------
1、开启蓝牙,然后使用蓝牙调试软件 BLE调试宝 这个APP连接esp32s3 app显示两次确认连接的对话框。
日志---------------------------------------
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x18 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
Octal Flash Mode Enabled
For OPI Flash, Use Default Flash Boot Mode
mode:SLOW_RD, clock div:1
load:0x3fce3808,len:0x1654
load:0x403c9700,len:0xbb8
load:0x403cc700,len:0x2f88
SHA-256 comparison failed:
Calculated: b7ce2f7693df2d6f0d0090eeaf59e9d7f3dc2aa28824f5729293528e3c41f764
Expected: 1d9205207d8d1080d6f0cfe002218a5b76dfac59ac50890fc374c07311e16718
Attempting to boot anyway...
entry 0x403c9954
I (50) boot: ESP-IDF v4.4.2-dirty 2nd stage bootloader
I (51) boot: compile time 18:00:25
I (51) boot: chip revision: 0
I (53) boot.esp32s3: Boot SPI Speed : 80MHz
I (58) boot.esp32s3: SPI Mode : SLOW READ
I (63) boot.esp32s3: SPI Flash Size : 4MB
I (67) boot: Enabling RNG early entropy source...
I (73) boot: Partition Table:
I (76) boot: ## Label Usage Type ST Offset Length
I (84) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (91) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (99) boot: 2 factory factory app 00 00 00010000 00100000
I (106) boot: End of partition table
I (110) esp_image: segment 0: paddr=00010020 vaddr=3c080020 size=1c7ach (116652) map
I (146) esp_image: segment 1: paddr=0002c7d4 vaddr=3fc945b0 size=03844h ( 14404) load
I (150) esp_image: segment 2: paddr=00030020 vaddr=42000020 size=713b0h (463792) map
I (261) esp_image: segment 3: paddr=000a13d8 vaddr=3fc97df4 size=000d8h ( 216) load
I (262) esp_image: segment 4: paddr=000a14b8 vaddr=40374000 size=105b0h ( 66992) load
I (285) esp_image: segment 5: paddr=000b1a70 vaddr=50000000 size=00010h ( 16) load
I (292) boot: Loaded app from partition at offset 0x10000
I (292) boot: Disabling RNG early entropy source...
I (306) cpu_start: Pro cpu up.
I (306) cpu_start: Starting app cpu, entry point is 0x40375194
0x40375194: call_start_cpu1 at D:/software/Espressif/frameworks/esp-idf-v4.4.2/components/esp_system/port/cpu_start.c:160
I (0) cpu_start: App cpu up.
I (320) cpu_start: Pro cpu start user code
I (320) cpu_start: cpu freq: 160000000
I (320) cpu_start: Application information:
I (323) cpu_start: Project name: sec_gatts_demo
I (328) cpu_start: App version: 1
I (332) cpu_start: Compile time: Sep 1 2022 18:00:04
I (339) cpu_start: ELF file SHA256: 0bb7ff711e029e97...
I (345) cpu_start: ESP-IDF: v4.4.2-dirty
I (350) heap_init: Initializing. RAM available for dynamic allocation:
I (357) heap_init: At 3FC9BD40 len 000442C0 (272 KiB): D/IRAM
I (364) heap_init: At 3FCE0000 len 0000EE34 (59 KiB): STACK/DRAM
I (370) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (377) spi_flash: detected chip: mxic
W (381) spi_flash: Detected flash size > 16 MB, but access beyond 16 MB is not supported for this flash model yet.
I (392) spi_flash: flash io: dio
W (396) spi_flash: Detected size(32768k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
I (410) sleep: Configure to isolate all GPIO pins in sleep state
I (416) sleep: Enable automatic switching of GPIO sleep configuration
I (423) coexist: coexist rom version e7ae62f
I (428) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
W (469) BT_INIT: esp_bt_controller_mem_release not implemented, return OK
I (469) BT_INIT: BT controller compile version [05195c9]
I (469) phy_init: phy_version 503,13653eb,Jun 1 2022,17:47:08
W (479) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
I (519) system_api: Base MAC address is not set
I (519) system_api: read default base MAC address from EFUSE
I (519) BT_INIT: Bluetooth MAC: 7c:df:a1:e1:10:c6
I (529) SEC_GATTS_DEMO: app_main init bluetooth
I (579) SEC_GATTS_DEMO: The number handle = 8
I (589) SEC_GATTS_DEMO: advertising start success
I (589) SEC_GATTS_DEMO: Bonded devices number : 0
I (589) SEC_GATTS_DEMO: Bonded devices list : 0
I (6979) SEC_GATTS_DEMO: ESP_GATTS_CONNECT_EVT
W (9449) BT_SMP: FOR LE SC LTK IS USED INSTEAD OF STK
I (9499) SEC_GATTS_DEMO: key type = ESP_LE_KEY_LENC
I (9499) SEC_GATTS_DEMO: key type = ESP_LE_KEY_PENC
I (9499) SEC_GATTS_DEMO: key type = ESP_LE_KEY_LID
I (9549) SEC_GATTS_DEMO: key type = ESP_LE_KEY_PID
I (9579) SEC_GATTS_DEMO: remote BD_ADDR: 501d1a9eb399
I (9579) SEC_GATTS_DEMO: address type = 1
I (9579) SEC_GATTS_DEMO: pair status = success
I (9579) SEC_GATTS_DEMO: auth mode = ESP_LE_AUTH_REQ_SC_BOND
I (9589) SEC_GATTS_DEMO: Bonded devices number : 1
I (9589) SEC_GATTS_DEMO: Bonded devices list : 1
I (9599) SEC_GATTS_DEMO: 50 1d 1a 9e b3 99
日志----------------------------------------------------------------
2、先断开app连接然后重启esp32s3,然后因为手机已经显示已绑定,直接在APP上连接
日志----------------------------------------
I (0) cpu_start: App cpu up.
I (320) cpu_start: Pro cpu start user code
I (320) cpu_start: cpu freq: 160000000
I (320) cpu_start: Application information:
I (322) cpu_start: Project name: sec_gatts_demo
I (328) cpu_start: App version: 1
I (332) cpu_start: Compile time: Sep 1 2022 18:00:04
I (339) cpu_start: ELF file SHA256: 0bb7ff711e029e97...
I (345) cpu_start: ESP-IDF: v4.4.2-dirty
I (350) heap_init: Initializing. RAM available for dynamic allocation:
I (357) heap_init: At 3FC9BD40 len 000442C0 (272 KiB): D/IRAM
I (364) heap_init: At 3FCE0000 len 0000EE34 (59 KiB): STACK/DRAM
I (370) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (377) spi_flash: detected chip: mxic
W (381) spi_flash: Detected flash size > 16 MB, but access beyond 16 MB is not supported for this flash model yet.
I (392) spi_flash: flash io: dio
W (396) spi_flash: Detected size(32768k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
I (410) sleep: Configure to isolate all GPIO pins in sleep state
I (416) sleep: Enable automatic switching of GPIO sleep configuration
I (423) coexist: coexist rom version e7ae62f
I (428) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
W (469) BT_INIT: esp_bt_controller_mem_release not implemented, return OK
I (469) BT_INIT: BT controller compile version [05195c9]
I (469) phy_init: phy_version 503,13653eb,Jun 1 2022,17:47:08
W (479) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
I (529) system_api: Base MAC address is not set
I (529) system_api: read default base MAC address from EFUSE
I (529) BT_INIT: Bluetooth MAC: 7c:df:a1:e1:10:c6
I (529) SEC_GATTS_DEMO: app_main init bluetooth
I (579) SEC_GATTS_DEMO: The number handle = 8
I (589) SEC_GATTS_DEMO: advertising start success
I (589) SEC_GATTS_DEMO: Bonded devices number : 0
I (589) SEC_GATTS_DEMO: Bonded devices list : 0
I (4959) SEC_GATTS_DEMO: ESP_GATTS_CONNECT_EVT
日志此处经过较长时间等待,预计有十几秒。
I (34969) SEC_GATTS_DEMO: remote BD_ADDR: 57819b836c7b
I (34969) SEC_GATTS_DEMO: address type = 1
I (34969) SEC_GATTS_DEMO: pair status = fail
I (34979) SEC_GATTS_DEMO: fail reason = 0x63
I (34979) SEC_GATTS_DEMO: Bonded devices number : 0
I (34989) SEC_GATTS_DEMO: Bonded devices list : 0
W (37969) BT_HCI: hci cmd send: disconnect: hdl 0x1, rsn:0x13
W (37969) BT_BTM: btm_sec_clr_temp_auth_service() - no dev CB
I (37969) SEC_GATTS_DEMO: ESP_GATTS_DISCONNECT_EVT, disconnect reason 0x16
W (37969) BT_HCI: hcif disc complete: hdl 0x1, rsn 0x16
E (37979) BT_BTM: Device not found
I (37989) SEC_GATTS_DEMO: advertising start success
日志------------------------------
3、这时候第二次连接刚开始显示连接了,但是过一会儿会自动断开,然后esp32s3会报错。我需要重新连接这个时候连接的时候还是需要两次确认配对。
日志-------------------------------
I (105939) SEC_GATTS_DEMO: ESP_GATTS_CONNECT_EVT
W (111009) BT_SMP: FOR LE SC LTK IS USED INSTEAD OF STK
I (111049) SEC_GATTS_DEMO: key type = ESP_LE_KEY_LENC
I (111059) SEC_GATTS_DEMO: key type = ESP_LE_KEY_PENC
I (111059) SEC_GATTS_DEMO: key type = ESP_LE_KEY_LID
I (111089) SEC_GATTS_DEMO: key type = ESP_LE_KEY_PID
I (111119) SEC_GATTS_DEMO: remote BD_ADDR: 501d1a9eb399
I (111119) SEC_GATTS_DEMO: address type = 1
I (111119) SEC_GATTS_DEMO: pair status = success
I (111119) SEC_GATTS_DEMO: auth mode = ESP_LE_AUTH_REQ_SC_BOND
I (111129) SEC_GATTS_DEMO: Bonded devices number : 1
I (111129) SEC_GATTS_DEMO: Bonded devices list : 1
I (111139) SEC_GATTS_DEMO: 50 1d 1a 9e b3 99
日志-------------------------------
Re: BLE蓝牙掉电绑定信息消失的问题求助
问题最后解决了,发现是我这个开发板的nvs分区能写入读取不出来了。不知道为什么。很神奇的问题。我的flash tone数据也读取出来是错的。但是程序写入运行都没有问题。
ESP_XuLZ wrote: ↑Wed Aug 31, 2022 3:28 am我这边使用 esp32s3 开发板测试ESP IDF 4.4.2下的 gatt_security_server 示例没有遇到这个问题; 重启esp32s3, 手机再次与之相连,绑定地址是之前配对手机的,绑定设备数目也是 1 个
企业微信截图_20220831111453.png
企业微信截图_20220831111721.png
在 gatt_security_server 中这个 remove_all_bonded_devices() https://github.com/espressif/esp-idf/bl ... emo.c#L581 API 是可以删除绑定设备信息的,但是这部分代码是默认屏蔽的
Who is online
Users browsing this forum: Bing [Bot] and 52 guests