This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Why do i get BLE_ERROR_UNSPECIFIED when connecting to a device while service discovery is running for another device?

Hi,

I am trying to connect to a device while service discovery for another device is running, this is needed to go through connecting multiple devices as fast as possible.

my structure:

multiple peripherals advertising simultaniously.

Central is scanning until it finds a device it wants to connect to, then stops scanning and connects.

at the end of the connection event, scanning is re-enabled and the service discovery starts.

when another device of interest appears, i want to connect to it, even if the service discovery of the first device is still running.

My Problem now is, that when i do ble.connect(...) i get an "BLE_ERROR_UNSPECIFIED" response and the device doesnt get connected.

why does this happen and how can i prevent this? my goal is to connect to devices as fast as possible.

my log:

RTT LOADED|  Hello, this is wt-ftbc-1809001  |
ftbcCmd=ftReady[SerialEvent] name: ftbcCmd | value: ftReady
FT100 signals readiness
 start scanning
BLE_SUCCESS
BLE_SUCCESS
new device ad received
string format: hex
wt-bbox-181028's mac address: 93E21FE9B8E0
device: wt-bbox-181028
looking for: wt-bbox-
 stop scanning
BLE_SUCCESS
macAuth[93E21FE9B8E0]=ok[SerialEvent] name: macAuth[93E21FE9B8E0] | value: ok
store MAC address
vector stored
look for best rssi
push mac to desiredPeerAddr
93 - E2 - 1F - E9 - B8 - E0 - trying to connect to 93E21FE9B8E0BLE_SUCCESS  <------------------ this is the first device I want to connect to
maxValue: -56 from device: 0
BLE_SUCCESS
thisBLE_SUCCESS
connection Callback
connection handle: 0
string format: hex
Ft100_BLE's role in this connection: Central
SUCCESS: wt-bbox-181028 connected with mac Address: 93E21FE9B8E0          <------------------ I am connected to the first device
 start scanning                                                         <------------------ scanning gets re-enabled
BLE_SUCCESS
TIMESTAMP BEGIN
Generic Access Service found:
Service UUID: [1800] attrs[1 9]
TIMESTAMP END
new device ad received
string format: hex
wt-bbox-181028's mac address: 591074700DE1                            <------------------ scanner found my second device
device: wt-bbox-181028
looking for: wt-bbox-
 stop scanning
BLE_SUCCESS
TIMESTAMP BEGIN
Generic Attribute Service found:
Service UUID: [1801] attrs[10 13]
TIMESTAMP END
TIMESTAMP BEGIN
Device Information Service found:
Service UUID: [180A] attrs[14 26]
TIMESTAMP END
macAuth[591074700DE1]=ok[SerialEvent] name: macAuth[591074700DE1] | value: ok          <------------------ I allow this mac to connect
store MAC address
vector stored
look for best rssi
push mac to desiredPeerAddr
59 - 10 - 74 - 70 - 0D - E1 - trying to connect to 591074700DE1BLE_ERROR_UNSPECIFIED <------------------ THIS IS THE FAILING PART!
maxValue: -48 from device: 0
BLE_SUCCESS
thisBLE_SUCCESS
DIS SN Char
CHAR UUID: [2A25]
DIS HW Char
CHAR UUID: [2A27]
DIS FW Char
CHAR UUID: [2A26]
DIS SW Char
CHAR UUID: [2A28]
TIMESTAMP BEGIN
PLOWDATA Service found:
Service UUID: [A001] attrs[27 30]
TIMESTAMP END
PLOWDATA Char
CHAR UUID: [A002]
TIMESTAMP BEGIN
Service UUID: [C001] attrs[31 65535]
TIMESTAMP END
MAINTENANCE Char
CHAR UUID: [C002]
terminated Service Discovery for handle 0
hrm Char found with notifications enabled
start looking for Descriptors now
descriptor found with:
connection_handle[0] UUID[2902] attribute_Handle[30] gattClient [536890060]
descriptorDiscovery terminated without errors
sending notification request now..
cccd state [1] sent successfully!
_________________________________________
rbl updates received: connHandle: 0, attrHandle: 29, Type: 1, length: 4plow updates received
identifier: [101]
_________________________________________
-------------
disconnected from connection nr. 0
disconnect reason: DISCONNECT_REASON_UNDEFINED
-------------

Ps. i noticed, that if a peripheral looses power as soon as it wanted to connect, the central wont do anything(I assumed the SupervisionTimeout would kick in) and if i want to restart scanning i get an "PARAM_OUT_OF_RANGE" Error.

thanks in advance,

Jonas

Parents Reply
  • I tried to upload it here, but that didnt work, so I uploaded it to our server and here is the link: http://portal.netwakevision.com/VSCODE_MBED_CENTRAL_MINIMAL_NORDICSUPPORT.zip

    let me know when you downloaded it, so i can delete it.

    Im sorry for the size, but i thought its better to include as much as possible, so nothing is missing later.

    the connect part is located in BleScanHandler.cpp at the very bottom.

    when you start the app you have to send ftbcCmd=ftReady\r\n  to start the scanning. or you just define DO_SCAN_ON_STARTUP 1 in basicDefines.h

    to reproduce you can use the NRF connect app as peripheral. Device name has to be wt-bbox-xxxxxx and Complete local name has to be broadcasted.

    now you start advertising, as soon as you get a connection request on serial, you reply with the same message but replace '?' with 'ok', it will now start to connect.

    If you do this a second time you will get the error.

    I hope this is not too much information, please let me know if you need any Infos.

    Ps. dont wonder why there are no event callbacks and such stuff, I removed almost everything that wasnt needed to reproduce.

Children
Related