1
votes

I’m building an application in which a smartphone needs to communicate with a peripheral over Bluetooth Low Energy but I’m having a hard time coming up with the right GATT service/characteristic structure for this communication. The phone and peripheral need to communicate with each other over a “custom protocol” containing multiple send/receive messages. What I mean with this is that he phone will send something to the peripheral (step 1 of the protocol), which will respond to this by sending a message to the phone (step 2 of the protocol), which will respond to this by sending the next message to the peripheral (step 3 of the protocol), etc. until the protocol completes (after let’s say 10 steps).

Should I make a new attribute for every step of the protocol I want to execute, i.e. have the phone write to an attribute “protocol1” and have the peripheral notify the phone with an attribute “protocol2” after which the phone writes “protocol3”, etc. Or should I use only 2 attributes for this: one for the phone to write to (TX), and another one for the phone to read (RX) through notifications? It seems that BLE (instead of Bluetooth 3.0) wasn’t really made for this kind of RX/TX communication, or am I wrong?

1
Many BLE peripherals implement a serial port type protocol using a pair of characteristics (one for transmit and one for receive). If your peripheral doesn't have specific "value" such as a heart rate monitor or temperature sensor then the serial port model may be appropriatePaulw11

1 Answers

1
votes

Two Characteristics, one for TX and one for RX should be enough.

Use Characteristic Write for TX and Characteristic Indication for RX.