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

OTA fail after set the public address

Hi,

I'm using the nRF5_sdk V11.0 and S130 on nRF51822, we need to write a 6 bytes address to the CUSTOMER register(address is 0x100010f8) of the UICR when mass production, then I will read it out to use sd_ble_gap_address_set function change the gap address. The code as follow:

   static void Mac_Addr_Set(void)
{
	 uint8_t i = 0;
	 uint8_t mac_addr[8];
	 uint32_t err_code;
	 ble_gap_addr_t gap_addr;
	 const uint8_t *addr = (uint8_t *)0x100010f8;
	
	 for(i=0;i<8;i++)
	 {
			mac_addr[i] = (uint8_t)*(addr);
			addr++;
	 }	
	 if(((mac_addr[0]!=0)&&(mac_addr[1]!=0)&&(mac_addr[2]!=0)&&(mac_addr[3]!=0)&&(mac_addr[4]!=0)&&(mac_addr[5]!=0))||
			((mac_addr[0]!=0xFF)&&(mac_addr[1]!=0xFF)&&(mac_addr[2]!=0xFF)&&(mac_addr[3]!=0xFF)&&(mac_addr[4]!=0xFF)&&(mac_addr[5]!=0xFF)))
	 {
			gap_addr.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC;
			memcpy(gap_addr.addr, mac_addr, 6); 			
	 
			err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &gap_addr);
			APP_ERROR_CHECK(err_code);				        
	 }

But I found that, OTA fails if I read the address out to set the public address,the APP stops at "Enabling DFU bootloader...". OTA is good if I don't call the Mac_Addr_Set() function to set gap address. what is more strange, when the OTA fail, I do OTA again and then is OK. Than is to say, I need to do twice OTA so that it can update the firmware.

Also I use the heart rate example(s130_with_dfu) to test, it meets the same problem. Could anyone give me some advice? Thanks.

Best regards, Alice

Related