This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

BLE_GATTS_EVT_HVN_TX_COMPLETE event does not works on NUS for multi-role device

Hi,

In a multi-role central-peripheral code for a nRF52840-DK based device, I have to send a buffer acting as a peripheral. I use the ble_nus_data_send function sent as a trigger in the BLE_GAP_EVT_CONNECTED (into the ble_evt_handler function). So, I send the first data packet once the connection as peripheral has been established.

The rest of the buffer was expected to be sent using the BLE_GATTS_EVT_HVN_TX_COMPLETE event into the ble_evt_handler function. However, the event does not never occurs.

In fact, when I execute ble_nus_data_send the first time, it returns a NRF_ERROR_INVALID_STATE because it detects a condition ike !p_client->is_notification_enabled.

I have tried to clone the NUS configuration (as a peripheral) from the ble_app_uart example, working using the nRF5_SDK_17.1.0_ddde560. And including the sdk_config.h file configuration.

What should I setup to enable the BLE_GATTS_EVT_HVN_TX_COMPLETE event? Should I use another event?

Thank you very much in advance.

Best Regards,

Joel

  • Hi Einar,

    I will make a double check. I will come back tomorrow.

    By the way, I will have to connect it to an iPhone app in the end. This app will work as the central that has to enable then the notifications. Do you see anything special should I do from the device side?

    Regards,

    Joel

  • Hi Einar,

    I attach the multi-role+multi-link code I'm using. It comes from the multi-link-multi-role example in github, adding the NUS service (I have modified it over SES environment).

    ble_aggregator_NUS_6.zip

    I have a problem. Acting as a peripheral I can see it the Aggregator device on the mobile app nRF Connect. However, it does not establish connection with a second nRF52840-DK board that has the ble_app_uart_c code running on it as a central. So, it's not clear that as an Aggregator multi-role could acting ok as a NUS peripheral. Please, may you suggest me something to get that this multi-role Aggregator can be linked also to a NUS Central?

    Thank you in advance.

    Regards,

    Joel

  • Hi Joel,

    jinvers said:
    It comes from the multi-link-multi-role example in github

    Which example is that? Can you link to it?

    jinvers said:
    However, it does not establish connection with a second nRF52840-DK board that has the ble_app_uart_c code running on it as a central.

    In this case, the phone is also acting as a central I assume? And you want to connect with a second central (phone running ble_app_uart_c)? If so, that will not work. The project you have uploaded supports multiple central links but only a single peripheral link.

    Is the intention to also support several peripheral links (links where the nRF acts as a peripheral role)? If so, the first thing you must do is adjust NRF_SDH_BLE_PERIPHERAL_LINK_COUNT and set it to the number of central links you want. This is among other things used when initializing the SoftDevice, so having this set to 1 more than 1 link will never work. You also need to do a bit of changes to the application code to support this (I see you have done some but I have not gone through your implementation in detail).

  • Hi,

    I have included the zip file with the example modified. The original link is

    github.com/.../nrf52-ble-multi-link-multi-role

    The example is a central and a peripheral device simultaneously. I have adjusted the parameters you have told me.

    Regards,

    Joel

  • HI Joel,

    Ah, I was not aware of that repo.

    I saw your project from your previous post. As mentioned, it clearly cannot support more than one connection in the peripheral role, particularly because you configure the SoftDevice handler library (and in turn the SoftDevice) to only support 1. So adjusting that needs to be the first thing you need to do (among several) for the problem you mentioned in your last post, which is that you cannot be connected to two centrals at the same time.

Related