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

Changing service depending on state

The thing I currently try to implement is to combine two 128-bit services in one app - custom and UART.

I arleady made run them separately - one service at app.

Way they should change - at the init before BLE init the state of variable is checked - let it be button input.

Depending on state, first or second service should turn on.

I know that I can't run two 128-bit services at one time, so I thought I can run one of two services at one time till core resets.

What I currently have - all works perfectly separately, but after I add BLE_CUS_DEF(m_cus) to UART project or BLE_NUS_DEF(m_nus) to custom service project, thing that worked before stops working.

No interaction with the second service instance is done, only initialisation and required includes.

Custom service connects, works for receiving data, but after I try to apply notification by timer, core holds.

UART service project fails to connect even.

I tried to increase memory size - does nothing.

Custom service project is done by example from Github for SDK 14.0 (https://github.com/bjornspockeli/custom_ble_service_example/tree/9ab5c4e381d8ffe36eb0eeebdead0cbe5b6cb1ce)

UART service is done by fixing example project, can provide my code if it's required.

The reason for SDK 14.0 is that target project I need to modify done on that version and I have no time to port it to actual SDK but if it will make it work - surely I would.

Expect some help.

Thanks.

Parents Reply Children
  • I don't know what may be failing here, a few things I would need to understand what may be failing:

    Does it connect as expected, does the discovery of services occur as expected, do the service and characteristic handles change after adding another service, is there any asserts, does BLE_GATTS_EVT_WRITE occur as expected (to enable CCCD or write to the rx handle), does the sd_ble_gatts_hvx() return any error code and does BLE_GATTS_EVT_HVN_TX_COMPLETE occur?

    Best regards,
    Kenneth

  • When I have two separate projects - each wprks like a charm.
    If I add initialisation of CUS to NUS, NUS fails to connect - but dev kit indicates as connected (light continiously on, not blinking).
    If I add initialisation of NUS to CUS, CUS connects, data is received by board but when I try to send the data from board by notify, it works one time and then core helds. 

    I added two services to the code and it failed to work, so I rolled back each step to make it work again, and this step was adding BLE_CUS_DEF(m_cus) or BLE_NUS_DEF(m_nus).

  • What you can check - is take CUS project and just add 

    #include "ble_nus.h"
    #include "app_uart.h"
    #include "app_util_platform.h"

    BLE_NUS_DEF(m_nus);

    and it should brake the project - data to board will come and from board will not.

    Or take NUS project and add 

    #include "ble_nus.h" - from a Github example 

    BLE_CUS_DEF(m_cus);

    and this way connection will fail.

Related