5 Replies Latest reply on Apr 6, 2017 9:50 AM by e.pratt_1639216

    MAC address

    brian.luebke

      I was led to believe that each CYBLE-022001-00 radio module has a unique  MAC address within.

         

      This appears to be true, as I can see it display, on the top of the screen, when I talk to the device with CySmart.

         

      I was told to use an API CyBle_GetDeviceAddress() to read this address.  However, the address this returns is the same every time, on every device.

         

      I'm reading "91:95:19:29:49:99" on every one of my boards, which doesn't look like a MAC address to me.  

         

      CySmart displays a unique number for each device I connect to. [FD:CB:A2:14:16:29] and [FD:CB:A2:14:16:18].

         

       

         

      How can I access this value with the software?  is CyBle_GetDeviceAddress() the right service? or is there another one to get what I'm after??

         

      Thanks

        • 1. Re: MAC address
          user_78878863

          GetDeviceAdress() doesn't return the MAC, but the "device address". This is the one configured in the BLE settings (see BLE component data sheet page 30). If you need a chip-specifi address then you can add a silicon-generated part to that address.

             

          I'm not sure what CySmart is showing you, I would need to look at the sources. What is the label for that field where you see this?

          • 2. Re: MAC address
            brian.luebke

            Thanks for the response!!  I also got some guidance from our local Cypress FAE.

               

            Here's what I did, worked great!

               

                    // read the value from the registers
                    cyBle_deviceAddress.bdAddr[0] = CYBLE_SFLASH_DIE_X_REG;
                    cyBle_deviceAddress.bdAddr[1] = CYBLE_SFLASH_DIE_Y_REG;
                    // cyBle_deviceAddress.bdAddr[2] = CYBLE_SFLASH_DIE_WAFER_REG;

               

                    // convert the values to ascii and store in the device name field.
                    DeviceName[7] = ((cyBle_deviceAddress.bdAddr[1] & 0xF0) >> 4) + 48 ;
                    DeviceName[8] = (cyBle_deviceAddress.bdAddr[1] & 0x0F) + 48 ;
                    DeviceName[9] = ((cyBle_deviceAddress.bdAddr[0] & 0xF0) >> 4) + 48 ;
                    DeviceName[10] = (cyBle_deviceAddress.bdAddr[0] & 0x0F) + 48 ;

               

                    CyBle_GapSetLocalName(DeviceName);

            • 3. Re: MAC address
              e.pratt_1639216

              For those looking for ways to get the BDAddress of the local device (the one running the code):

                 

              Cyble_GetDeviceAddress()

                 

              For those looking to get the BDAddress of the remote device (the one we are connected with using bluetooth):

                 

              Cyble_GapGetPeerBdAddr()

                 

              Both are listed in the BLE component datasheet for more details.

              • 4. Re: MAC address
                mas129_2256741

                For Cyble_GapGetPeerBdAddr() what is the uint8 bdHandler that you pass?  Or can you explain a little more about the function?

                • 5. Re: MAC address
                  e.pratt_1639216

                  After connecting to another Bluetooth device, or being connected to by it, you can call Cyble_GapGetPeerBdAddr() to get the 6-byte bluetooth address of the connected device.

                     

                  The bdHandle is the value of the handle to the connected device. Currently the chips only support one at a time, so I pass cyBle_connHandle.bdHandle to it, and the second parameter is a pointer to the CYBLE_GAP_BD_ADDR_T variable to store the retrieved address in.

                     

                  Here's an example call:

                     

                  result = CyBle_GapGetPeerBdAddr(cyBle_connHandle.bdHandle, &CurrentDeviceAddress);

                     

                  Here is what the source code comment says:

                     

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

                     

                  * Function Name: CyBle_GapGetPeerBdAddr

                     

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

                     

                     

                  *  This function reads the peer Bluetooth device address which has already been

                     

                  *  fetched by the BLE Stack. 'peerBdAddr' stores the peer's Bluetooth device

                     

                  *  address identified with 'bdHandle'. This is a blocking function. No event is

                     

                  *  generated on calling this function.

                     

                  *     

                     

                  *  \param bdHandle: Peer device handle.

                     

                  *  \param peerBdAddr: Empty buffer where the Bluetooth device address gets stored.

                     

                     

                  * \return

                     

                  *  CYBLE_API_RESULT_T : Return value indicates if the function succeeded or

                     

                  *  failed. Following are the possible error codes.

                     

                  *

                     

                  *   Errors codes                     | Description

                     

                  *   ------------                     | -----------

                     

                  *   CYBLE_ERROR_OK                   | On successful operation.

                     

                  *   CYBLE_ERROR_INVALID_PARAMETER    | On specifying NULL as input parameter for 'peerBdAddr'.

                     

                  *   CYBLE_ERROR_NO_DEVICE_ENTITY     | Specified device handle does not map to any device handle entry in BLE stack.

                     

                     

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