Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to force the notification to turn on from the server not the client?


    buffer[0] = 13;//24;//13;      // cccd handle
    buffer[1] = 2;       // cccd attribute size = 2
    buffer[2] = 1;//2;       // 1 = enable notifications
	buffer[3] = crc16_compute((uint8_t const*)buffer, 6, NULL);				
		
    err_code = sd_ble_gatts_sys_attr_set(p_ble_evt->evt.gap_evt.conn_handle, (uint8_t*)(buffer), 8, 0);    // initialize cccd attribute
	APP_ERROR_CHECK(err_code);

I add this code in 'static void on_connect(ble_nus_t * p_nus, ble_evt_t const * p_ble_evt) '  on the sever.I got an err_code NRF_ERROR_INVALID_DATA. Softdevice is s132nrf52611. Any suggestions to force the notification?

Parents Reply
  • Hi Amanda,

    When the inputted flags is BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS, the following function's returned value will be NRF_SUCCESS. However, sd_ble_gatts_hvx(conn_handle, &hvx_params) returns an ERROR 13313. It seems like the notification still not enabled. So, how to enable the notification by the server?

        err_code = sd_ble_gatts_sys_attr_set(p_ble_evt->evt.gap_evt.conn_handle, (uint8_t*)(buffer), 8, BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS);    // initialize cccd attribute
        APP_ERROR_CHECK(err_code);
    Any help would be very welcome, and thank you for your time.

Children
Related