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

Can i set macaddress in bootloader and advertising it?

bootloader.rar(/attachment/d5fd4fbbc7d37433740f6c9468f3110b) bootloader_dfu.rar Hi,all.i want to set same macaddress with my app in bootloader,and advertise it in bootloader,that my phone can know the device is the updating device.Can do it as this?Thanks a lot!

Parents
  • @wuvo.leo: You can simply remove the part that we change the address in the bootloader at dfu_transport_update_start() , where we call sd_ble_gap_address_set().

    You can have a look here at question I, for the explanation why we do that.

    dfu_transport_ble.c

  • Hi,Hung Bui.Thanks for your reply first. i still have trouble.i paste my function here:


    static void advertising_init(uint8_t adv_flags)
    {
        uint32_t      err_code;
        ble_advdata_t advdata;
        ble_uuid_t    service_uuid;
    	  ble_advdata_manuf_data_t manufdata;
    	  int32_t       uniqueid[2] = {NRF_FICR->DEVICEADDR1, NRF_FICR->DEVICEADDR0};
        uint8_t addrarray[8] = { 0 };
    
        service_uuid.type = m_dfu.uuid_type;
        service_uuid.uuid = BLE_DFU_SERVICE_UUID;
    		
    	  memset(&manufdata, 0, sizeof(manufdata));
        manufdata.company_identifier = 0xFF90;
        manufdata.data.size = 6;
    	
    	  memcpy( (void *)&addrarray,(void *)&uniqueid,sizeof(addrarray) );
    	  addrarray[1] |= 0xc0;
    	  memcpy( (void *)&addrarray[2],(void *)&addrarray[4],4);
    	  manufdata.data.p_data = ((unsigned char*)addrarray);
        memset(&advdata, 0, sizeof(advdata));
    
        advdata.name_type                     = BLE_ADVDATA_FULL_NAME;
        advdata.include_appearance            = false;
        advdata.flags                         = adv_flags;
        advdata.uuids_more_available.uuid_cnt = 1;
        advdata.uuids_more_available.p_uuids  = &service_uuid;
    		advdata.p_manuf_specific_data   = &manufdata;
    
        err_code = ble_advdata_set(&advdata, NULL);
        APP_ERROR_CHECK(err_code);
    }
    

    i used nRF Master Control pannel to find my device,and display my device name "n/a",no connect button.Please help me.Thank you!

Reply
  • Hi,Hung Bui.Thanks for your reply first. i still have trouble.i paste my function here:


    static void advertising_init(uint8_t adv_flags)
    {
        uint32_t      err_code;
        ble_advdata_t advdata;
        ble_uuid_t    service_uuid;
    	  ble_advdata_manuf_data_t manufdata;
    	  int32_t       uniqueid[2] = {NRF_FICR->DEVICEADDR1, NRF_FICR->DEVICEADDR0};
        uint8_t addrarray[8] = { 0 };
    
        service_uuid.type = m_dfu.uuid_type;
        service_uuid.uuid = BLE_DFU_SERVICE_UUID;
    		
    	  memset(&manufdata, 0, sizeof(manufdata));
        manufdata.company_identifier = 0xFF90;
        manufdata.data.size = 6;
    	
    	  memcpy( (void *)&addrarray,(void *)&uniqueid,sizeof(addrarray) );
    	  addrarray[1] |= 0xc0;
    	  memcpy( (void *)&addrarray[2],(void *)&addrarray[4],4);
    	  manufdata.data.p_data = ((unsigned char*)addrarray);
        memset(&advdata, 0, sizeof(advdata));
    
        advdata.name_type                     = BLE_ADVDATA_FULL_NAME;
        advdata.include_appearance            = false;
        advdata.flags                         = adv_flags;
        advdata.uuids_more_available.uuid_cnt = 1;
        advdata.uuids_more_available.p_uuids  = &service_uuid;
    		advdata.p_manuf_specific_data   = &manufdata;
    
        err_code = ble_advdata_set(&advdata, NULL);
        APP_ERROR_CHECK(err_code);
    }
    

    i used nRF Master Control pannel to find my device,and display my device name "n/a",no connect button.Please help me.Thank you!

Children
No Data
Related