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,

    I updated the write_callback function to check for the length of the data (found this in some sample)

        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 *value ;
            printk("reached here and offset is %d and length is %d\n", offset, len);
        if (offset + len > sizeof(write_callback)) {
            printk("Error and length is %d \n", len);
            return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
            printk("Error\n");
        }
        memcpy(value, buf, len);
        printk("Data is %d\n",value);
        return len;
        //
        }

    However, during execution of the mempcy step the script fails with:

    [00:00:11.740,264] [1B][1;31m<err> os: ***** MPU FAULT *****[1B][0m
    [00:00:11.740,264] [1B][1;31m<err> os:   Data Access Violation[1B][0m
    [00:00:11.740,264] [1B][1;31m<err> os:   MMFAR Address: 0x0[1B][0m
    [00:00:11.740,295] [1B][1;31m<err> os: r0/a1:  0x00000000  r1/a2:  0x20005fb7  r2/a3:  0x20005fb7[1B][0m
    [00:00:11.740,295] [1B][1;31m<err> os: r3/a4:  0xffffffff r12/ip:  0x00001000 r14/lr:  0x00000a5f[1B][0m
    [00:00:11.740,295] [1B][1;31m<err> os:  xpsr:  0x81000000[1B][0m
    [00:00:11.740,295] [1B][1;31m<err> os: Faulting instruction address (r15/pc): 0x000101a2[1B][0m
    [00:00:11.740,295] [1B][1;31m<err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0[1B][0m
    [00:00:11.740,295] [1B][1;31m<err> os: Current thread: 0x20000bc0 (unknown)[1B][0m
    [00:00:11.801,971] [1B][1;31m<err> fatal_error: Resetting system[1B][0m

Children
No Data
Related