GATT Server - Write or Write without Response characteristic sample

Hello,

is there a zephyr or nrf sample where I could check how a characteristic with write or write_withour_resp perimissions is handled by the gatt server ?

What I am trying is to find out how the gatt server can process the data written by a gatt client.

Thank you in advance

Parents Reply
  • Hello Kenneth,

    this is how I have used the BT_GATT_CHARACTERISTIC:

    BT_GATT_CHARACTERISTIC(BT_UUID_FSR, BT_GATT_CHRC_WRITE_WITHOUT_RESP,
                           HRS_GATT_PERM_DEFAULT & GATT_PERM_WRITE_MASK,
                           NULL, write_callback, &user_dt),

    and this is the write_callback function:

    static ssize_t write_callback(struct bt_conn *conn, const struct bt_gatt_attr *attr,
                     void *buf, uint16_t len, uint16_t offset, uint8_t flags)
        {
            uint16_t write_data ;
            memcpy(write_data, attr->user_data, sizeof(attr->user_data));
            printk("HRS CONTROL POINT is %u\n", write_data);
            printk("HRS CONTROL POINT is %u\n", &write_data);
                printk("HRS CONTROL POINT is %u\n", attr->user_data);
                printk("HRS CONTROL POINT is %u\n", user_dt);
        }

    I am testing by writing a uint16_t value, but I am not able to see the same value in the printk result.

Children
Related