Error writing characteristic

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

cross mob
Anonymous
Not applicable

So I am trying to write a temperature characteristic. I am using..

#define HANDLE_SENSOR_TEMP_NOTIFY                    0x7f

    CHARACTERISTIC_UUID128 (0x007e, HANDLE_SENSOR_TEMP_NOTIFY, UUID_CHARACTERISTIC_TEMP,

                           LEGATTDB_CHAR_PROP_READ | LEGATTDB_CHAR_PROP_NOTIFY | LEGATTDB_CHAR_PROP_INDICATE,

                           LEGATTDB_PERM_READABLE, 2),

      0x00, 0x00,

then... 

UINT32 thermvolt = adc_readVoltage(THERMISTOR);

BLEPROFILE_DB_PDU db_pdu;

bleprofile_ReadHandle(HANDLE_SENSOR_TEMP_NOTIFY, &db_pdu);

db_pdu.pdu[0] = thermvolt & 0xFF;

      db_pdu.pdu[1] = (thermvolt >> 😎 & 0xFF;

      ble_trace1("pdu0: %d\n", thermvolt & 0xFF);

      ble_trace1("pdu1: %d\n", (thermvolt >> 😎 & 0xFF);

bleprofile_WriteHandle(HANDLE_SENSOR_TEMP_NOTIFY, &db_pdu);

It seems that it works for certain numbers.. but if the number gets to a certain format, I am unable to read it on my smartphone application. E.g.. I can read 3030 (or '0''0').. but I cannot read the ADC reading of 1700 or initialize it to 0xFF, 0xFF..

Any ideas on how to remedy this? Thank you.

0 Likes
1 Solution
Anonymous
Not applicable

Thanks. Just wanted to make sure I didn't miss any declarations of any sort.
Turns out the issue was the application I was using was not able to view these values (for some reason). By switching over to a different app I was able to see the values I was writing into the characteristic.

View solution in original post

0 Likes
4 Replies
VictorZ_46
Employee
Employee
5 comments on blog 25 sign-ins 250 likes received

I just modified hello_sensor to use 2 bytes instead of 7 and tested with various values including ffff.  Lighblue displayed them just fine.

0 Likes
Anonymous
Not applicable

Hello,

Could you please elaborate?
Thanks.

0 Likes

I am not sure what else to say.  Following is the change that I did in the database

CHARACTERISTIC_UUID128 (0x0029, HANDLE_HELLO_SENSOR_VALUE_NOTIFY, UUID_HELLO_CHARACTERISTIC_NOTIFY,

LEGATTDB_CHAR_PROP_READ | LEGATTDB_CHAR_PROP_NOTIFY | LEGATTDB_CHAR_PROP_INDICATE,

LEGATTDB_PERM_READABLE, 2),

0xff,0xf0,

and in the interrupt handler

db_pdu.pdu[1]++;


Light Blue application is available through Apple Store.


0 Likes
Anonymous
Not applicable

Thanks. Just wanted to make sure I didn't miss any declarations of any sort.
Turns out the issue was the application I was using was not able to view these values (for some reason). By switching over to a different app I was able to see the values I was writing into the characteristic.

0 Likes