使用demo bt_l2cap_server未做改动,测试发现蓝牙spp连接不上

chenARM
Posts: 8
Joined: Wed Sep 07, 2022 9:52 am

使用demo bt_l2cap_server未做改动,测试发现蓝牙spp连接不上

Postby chenARM » Thu Jul 20, 2023 3:40 am

demo路径:D:\Espressif\frameworks\esp-idf-v5.0.2\examples\bluetooth\bluedroid\classic_bt\bt_l2cap_server

完整log:

[11:27:23.115]收←◆ets Jun 8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:6944
load:0x40078000,len:15500
load:0x40080400,len:3844
entry 0x4008064c
[0;32mI (27) boot: ESP-IDF v5.0.2-dirty 2nd stage bootloader[0m
[0;32mI (27) boot: compile time 19:22:35[0m
[0;32mI (27) boot: chip revision: v1.0[0m
[0;32mI (31) boot.esp32: SPI Speed : 40MHz[0m
[0;32mI (35) boot.esp32: SPI Mode : DIO[0m
[0;32mI (40) boot.esp32: SPI Flash Size : 2MB[0m
[0;32mI (44) boot: Enabling RNG early entropy source...[0m
[0;32mI (50) boot: Partition Table:[0m
[0;32mI (53) boot: ## Label Usage Type ST Offset Length[0m
[0;32mI (61) boot: 0 nvs WiFi data 01 02 00009000 00006000[0m
[0;32mI (68) boot: 1 phy_init RF data 01 01 0000f000 00001000[0m
[0;32mI (76) boot: 2 factory factory app 00 00 00010000 00100000[0m
[0;32mI (83) boot: End of partition table[0m
[0;32mI (87) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=25218h (152088) map[0m
[0;32mI (151) esp_image: segment 1: paddr=00035240 vaddr=3ffbdb60 size=041d4h ( 16852) load[0m
[0;32mI (158) esp_image: segment 2: paddr=0003941c vaddr=40080000 size=06bfch ( 27644) load[0m
[0;32mI (169) esp_image: segment 3: paddr=00040020 vaddr=400d0020 size=93f04h (605956) map[0m

[11:27:23.490]收←◆[0;32mI (388) esp_image: segment 4: paddr=000d3f2c vaddr=40086bfc size=111bch ( 70076) load[0m
[0;32mI (429) boot: Loaded app from partition at offset 0x10000[0m
[0;32mI (430) boot: Disabling RNG early entropy source...[0m
[0;32mI (441) cpu_start: Pro cpu up.[0m
[0;32mI (441) cpu_start: Starting app cpu, entry point is 0x4008130c[0m
[0;32mI (0) cpu_start: App cpu up.[0m
[0;32mI (458) cpu_start: Pro cpu start user code[0m
[0;32mI (458) cpu_start: cpu freq: 160000000 Hz[0m
[0;32mI (458) cpu_start: Application information:[0m
[0;32mI (462) cpu_start: Project name: bt_l2cap_server[0m
[0;32mI (468) cpu_start: App version: v5.0.2-dirty[0m
[0;32mI (473) cpu_start: Compile time: Jul 19 2023 19:23:10[0m
[0;32mI (479) cpu_start: ELF file SHA256: cf936da0b6a89baa...[0m
[0;32mI (485) cpu_start: ESP-IDF: v5.0.2-dirty[0m
[0;32mI (491) cpu_start: Min chip rev: v0.0[0m
[0;32mI (496) cpu_start: Max chip rev: v3.99 [0m
[0;32mI (500) cpu_start: Chip rev: v1.0[0m
[0;32mI (505) heap_init: Initializing. RAM available for dynamic allocation:[0m
[0;32mI (513) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM[0m
[0;32mI (518) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM[0m
[0;32mI (524) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM[0m
[0;32mI (531) heap_init: At 3FFC9A08 len 000165F8 (89 KiB): DRAM[0m
[0;32mI (537) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM[0m
[0;32mI (543) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m
[0;32mI (550) heap_init: At 40097DB8 len 00008248 (32 KiB): IRAM[0m
[0;32mI (557) spi_flash: detected chip: generic[0m
[0;32mI (561) spi_flash: flash io: dio[0m
[0;33mW (564) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.[0m
[0;32mI (579) cpu_start: Starting scheduler on PRO CPU.[0m
[0;32mI (0) cpu_start: Starting scheduler on APP CPU.[0m
[0;32mI (648) BTDM_INIT: BT controller compile version [2c56073][0m
[0;32mI (648) system_api: Base MAC address is not set[0m
[0;32mI (648) system_api: read default base MAC address from EFUSE[0m
[0;32mI (658) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07[0m

[11:27:24.427]收←◆[0;32mI (1358) L2CAP_TAG: ESP_BT_L2CAP_INIT_EVT: status:0
[0m
[0;32mI (1358) L2CAP_TAG: ESP_BT_L2CAP_START_EVT: status:0, hdl:0x0, sec_id:0x37
[0m
[0;32mI (1358) SDP_TAG: ESP_SDP_INIT_EVT: status:0
[0m
[0;32mI (1368) SDP_TAG: ESP_SDP_CREATE_RECORD_COMP_EVT: status:0
[0m
[0;32mI (1378) L2CAP_TAG: event: 10[0m
[0;32mI (1378) L2CAP_TAG: Own address:[7c:9e:bd:c0:90:4a][0m

[11:27:29.785]收←◆[0;33mW (6708) BT_HCI: hcif conn complete: hdl 0x81, st 0x0[0m
[0;32mI (6708) L2CAP_TAG: event: 16[0m
[0;33mW (6728) BT_HCI: hcif link supv_to changed: hdl 0x81, supv_to 8000[0m

[11:27:29.957]收←◆[0;32mI (6878) L2CAP_TAG: ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: 407735[0m

[11:27:31.723]收←◆[0;32mI (8638) L2CAP_TAG: authentication success: P30 bda:[fc:87:43:e1:eb:99][0m

[11:27:35.925]收←◆[0;33mW (12848) BT_HCI: hci cmd send: disconnect: hdl 0x81, rsn:0x13[0m

[11:27:36.018]收←◆[0;33mW (12938) BT_HCI: hcif disc complete: hdl 0x81, rsn 0x16[0m


[11:27:51.140]收←◆[0;33mW (28068) BT_HCI: hcif conn complete: hdl 0x80, st 0x0[0m
[0;32mI (28068) L2CAP_TAG: event: 16[0m
[0;33mW (28088) BT_HCI: hcif link supv_to changed: hdl 0x80, supv_to 8000[0m

[11:27:55.857]收←◆[0;33mW (32778) BT_HCI: hci cmd send: disconnect: hdl 0x80, rsn:0x13[0m

[11:27:55.936]收←◆[0;33mW (32858) BT_HCI: hcif disc complete: hdl 0x80, rsn 0x16[0m


红色标记部分为:P30系统蓝牙配对过程;
紫色标记部分为:P30使用飞易通蓝牙工具连接过程;

麻烦各位帮忙看看。

bidrohini
Posts: 202
Joined: Thu Oct 27, 2022 12:55 pm

Re: 使用demo bt_l2cap_server未做改动,测试发现蓝牙spp连接不上

Postby bidrohini » Thu Jul 20, 2023 3:43 pm

根据您提供的日志,我能看到以下事件序列:

1. 开机启动,加载应用程序,并初始化蓝牙设备(ESP_BT_L2CAP_INIT_EVT)。
2. 蓝牙L2CAP服务启动成功(ESP_BT_L2CAP_START_EVT)。
3. 蓝牙SDP服务初始化成功(ESP_SDP_INIT_EVT)并创建记录完成(ESP_SDP_CREATE_RECORD_COMP_EVT)。
4. 手机P30尝试与设备进行蓝牙连接,连接成功(hcif conn complete)。
5. P30请求进行身份验证,身份验证成功(authentication success)。
6. P30主动断开蓝牙连接(hci cmd send: disconnect)。

通过日志,可以看到P30和ESP32成功建立了蓝牙连接并进行了身份验证。但是之后P30主动断开了蓝牙连接,原因是hci cmd send: disconnect,其中rsn:0x13代表"Remote User Terminated Connection",表示蓝牙连接被远程用户终止。

由于该日志并未涵盖完整的应用程序代码,无法直接判断具体原因。通常情况下,蓝牙连接被断开的原因可能包括以下几点:

1. 蓝牙协议栈配置问题:请确保应用程序正确地配置了蓝牙协议栈,包括正确的服务、特征值等配置。

2. 通信稳定性问题:检查应用程序的通信过程是否稳定,是否出现通信错误或异常。

3. 超时问题:某些情况下,蓝牙连接可能会因为超时而断开,例如连接超时、认证超时等。可以检查蓝牙连接时的超时设置。

4. 资源问题:确保设备有足够的资源来维持蓝牙连接,包括内存、CPU资源等。

5. 驱动或固件问题:请确保设备上使用的蓝牙驱动和固件是稳定和适配的版本。

为了更好地理解问题,建议您检查您的应用程序代码,并查看在断开连接时是否有相关的错误或警告信息。另外,查阅蓝牙协议栈和相关库的文档,以确保您的蓝牙连接的配置是正确的。

如果您需要更详细的帮助,您可以在ESP32的开发者社区或蓝牙技术支持渠道寻求帮助,因为他们可能能够提供更具体和针对性的建议。

chenARM
Posts: 8
Joined: Wed Sep 07, 2022 9:52 am

Re: 使用demo bt_l2cap_server未做改动,测试发现蓝牙spp连接不上

Postby chenARM » Mon Jul 24, 2023 3:19 am

感谢您的回复,我这边按照您的建议进行逐一排查。

Who is online

Users browsing this forum: No registered users and 71 guests