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

Can central master(nrf52840) discover the characteristics of the DFU service on peripheral(nrf52840)

Hi All,

I want to use DFU to update the firmware from central to peripheral over BLE ,  both central master and peripheral are nrf52840.

Central master can find unknown service(0263000a..) and its characteristics (0x0b and 0x0c)  and DFU service (0xfe59) on peripheral but the volid characteristics of DFU can't be found.

Just a charateristic which uuid is 0 is found.

logs are below

<00> info>ble_hrs_c:discovered_db.srv_uuid.uuid:FE59
00> 
<00> info>ble_hrs_c:discovered_db.char_count:1
00> 
<00> info>ble_hrs_c:discovered_db.charateristics[i].uuid:0
00> 
<00> info>ble_hrs_c:discovered_db.srv_uuid.uuid:A
00> 
<00> info>ble_nus_c:db.handle_value:10
00> 
<00> info>ble_nus_c:characteristic.UUID.UUID:C
00> 
<00> info>ble_nus_c:characteristic.UUID.UUID:B
00> 
<00> info>app:Discovery complete.

 peripheral service and characteristics are below

I have no idea of why DFU characteristics can't be found . Please give me some advice.

Thank you!

  • Hi,

    Could you let me know how did you do the service discovery ? 

    Please note that the DFU service has different UUID to the NUS service. So you would need to feed the base UUID to the softdevice by calling sd_ble_uuid_vs_add() similar to what implemented in ble_nus_c.c make sure you used the uuid_type returned from that function as the input for ble_db_discovery_evt_register() calls. 

  • Hi Hung,

    Thanks for the reply.

    I used the example of "nRF5_SDK_16.0.0_98a08e2\examples\ble_central\ble_app_hrs_c\pca10056\s140\arm5_no_packs" and changed the UUID.I have fed DFU service base UUID to the softdevice by calling sd_ble_uuid_vs_add()  in ble_hrs_c_init()

    //the funcion is from "nRF5_SDK_16.0.0_98a08e2\examples\ble_central\ble_app_hrs_c" and I changed the UUID
    uint32_t ble_hrs_c_init(ble_hrs_c_t * p_ble_hrs_c, ble_hrs_c_init_t * p_ble_hrs_c_init)
    {
    	uint32_t      err_code;
        VERIFY_PARAM_NOT_NULL(p_ble_hrs_c);
        VERIFY_PARAM_NOT_NULL(p_ble_hrs_c_init);
    
    	uint8_t dfu_uuid_type;
        ble_uuid_t dfu_uuid;
    	ble_uuid_t dfu_nus_uuid;
    	//DFU_BASE_UUID = {{0xfb,0x34,0x9b,0x5f,0x80,0x00,0x00,0x80,0x00,0x10,0x00,0x00,0x0,0x0,0x00,0x00}};
    	// the 128 bits uuid above was found by Android Studio
    	ble_uuid128_t dfu_base_uuid = DFU_BASE_UUID;
        err_code = sd_ble_uuid_vs_add(&dfu_base_uuid, &dfu_uuid_type);
    	VERIFY_SUCCESS(err_code);
        dfu_uuid.type = dfu_uuid_type;    	
        dfu_uuid.uuid = BLE_DFU_SERVER_UUID; 	//0xFE59	
    	
        p_ble_hrs_c->evt_handler                 = p_ble_hrs_c_init->evt_handler;
        p_ble_hrs_c->error_handler               = p_ble_hrs_c_init->error_handler;
        p_ble_hrs_c->p_gatt_queue                = p_ble_hrs_c_init->p_gatt_queue;
        p_ble_hrs_c->conn_handle                 = BLE_CONN_HANDLE_INVALID;
        p_ble_hrs_c->peer_hrs_db.hrm_cccd_handle = BLE_GATT_HANDLE_INVALID;
        p_ble_hrs_c->peer_hrs_db.hrm_handle      = BLE_GATT_HANDLE_INVALID;
    
        return ble_db_discovery_evt_register(&dfu_uuid);
    }

    service discovery function is below,just show which service and characteristic is found

    void ble_hrs_on_db_disc_evt(ble_hrs_c_t * p_ble_hrs_c, const ble_db_discovery_evt_t * p_evt)
    {
    	NRF_LOG_INFO("discovered_db.srv_uuid.uuid :%x",p_evt->params.discovered_db.srv_uuid.uuid);
        if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE &&
            p_evt->params.discovered_db.srv_uuid.uuid == BLE_DFU_SERVER_UUID &&
            p_evt->params.discovered_db.srv_uuid.type == BLE_UUID_TYPE_BLE)
        {
    		NRF_LOG_INFO("discovered_db.char_count:%x",p_evt->params.discovered_db.char_count);
    		NRF_LOG_INFO("discovered_db.charateristics[i].uuid:%d",p_evt->params.discovered_db.charateristics[0].characteristic.uuid.uuid);
    	
        }
    }
    

    I have noted that the base UUID of NFC service and its characteristics are different in "nRF5_SDK_16.0.0_98a08e2\examples\ble_peripheral\ble_app_buttonless_dfu" , and I tried to feed the characteristic base UUID to the softdevice by calling sd_ble_uuid_vs_add() and ble_db_discovery_evt_register() in ble_hrs_c_init(), but the result was central master cound not connect with peripheral at all.

    Best regards,

            steven

  • I've solved this problem,  the DFU service and its characteristics are not based on the same service.

    In my first picture,  I changed the characteristic's base UUID as same as DFU service base UUID but the program has some bugs which cause the characteristic UUID not to be read. 

    Another problem arises, how can I use the central master(nrf52840) transmits upgrade program to upgrade the peripheral? In "nRF Connect" APP , just send the zip file and wait for upgrading, but I don't know how it works, where can I get details?

    Best regards,

            steven

  • Hi Steven, 

    Are you planning to handle the receiving of the new image in your application (background DFU) ? Or you plan to switch from application to the bootloader (buttonless DFU) and the bootloader will handle the receiving of the image ? 

    Regarding the protocol to send the image, please have a look at the documentation here. Note that when the nRF Connect app sending the image, it unzips the files and send the binary image inside , not the .zip itself. 
    I have made an example on how to do DFU update from an nRF52 to another nRF52 on UART and SPI. It's not for BLE but I think it's a good source of reference. Have a look here.

  • Hi Hung,

    Thanks for the reply. 

    The peripheral has bootloader, my work is sending image from central master(nrf52840) to peripheral and bootloader will handle the reciving of the image. The image has been stored in master Flash(GD25VE16C) as below

    I will study documentation and examples you provided in the next few days.

    Thanks again.

    Best regards,

            Steven

Related