BD Address with external memory

5 posts / 0 new
Last post
Shuhei Matsushita
Offline
Last seen:1 year 8 months ago
Joined:2014-01-27 06:53
BD Address with external memory

Hello Dialog Team

I want to reflect BD Address which read form a specific area of external memory to DA14580 .
In AN-B23 chapter 9.1.1 and chapter 12.5 , example source has been described for only trimmig value.
About BD address value read from External memory, I do not know the modification .
How should BD address value from extenal memory reflect to DA14580 ?

Best Regards

WT_Dialog
Offline
Last seen:3 years 2 months ago
Staff
Joined:2013-12-05 14:43
Hi Shuhei,

Hi Shuhei,

BD address is loaded by custom_nvds_get_func into the stack.

uint8_t custom_nvds_get_func(uint8_t tag, nvds_tag_len_t * lengthPtr, uint8_t *buf)
{
uint8_t status = NVDS_FAIL;
switch (tag)
{
case NVDS_TAG_BD_ADDRESS:
#ifdef BDADDR_FROM_OTP //check if dev_bdaddr is not zero
{
if(memcmp(&dev_bdaddr, &co_null_bdaddr, NVDS_LEN_BD_ADDRESS))
{
memcpy(buf,&dev_bdaddr,NVDS_LEN_BD_ADDRESS);
*lengthPtr = NVDS_LEN_BD_ADDRESS;
return NVDS_OK;
}
}
#endif
if (nvds_data_ptr->NVDS_VALIDATION_FLAG & BD_ADDRESS_VALID)
{
if (*lengthPtr < NVDS_LEN_BD_ADDRESS)
{
*lengthPtr = 0;
status = NVDS_LENGTH_OUT_OF_RANGE;
}
else
{
memcpy(buf,nvds_data_ptr->NVDS_TAG_BD_ADDRESS,NVDS_LEN_BD_ADDRESS);
*lengthPtr = NVDS_LEN_BD_ADDRESS;
status = NVDS_OK;
}
}
break;
Instead of copying BD address from the OTP, you can copy the BD address from the flash and assign it the the "buf".
Hope this answers your question.
Shuhei Matsushita
Offline
Last seen:1 year 8 months ago
Joined:2014-01-27 06:53
Hello Dialog Team

Hello Dialog Team

Thanks for your reply.
I confirmed it works well by copying the BD address read from external memory to "buf" in nvds.c, .
I appreciate your information.

BestRegards

Best Regards

double524
Offline
Last seen:3 years 10 months ago
Joined:2016-11-22 02:10
Hi, Dialog

Hi, Dialog
My chipset is also 14580.
I want to change BD address dynamically, therefor, I reference this artical.
I know I must modify custom_nvds_get_func in nvds.c
so I prepare a bd address in char array: {{0x61},{0x62},{0x63},{0x64},{0x65},{0x66}}
here is my custom_nvds_get_func:

extern char device_bd_addr[6];
uint8_t custom_nvds_get_func(uint8_t tag, nvds_tag_len_t *lengthPtr, uint8_t *buf)
{
switch (tag)
{
case NVDS_TAG_BD_ADDRESS:
if (nvds_data_ptr->NVDS_VALIDATION_FLAG & BD_ADDRESS_VALID)
{
if (*lengthPtr < NVDS_LEN_BD_ADDRESS)
{
*lengthPtr = 0;
return NVDS_LENGTH_OUT_OF_RANGE;
}
else
{
uint8_t buf1[6];
memcpy(&buf1,&device_bd_addr,NVDS_LEN_BD_ADDRESS);
*lengthPtr = NVDS_LEN_BD_ADDRESS;
return nvds_get_func(tag, lengthPtr, buf1);
}
}
break;
}
return nvds_get_func(tag, lengthPtr, buf);
}

my invoker is in uart_sps.c

nvds_tag_len_t lengthPtr;
uint8_t buff1[6];
uint8_t re = custom_nvds_get_func(NVDS_TAG_BD_ADDRESS, &lengthPtr, buff1);
if(re == NVDS_OK)
{
app_gapm_reset_msg_create();
app_easy_gap_advertise_with_timeout_stop();
app_easy_gap_undirected_advertise_start();
}

The final bd address had really changed (not default{0x00, 0x00, 0x00, 0xCA, 0xEA, 0x80} ), but its value is not expected {{0x61},{0x62},{0x63},{0x64},{0x65},{0x66}}
it is 0x00, 0x06, 0x00, 0x00, 0x00, 0x00
what's wrong?

MT_dialog
Offline
Last seen:1 hour 42 min ago
Staff
Joined:2015-06-08 11:34
Hi double524,

Hi double524,

I dont exactly get what you are trying to do, but why you allocate an extra local array and copy the bd address from the array that you allready have in a global variable and also why after doing that you call the nvds_get_func() again ?

只要做以下,你将能够get the advertising address that you want from the device_bd_addr array that you have set.

case NVDS_TAG_BD_ADDRESS:
{
if (nvds_data_ptr->NVDS_VALIDATION_FLAG & BD_ADDRESS_VALID)
{
if (*lengthPtr < NVDS_LEN_BD_ADDRESS)
{
*lengthPtr = 0;
return NVDS_LENGTH_OUT_OF_RANGE;
}
else
{
memcpy(buf,device_bd_addr,NVDS_LEN_BD_ADDRESS);
*lengthPtr = NVDS_LEN_BD_ADDRESS;
return(NVDS_OK);
}
}
break;
}

Thanks MT_dialog