ESP32 经典蓝牙无法成功连接到手机

Moderator: ESP_XCGuang

ESP_Mary
Posts: 14
Joined: Tue Sep 29, 2020 9:46 am

ESP32 经典蓝牙无法成功连接到手机

Postby ESP_Mary » Thu Aug 26, 2021 3:10 am

硬件:ESP32-WROOM-32E
软件:本地编译的支持经典蓝牙的 AT 固件
版本信息如下:

Code: Select all

AT+GMR
AT version:2.2.0.0(4bfff91 - ESP32 - Aug 19 2021 08:17:22)
SDK version:v4.2.2-76-gefa6eca8b8-dirty
compile time(7135f05):Aug 23 2021 17:05:16
Bin version:2.2.0(WROOM-32)

OK
问题描述:
ESP32 作 master 设备,可以扫描到手机蓝牙设备,但是有时候无法连接成功,直接返回 ERROR,不知道具体的原因是什么。

测试 AT 序列如下:

Code: Select all

AT+BTINIT=1

OK
AT+BTNAME?
+BTNAME:esp32-bt-test

OK
AT+BTSCANMODE=2

OK
AT+BTSTARTDISC=0,10,10
+BTSTARTDISC:"9c:5a:81:18:2e:c7",,0x2,0x3,0x2d0,-85
+BTSTARTDISC:"44:17:93:58:6e:fa",ESP_SPEAKER,0x4,0x5,0x120,-53
+BTSTARTDISC:"7c:2a:db:7f:bf:f4",Tony鐨凪i 10 Ultra,0x2,0x3,0x2d0,-67
+BTSTARTDISC:"44:17:93:58:6e:fa",ESP_SPEAKER,0x4,0x5,0x120,-61
+BTSTARTDISC:"44:17:93:58:6e:fa",ESP_SPEAKER,0x4,0x5,0x120,-60
+BTSTARTDISC:"88:f8:72:82:b4:a0",mali_phone,0x2,0x3,0x2d0,-32
+BTSTARTDISC:"44:17:93:58:6e:fa",ESP_SPEAKER,0x4,0x5,0x120,-65
+BTSTARTDISC:"44:17:93:58:6e:fa",,0x4,0x5,0x120,-64
+BTSTARTDISC:"7c:2a:db:7f:bf:f4",Tony鐨凪i 10 Ultra,0x2,0x3,0x2d0,-71
+BTSTARTDISC:"44:17:93:58:6e:fa",ESP_SPEAKER,0x4,0x5,0x120,-55
+BTSTARTDISC:"44:17:93:58:6e:fa",ESP_SPEAKER,0x4,0x5,0x120,-60
+BTSTARTDISC:"44:17:93:58:6e:fa",,0x4,0x5,0x120,-60
+BTSTARTDISC:"44:17:93:58:6e:fa",ESP_SPEAKER,0x4,0x5,0x120,-65
+BTSTARTDISC:"44:17:93:58:6e:fa",ESP_SPEAKER,0x4,0x5,0x120,-62
+BTSTARTDISC:"44:17:93:58:6e:fa",ESP_SPEAKER,0x4,0x5,0x120,-59
+BTSTARTDISC:"44:17:93:58:6e:fa",ESP_SPEAKER,0x4,0x5,0x120,-53
+BTSTARTDISC:"44:17:93:58:6e:fa",ESP_SPEAKER,0x4,0x5,0x120,-53
+BTSTARTDISC:"7c:2a:db:7f:bf:f4",,0x2,0x3,0x2d0,-75
+BTSTARTDISC:"7c:6b:9c:06:c9:56",,0x2,0x3,0x2d0,-88

OK
AT+BTSPPINIT=1

OK
AT+BTSPPCONN=0,0,"88:f8:72:82:b4:a0"

ERROR

ESP_Alson
Posts: 106
Joined: Mon Mar 22, 2021 3:37 am

Re: ESP32 经典蓝牙无法成功连接到手机

Postby ESP_Alson » Fri Aug 27, 2021 3:29 am

您好,对于您的问题回答如下:
您的 AT 指令是没有问题的,如果想连接到手机,前提是手机要支持 Slave 模式,您可以下载 SPP蓝牙串口 APP,运行后点击右上角的 + 号选择服务端模式进行测试即可。

ESP_Mary
Posts: 14
Joined: Tue Sep 29, 2020 9:46 am

Re: ESP32 经典蓝牙无法成功连接到手机

Postby ESP_Mary » Fri Aug 27, 2021 6:04 am

您好:
感谢您的回复。
根据您的建议进行测试,可以连接成功。

Code: Select all

AT+BTSPPCONN=0,0,"88:f8:72:82:b4:a0"
+BTSPPCONN:0,"88:f8:72:82:b4:a0"

OK
AT+BTSPPSEND=0,4
>
OK
+BTDATA:8,12345678

Who is online

Users browsing this forum: No registered users and 33 guests