1 2 Previous Next 16 Replies Latest reply on Jan 6, 2019 11:58 PM by srme_3928751

    How to receive string from Mobile to Psoc and vice versa




         I am working on CY8CKIT-142 and I created one custom profile BLE application with reference to CAPSENSE_RGB_LED_SENSOR application.Now my queries are


      1.How to  receive the string sent from BLE Android Application to PSOC BLE.

      2.In the same way how to send the string from PSOC to Android App.

      3.While sending and receiving the data the data should be of length 20????


          As the test application was not ready I didn't test the below code which I wrote,so please can anyone suggest whether I am following correct way of coding:

        For the first query the code as follows which I was trying:


               uint8 *Transfer_Data;

               case CYBLE_EVT_GATTS_WRITE_REQ:

                  /* This event is received when Central device sends a Write command on an Attribute */

                  wrReqParam = (CYBLE_GATTS_WRITE_REQ_PARAM_T *) event Param


                     Receive_Data = &wrReqParam->handleValPair.value.val[0];   //Will this assaignment will work for receiving string.

                       uart_write(Receive_Data,len);  //Fuction created to write to UART

      For the Second query the code as follows which I was trying:

                 case CYBLE_EVT_GATTS_WRITE_REQ:



                      /* Save character received by UARTx device into the receive buffer */ 

                       while(!(*(uint8_t*)Transfer_Data = (unsigned char)UART_1_UartGetChar())); 

                      /* Stop reading if CR (Ox0D) character is received */ 

                       if (*(uint8_t*)Transfer_Data == '\0') {     /* New line character (CR) received ? */ 

                        *(uint8_t*)Transfer_Data = '\n';           /* Yes, convert LF to '\n' char. */ 

                       break;                           /* Stop loop and return received char(s) */ 


                      Transfer_Data++;                   /* Increase buffer pointer */ 



                       BLENotificationCCCDhandle.value.val  = Transfer_Data;

                       BLENotificationCCCDhandle.value.len  = 20;

                       CyBle_GattsWriteAttributeValue(&BLENotificationCCCDhandle,FALSE, &connectionHandle, CYBLE_GATT_DB_PEER_INITIATED);


      For the Third query does below code is enough:    

                      BLENotificationCCCDhandle.value.len  = 20;

        1 2 Previous Next