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

The ble_nus cann't Tx data or notification in Central_Peripheral projects.

Hi Sir,

I hope to add ble_nus and ble_nus_c into Central_and_Peripheral projects (ble_app_multirole_lesc and ble_app_hrs_rscs_relay), I use SDK 15.0.0 and nRF52832.

There are some issues in ble_nus:

Issue 1: Plug the ble_nuc.c into the project (ble_app_multirole_lesc), the APP nRFConnect only RX to send data to the device, but its TX notification can't get data from the device.  In the                        device firmware, it can't receive a notification form APP. I use the same ble_nus.c in a peripheral project (ble_app_uart), RX and TX are OK with nRFConnect.

              Do you have new example for these topic (ble_nus + ble_nus_c) for the Central_and_Peripheral project?

Issue2: I use ble_nus_c and define a new Service for Send and Receive data (it is not a UART), It has the same issue, the nRFConnect APP can send data to the device, and the Receive notification no response.

Can you recommend a temple service (i.e. Battery, HRS, etc.) for me to define my custom Service? 

 

Parents
  • Hi,

    Not entirely sure what might be the problem here no, but to be able to send notifications the central needs to enable the CCCD for the characteristic. When this occurs the peripheral softdevice will generate a BLE_GATTS_EVT_WRITE event, and the application should then check the if the handle equal the cccd_handle for the NUS characteristic, typically done by:

    if(p_evt_write->handle == m_conn_params_config.start_on_notify_cccd_handle)

    You should be able to search a BLE service for on_write() on how this is done. Once the CCCD handle is written from the central, then the peripheral can start calling sd_ble_gatts_hvx() to send data to the central.

    That is the place I would start for debugging.

    Best regards,
    Kenneth

Reply
  • Hi,

    Not entirely sure what might be the problem here no, but to be able to send notifications the central needs to enable the CCCD for the characteristic. When this occurs the peripheral softdevice will generate a BLE_GATTS_EVT_WRITE event, and the application should then check the if the handle equal the cccd_handle for the NUS characteristic, typically done by:

    if(p_evt_write->handle == m_conn_params_config.start_on_notify_cccd_handle)

    You should be able to search a BLE service for on_write() on how this is done. Once the CCCD handle is written from the central, then the peripheral can start calling sd_ble_gatts_hvx() to send data to the central.

    That is the place I would start for debugging.

    Best regards,
    Kenneth

Children
Related