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

gattc parameters in sd_ble_gattc_write() for dfu

Hi, I want to turn peripheral device from application mode to bootloader mode from a central device(not app), so I am trying to write value 0x01 to dfu service. Following is the parameters I set for sending message:

uint8_t value = 1; uint32_t dfu_conn_handle; ble_gattc_write_params_t dfu_params;

 if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE)// &&
	{
		 dfu_params.write_op = BLE_GATT_OP_WRITE_CMD;
		 dfu_params.flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE;
		 dfu_params.handle = 0x0001;
		 dfu_params.offset = 0;
		 dfu_params.len = sizeof(value);
		 dfu_params.p_value = &value;

	} 
   
         dfu_conn_handle = p_gap_evt->conn_handle;

         err_code = sd_ble_gattc_write(dfu_conn_handle,&dfu_params);

Peripheral device turns to bootloader mode by nRF connect app. sd_ble_gattc_write() returning NRF_SUCCESS.

Please help me to understand where i am going wrong.

  • Hi Raju,

    You may need to enable CCCD of the DFU control point characteristic to enable notification before you write 0x01 to the charactersitic.

    You may need to use write request instead of WRITE_CMD

    The handle = 0x0001 doesn't seem right.

    I would suggest you to test with nRFConnect /nRF Master Control Panel on PC . Or nRFConnect on the phone but not using the DFU button but doing it manually.

    So that you know exactly the handle you will have to write to.

Related