esp-at
esp-at copied to clipboard
AT+BLECONN connecting fails
Answers checklist
- [X] I have read the documentation ESP-AT Programming Guide and the issue is not addressed there.
- [X] I have used the latest released firmware or have updated my ESP-AT branch (master or release) to the latest version and checked that the issue is present there.
- [X] I have searched the issue tracker for a similar issue and not found a similar issue.
AT+GMR
at+gmr AT version:3.2.0.0(s-ec2dec2 - ESP32 - Jul 28 2023 07:05:28) SDK version:v5.0.2-376-g24b9d38a24-dirty compile time(6118fc22):Jul 28 2023 09:47:28 Bin version:v3.2.0.0(WROOM-32)
ESP-AT Firmware Source
ESP32-WROOM-32-V3.2.0.0 github package
Hardware Information
WROOM-32
Power Supply used
USB
What is the expected behavior?
ESP32 cannot connect to another BLE device without scanning and other device showing up in that scan.
ready
AT+BLEINIT=1
// not scanning first, connecting fails
AT+BLECONN=0,"d9:2c:b0:e1:26:09"
+BLESCANDONE
+BLECONN:0,-1
ERROR
//scanning
AT+BLESCAN=1,3
+BLESCAN:"d9:2c:b0:e1:26:09",-47,,,1
+BLESCANDONE
// then connecting passes
AT+BLECONN=0,"d9:2c:b0:e1:26:09"
+BLESCANDONE
+BLECONN:0,"d9:2c:b0:e1:26:09"
OK
I know that it's in range so why I need to scan first? It also generates a ton of data on serial if there are many devices near by.
What is the actual behavior?
It should able to connect to another device without scanning first, or fail if it's out of reach, but it shouldn't fail because I didn't scan first.
Probability of recurrence
always
AT+SYSRAM?
+SYSRAM:104184,100884
Steps to reproduce
see above script
AT command port output
see above
AT log port output
not needed
More Information.
No response
even when it shows up, connecting is not reliable:
AT+BLESCAN=1,3
+BLESCAN:"d9:2c:b0:e1:26:09",-56,,,1
+BLESCANDONE
// try 1
AT+BLECONN=0,"d9:2c:b0:e1:26:09"
+BLESCANDONE
+BLECONN:0,-1
ERROR
// try 2
AT+BLECONN=0,"d9:2c:b0:e1:26:09"
+BLESCANDONE
+BLECONN:0,-1
ERROR
AT+BLESCAN=1,3
+BLESCAN:"d9:2c:b0:e1:26:09",-54,,,1
+BLESCANDONE
// for 3rd!! try it worked
AT+BLECONN=0,"d9:2c:b0:e1:26:09"
AT+BLECONN=0,"d9:2c:b0:e1:26:09"
+BLESCANDONE
+BLECONN:0,"d9:2c:b0:e1:26:09"
OK
This is far from production ready.
I have the same problem. After AT+RST, first time do AT+BLESCAN and do AT+BLECONN, always fail (and take a long time to get the ERROR answer), need to redo AT+BLESCAN and do AT+BLECONN again to get connection.
Another example
//make sure we are not connected
AT+BLEDISCONN=0
ERROR
//try connecting
AT+BLECONN=0,"f2:4c:24:47:3d:2b",1,4
+BLESCANDONE
ERROR
//maybe 2nd channel will work
AT+BLECONN=1,"f2:4c:24:47:3d:2b",1,4
+BLESCANDONE
ERROR
//lets try deinit
AT+BLEINIT=0
ready // rebooted???????
AT+BLEINIT=1
OK
//it worked!
AT+BLECONN=0,"f2:4c:24:47:3d:2b",1,4
+BLESCANDONE
+BLECONN:0,"f2:4c:24:47:3d:2b"
OK
//version
AT+GMR
AT version:3.2.0.0(s-ec2dec2 - ESP32 - Jul 28 2023 07:05:28)
SDK version:v5.0.2-376-g24b9d38a24-dirty
compile time(6118fc22):Jul 28 2023 10:14:50
Bin version:v3.2.0.0(PICO-D4)
this is useless.
And why does it sometimes it refuses to deinit?
AT+BLEINIT=0 // should be callable any time, OK + ERROR at the same time for one command???
OK
ERR CODE:0x01030000
ERROR
AT+BLEINIT=1
OK
@mrx23dot
- The issue in the log below will be fixed soon.
AT+BLEDISCONN=0
ERROR
//try connecting
AT+BLECONN=0,"f2:4c:24:47:3d:2b",1,4
+BLESCANDONE
ERROR
//maybe 2nd channel will work
AT+BLECONN=1,"f2:4c:24:47:3d:2b",1,4
+BLESCANDONE
ERROR
- Probably because although the BLE connection failed due to timeout, the underlying layer is still executing some interaction packets. At this time, if AT+BLEINIT=0 is executed, a restart will occur. It is recommended to execute AT+BLEINIT=0 before executing the AT+BLEDISCONN=0 command.
//lets try deinit
AT+BLEINIT=0
ready // rebooted???????
- The error code is due to "AT" not being detected. Are you sending
AT+BLEINIT=0\r\n\r\n, you can view the AT error code in the esp_at_core.h file of the AT project.
AT+BLEINIT=0 // should be callable any time, OK + ERROR at the same time for one command???
OK
ERR CODE:0x01030000
ERROR
2 Reboot is not acceptable, since it takes seconds, and we are losing the previous state, just store the deinit request and return busy or delay OK.
3 This doesn't make sense, if it had bad line ending then it would return ERROR not OK. And line ending didn't change. So I think something got stuck in uart receive buffer. I only pressed enter once.
AT+BLEINIT=0 // should be callable any time, OK + ERROR at the same time for one command???
OK
ERR CODE:0x01030000
ERROR
AT+BLEINIT=0 // should be callable any time, OK + ERROR at the same time for one command???
OK
ERR CODE:0x01030000
ERROR
Is this issue easy to reproduce? Can you provide the data converted into hexadecimal format for the AT+BLEINIT=0 command you sent when reproducing this issue?
I have only seen this once. AT+BLEINIT=0 got accepted with an OK so line ending was fine. I will try to record it next time.