8 Replies Latest reply on May 20, 2015 4:35 PM by user_464999847

    CyBle_GattsNotification() error

    user_464999847

       I have been working on a early development system to read sensor data and transmit using BLE.  My system seems to be working well except for sending the notification data.  The error returned is CYBLE_ERROR_INVALID_PARAMETER.  The manual states the "'connHandle' value does not represent any existing entry in the Stack", but I'm using the global connHandle:

         

          /* Initialize Notification handle */

         

          SensorDataNTF.attrHandle = CYBLE_SENSOR_SERVICE_SENSOR_DATA_CHAR_HANDLE;

         

          SensorDataNTF.value.val = (uint8 *)&gi_ADC_Count;

         

          SensorDataNTF.value.len = sizeof(gi_ADC_Count);

         

       

         

          /* Send notification */

         

          apiResult = CyBle_GattsNotification(cyBle_connHandle, &SensorDataNTF);

         

          if (CYBLE_ERROR_OK != apiResult) {

         

              apiResult = CYBLE_ERROR_OK;

         

          }

         

      I've verified that cyBle_connHandle.bdHandle is not 0.

         

      I'm hoping I'm missing something obvious and that one of you will be able to point me in the right direction to correct the problem.

        • 1. Re: CyBle_GattsNotification() error
          vavc

           Hi,

             

           

             

          Pls check whether the handle is correct or not.

             

           

             

          Can you share the project?

             

           

             

          Regards,

             

          Vikas

          • 2. Re: CyBle_GattsNotification() error
            user_464999847

            I had understood that the BLE code handles the setting of the cyBle_connHandle variable and would always reflect the current connection.  Am I incorrect in that assumption?  What would I be comparing it to to verify that it is correct?

            • 3. Re: CyBle_GattsNotification() error
              vavc

               I meant to say CYBLE_SENSOR_SERVICE_SENSOR_DATA_CHAR_HANDLE not Cyble_ConnHandle.

                 

               

                 

              Please share the project

                 

               

                 

              Regards,

                 

              Vikas

              • 4. Re: CyBle_GattsNotification() error
                user_464999847

                 Project attached.

                   

                The Define of CYBLE_SENSOR_SERVICE_SENSOR_DATA_CHAR_HANDLE seems correct to me.  Same as the Data characteristic.

                • 5. Re: CyBle_GattsNotification() error
                  vavc

                   Hi,

                     

                   

                     

                  MTU size is set to 23(BLE component->GAP settings->General

                     

                   

                     

                  But you are trying to send 64 bytes of notification. You cannot send a notification of size greater than MTU-3 in a single trasnfer.Change the MTU to 67 and then try.

                     

                   

                     

                  Also I found that you are trying to enablethe notifications locally by writing to the CCCD. It doesn't make any sense by enabling the notifications locally.It is supposed to be enabled by client

                     

                   

                     

                  Regards,

                     

                  Vikas

                  • 6. Re: CyBle_GattsNotification() error
                    user_464999847

                    It works with the change you suggested.  Thank you.

                       

                    Would you be able to explain further?  I'd like a better understanding.  What was I able to get a read of the attribute to work, but not the notification when the MTU size was still at 23?  I thought the system would be able to split data between multiple packets.  Is this true for reads, but not for notifications?

                    • 7. Re: CyBle_GattsNotification() error
                      vavc

                       Hi,

                         

                       

                         

                      Attribute length which is more than MTU-1 are called long attributes.

                         

                      When you try to read an attribute with size MTU-1 you can read by sending readrequest.

                         

                       

                         

                      In case if the size is more than MTU-1 you cann't read by sending readrequest.You have to send readblob reqeust.

                         

                       

                         

                      Probably your app might be sending the readblob(readlongcharacteristic) request instead of read request.

                         

                       

                         

                      In more detail:

                         

                       

                         

                      When sending a notifciation you have to include attribute opcode(1byte), attribute handle(2bytes) and 20bytes of data(max when MTU is 23

                         

                       

                         

                      If you trying to read,client send a request by sending the request with the particualr attribute handle

                         

                      .Server respond with attribute opcode(1byte) and attribute data of MTU-1

                         

                       

                         

                      Regards,

                         

                      Vikas

                      • 8. Re: CyBle_GattsNotification() error
                        user_464999847

                         That is very helpful.  Thank you, Vikas.

                           

                        Best regards,

                           

                        Matt