I have my software set up so that it does some computation within the Attribute write callback function like this.
static ssize_t KeyInitiation(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags) { uint8_t kew_vouch[KEY]; uint8_t kew_new[KEY]; uint8_t signature[SIGNATURE]; memcpy(kew_vouch, buf, KEY); memcpy(kew_new, buf + KEY, KEY); memcpy(signature, buf + KEY + KEY, SIGNATURE); #if CONFIG_LOG LOG_HEXDUMP_DBG(kew_new, KEY, "kew_new"); LOG_HEXDUMP_DBG(kew_vouch, KEY, "kew_vouch"); LOG_HEXDUMP_DBG(signature, SIGNATURE, "signature"); #endif broadcastKeyHandler(kew_new, kew_vouch, signature); return len; }
broadcastKeyHandler does somewhat of a big jobb here. calling broadcastKeyHandler from main does not seem to be a problem. but when called from the attribute, I get this error:
[00:00:13.891,632] <err> os: ***** USAGE FAULT ***** [00:00:13.891,662] <err> os: Stack overflow (context area not valid) [00:00:13.891,693] <err> os: r0/a1: 0x2003fb70 r1/a2: 0x0000000c r2/a3: 0x00000000 [00:00:13.891,723] <err> os: r3/a4: 0x2003fb2c r12/ip: 0x00000003 r14/lr: 0x00044925 [00:00:13.891,723] <err> os: xpsr: 0x61000200 [00:00:13.891,723] <err> os: Faulting instruction address (r15/pc): 0x00042d40 [00:00:13.891,784] <err> os: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0 [00:00:13.891,815] <err> os: Current thread: 0x20031348 (unknown)
I think this might because of the stack size delegated to the thread spawned when the attribute is called upon. If that is the case, then how do I increase the stack size of the thread?