Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit c03e474

Browse files
committed
Update serial_protocol.md
1 parent bc4a518 commit c03e474

File tree

1 file changed

+49
-18
lines changed

1 file changed

+49
-18
lines changed

serial_protocol.md

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Only needs to be called when the chiplet is in a new environment and needs to co
2020
NETWORK $SSID
2121
NETWORK $SSID $PASSWORD
2222
###Response
23-
CONNECTED - When connected to new network
24-
UNABLE_TO_CONNECT - When unable to connect
23+
+CONNECTED - When connected to new network
24+
-UNABLE_TO_CONNECT - When unable to connect
2525
###Examples
2626
>> NETWORK home-guest
2727
<< +CONNECTED
@@ -36,14 +36,14 @@ Must be called after creating a Serial connection, it can take either just a hos
3636
BEGIN $Host
3737
BEGIN $Host $Secret
3838
###Response
39-
OK - Accepted initialization parameters
39+
+OK - Accepted initialization parameters
4040
###Examples
4141
>> BEGIN https://samplechat.firebaseio-demo.com
4242
<< +OK
4343
>> BEGIN https://samplechat.firebaseio-demo.com nnz...sdf
4444
<< +OK
4545
##GET
46-
Fetches the value at $Path and returns it on the serial line. If $PATH points to a leaf node you will get the raw value back, if it points to an internal node you will get a JSON string with all children.
46+
Fetches the value at $PATH and returns it on the serial line. If $PATH points to a leaf node you will get the raw value back, if it points to an internal node you will get a JSON string with all children.
4747
###Usage
4848
GET $PATH
4949
###Response
@@ -78,24 +78,41 @@ Store the data provided at the path provided. This method should be used for sim
7878
+OK
7979
-FAIL
8080
###Examples
81-
>>SET /user/aturning/first Alan
81+
>>SET /user/aturing/first Alan
8282
<<+OK
8383
##SET$
84-
Similar to SET above but used to write multiline strings or raw binary data. Data format is similar to the batch string ($) return type, we specify the $DATA_BYTE_COUNT on the same line as SET$ then a newline and all data.
84+
Similar to SET above but used to write multiline strings or raw binary data. Data format is similar to the batch string ($) return type, we specify the $DATA_BYTE_COUNT on the same line as SET$ then a newline and all data. However which the batch string ($) return type returns data json escaped and quoted you may provide raw data and we will handle the escaping.
8585

8686
Receiver will wait until a timeout for client to send $DATA_BYTE_COUNT worth of data before becoming responsive again.
8787
###Usage
88-
SET$ $PATH $DATA_BYTE_COUNT
88+
SET$ $PATH
89+
$DATA_BYTE_COUNT
8990
$DATA
9091
###Response
9192
+OK
9293
-FAIL
9394
-FAIL_TIMEOUT
9495
###Examples
95-
>>SET /user/aturning/address 24
96+
>>SET /user/aturing/address
97+
>>24
9698
>>78 High Street,
9799
>>Hampton
98100
<<+OK
101+
102+
##SET{+,*,#,.,?}
103+
Same as SET but will force the value to be stored in the given type or return an error if we cannot parse it as that type.
104+
###Usage
105+
SET+ $PATH $VALUE
106+
SET: $PATH $VALUE
107+
SET? $PATH $VALUE
108+
###Response
109+
+OK
110+
-INCORRECT_TYPE
111+
###Examples
112+
>>SET? /user/aturing/was_human true
113+
<<+OK
114+
>>SET? /user/aturing/was_human He was not a computer.
115+
<<-INCORRECT_TYPE
99116

100117
##REMOVE
101118
Deletes the value located at the path provided.
@@ -105,7 +122,7 @@ Deletes the value located at the path provided.
105122
+OK
106123
-FAIL
107124
###Examples
108-
>>REMOVE /user/aturning
125+
>>REMOVE /user/aturing
109126
<<+OK
110127

111128
##PUSH
@@ -115,43 +132,57 @@ Adds a value to the list located at the path provided and returns the key at whi
115132
###Response
116133
$KEY
117134
###Examples
118-
>>PUSH /user/aturning/login_timestamps 1455052043
135+
>>PUSH /user/aturing/login_timestamps 1455052043
119136
<<+-K94eLnB0rAAvfkh_WC2
120137

121138
##PUSH$
122139
Similar to PUSH but used to write multiline strings or raw binary data. Data format is similar to the batch string ($) return type, we specify the $DATA_BYTE_COUNT on the same line as SET$ then a newline and all data. However you are not required to json escape all of your data, that will be handled for you.
123140

124141
Receiver will wait until a timeout for client to send $DATA_BYTE_COUNT worth of data before becoming responsive again.
125142
###Usage
126-
PUSH_BULK $PATH $DATA_BYTE_COUNT
143+
PUSH$ $PATH $DATA_BYTE_COUNT
127144
$DATA
128145
###Response
129146
$KEY
130147
###Examples
131-
>>PUSH /user/aturning/quotes 91
148+
>>PUSH$ /user/aturing/quotes 91
132149
>>We can only see a short distance ahead,
133150
>>but we can see plenty there that needs to be done.
134151
<<+-K94eLnB0rAAvfkh_WC3
135152

136-
##STREAM
153+
##BEGIN_STREAM
137154
Used to register to receive a stream of events that occur to the object at the provided path.
138155

139156
After registering you will start receiving events on the response line. They will be formatted as one line with the event type {PUT,PATCH,etc..} followed by the sub_path that changed and the other line with the data associated with that event type. This data will be formatted similar to GET results and can have multi-line batch strings (*) or json strings (&).
140157

141-
The event stream will continue until you send CANCEL_STREAM.
158+
The event stream will continue until you send END_STREAM.
159+
160+
When there is an ongoing event stream no other commands can be processed until you call END_STREAM as the event stream owns the return line.
142161
###Usage
143-
STREAM $PATH
144-
CANCEL_STREAM
162+
BEGIN_STREAM $PATH
145163
###Response
146164
$EVENT_NAME $SUB_PATH
147165
$DATA
148166
+OK
149167
###Examples
150-
>>STREAM /user/aturning
168+
>>BEGIN_STREAM /user/aturing
151169
<<+PUT /last_login
152170
<<:1455052043
153171
<<+PUT /address
154172
<<$24
155173
<<"78 High Street,\r\nHampton"
156-
>>CANCEL_STREAM
174+
175+
##END_STREAM
176+
Used to stop listening to events at a given path. This must be the same path provided to a previous BEGIN_STREAM call.
177+
178+
###Usage
179+
END_STREAM $PATH
180+
###Response
181+
+OK
182+
-NOT_STREAMING_PATH
183+
###Examples
184+
>>END_STREAM /user/aturing
185+
<<-NOT_STREAMING_PATH
186+
>>BEGIN_STREAM /user/aturing
187+
>>END_STREAM /user/aturing
157188
<<+OK

0 commit comments

Comments
 (0)