MAC address

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

cross mob
Anonymous
Not applicable

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

0 Likes
1 Solution
Anonymous
Not applicable

Hi Brian,

The CyBle_GetDeviceAddress() function needs to be called after CYBLE_STACK_ON, i.e. after the stack has been initialized. If you call it before that, the function might return invalid data.

Also, you don't have to set the device address manually as you have mentioned in 2. Re: MAC address . If you select the Silicon Generated ID in the BLE component, then it will be initialized automatically.

View solution in original post

0 Likes
6 Replies
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

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?

0 Likes
Anonymous
Not applicable

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);

0 Likes
Anonymous
Not applicable

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.

0 Likes
Anonymous
Not applicable

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

0 Likes
Anonymous
Not applicable

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.

   

   

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

0 Likes
Anonymous
Not applicable

Hi Brian,

The CyBle_GetDeviceAddress() function needs to be called after CYBLE_STACK_ON, i.e. after the stack has been initialized. If you call it before that, the function might return invalid data.

Also, you don't have to set the device address manually as you have mentioned in 2. Re: MAC address . If you select the Silicon Generated ID in the BLE component, then it will be initialized automatically.

0 Likes