This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Zephyr - nRF52840 BLE data characteristic write does not give a response.

Hello,

I am writing code in zephyr on nRF52840. I am advertising my BLE. and we have a stable android app (built-in a flutter). My problem is when I am trying to write an array of data from android app data characteristics one by one. It writes first data and it stucks, it seems that nRF52840 does not respond to write. I haven't used the write without response property but still, I have to write property in flutter "withoutResponse:true" to proceed. that's why I believe nRF52840 is not responding. Is this understanding correct?

await characteristic.write(bytes, withoutResponse: true ); //flutter code

I have defined Characteristic as shown below:
//DECLARATION ENDS
static ssize_t read_vnd(struct bt_conn *conn, const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset)
{
const char *value = attr->user_data;
printk("main read_vnd Received value : %X",value);
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
strlen(value));
}
/* Prototype */
static ssize_t recv(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
uint16_t len, uint16_t offset, uint8_t flags)
{
char *value = attr->user_data;
char s[1000];

strcpy(s, buf);
s[len]='\0';
printk(" write_without_rsp_vnd Received value : %s",s);

memcpy(value + offset, buf, len);

return 11;

}
/* ST Custom Service */
static struct bt_uuid_128 SERVICE_UUID = BT_UUID_INIT_128(
BT_UUID_128_ENCODE(0xbeb5483e, 0x36e1, 0x4688, 0xb7f5, 0xea07361b26a8));
//beb5483e-36e1-4688-b7f5-ea07361b26a8

/* ST LED service */
static struct bt_uuid_128 CHARACTERISTIC_UUID = BT_UUID_INIT_128(
BT_UUID_128_ENCODE(0x4fafc201, 0x1fb5, 0x459e, 0x8fcc, 0xc5c9c331914b));
//4fafc201-1fb5-459e-8fcc-c5c9c331914b

/* BLE connection */
struct bt_conn *conn;
/* ST BLE Sensor GATT services and characteristic */

BT_GATT_SERVICE_DEFINE(IOTians_IMU,
BT_GATT_PRIMARY_SERVICE(&CHARACTERISTIC_UUID),
BT_GATT_CHARACTERISTIC(&SERVICE_UUID.uuid,
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE, read_vnd, recv, &vnd_value),

);

Is there anything wrong with my code? How can I make sure my nRF52840 is responding back?

Thanks in advance,

Regards,
Neeraj Dhekale
Parents Reply Children
Related