4 Replies Latest reply on Nov 17, 2020 6:16 AM by SudheeshK_26

    CyBle sends only 16 Byte Data


      Hello Together,


      we made a Bluetooth Dongle, which sends Data from Com-Port to a BLE-Device.


      we use the CyBle_GattcWriteLongCharacteristicValues, but only 16 Bytes where received on the BLE-Device.


      The handler is build up like this:

            CYBLE_GATTC_PREP_WRITE_REQ_T tempHandle;


          tempHandle.handleValuePair.attrHandle = cyBle_customCServ[CYBLE_CUSTOMC_SERVER_UART_SERVICE_INDEX]



          tempHandle.handleValuePair.value.val = UART_data;

          tempHandle.handleValuePair.value.len = dataLen;  


          volatile CYBLE_API_RESULT_T t = CyBle_GattcWriteLongCharacteristicValues(cyBle_connHandle, &tempHandle);


      The dataLen is 60 and all Data are in the UART_data.


      We dont know the mistake yet, maybe you guys have an idea, what is wrong with this method.


      Thank you.

        • 1. Re: CyBle sends only 16 Byte Data



          What is the MTU size you have set in your application?


          Please note that if the data size you want to transmit is greater than MTU size, then the data will go to server in multiple packets. The size of data that will be transferred in a single packet is MTU-3. So on the server side, the event CYBLE_EVT_GATTS_PREP_WRITE_REQ triggers multiple times.


                  uint16 longwritecount=0;
                  CYBLE_GATTS_PREP_WRITE_REQ_PARAM_T * longwriteparam;
                  case CYBLE_EVT_GATTS_PREP_WRITE_REQ :
                  longwriteparam = (CYBLE_GATTS_PREP_WRITE_REQ_PARAM_T *)eventParam;
                  for(uint16 i=0;i<longwriteparam->baseAddr[longwritecount].handleValuePair.value.len;i++)
                  printf("%02X ",longwriteparam->baseAddr[longwritecount].handleValuePair.value.val[i]);


          So on the server side, the event CYBLE_EVT_GATTS_PREP_WRITE_REQ triggers multiple times.


          Please find the attached code examples for Server and Client and check if they are working for you.


          Thanks and regards


          • 2. Re: CyBle sends only 16 Byte Data



            the MTU size is on 23.


            Can i Turn this up or does this dont work?


            When i would use your type of implementation, it would trigger multiple events on the server AND the Client side?


            Because our type of implementation processes the message every time, so i had to wait for the full message.


            Do i get a trigger for Message_Send or smth. like this to know we are at the end?


            Thanks and regards



            • 3. Re: CyBle sends only 16 Byte Data



              we set up the MTU and tried it again, but this dont help, the message received in the Server is still the same length.


              It showed up, that the entered length in the handle got overwritten due the process of sending. We dont get, how this is possible.


              We compaired our settings to your Programs and they are even, so why does the datalen got overwritten in the process?


              Do you have a clue, why this happen?


              Thanks and regards



              • 4. Re: CyBle sends only 16 Byte Data



                After sending data from client to server using the API CyBle_GattcWriteLongCharacteristicValues(), you can wait for the event CYBLE_EVT_GATTS_EXEC_WRITE_REQ instead of CYBLE_EVT_GATTS_PREP_WRITE_REQ. Server receives the event CYBLE_EVT_GATTS_EXEC_WRITE_REQ  at the end of write operation. Please see the information from BLE component datasheet below,



                You can read data sent from client as below.


                        //CLIENT COMPLETED LONG WRITE
                        CYBLE_GATTS_EXEC_WRITE_REQ_T * execwrresp;
                        case CYBLE_EVT_GATTS_EXEC_WRITE_REQ:       
                        printf("CYBLE_EVT_GATTS_EXEC_WRITE_REQ \r\n");
                        execwrresp = (CYBLE_GATTS_EXEC_WRITE_REQ_T *)eventParam; 
                            for(j = 0; j< execwrresp->baseAddr[i].handleValuePair.value.len; j++)
                                printf("%02X ",execwrresp->baseAddr[i].handleValuePair.value.val[j]);


                I have updated the SERVER project that we already shared on 13th November and attached with this response. Could you test with the updated SERVER project and see if meets your requirement?


                Thanks and Regards,