3 Replies Latest reply on Jun 7, 2019 1:33 AM by GeonaP_26

    PSOC4 BLE data limit

    sapc_3956266

      We are testing DATA over BLE.  it was running properly.

      now we increased the payload size from 180 to 240 bytes at the android application end.
        it stopped working after increasing the payload size.

      It is not going into the state of "CYBLE_EVT_GATTS_WRITE_CMD_REQ".

      it is always running into default case instead.

      What might be the issue?

      MTU size for attribute was 250 & changed to 450 bytes. But still no success.

       

       

      void CustomEventHandler(uint32 event, void * eventParam)

       

        switch(event)

          {

                   case CYBLE_EVT_STACK_ON:

                case CYBLE_EVT_TIMEOUT:

                case CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP:

                case CYBLE_EVT_GAP_DEVICE_CONNECTED:

                case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:

                case CYBLE_EVT_GATT_CONNECT_IND:

                case CYBLE_EVT_GATT_DISCONNECT_IND:

                 case CYBLE_EVT_GATTS_WRITE_REQ:

                 case CYBLE_EVT_GATTS_WRITE_CMD_REQ:

                case CYBLE_EVT_L2CAP_CONN_PARAM_UPDATE_RSP:

                case CYBLE_EVT_STACK_BUSY_STATUS:

                default:

      }

        • 1. Re: PSOC4 BLE data limit
          sapc_3956266

          I have gone through this note: PSoC 4 BLE Troubleshooting Guide – KBA220490

          Got the below mentioned reference:

          14. If I set the MTU of the connection as 23 bytes and Server GATT characteristic size to 512 bytes (maximum value), I can send larger values using the GATT Write Long Characteristic Value operation. However, if the MTU size is 512 bytes, I can use the simple GATT write request. What are the differences between these two write operations?

           

          A) The maximum length of an attribute value is 512 octets

          If you are using a Write request, you can write up to (max negotiated MTU) – 3 bytes. Thus, if the negotiated MTU size is 512 bytes, the maximum value which you can write is 509 bytes in a single write operation.

          In the Write long method, you can write a maximum value up to the maximum attribute length, that means up to 512 bytes.

          Application example: Suppose your Peripheral is a CyBLE device and has a Central device (mobile phone, CyBLE etc.). Some mobile phones have the MTU size restricted to a particular value, say 23. The negotiated MTU size becomes 23 regardless of the MTU size of your Peripheral device because your Central device's MTU size is 23. If you want to write a value to the GATT Server characteristic which is greater than 23 bytes, the only option is write long

          Note: Negotiated MTU size means the minimum of (MTU size of Central, MTU size of Peripheral). This negotiated MTU size will be used for the rest of the communication between Central and Peripheral.

           

          We found the below event in BLE for long characteristic value : CYBLE_EVT_GATTS_EXEC_WRITE_REQ.

           

          Is there any application note, to write this procedure ?

          is there any reference code available ?

          • 2. Re: PSOC4 BLE data limit
            sapc_3956266

            Please check this:

             

             

                    case CYBLE_EVT_GATTS_EXEC_WRITE_REQ:

                            #ifdef UART_PRINT_UART_LOG  

                             UART_DBG_PutString("\n BLE: CYBLE_EVT_GATTS_EXEC_WRITE_REQ ");               

                            #endif

                           

                        execwriteReqparam=(CYBLE_GATTS_EXEC_WRITE_REQ_T *)eventParam;

                        write_data_len=0;

                       

                       

                        write_characteristic.attrHandle=CYBLE_ALTROSMARTLOCK_USDIO_CHAR_HANDLE;

                       

                        errorcode=CyBle_GattsWriteAttributeValue(&write_characteristic, 0, &cyBle_connHandle, CYBLE_GATT_DB_PEER_INITIATED);

                       

                            if(errorcode!=CYBLE_GATT_ERR_NONE)

                           {

                            CYBLE_GATTS_ERR_PARAM_T err_rsp;

                            err_rsp.attrHandle = write_characteristic.attrHandle;

                            err_rsp.errorCode = errorcode;       

                            err_rsp.opcode = (uint8) CYBLE_GATT_WRITE_REQ;

                            write_data_ready=0;

                            CyBle_GattsErrorRsp(cyBle_connHandle,&err_rsp);

                            break;

                           }

                       

                            else

                           {

                            write_data_ptr=execwriteReqparam->baseAddr->handleValuePair.value.val;

                            write_data_ready=1;              

                           }

                       

                       uint8 i;

                       

                        if(write_data_ready)

                        {

                         write_data_ready=0;

                         UART_DBG_PutString("Long characteristic written by GATT client. The written values are:\n\r");

                           

                    /*Compute the total length of the long characteristic*/   

                            for(i=0;i<execwriteReqparam->prepWriteReqCount;i++)

                            {

                             write_data_len =    write_data_len  + execwriteReqparam->baseAddr[i].handleValuePair.value.len; 

                            }

                       

                            for(i=0;i<write_data_len;i++)

                            {

                             UART_DBG_PutChar(*write_data_ptr);  

                             write_data_ptr++;

                            } 

                         printf("\n\r\n\r");  

                        }

                       

                        CyBle_GattsWriteRsp(cyBle_connHandle);

                       

                        break;