Emill / node-ble-host

A Bluetooth Low Energy host implementation for Node.js
ISC License
55 stars 15 forks source link

Question - request/respond over GATT #7

Closed PhantomRay closed 2 years ago

PhantomRay commented 2 years ago

Hi @Emill Quick question, I want to send a request (write) to gatt server, and then gatt server will reply with response data.

How do I achieve this combination?

Thanks in advance.

Emill commented 2 years ago

If you want to transmit data in both directions, I suggest you to use "Write Without Response" when writing data to the GATT server and Notifications when responding with data to the GATT client. If you would have used "Write With Response", then per the GATT standard, the response is always empty and cannot contain any data.

To enable support for "Write Without Response" on a GATT characteristic when node-ble-host acts as a server, see https://github.com/Emill/node-ble-host/blob/master/docs/api/gatt-server.md#characteristicproperties how to add the write-without-response property. See the main readme for an example how to send notifications.

PhantomRay commented 2 years ago

That's what I thought but wasn't sure.

Thank you Emill!