1 2 Previous Next 15 Replies Latest reply on May 21, 2019 3:39 PM by StKe_3927516

    How do I Send UUID Address as one string (via UART)?

    StKe_3927516

      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[k] = (unsigned char)tempChar;

                                  }

                              }

       

       

      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

        • 1. Re: How do I Send UUID Address as one string (via UART)?
          StKe_3927516

          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[k] = (unsigned char)tempChar;

                                          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"

          • 2. Re: How do I Send UUID Address as one string (via UART)?
            GyanC_36

            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

            • 3. Re: How do I Send UUID Address as one string (via UART)?
              StKe_3927516

              Hi Gyan,

               

              I have not been able to get it to work.

               

              Thank you for the resource. Do you know which one(s)?

               

              -Steve

              • 4. Re: How do I Send UUID Address as one string (via UART)?
                StKe_3927516

                I have code that now gives me this:

                804929199580

                 

                When the actual UUID is:

                00a0509ab3d5

                 

                Am I missing a conversion somewhere?

                • 5. Re: How do I Send UUID Address as one string (via UART)?
                  MiRo_263836

                  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.

                  • 6. Re: How do I Send UUID Address as one string (via UART)?
                    ScottK_91

                    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

                    • 7. Re: How do I Send UUID Address as one string (via UART)?
                      StKe_3927516

                                          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

                                                     

                                                  }

                                              }

                                          }

                      • 8. Re: How do I Send UUID Address as one string (via UART)?
                        ScottK_91

                        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;

                        • 9. Re: How do I Send UUID Address as one string (via UART)?
                          StKe_3927516

                          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.

                          • 10. Re: How do I Send UUID Address as one string (via UART)?
                            ScottK_91

                            Hmmm.  What does the debugger see for tempChar each time before if does the SendCommand?

                            • 11. Re: How do I Send UUID Address as one string (via UART)?
                              StKe_3927516

                              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.

                               

                               

                              • 12. Re: How do I Send UUID Address as one string (via UART)?
                                MoTa_728816

                                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

                                • 13. Re: How do I Send UUID Address as one string (via UART)?
                                  StKe_3927516

                                  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

                                  • 14. Re: How do I Send UUID Address as one string (via UART)?
                                    StKe_3927516

                                    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

                                    1 2 Previous Next