Hello,
I have been working with BLE on the nRF52840 with softdevice 140 and the latest in terms of SDK.
The problem I have run into is with reading the value that has been written to by the client.
I'm using the peripheral heart rate example as base code, the only thing I wanted to add was to read and display the value that has been written to the characteristic control point by the client device (phone). I'm able to write from the client device and I have a write callback function for the characteristic but I was not able to figure out how to get the value that was being sent. The call back function that I currently have is given below:
static ssize_t write_on(struct bt_conn *conn, const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset)
{
uint8_t val;
int err = bt_gatt_attr_read(conn, attr, buf, len, offset, &val ,sizeof(val));
printk("[MY] Value received -> %d \n", (uint8_t)(buf));
return 1;
}
Currently, it always prints the same value out i.e. 153
Any help would be appreciated,
Cheers