How do I change/assign the BDAddr of a Advertising BLE node?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

Hi,

I've got multiple BLE Advertising nodes and one Observer.  I'm trying to identify each Advertiser uniquely at the Observer.  Right now, they all have the same 48bit BDAddr.

All the Advertising nodes have the same application in it. Is there a way to use part of the SIlicon ID as the BDAddr?

I've trying using the following code to change the BDAddr with no luck.  Maybe this is the correct code but not in the correct place.

    cy_stc_ble_gap_bd_addr_t bdaddr = {{0xFF, 0xBB, 0xAA, 0x50, 0xA0, 0x00}, 0};    // create the BDAddr struct

    Cy_BLE_ChangeAdDeviceAddress(&bdaddr, 0);            // fill in the new BDAddr

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
1 Solution

Hi Leo,

It is a known issue - "if the BLE configured only as a broadcaster, the configuration for a BD address in the BLE customizer is not effective"

the issue will be fixed in PDL 3.1.1 / BLE_PDL 2.20 (for PSoC Creator) -  Q1 2020.

for ModusToolbox, it has already fixed in BLESS MW 3.30.

W/A(s):
1. Enable "Peripheral" GAP Role in BLE Customizer (additional to Broadcaster)

or

2. Generate and set BD address from the application (Cy_BLE_GAP_SetBdAddress)

Regards,

Nazar

View solution in original post

11 Replies
lock attach
Attachments are accessible only for community members.
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello Len,

Ques: Is there a way to use part of the SIlicon ID as the BDAddr?
Ans: In the BLE component, if you enable 'Silicon generated “Company assigned” part of device address'(as shown in below attached image) the “Company assigned” part of the device address will be generated using the factory programmed die X/Y location, wafer ID and lot ID of the silicon. Please refer to this KBA link for more information Setting Bluetooth Device Address – KBA211407 .


1. In the CY_BLE_EVT_STACK_ON event, please use the Cy_BLE_GAP_GenerateBdAddress() to first generate an address followed by Cy_BLE_GAP_SetBdAddress(). This function generates either public or random address based on 'type' specified by param->'addrType'. Application should call Cy_BLE_GAP_SetBdAddress() function to set the generated address. Please refer to the below attached sample project for setting the device address.
2. If the application sets a public or random static address using Cy_BLE_GAP_SetBdAddress() function, then the application should set the same address as the Identity address by calling Cy_BLE_GAP_SetIdAddress() function.

The function Cy_BLE_ChangeAdDeviceAddress() is used to set the Bluetooth device address into the advertisement or scan response data structures. So, during Advertisement, device will advertise this address through advertisement or scan response data.


Thanks,
P Yugandhar.

P Yugandhar,

Thank you for your help.  I've modified my code as per your suggestions (See code frags below).  Sadly, I'm getting a run-time fault.

pastedImage_2.png

If I set a breakpoint at line 13, here is the local var results of new_bdaddr:

pastedImage_3.png

#define TARGET_BDADDR   {{0xFF, 0xBB, 0xAA, 0x50, 0xA0, 0x00}, 0}

_Bool devaddrgencmpt = false;

/*******************************************************************************/

void BLE_Adv_Config(uint8_t config_idx)

{

    Cy_BLE_GAPP_StopAdvertisement();

    while(Cy_BLE_GetAdvertisementState() != CY_BLE_ADV_STATE_STOPPED){Cy_BLE_ProcessEvents();}    // wait until advertising stops.

cy_stc_ble_gap_bd_addr_info_t new_bdaddr= { .addrType = CY_BLE_GAP_PUBLIC_ADDR, .gapBdAddr = TARGET_BDADDR,};

    Cy_BLE_GAP_GenerateBdAddress(&new_bdaddr);

    devaddrgencmpt = false;

    while(devaddrgencmpt == true) {Cy_BLE_ProcessEvents();}

    Cy_BLE_GAP_SetBdAddress(&new_bdaddr.gapBdAddr);

    Cy_BLE_GAPP_StartAdvertisement(CY_BLE_ADVERTISING_FAST, config_idx);

}

/*******************************************************************************/

void StackEventHandler(uint32 event, void *eventParam)

{

...

        /* This event is received when the BLE component is Started */

        case CY_BLE_EVT_STACK_ON:

        {

...

            BLE_Adv_Config(CY_BLE_BROADCASTER_CONFIGURATION_0_INDEX);

            break;

          }

...

        case CY_BLE_EVT_GAP_DEVICE_ADDR_GEN_COMPLETE: /* 0x4013u */

        {

            DEBUG_BLE("CY_BLE_EVT_GAP_DEVICE_ADDR_GEN_COMPLETE \r\n");

                devaddrgencmpt = true;

            break;

        }

...

}

if I comment out lines 9 through 13, the code runs but the BdAddr is not set to my intended BdAddr but to default BdAddr.

Len
"Engineering is an Art. The Art of Compromise."

P Yugandhar,

Update:

I was able to get the TARGET_BDADDR to set and work if I do I of two changes to the code in the previous post.

  • change line 9 to:

static cy_stc_ble_gap_bd_addr_info_t new_bdaddr= { .addrType = CY_BLE_GAP_PUBLIC_ADDR, .gapBdAddr = TARGET_BDADDR,};

or

  • move line 9 outside all the functions as a module static var.

Now the problem is partially solved.  The now working-ish code loads a static public BdAddr to use during the advertisement.  This is the technique used in the CE217637_BLE_Find_Me01 project you attached.

I want to use a unique BdAddr address based on the Silicon ID as you mentioned in your original post.  My BLE configuration does have the Silicon generated "Company assigned" part of device address checked.  What else do I need to do to get the Cy_BLE_GAP_GenerateBdAddress() to create this unique BdAddr?

pastedImage_3.png

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hello Len,

The APIs (Cy_BLE_GAP_GenerateBdAddress(), Cy_BLE_GAP_SetBdAddress()) are used by the user for setting the Bluetooth device address in the firmware. If you want to use the Silicon generated part of the device address then you have to enable it in the BLE component (where the “Company assigned” part of the device address will be generated using the factory programmed die X/Y location, wafer ID and lot ID of the silicon) without using the APIs in firmware. This will generate a unique device address based on silicon ID.

Thanks,
P Yugandhar.

P Yugandhar,

My BLE configuration does have the Silicon generated "Company assigned" part of device address checked.

I commented out the Cy_BLE_GAP_GenerateBdAddress() and Cy_BLE_GAP_SetBdAddress() API calls.

When I rebuilt the project, ALL BLE Broadcasters with this build have the exact same BdAddr of 80:CD:AB:CD:AB:80:Public 

Apparently something else is not working.

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hello Len,

Could you please check the silicon ID of your device? The API Cy_SysLib_GetUniqueId() is used to get the silicon unique ID. Where, the ID includes Die lot[3], Die Wafer, Die X, Die Y, Die Sort, Die Minor and Die Year.

Thanks,
P Yugandhar.

0 Likes

P Yugandhar,

Done.  Below is the Silicon ID one one of the PSoC6s.

"Broadcast Role" Build: 3.4.1 Jan  4 2020 15:13:16

Unique Silicon ID: ED6F081A1295C7C0

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hello Len,

Could you please check all the devices silicon ID ?

Thanks,

P Yugandhar.

0 Likes

P Yugandhar,

Here is a debug snippet of the Observer decoding the data in advertising packets from three Broadcasters.

Shown in the snippet is the BdAddr and Manufacturer Specific Data with 8 bytes of data being the Silicon ID for each Broadcaster.

pastedImage_1.png

If the BdAddr is Silicon ID generated "unique", then the algorithm is not so unique.

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hi Leo,

It is a known issue - "if the BLE configured only as a broadcaster, the configuration for a BD address in the BLE customizer is not effective"

the issue will be fixed in PDL 3.1.1 / BLE_PDL 2.20 (for PSoC Creator) -  Q1 2020.

for ModusToolbox, it has already fixed in BLESS MW 3.30.

W/A(s):
1. Enable "Peripheral" GAP Role in BLE Customizer (additional to Broadcaster)

or

2. Generate and set BD address from the application (Cy_BLE_GAP_SetBdAddress)

Regards,

Nazar

Nazar,

Thank you.  This would explain what I am seeing.

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes