You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+103Lines changed: 103 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,109 @@ Click `Add` (`3`) when the information on the dialog looks good.
42
42
43
43
Click `Done` (`4`) to finish the `ble in` node settings.
44
44
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`).
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
+

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
+

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
+

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
+

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
+

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`.
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
+

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
+

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
+

145
+
146
+
Let's read the characteristic value by clicking `inject` node pedal. The read result will be displayed on the debug tab.
0 commit comments