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

unable to enable Notifications using sd_ble_gattc_write (SDK 15.2)

Hi there,

I am migrating my central project from SDK 13 to SDK 15.2, almost all the project is already migrated, but I am having an issue with sd_ble_gattc_write() it is not enabling the notifications when I start a connection and skip ble_db_discovery_start()

so, the first thing I do in my central when it has established a connection with a peripheral is enable the CCCD using sd_ble_gattc_write(), I do it to avoid extra consumption discovering every time the same attribute table for the same Peripheral that already known 

SDK 13 code: it works fine

case BLE_GAP_EVT_CONNECTED:
		{
			NRF_LOG_INFO("Connected\r\n");
			
			(void) sd_ble_gap_scan_stop();

			uint32_t err_code;	
			ble_gattc_write_params_t write_params;
			uint8_t	EnableNotification[2] = {0x01, 0x00};		

			write_params.write_op = BLE_GATT_OP_WRITE_REQ;						
			write_params.handle   = 0x0011;  			
			write_params.offset   = 0;															
			write_params.len      = 2;																
			write_params.p_value  = EnableNotification;													
			
			err_code = sd_ble_gattc_write(0x0000 , &write_params);
			APP_ERROR_CHECK(err_code);

			bsp_board_led_on(LED_CONNECTED);
		} break;

since then I am using it Bypass or skip the discovery service nRF52 SDK 12.2

I am trying to use the same code for the SDK 15.2, it is writing on the peripheral 0x01 0x00 but it is still not enabling the notification (I am writting it on the CCCD handle like when the discovery service is performed) the only way I can make it work is after a ble_db_discovery_start() and event BLE_LBS_C_EVT_DISCOVERY_COMPLETE, but it no makes sense to me if I want to avoid performing a discovery service each time for the same device

as a reference, I am using the BLE Blinky peripheral and central projects to replicate the issue

any suggestion?

Regards,

Arepa

Related