Automation IO GATT Service with an Analog Characteristic

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

cross mob
GeIo_1586191
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

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

pastedImage_2.png

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.

0 Likes
1 Solution
GeIo_1586191
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

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.

View solution in original post

0 Likes
1 Reply
GeIo_1586191
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

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.

0 Likes