5 years, 5 months ago.

why cant i connect multiple peripherals to one Central running on MBED?

hi, Im desperately trying to connect one Central device to multiple Peripherals, but I cant get it to work. I always get BLE_ERROR_UNSPECIFIED when I try to connect to the second device. I used the LED example and started to modify it, its attached.

serial log output

[18:17:59:612] connectingadvtest peerAddr[77 b8 b0 61 26 59] rssi -54, isScanResponse 0, AdvertisementType 0, conERR=0
[18:18:00:682] connected! handle = 0connected! handle = 0 scanrestart err=0terminated SD for handle 0
[18:18:06:731] connectingadvtest peerAddr[61 15 fc b7 9d f3] rssi -28, isScanResponse 0, AdvertisementType 0, conERR=11

the first time it connect with error=0, second time I get err=11(unspecified) to reproduce it I used 2 android devices running NRF connect.

any help is highly appreciated! thanks in advance, Jonas /media/uploads/Jwoerner/mbedtest_main.cpp

1 Answer

5 years, 5 months ago.

Hi Jonas,

Could you check the value of these three configuration in mbed_congfig.h?

mbed_config.h

NRF_SDH_BLE_CENTRAL_LINK_COUNT
NRF_SDH_BLE_PERIPHERAL_LINK_COUNT
NRF_SDH_BLE_TOTAL_LINK_COUNT

It could be the configuration limiting the link count, if so, you could modify the macro value in FEATURE_BLE/targets/{Your Target}/mbed_lib.json

Bedsides this, if you only connect the second one, will it succeed?

Please let me know if you have any questions!

- Desmond, team Mbed

Hi, thanks for your reply, CENTRAL_LINK_COUNT = 3 PERIPHERAL_LINK_COUNT = 1

but i didnt find TOTAL_LINK COUNT..

so everything is set up correctly, isnt it? btw, why is it set to 3, the softdevice can handle 20 concurrent connections i think?

and yes, if i only connect the second one, it will work properly.

posted by Jonas Woerner 16 Nov 2018

Ok, i have more infos, I looked further into the MBED librarys and piped the NRF error code to my main code, its NRF_ERROR_CONN_COUNT.

may I suggest to change the library so the error is directly piped through from the NORDIC SDK, this would help a lot I guess.

posted by Jonas Woerner 16 Nov 2018

So, I am finally able to connect more than one device, you pointed me in the right direction, but that MBED error handling cost me 2 days of work because the error wasnt passed through. now I have one question remaining: I changed NRF_SDH_BLE_TOTAL_LINK_COUNT in sdk_config.h and that works, but if I set NRF_SDH_BLE_CENTRAL_LINK_COUNT to something other than 0 my app wont work anymore, why is that?

posted by Jonas Woerner 16 Nov 2018

btw, how come that the values set in mbed_config.h dont take effect?

posted by Jonas Woerner 16 Nov 2018

one more thing, i just ran into: how can/should i change the ram used by MBED in order to give enough ram to the Softdevice?

posted by Jonas Woerner 16 Nov 2018

Thank you for your suggestion, this is really a good point, an appropriate error code always helps, I will discuss this with others.

Could you attach the value of three definitions that makes your app not working? (The case of NRF_SDK_BLE_CENTRAL_LINK_COUNT)

mbed_config.h is the final output file, it's not the input file, if you would like to change some parameters, you have to change them with *.json or sdk_config.h which is for Nordic SDK.

Could you open another question about the ram issue? That will helps other people find the right answer quicker!

posted by Desmond Chen 19 Nov 2018

Hi, I did some further testing, and it here are the results: mbed_lib.json is all default (CENTRALCOUNT = 10 / PERIPHERALCOUNT = 2) but changing the values didnt do anything anyways...?

sdk_config.h:

NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 1 ; NRF_SDH_BLE_CENTRAL_LINK_COUNT 3 ; NRF_SDH_BLE_TOTAL_LINK_COUNT 4 ; this and anything below works! NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 1 ; NRF_SDH_BLE_CENTRAL_LINK_COUNT 4 ; NRF_SDH_BLE_TOTAL_LINK_COUNT 5 ; this and anything above does not work! NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 1 ; NRF_SDH_BLE_CENTRAL_LINK_COUNT 1 ; NRF_SDH_BLE_TOTAL_LINK_COUNT 5 ; this does also not work! I assume this has to do with RAM management, but i will post a new question. thanks for your help :)

posted by Jonas Woerner 19 Nov 2018