1 Reply Latest reply on Nov 22, 2018 11:31 AM by GerrikoIoT

    Automation IO GATT Service with an Analog Characteristic

    GerrikoIoT

      I am in the process of creating an application that will use the Automation IO GATT Service with an Analog Characteristic.

       

       

      In the process of writing my code it threw up a warning on the expected data type for the analog parameter in the Send Notification function.

       

      uint16_t myAnalogValue;
      
      apiResult = Cy_BLE_AIOSS_SendNotification(appConnHandle, CY_BLE_AIOS_ANALOG, CY_BLE_AIOS_ANALOG, sizeof(myAnalogValue), &myAnalogValue);
      
      

       

      When I look at "Cy_BLE_AIOSS_SendNotification" function, I see that the value parameter is defined as uint8_t, while the default for an analog value is uint16_t.

       

      So, before I trawl through the generated source library code, to fathom my method to handle this, I simply wondered (weathers cold and brain like a battery) what's the recommended way to remove the warning.

        • 1. Re: Automation IO GATT Service with an Analog Characteristic
          GerrikoIoT

          Now that brain has warmed up I'm thinking a little clearer.

           

          The solution is relatively straightforward

           

          #define INSTANCE_ANALOG (0u)
          uint16_t myAnalogValue;
          uint8_t myByteArray[2];
          
          myByteArray[0] = (myAnalogValue & 0xFF);
          myByteArray[1] = (myAnalogValue >> 8);
          
          apiResult = Cy_BLE_AIOSS_SendNotification(appConnHandle, CY_BLE_AIOS_ANALOG, INSTANCE_ANALOG, sizeof(myByteArray), (uint8 *)&myByteArray );
          
          

           

          Now surely, this opens up the ability to send uint8_t array sizes of any length, which goes against the Automation IO Service analog value requirement of only using a uint16_t type for value with an exponent to show size.

           

          Hence I am suggesting that the API changes to only allowing uint16_t values and the size option is removed as a parameter.