Hi Dialog,
In your sample128 project, I set device name as "12345" manually in app_adv_function. I also set the device name in NVDS as "abc" and at the same time UNDEFINE CFG_NVDS. In this situation, I think BLE stack will NOT use NVDS anymore.
But, I found in LightBlue app, only in scanning mode(when we could see a list of devices), the device name is showed as what I expected( "12345"). Once I connect to the device through the app, the device name change to the value in NVDS("abc"). If I pair the device with iOS, the device name in pair list is also "abc", NVDS value. I don't think the device name store in NVDS should appear in any case because I have already undefined CFG_NVDS.
So, my question will be:
1. Why sometimes the device name is the value I set in app_adv_func and sometime it is the value store in NVDS even after I undefine CFG_NVDS.
2. How could I maintain a unify device name if I want to set the device name dynamically(through a I2C event)?
Thanks a lot and looking forward to your response.
Best Regards,
Question update:
I change the Device name in NVDS in main_func before BLE stack before BLE init function. Now the device name work as I expect.
But I meet a found a new problem:
I generated resolvable private random address and Security mode 1 level 3 in my application. If I just pair one device with my iPhone, everything is all right. But if I paired the second device, my first device will not even shown in device list of LightBlue app. If I delete the pairing information of my second device in iOS setting, the first device will show in the list again.
Do you think this issue is also related to some NVDS values? I am sure the IRK of these two device is different because I set two different value manually in app_configuration_func.
Thanks a lot,
HiZeyu,
Can you please re-state your objectives. What behaviour you would like to see.
The description above is based on the changes you have made.
It will be easier if you can clarify your end objective, then we can suggest some modifications.
Thanks,
TR_DIALOG
Hi TR_Dialog,
Thanks a lot for your reply. Before everything, all my code are based on your sample128 project.
1.I undefine CFG_NVDS and set device name in app_adv_func. When I try to discovery the device under Light Blue app for iOS, the device name is shown as the value I set in app_adv_func. But after I connect to the device, device name change to the value in NVDS. The device name in iOS paired device list is also the same as NVDS device name value.
I solved this problem by setting device name in NVDS before BLE stack is inited, but I am really curious about why the device name store in NVDS still shows in some place even I undefine CFG_NVDS.
2. I use Generated resolvable private random address and Security mode 1 Level 3 in my application. I paired two device to the same iPhone and each of these device has a unique IRK and device name. I could see two paired device in iOS paired device list. But after I paired the second device, the first device will shown as the second device's name. I change the device address in NVDS, everything is right.
From all the things I observed, I really want to know:
1 Why BLE still use information in NVDS even after I undefine CFG_NVDS.
2. What's the difference of setting advertising data in app_adv_func and NVDS data section.
3. Is that true that the Generated resolvable private random address is based on the device address value in NVDS?
Please feel free to contact me if any additional information is needed.
非常感谢,等待您的回复。
Hi Zeyu:
Thanks for describing your modifications. From that I infer the following as your objective:
- You would like to change the Device Name in advertisements in two different images loaded onto two different devices? Is this what you are trying to achieve.If that is the goal you just have to modify the field NVDS_TAG_DEVICE_NAME in nvds.c
What is the need for undefining CFG_NVDS?
Thanks,
TR_DIALOG
Hi TR_Dialog,
The reason why I undefined CFG_NVDS is I want to set the BLE parameter(device name, IRK...) through I2C bus by another processor.
So, to start with, I make the program wait at main_func for an I2C set device name package. After that, I store the device name in a buffer and use the buffer date to set device name and IRK in app_adv_func and app_configuration_func. Since I get the device name from my buffer, not from NVDS, so I disable CFG_NVDS.
In this way, the device name shows buffer value before I connect DA to my iPhone. But after I connected DA to my iPhone, the device name change to the value in NVDS. I am confused by why my device shows as two different names and what's the difference of setting device name in app_adv_func and setting device name in NVDS.
I solve this problem by setting the device name in NVDS according to my buffer data before BLE stack init. But I am still wondering why the device name stored in NVDS is still being used even I undefined CFG_NVDS and when exactly the information in NVDS is used.
Latter on, I found if I paired two of my devices to the same iPhone, iOS with regard the first device as the second one(latter paired device). I am sure each of them has a unique IRK. Latter, I change the device address value in NVDS according my I2C package before BLE stack is init and solve the problem. I think the reason here is even I use a private resolvable random address and undefined CFG_NVDS, the BLE stack still generate the resolvable random address base on the information in NVDS.
Again, I solve the two problems by changing the value in NVDS in the case that I think I totally disable NVDS. So, questions I want to ask is:
1. Why the date in NVDS is still being used even I undefined CFG_NVDS.
2. When device name stored in NVDS is used and when device set in app_adv_func is used? Why if the device name in NVDS is different from the on I set in app_adv_func, I could get two different names of the same device before and after the connection is built.
3. Is the generated resolvable private random address related to the device address store in NVDS? To expand this question, when the data store in NVDS is used?
Am I make things clear?
Thanks a lot.
您好对话框:
I modifiy field dA14580 to Dialog_14580. Now i face problem of length of field. How to increase the length of this field so that we can have longer Name .
in nvds.c
德维克E_NAME_TAG_LEN
Hi Zeyu:
Can you clarify the following comment: "In this way, the device name shows buffer value before I connect DA to my iPhone. But after I connected DA to my iPhone, the device name change to the value in NVDS.". Does it show in advertisement? I can say that in app_adv_func, whatever name you put will show up in advertisement. Let me know if you are seeing the device name change thru the following sequence: advertising -> connect -> disconnect -> advertising. The device name should not chnage thru this sequence.
To answer one of your questions: BLE stack retrieves parameters via custom_nvds_get_func when it is reset.
can you post your code for the function app_adv_func?
Also, you might want to review the following document:http://support.dialog-semiconductor.com/system/files/resources/AN-B-022_DA14580_Resolvable_private_address_guidelines.pdf
Thanks,
TR_DIALOG
Hi TR_Dialog,
If you use Light Blue app, you will see the device name change after I connect to the device. After connected, you could also find the Device name shown at the TOP is different from the advertisement package. Please make the device name in app_adv_func differ from value in NVDS. undefine NVDS and see whether you will get the same result as me.
My app_adv_func:
void app_adv_func(struct gapm_start_advertise_cmd *cmd)
{
// Start advertising. Fill GAPM_START_ADVERTISE_CMD message
// Device Name Length
uint8_t device_name_length;
int8_t device_name_avail_space;
uint8_t device_name_temp_buf[64];
uint8_t manufacture_date[10];
cmd->op.code = GAPM_ADV_UNDIRECT;
cmd->op.addr_src = GAPM_GEN_RSLV_ADDR;/*GAPM_GEN_STATIC_RND_ADDR;*///GAPM_PUBLIC_ADDR;
cmd-> op.renew_dur = 15000;
cmd->intv_min = APP_ADV_INT_MIN;
cmd->intv_max = APP_ADV_INT_MAX;
cmd->channel_map = APP_ADV_CHMAP;
cmd->info.host.mode = GAP_GEN_DISCOVERABLE;
/*-----------------------------------------------------------------------------------
* Set the Advertising Data and the Scan Response Data
*---------------------------------------------------------------------------------*/
cmd->info.host.adv_data_len = APP_ADV_DATA_MAX_SIZE;
cmd->info.host.scan_rsp_data_len = APP_SCAN_RESP_DATA_MAX_SIZE;
#ifdef HAS_WHITE_LIST
if (white_list_written)
cmd->info.host.adv_filt_policy = ADV_ALLOW_SCAN_WLST_CON_WLST;
else
cmd->info.host.adv_filt_policy = ADV_ALLOW_SCAN_ANY_CON_ANY;
#else
cmd->info.host.adv_filt_policy = ADV_ALLOW_SCAN_ANY_CON_ANY;
#endif
//cmd->info.host.adv_filt_policy = ADV_ALLOW_SCAN_ANY_CON_ANY;
// Advertising Data
#if (NVDS_SUPPORT)
if(nvds_get(NVDS_TAG_APP_BLE_ADV_DATA, &cmd->info.host.adv_data_len,
&cmd->info.host.adv_data[0]) != NVDS_OK)
#endif //(NVDS_SUPPORT)
{
//GPIO_SetActive(GPIO_PORT_1,GPIO_PIN_0);
cmd->info.host.adv_data_len = 10;
memcpy (&manufacture_date [0], " \ x09 \ xff ", 2);
memcpy(&manufacture_date[0] + 2, &bb_device_name[0] + 4, 8);
memcpy(&cmd->info.host.adv_data[0], &manufacture_date[0], cmd->info.host.adv_data_len);
}
// Scan Response Data
#if (NVDS_SUPPORT)
if(nvds_get(NVDS_TAG_APP_BLE_SCAN_RESP_DATA, &cmd->info.host.scan_rsp_data_len,
&cmd->info.host.scan_rsp_data[0]) != NVDS_OK)
#endif //(NVDS_SUPPORT)
{
cmd->info.host.scan_rsp_data_len = APP_SCNRSP_DATA_LENGTH;
memcpy(&cmd->info.host.scan_rsp_data[0], APP_SCNRSP_DATA, cmd->info.host.scan_rsp_data_len);
}
// Get remaining space in the Advertising Data - 2 bytes are used for name length/flag
device_name_avail_space = app_add_data_max_size - cmd-> info.host.adv_data_len - 2;
// Check if data can be added to the Advertising data
if (device_name_avail_space > 0)
{
// Get the Device Name to add in the Advertising Data (Default one or NVDS one)
/*#if (NVDS_SUPPORT)
device_name_length = NVDS_LEN_DEVICE_NAME;
if (nvds_get(NVDS_TAG_DEVICE_NAME, &device_name_length, &device_name_temp_buf[0]) != NVDS_OK)
#endif //(NVDS_SUPPORT)
{
// Get default Device Name (No name if not enough space)
device_name_length = strlen(APP_DEVICE_NAME);
memcpy(&device_name_temp_buf[0], APP_DEVICE_NAME, device_name_length);
}
*/
device_name_length = BB_DEVICENAME_SIZE;
memcpy(&device_name_temp_buf[0],bb_device_name,BB_DEVICENAME_SIZE);
//memcpy(device_name_temp_buf,"bfob01234567",12);
if(device_name_length > 0)
{
// Check available space
device_name_length = co_min(device_name_length, device_name_avail_space);
// Fill Length
cmd->info.host.adv_data[cmd->info.host.adv_data_len] = device_name_length + 1;
// Fill Device Name Flag
cmd->info.host.adv_data[cmd->info.host.adv_data_len + 1] = '\x09';
// Copy device name
memcpy (cmd - > info.host.adv_data [cmd - > info.host.adv_data_len + 2], device_name_temp_buf, device_name_length);
// Update Advertising Data Length
cmd->info.host.adv_data_len += (device_name_length + 2);
}
}
return;
}
Thanks!
Hi Zeyu:
One thing i would like to point out that the device name you see on Light Blue on iPhone is not necessarily the device name DA14580 is putting out on the air. ios does cache some information hence the discrepancy. To get around this I always sniff, using Front Line, over the air while developing code.
I will review your app_adv_func and provide feedback. Did you have a chance to review the document:http://support.dialog-semiconductor.com/system/files/resources/AN-B-022_DA14580_Resolvable_private_address_guidelines.pdf
Thanks,
TR_DIALOG
HI TR_DIALOG,
I understand there is some special BLE policy in iOS, but it seems the device name shown in Light Blue after I connected the device will always keep the same as the one store in NVDS.
Also, I changed Sample128 project as AN-B-022 and I think the resolvable random address works fine for a single device: each time the device will show as a different address and iOS could reconnect to it after paired. But if I turn on two device at the same time and paired both of my device to the same iPhone. IPhone will regard both of them as the latter paired one.
Latter on, I changed the device in NVDS. After that, my iPhone could distinguish these two devices without any error.
Again, I guess even I undefine CFG_NVDS and set my own BLE setting in those app_xxx function, BLE still use information store in NVDS. So, I really want to check with your guys to see whether I configure something wrong and how exactly NVDS is utilized by BLE stack.
Thanks!
hi,
.NVDS_TAG_APP_BLE_SCAN_RESP_DATA = "xxx"
#define APP_SCNRSP_DATA "xxx"
what are the relationship and difference between them?
Thank you!
when you can read scan response data successfully, the NVDS_TAG_APP_BLE_SCAN_RESP_DATA is used. And if there is something wrong, APP_SCNRSP_DATA is used.
if(nvds_get(NVDS_TAG_APP_BLE_SCAN_RESP_DATA, &cmd->info.host.scan_rsp_data_len,
&cmd->info.host.scan_rsp_data[0]) != NVDS_OK)
{
cmd->info.host.scan_rsp_data_len = APP_SCNRSP_DATA_LENGTH;
memcpy(&cmd->info.host.scan_rsp_data[0], APP_SCNRSP_DATA, cmd->info.host.scan_rsp_data_len);
}
Thank you, summer20100514
I have a app to connect the da14580, when the uuid is included in the scan response data, the app will show the device and I can connect,
I change the APP_SCNRSP_DATA , app works fine,
I change the response data in nvds.c, from app I can't see the device,
that means nvds_get is always not ok, when it will become ok, and why define in two different places?
There must be something wrong with your settings of response data in nvds.c, you may check the format and length of it.
Thank you for your reply!
the code is:
#define APP_SCNRSP_DATA "\x11\x06\xDE\x12\xA5\x98\x1A\x03\x34\xF7\xAB\xA8\x95\xA2\x80\x29\x70\xB0"
.NVDS_TAG_APP_BLE_SCAN_RESP_DATA = " \ x09 \ xFF \ x00 \ x60\x52\x57\x2D\x42\x4C\x45",
.SCAN_RESP_DATA_TAG_LEN = 10,
why app scan, da14580 always response data from APP_SCNRSP_DATA, but the dev name is always from nvds.c?
when NVDS_TAG_APP_BLE_SCAN_RESP_DATA will be used, and why use "\x"?