- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a custom board that, among other things, includes the cyble 222014-01 and a cell modem. I have basic UART working between the modules. I need to be able to send the BLE's UUID as one string to the Cell Modem, but I am having issues.
(please be nice to me, if this is a simple fix; I am new-ish to embedded and C)
I found basic code to print the UUID (as multiple prints):
localAddr.type = 0u;
CyBle_GetDeviceAddress(&localAddr);
for(i = CYBLE_GAP_BD_ADDR_SIZE; i > 0u; i--)
{
DBG_PRINTF("%2.2x", localAddr.bdAddr[i-1]);
}
My current code is (btw, I've tried many variations):
localAddr.type = 0u;
if(CyBle_GetDeviceAddress(&localAddr) == CYBLE_ERROR_OK){
for(uint k = CYBLE_GAP_BD_ADDR_SIZE; k > 0u; k--){
char tempChar;
sprintf(&tempChar, "%d", localAddr.bdAddr[i-1]);
ThisAddress
}
}
And, it sends:
{000000_lqç[M߇МN@²]×èvqÑÉ£Us>/•Ú«<SI>¿©ÝÄ.¬H}ù¡ÒŸÇßRœÂßtÞŒ*géú#ìôýûß×ýyjÖé<DLE>ë#<ETX>S+½8U\íþÖ"Å<SYN>“aÊÕÎÁ<SO>×GIÿÆ—îë+ÄÃéŒÿZç½ä~Ûeé6gvÙë¯Ïß<GS>“ÇÐñ„)|]ÆÆ7×<DC3/XOFF>‰·Ø÷øYR—WÙvKu™7*Äѧìò<DC1/XON>ެþ'衈p5µµÓ7ùh—¯¦ê”פ¯–_žs©<NAK>éR5½§FÚíW6ùw<EM>XíÿL¾«®Úë°œêÏÅîÝi‡iulœü˜¡Ô=<ENQ>Fû¶ç<STX>>Ì»´ÿîÿ{ÿºÿV½<DEL>ŸAT
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I got it!
I had to put CyBle_ProcessEvents(); after the CyBle_Start(AppCallBack); for some reason.
Maybe because I start my UART before the BLE.
Either way, I have it working.
ps - why does the default example code print the MAC Address (UUID) backwards?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With my code changed to:
localAddr.type = 0u;
if(CyBle_GetDeviceAddress(&localAddr) == CYBLE_ERROR_OK){
for(uint k = CYBLE_GAP_BD_ADDR_SIZE; k > 0u; k--){
char tempChar;
//sprintf(&tempChar, "%d", localAddr.bdAddr[i-1]);
//ThisAddress
sprintf(&tempChar, "%2.2x", localAddr.bdAddr[i-1]);
SendCommand(&tempChar);
}
}
It now prints/sends: 000000000000
In topdesign, I set the BLE to "Silicon generated "Company assigned" part of device address"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve,
Were you able to get the data over UART ?
You can refer code examples from below link ...where some of the examples do send the device address over UART.
https://github.com/cypresssemiconductorco/PSoC-4-BLE/tree/master/100_Projects_in_100_Days
-Gyan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Gyan,
I have not been able to get it to work.
Thank you for the resource. Do you know which one(s)?
-Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have code that now gives me this:
804929199580
When the actual UUID is:
00a0509ab3d5
Am I missing a conversion somewhere?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looking like you are sending decimal but you want to send hex. Use the debugger and see what tempChar is each time before you do the SendCommand.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Steve,
Could you post the code which gave you this result, please?
"I have code that now gives me this:
804929199580
When the actual UUID is:
00a0509ab3d5"
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.
Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if(CYBLE_EVT_STACK_ON){
localAddr.type = 0x00; //public = 0, Random = 1
CYBLE_API_RESULT_T CyBle_GetDeviceAddress(CYBLE_GAP_BD_ADDR_T* localAddr);
if(CyBle_GetDeviceAddress(&localAddr) == CYBLE_ERROR_OK){
for(uint8 k = CYBLE_GAP_BD_ADDR_SIZE; k > 0; k--){
char tempChar;
sprintf(&tempChar, "%.2x", (unsigned char)localAddr.bdAddr[k-1]);
SendCommand(&tempChar); //send command via uart
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Confirm that the BLE stack component has been started.
This example code was taken from "Day 25" main.c.
int main()
{
/* Start BLE component */
CyBle_Start(AppCallBack);
.
.
.
.
void AppCallBack(uint32 event, void* eventParam)
{
CYBLE_API_RESULT_T apiResult;
CYBLE_GAP_BD_ADDR_T localAddr;
uint32 i = 0u;
switch (event)
{
/**********************************************************
* General Events
***********************************************************/
case CYBLE_EVT_STACK_ON: /* This event received when component is Started */
/* Enter into discoverable mode so that remote can search it. */
apiResult = CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
if(apiResult != CYBLE_ERROR_OK)
{
DBG_PRINTF("StartAdvertisement API Error: %d \r\n", apiResult);
}
DBG_PRINTF("Bluetooth On, StartAdvertisement with addr: ");
localAddr.type = 0u;
CyBle_GetDeviceAddress(&localAddr);
for(i = CYBLE_GAP_BD_ADDR_SIZE; i > 0u; i--)
{
DBG_PRINTF("%2.2x", localAddr.bdAddr[i-1]);
}
DBG_PRINTF("\r\n");
break;
case CYBLE_EVT_HARDWARE_ERROR: /* This event indicates that some internal HW error has occurred. */
DBG_PRINTF("CYBLE_EVT_HARDWARE_ERROR\r\n");
break;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My 'if' statement makes sure the BLE stack is on. -- it is turned on in another part of the code.
When my code is run on the device, it goes into the 'if' statement, therefore, it is on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hmmm. What does the debugger see for tempChar each time before if does the SendCommand?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
While in debug mode,
the localAddr.bdAddr is:
0x80
0x95
0x19
0x29
0x49
0x80
When going through the loop, the TempChar is:
0x38 '8'
0x34 '4'
0x32 '2'
0x31 '1'
0x39 '9'
0x38 '8'
BTW, if I do "random," it is all 0x00
And, it doesn't matter if I check the "Silicon generated "Company assigned" part of device" in GAP settings or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
May be I'm off the point, but I'd rather write something like
=======
for (uint k = CYBLE_GAP_BD_ADDR_SIZE; k > 0u ; k--) {
char tempChar[3] ;
sprintf(tempChar, "%02x", localAddr.bdAddr[k-1] ;
SendCommand(tempChar) ;
}
=======
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Moto,
That makes more sense for the TempChar part, but it still doesn't answer why the address is wrong compared to what is being shown when advertised.
-Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just so you all know, this is saying the device address is 804929199580 no matter which device I program/use.
This thread/question also mentions the same address PRIVACY :LE Create Connection Command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I got it!
I had to put CyBle_ProcessEvents(); after the CyBle_Start(AppCallBack); for some reason.
Maybe because I start my UART before the BLE.
Either way, I have it working.
ps - why does the default example code print the MAC Address (UUID) backwards?