- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to have the last 4 characters of my device name be the last 4 hex characters of the MAC address.
So in order to do this:
-How do I retrieve the device MAC address?
-How do I programmatically set the device name ?
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use CyBle_GetDeviceAddress to get the device MAC address. Use CyBle_GapSetLocalName to set the device local name. Call this API before the advertisement start APIs so that the device advertises with the new address.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use CyBle_GetDeviceAddress to get the device MAC address. Use CyBle_GapSetLocalName to set the device local name. Call this API before the advertisement start APIs so that the device advertises with the new address.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks.
I am testing on a few devices, and for every single device I am getting same address when calling CyBle_GetDeviceAddress with the addr type set to 0 for public address.
I have 'Silicon generated "Company assigned" part of the address' checked in the BLE component, and the public address remains as:
00A050-XXXXXX
on every call to CyBle_GetDeviceAddress I am getting: 0x80 0x95 0x19 0x29 0x49 0x80
Am I comparing two different addresses? Shouldn't the company prefix and 'die' assigned address be there?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay,
I got a little further following this advice: http://www.cypress.com/forum/proc-ble/update-device-name-id-during-advertising
I am now waiting until the BLESS state is event_close before getting the device address.
while( CyBle_GetBleSsState() != CYBLE_BLESS_STATE_EVENT_CLOSE )
{
CyBle_ProcessEvents();
}
(CyBle_GetDeviceAddress(&device_mac_addr)
This gets me unique mac addresses.
The other issue I ran into was that CyBle_GapSetLocalName was truncating the custom name I was setting based on the length I put in the component:
charLen = (uint8)CYBLE_GATT_DB_ATTR_GET_ATTR_GEN_MAX_LEN(CYBLE_GAP_DEVICE_NAME_INDEX + 1u);
Once I padded out the name I put in the component settings, this stopped truncating.
Is there a better way to do that?