- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am using the CYBLE-0220001--00 module on PSoC 4.3. and I am developing an asset tracking product and there will be lots of assets in one place. My problem is that currently, I have set a local name by using CyBle_GapSetLocalName("Asset") function. But I want to advertise its local name identify by using the last 4 characters of MAC address like "Asset-A0B2" So that we can tag A0B2 on our product for further identification. Could you please help me to get the MAC address of my BLE I have tried below code but no expected result.
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[0] = ((cyBle_deviceAddress.bdAddr[1] & 0xF0) >> 4) + 48 ;
DeviceName[1] = (cyBle_deviceAddress.bdAddr[1] & 0x0F) + 48 ;
DeviceName[2] = ((cyBle_deviceAddress.bdAddr[0] & 0xF0) >> 4) + 48 ;
DeviceName[3] = (cyBle_deviceAddress.bdAddr[0] & 0x0F) + 48 ;
If you can provide example code. it would be great.
Thanks in advance.
Regards.
Neeraj Dhekale
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Neeraj,
You can use the API CyBle_GetDeviceAddress() to get the public address of the device.
CYBLE_GAP_BD_ADDR_T address;
address.type =0x00;
checkapiresult(CyBle_GetDeviceAddress(&address));
printf("My public address is %x %x %x :%x %x %x \r\n", address.bdAddr[5],address.bdAddr[4],address.bdAddr[3],address.bdAddr[2],address.bdAddr[1],address.bdAddr[0] );
Hope this helps !
Thanks
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Neeraj,
You can use the API CyBle_GetDeviceAddress() to get the public address of the device.
CYBLE_GAP_BD_ADDR_T address;
address.type =0x00;
checkapiresult(CyBle_GetDeviceAddress(&address));
printf("My public address is %x %x %x :%x %x %x \r\n", address.bdAddr[5],address.bdAddr[4],address.bdAddr[3],address.bdAddr[2],address.bdAddr[1],address.bdAddr[0] );
Hope this helps !
Thanks
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ganesh,
I have checked code and for checkapiresult function, I am getting error message it is undefined.
Could you please help me? where I can get function definition for checkapiresult?
Regards,
Neeraj Dhekale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Neeraj,
Sorry. That is a custom function and I forgot to attach. You need to use a UARt component to print the result of that function return.
//BLE APIRESULT CHECK
void checkapiresult(CYBLE_API_RESULT_T apiResult)
{
switch ((uint8)apiResult)
{
case 0x00:
UART_UartPutString("CYBLE_ERROR_OK\r\n");
break;
case 0x01:
UART_UartPutString("CYBLE_ERROR_INVALID_PARAMETER\r\n");
break;
case 0x02:
UART_UartPutString("CYBLE_ERROR_INVALID_OPERATION\r\n");
break;
default :
printf("The API result is %x \r\n", apiResult);
break;
}
}
Thanks
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Ganesh,
Under the GAP settings tab Silicon generated "Company assigned" part of the device address option is Checked.
I can see BLE is started and able to find it on the nRF Connect app.
I am getting output:
My public address is 80 49 29 :19 95 80
Whereas my actual BLE MAC address is 00:a0:50:31:5a:24
80 49 29 :19 95 80 what is this?
Regards,
Neeraj Dhekale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ganesh,
Your solution works for me. The only important thing I was missing to make sure the above code should have executed after the CYBLE_EVT_STACK_ON event.
Thank you so much for your help.
Regards,
Neeraj Dhekale