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

Buttonless DFU service; if (p_evt_write->handle != p_dfu->control_point_char.cccd_handle)

Hi everybody,

This is my set-up : nRF5_SDK_13.0.0_04a0bfd, Eclipse 2019 03 IDE, NRF52832_xxAA, s132_nrf52_4.0.2_softdevice, windows 64 bits, NRFConnect 4.22.3, JLINK RTT Viewer.

I'm trying to enter in bootloader from Buttonless DFU service on NRFConnect, but it failed.

The problem I guess in the IF condition :

if (p_evt_write->handle != p_dfu->control_point_char.cccd_handle) { return;} , the value are not equal...

Why are they not equal ? Is it possible to set them in order to be equal ? 

Here below my code of the ble_dfu.c

/**@brief Write event handler.
*
* @param[in] p_dfu DFU Service structure.
* @param[in] p_ble_evt Event received from the BLE stack.rtt
*/
static void on_write(ble_dfu_t * p_dfu, ble_evt_t const * p_ble_evt)
{
         //DEBUG
         NRF_LOG_INFO("Enter on_write function ' DFU'\r\n");
         //DEBUG
         SEGGER_RTT_WriteString(0,"Enter on_write function ' DFU'\r\n");

const ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write;

if (p_evt_write->handle != p_dfu->control_point_char.cccd_handle)
{
      NRF_LOG_INFO("p_evt_write->handle %d, p_dfu->control_point_char.cccd_handle %d\r\n", p_evt_write->handle, p_dfu->control_point_char.cccd_handle);
      return;
}

   if (p_evt_write->len == BLE_CCCD_VALUE_LEN)
   {
          // CCCD written, update indications state
          p_dfu->is_ctrlpt_indication_enabled = ble_srv_is_indication_enabled(p_evt_write->data);

          NRF_LOG_INFO("Received indication state %d, notification state %d\r\n", p_dfu->is_ctrlpt_indication_enabled, ble_srv_is_notification_enabled(p_evt_write->data));
         //DEBUG
         SEGGER_RTT_printf(0,"Received indication state %d, notification state %d\r\n", p_dfu->is_ctrlpt_indication_enabled, ble_srv_is_notification_enabled(p_evt_write->data));
         

         if (p_dfu->evt_handler != NULL)
         {
                   ble_dfu_evt_t evt;

                   if (p_dfu->is_ctrlpt_indication_enabled)
                   {
                         evt.type = BLE_DFU_EVT_INDICATION_ENABLED;
                         //DEBUG
                         SEGGER_RTT_WriteString(0,"BLE_DFU_EVT_INDICATION_ENABLED");

                   }
                 else
                 {
                        evt.type = BLE_DFU_EVT_INDICATION_DISABLED;
                 }

                 p_dfu->evt_handler(p_dfu, &evt);
       }
    }
}

Thank you.

Related