11 Replies Latest reply on Jan 7, 2020 4:47 AM by LePo_1062026

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

    LePo_1062026

      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

        • 1. Re: How do I change/assign the BDAddr of a Advertising BLE node?
          PY_21

          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.

          1 of 1 people found this helpful
          • 2. Re: How do I change/assign the BDAddr of a Advertising BLE node?
            LePo_1062026

            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.

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

            #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.

            1 of 1 people found this helpful
            • 3. Re: How do I change/assign the BDAddr of a Advertising BLE node?
              LePo_1062026

              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?

              Len

              • 4. Re: How do I change/assign the BDAddr of a Advertising BLE node?
                PY_21

                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.

                1 of 1 people found this helpful
                • 5. Re: How do I change/assign the BDAddr of a Advertising BLE node?
                  LePo_1062026

                  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

                  • 6. Re: How do I change/assign the BDAddr of a Advertising BLE node?
                    PY_21

                    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.

                    • 7. Re: How do I change/assign the BDAddr of a Advertising BLE node?
                      LePo_1062026

                      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

                      • 8. Re: How do I change/assign the BDAddr of a Advertising BLE node?
                        PY_21

                        Hello Len,

                         

                        Could you please check all the devices silicon ID ?

                         

                        Thanks,

                        P Yugandhar.

                        • 9. Re: How do I change/assign the BDAddr of a Advertising BLE node?
                          LePo_1062026

                          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.

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

                           

                          Len

                          • 10. Re: How do I change/assign the BDAddr of a Advertising BLE node?
                            NazarP_56

                            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

                            3 of 3 people found this helpful
                            • 11. Re: How do I change/assign the BDAddr of a Advertising BLE node?
                              LePo_1062026

                              Nazar,

                               

                              Thank you.  This would explain what I am seeing.

                               

                              Len