I have a Bluetooth question and would like to consult you. How to ensure the uniqueness of the Bluetooth address, the same program is burned into different chips, how to ensure that the Bluetooth address is different?
我说的是Bluetooth MAC address.What I am talking about is the Bluetooth MAC address. The problem is that downloading the same program will have the same Bluetooth MAC address
What is the BD address that the device is advertising? If you are not using random BD address, the device will advertise with the BD address that is set in your application code. Can you please share more inputs for what you have accomplish? What is the type of the BD address?
Yes,it is advertising BD address.Does a random Bluetooth address guarantee that every BD address is different? How do I use a random Bluetooth address, please guide me.
In order to advertise with static random BD address, you should change the .addr_src item of user_adv_conf structure to GAPM_GEN_STATIC_RND_ADDR. This structure is under user_config.h file. Please take a look into the app_easy_gap_undirected_advertise_start_create_msg() function that creates the advertising message for connectable undirected event. If the user_adv_conf.addr_src is configured as GAPM_GEN_STATIC_RND_ADDR, the generate_static_random_address() will be triggered, that generates 48-bit static random address.
It’s under5.0.4\sdk\app_modules\src\app_common\app.c SDK path. Which SDK version are you using? You have tagged the DA14580 product, so the recommend SDK is version 5.0.4.
By default, the device starts advertising with static public BD Address. The default value of the public address is declared in sdk/ble/config/ble_config.h file. If a new value is required to be defined then the new macro definition should take place in config/custom_config_xxx.h file where all custom definitions should be declared. For example :
In case of setting a random BD address, you should do the following:
/*Initialize the BLE structure related to the BD address */ static const own_address_t user_bd_address = { .addr_type = PRIVATE_RANDOM_NONRESOLVABLE_ADDRESS, .addr = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06} }; /*Set the Bluetooth address */ ble_gap_address_set(&user_bd_address, 0x00FF);
If you follow your example, then in mass production, the Bluetooth MAC address of each product will be the same. This will definitely not work,Is there a better way?
不,它将为每个设备和BD地址是唯一的ss of device will change at least every 150s. But if you set address type is PRIVATE_RANDOM_NONRESOLVABLE_ADDRESS, as PM_Dialog said, you will be not able to connect. Nonresolvable address is for beacons or non-connectable devices.
I use ble_gap_address_set (& user_bd_address, 0x00FF) to set the BD address. Why can this device be scanned by Android phones, but not by Apple phones? My data is as follows:
/*Initialize the BLE structure related to the BD address */ static own_address_t user_bd_address = { .addr_type = PRIVATE_STATIC_ADDRESS, .addr = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06} };
Let me explain how the BD address in handled in our SDK. When the device boots, the BLE adapter will access the NVMS_PARAM_PART partition and check if a valid BD address is placed in this partition. The first entry of that partition, is the NVPARAM_BLE_PATFORM_BD_ADDRESS and it has 7 bytes length:
- 6 bytes for the BD address
- 1 byte that designates the validity of the written BD address.
You can also use the SmartSnippets Toolbox to read the NVMS_PARAM_PART.
If the user has not written any BD address in that partition or if the flag is invalid (disabled) then, the application will take the default public BD address. Please check read_public_address() function in BLE adapter (ad_ble.c file).
When no device address is provided by the developer the Bluetooth public address is used. The default value of the public address is declared in sdk/ble/config/ble_config.h file. If a new value is required to be defined then the new macro definition should take place in config/custom_config_xxx.h file where all custom definitions should be declared.
The update_bd_address() function aims to generate a BD address based on the TRNG (True Random Number Generator) engine and set it by calling the ble_gap_address_set(). Then, the previously generated address will be written into the NVMS_PARAM_PART. So, after a cold boot (reset) takes place, the device will use the BD address written in the flash. Please find the source code in the attachments. You will also find code snippet for the verification.
Generally, there are three (3) ways to configure the BD address:
1. Define a unique public address. So, the defaultBLE_STATIC_ADDRESS macro should be defined in custom_config_xxx.h
2. Write a BD address in the NVMS_PARAM_PART flash partition. The SDK will overwrite the public address defined in defaultBLE_STATIC_ADDRESS macro definition.
3. Define a unique BD address by calling the ble_gap_address_set() API. This API can be called at any time to change the BD address of the device.
Hi There,
What kind of BD address are you using? Is it static random? Can you please share more inputs on this?
Thanks, PM_Dialog
hi,
我说的是Bluetooth MAC address.What I am talking about is the Bluetooth MAC address. The problem is that downloading the same program will have the same Bluetooth MAC address
Hi There,
What is the BD address that the device is advertising? If you are not using random BD address, the device will advertise with the BD address that is set in your application code. Can you please share more inputs for what you have accomplish? What is the type of the BD address?
Thanks, PM_Dialog
Hi,
Yes,it is advertising BD address.Does a random Bluetooth address guarantee that every BD address is different? How do I use a random Bluetooth address, please guide me.
Hi There,
In order to advertise with static random BD address, you should change the .addr_src item of user_adv_conf structure to GAPM_GEN_STATIC_RND_ADDR. This structure is under user_config.h file. Please take a look into the app_easy_gap_undirected_advertise_start_create_msg() function that creates the advertising message for connectable undirected event. If the user_adv_conf.addr_src is configured as GAPM_GEN_STATIC_RND_ADDR, the generate_static_random_address() will be triggered, that generates 48-bit static random address.
Thanks, PM_Dialog
hi,
I can't find the app_easy_gap_undirected_advertise_start_create_msg () function? Please explain the location of that function.
Hi There,
It’s under5.0.4\sdk\app_modules\src\app_common\app.c SDK path. Which SDK version are you using? You have tagged the DA14580 product, so the recommend SDK is version 5.0.4.
Thanks, PM_Dialog
hi there,
Sorry, the product and SDK I marked are wrong, I use DA14695, and use the latest SDK version
Hi There,
By default, the device starts advertising with static public BD Address. The default value of the public address is declared in sdk/ble/config/ble_config.h file. If a new value is required to be defined then the new macro definition should take place in config/custom_config_xxx.h file where all custom definitions should be declared. For example :
In case of setting a random BD address, you should do the following:
The .addr will be ignored.
Thanks, PM_Dialog
Hi There,
If you follow your example, then in mass production, the Bluetooth MAC address of each product will be the same. This will definitely not work,Is there a better way?
不,它将为每个设备和BD地址是唯一的ss of device will change at least every 150s. But if you set address type is PRIVATE_RANDOM_NONRESOLVABLE_ADDRESS, as PM_Dialog said, you will be not able to connect. Nonresolvable address is for beacons or non-connectable devices.
I set up my unique address in this way:
you are able to change the address renew period.
Unfortunately, there is no private static BD address burned at production, like at nRF52 MCUs.
Hi There,
I use ble_gap_address_set (& user_bd_address, 0x00FF) to set the BD address. Why can this device be scanned by Android phones, but not by Apple phones? My data is as follows:
/*Initialize the BLE structure related to the BD address */
static own_address_t user_bd_address = {
.addr_type = PRIVATE_STATIC_ADDRESS,
.addr = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06}
};
Hi There,
Let me explain how the BD address in handled in our SDK. When the device boots, the BLE adapter will access the NVMS_PARAM_PART partition and check if a valid BD address is placed in this partition. The first entry of that partition, is the NVPARAM_BLE_PATFORM_BD_ADDRESS and it has 7 bytes length:
- 6 bytes for the BD address
- 1 byte that designates the validity of the written BD address.
You can also use the SmartSnippets Toolbox to read the NVMS_PARAM_PART.
If the user has not written any BD address in that partition or if the flag is invalid (disabled) then, the application will take the default public BD address. Please check read_public_address() function in BLE adapter (ad_ble.c file).
When no device address is provided by the developer the Bluetooth public address is used. The default value of the public address is declared in sdk/ble/config/ble_config.h file. If a new value is required to be defined then the new macro definition should take place in config/custom_config_xxx.h file where all custom definitions should be declared.
The update_bd_address() function aims to generate a BD address based on the TRNG (True Random Number Generator) engine and set it by calling the ble_gap_address_set(). Then, the previously generated address will be written into the NVMS_PARAM_PART. So, after a cold boot (reset) takes place, the device will use the BD address written in the flash. Please find the source code in the attachments. You will also find code snippet for the verification.
Generally, there are three (3) ways to configure the BD address:
1. Define a unique public address. So, the defaultBLE_STATIC_ADDRESS macro should be defined in custom_config_xxx.h
2. Write a BD address in the NVMS_PARAM_PART flash partition. The SDK will overwrite the public address defined in defaultBLE_STATIC_ADDRESS macro definition.
3. Define a unique BD address by calling the ble_gap_address_set() API. This API can be called at any time to change the BD address of the device.
Thanks, PM_Dialog