PSOC 4 BLE Notification of custom characteristinc returns ERROR code 1

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
manusharian
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

Hello Everybody,

   

Today I reach another strange topic that I personally do not get it.

   

I have a big custom characteristic of 44 bytes(11 int32 fields) that changes often( once at 4 seconds) and therefore I want them to notify the cell phone when the value changed.  Since the code is very long I will put here only the notification part. I may say that a simple slider example works perfectly. Also this example works in some conditions.

   

<code>

   


 tstSensorsForBLE tstValue;
   
    
    tstValue.CO = astSensor[0].i32AvgValue;
    tstValue.SO2 = astSensor[1].i32AvgValue;
    tstValue.NO2 = astSensor[2].i32AvgValue;
    tstValue.O3 = astSensor[3].i32AvgValue;
    tstValue.NO = astSensor[4].i32AvgValue;
    tstValue.Spec = astSensor[5].i32AvgValue;
    tstValue.CO2 = astSensor[6].i32AvgValue;
    tstValue.VOC = astSensor[7].i32AvgValue;
    tstValue.T = astSensor[8].i32AvgValue;
    tstValue.H = astSensor[9].i32AvgValue;
    tstValue.P = astSensor[10].i32AvgValue;

   


 if(u8ConnectionFlag != 0)
    {
        /* Get a handle for the notification characteristic */
        CYBLE_GATTS_HANDLE_VALUE_NTF_T tempHandle;
        /* Take the characteristic */
        tempHandle.attrHandle = CYBLE_SENSORSSERVICE_SENSORSVALUE_CHAR_HANDLE;
        /* Update the value and specify the lenght */
        tempHandle.value.val = (uint8 *)&tstValue;
        tempHandle.value.len = 44;
       
        CyBle_GattsWriteAttributeValue(&tempHandle, 0, &cyBle_connHandle, 0);
       
        /* If the BLE is connected with the phone notify it */
        if(u8Notif != 0)
        {
           char str[20];
            CYBLE_API_RESULT_T result;
            /* Notify the phone that the values are update */
            result  = CyBle_GattsNotification(cyBle_connHandle,  &tempHandle);
            sprintf(str, "ERORR: %d wsdfgrfthjhuy\n",result);
            UART_UartPutString(str);
        }
    }

   

</code>

   

The result code is always 1 which mean that one input parameter is not correct.

   

I track the problem to the size of the characteristic. If Instead of 44 length I put 20 then there is no error and it notifies correctly but above 20 I always have code 1.

   

My questions is: Is there a problem because I try to notify a characterstic of 44 bytes? If yes How can I do this notification of such big characteristic? 

   

 

   

Thanks!

0 Likes
1 Solution
Anonymous
Not applicable

Hello Marian,

   

In BLE 4.1v, the maximum link layer packet size is 27bytes. So you cannot send notification of more than 20bytes.

   

In BLE 4.2v the  Data length Extension feature supports PDU size of 251 bytes, with which you can send larger size packets.

View solution in original post

0 Likes
2 Replies
Anonymous
Not applicable

Hello Marian,

   

In BLE 4.1v, the maximum link layer packet size is 27bytes. So you cannot send notification of more than 20bytes.

   

In BLE 4.2v the  Data length Extension feature supports PDU size of 251 bytes, with which you can send larger size packets.

0 Likes
manusharian
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

Hello,

   

Thank you for your answer. I enlarged the MTU to 47 bytes and now my custom iOS application is able to receive notification for that characteristic. Thank you!

0 Likes