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

ble_peripheral/ble_app_beacon modification, error 0x12

Using Segger Embedded Studio 310i in Linux and SDK12.2.0, I imported the Beacon example project (ble_peripheral/ble_app_beacon) from Keil. Right now I'm trying to make it advertise rather than act as a beacon. I removed what I thought to be unnecessary for this. Here is main.c now: bpaste.net/.../e839e61fa3ea

All the declarations of a variable a are just so that I can set a breakpoint. My problem is that there is no advertising and the LED doesn't blink. When debugging, it clearly crashes in advertising_start. In the breakpoint at line 101, I see that I have err_code = 0x12 = 18:

#define  NRF_ERROR_CONN_COUNT   (NRF_ERROR_BASE_NUM + 18)
  Maximum connection count exceeded. 

I don't understand why I get this error, even before it starts advertising.

I also tried to set PERIPHERAL_LINK_COUNT and CENTRAL_LINK_COUNT both to 1. Is a link a connection? - Then the error does make sense. However, it then crashes at the call to softdevice_enable_get_default_config, it seems. In the comments (line 33 and 34), it says that "When changing this number remember to adjust the RAM settings". But I'm not sure what is meant by that.

  • "Right now I'm trying to make it advertise rather than act as a beacon."

    That doesnt make any sense.

    All BLE application have to advertise, otherwise no other device knows of their existence and hence can't connect.

    If you are saying you want it to advertise differently, e.g. has services etc etc, then I'd recommend you use the ble_app_template instead of the ble_app_beacon example

    If you want continue modifying the beacon example, I'd advise you go back to a clean unmodified version of the beacon and then make your changes one by one, and each time test whether the code is still working afterwards. So that you can isolate precisely which change broke the application

  • What I meant is to advertise to make connection possible, and send scan response data. I might try to start from scratch - but it would still be nice if someone could spot the error in this program also.

  • Although you can modify the beacon example to add services etc, so that devices can connect, IMHO you are better off starting using one of the other examples

    Which example to use will depend on whether you want to just read data from your device or whether you also want to write data to it.

    e.g. ble_app_hrs includes the heart rate service

  • Hi,

    You are doing BLE_GAP_ADV_TYPE_ADV_IND advertising (Connectable undirected), you therefore need to set PERIPHERAL_LINK_COUNT 1, or else you will get the NRF_ERROR_CONN_COUNT error. CENTRAL_LINK_COUNT should be 0. But as Roger Clark recommend, the beacon example does not show you how to set up a connection to a central, and you will save yourself from a lot of work if you start from scratch with e.g. ble_app_uart or ble_app_template example project. (Example that is actually set-up to act as a peripheral with a connection to a central.).

Related