Skip to content

Commit 06dbefe

Browse files
author
Daisuke Baba
committed
Add instructions for how to translate gatttool commands into flow
1 parent ac83d10 commit 06dbefe

File tree

9 files changed

+103
-0
lines changed

9 files changed

+103
-0
lines changed

README.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,109 @@ Click `Add` (`3`) when the information on the dialog looks good.
4242

4343
Click `Done` (`4`) to finish the `ble in` node settings.
4444

45+
## How to translate gatttool command into flow
46+
47+
In this example, we show how to describe `gatttool` commands for characteristic value write and read with Generic BLE nodes.
48+
49+
### Characteristics Value Write
50+
51+
The following simple command line just issues a characteristic write request to the handle `0x0027`, which `gatttool` associates with the characteristic uuid `f000aa02-0451-4000-b000-000000000000`(uuids and handles can be listed by `gatttool -b 88:99:00:00:FF:FF --characteristics command`).
52+
53+
```
54+
$ gatttool -b 88:99:00:00:FF:FF --char-write-req --handle=0x0027 --value=ca
55+
Characteristic value was written successfully
56+
```
57+
58+
In this tutorial, we translate the above command into Node-RED flow.
59+
60+
First of all, we use the following nodes.
61+
62+
1. `inject` node to trigger a write request
63+
1. `Generic BLE out` node to perform the write request
64+
65+
![gatttool](images/gatttool-001.jpg)
66+
67+
So the first step to create a flow is to place the above nodes on the workspace and connect them as shown above.
68+
69+
Next, open the `inject` dialog so that you can provide the write request parameters, the characteristic uuid and the value.
70+
71+
** Important!) Unlike `gatttool`, Generic BLE nodes NEVER use `handles`. Always use `uuid`s instead. **
72+
73+
![gatttool](images/gatttool-002.jpg)
74+
75+
In this dialog, choose `JSON` at Payload input item since `Generic BLE out` node accepts a JSON object as its input value. See `Inputs` in the node description shown in the `info` tab for detail.
76+
77+
![gatttool](images/gatttool-003.jpg)
78+
79+
Click/tap `...` to launch JSON value editor and populate the following JSON text.
80+
81+
```
82+
{
83+
"f000aa0204514000b000000000000000": "ca"
84+
}
85+
```
86+
87+
The property `f000aa0204514000b000000000000000` is a characteristic `uuid`. However, unlike `gatttool`, you must strip hyphens from the original uuid value. `Generic BLE` nodes doesn't accept `gatttool` style uuid format.
88+
89+
The value `ca` is a hex string to be written, which is identical to the above command line.
90+
91+
So you'll see the following image.
92+
93+
![gatttool](images/gatttool-004.jpg)
94+
95+
Close the dialog by clicking `Done` button after entering the JSON text.
96+
97+
Configure `Generic BLE out` node for your BLE peripheral (This step is already introduced above so we don't describe here. See `How to configure a new BLE peripheral`).
98+
99+
Now you're ready to issue a characteristic write request to your BLE peripheral. Click `Deploy` and click `inject` node to issue a characteristic write request.
100+
101+
![gatttool](images/gatttool-005.jpg)
102+
103+
Node-RED shows the notification message after your write request is performed successfully.
104+
105+
Here in this tutorial, we use `inject` node to create characteristic write request parameters. However, this isn't the only way to do so. You can use other nodes than `inject` node. All you need is to prepare a valid JSON object for `Generic BLE out` node and provide it to the node.
106+
107+
In order to retrieve the written value from your BLE peripheral, go to the next step.
108+
109+
### Characteristics Value Read
110+
111+
The both commands perform characteristic value read commands and return the same result, the characteristic value of the uuid `f000aa02-0451-4000-b000-000000000000`.
112+
113+
```
114+
$ gatttool -b 88:99:00:00:FF:FF --char-read -u f000aa02-0451-4000-b000-000000000000
115+
handle: 0x0027 value: ca
116+
117+
$ gatttool -b 88:99:00:00:FF:FF --char-read --handle=0x0027
118+
Characteristic value/descriptor: ca
119+
```
120+
121+
In this tutorial, we translate the above commands into Node-RED flow.
122+
123+
We use the following nodes this time.
124+
125+
1. `inject` node to trigger a read command
126+
1. `Generic BLE in` node to perform the read command
127+
1. `debug` node to show the read value
128+
129+
![gatttool](images/gatttool-006.jpg)
130+
131+
132+
Put the above nodes onto your workspace and add connectors like above.
133+
134+
Open `inject` node dialog and enter the characteristic `uuid` at Topic input box. Leave default values other than Topic since `Generic BLE in` sees only the topic value.
135+
136+
You can also leave Topic empty when you want to retrieve all characteristics values.
137+
138+
![gatttool](images/gatttool-007.jpg)
139+
140+
Click `Done` after entering the uuid to close the dialog. You need to configure `Generic BLE in` node to use your BLE peripheral but we skip to mention here as the instruction is described above (See `How to configure a new BLE peripheral` for detail).
141+
142+
Click `Deploy` to function the flow.
143+
144+
![gatttool](images/gatttool-008.jpg)
145+
146+
Let's read the characteristic value by clicking `inject` node pedal. The read result will be displayed on the debug tab.
147+
45148
## BLE in and out nodes
46149

47150
See `info` tab for detail on the editor UI.

images/gatttool-001.jpg

60.4 KB
Loading

images/gatttool-002.jpg

100 KB
Loading

images/gatttool-003.jpg

96 KB
Loading

images/gatttool-004.jpg

96.6 KB
Loading

images/gatttool-005.jpg

125 KB
Loading

images/gatttool-006.jpg

88.3 KB
Loading

images/gatttool-007.jpg

108 KB
Loading

images/gatttool-008.jpg

183 KB
Loading

0 commit comments

Comments
 (0)