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

Commit f004ae5

Browse files
committed
Update serial_protocol.md
1 parent 6530949 commit f004ae5

File tree

1 file changed

+40
-13
lines changed

1 file changed

+40
-13
lines changed

serial_protocol.md

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Must be called after creating a Serial connection, it can take either just a hos
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,10 +78,10 @@ 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
@@ -92,10 +92,25 @@ Receiver will wait until a timeout for client to send $DATA_BYTE_COUNT worth of
9292
-FAIL
9393
-FAIL_TIMEOUT
9494
###Examples
95-
>>SET /user/aturning/address 24
95+
>>SET /user/aturing/address 24
9696
>>78 High Street,
9797
>>Hampton
9898
<<+OK
99+
100+
##SET{+,*,#,.,?}
101+
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.
102+
###Usage
103+
SET+ $PATH $VALUE
104+
SET: $PATH $VALUE
105+
SET? $PATH $VALUE
106+
###Response
107+
+OK
108+
-INCORRECT_TYPE
109+
###Examples
110+
>>SET? /user/aturing/was_human true
111+
<<+OK
112+
>>SET? /user/aturing/was_human He was not a computer.
113+
<<-INCORRECT_TYPE
99114

100115
##REMOVE
101116
Deletes the value located at the path provided.
@@ -105,7 +120,7 @@ Deletes the value located at the path provided.
105120
+OK
106121
-FAIL
107122
###Examples
108-
>>REMOVE /user/aturning
123+
>>REMOVE /user/aturing
109124
<<+OK
110125

111126
##PUSH
@@ -115,43 +130,55 @@ Adds a value to the list located at the path provided and returns the key at whi
115130
###Response
116131
$KEY
117132
###Examples
118-
>>PUSH /user/aturning/login_timestamps 1455052043
133+
>>PUSH /user/aturing/login_timestamps 1455052043
119134
<<+-K94eLnB0rAAvfkh_WC2
120135

121136
##PUSH$
122137
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.
123138

124139
Receiver will wait until a timeout for client to send $DATA_BYTE_COUNT worth of data before becoming responsive again.
125140
###Usage
126-
PUSH_BULK $PATH $DATA_BYTE_COUNT
141+
PUSH$ $PATH $DATA_BYTE_COUNT
127142
$DATA
128143
###Response
129144
$KEY
130145
###Examples
131-
>>PUSH /user/aturning/quotes 91
146+
>>PUSH /user/aturing/quotes 91
132147
>>We can only see a short distance ahead,
133148
>>but we can see plenty there that needs to be done.
134149
<<+-K94eLnB0rAAvfkh_WC3
135150

136-
##STREAM
151+
##BEGIN_STREAM
137152
Used to register to receive a stream of events that occur to the object at the provided path.
138153

139154
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 (&).
140155

141156
The event stream will continue until you send CANCEL_STREAM.
142157
###Usage
143-
STREAM $PATH
144-
CANCEL_STREAM
158+
BEGIN_STREAM $PATH
145159
###Response
146160
$EVENT_NAME $SUB_PATH
147161
$DATA
148162
+OK
149163
###Examples
150-
>>STREAM /user/aturning
164+
>>BEGIN_STREAM /user/aturing
151165
<<+PUT /last_login
152166
<<:1455052043
153167
<<+PUT /address
154168
<<$24
155169
<<"78 High Street,\r\nHampton"
156-
>>CANCEL_STREAM
170+
171+
##END_STREAM
172+
Used to stop listening to events at a given path. This must be the same path provided to a previous BEGIN_STREAM call.
173+
174+
###Usage
175+
END_STREAM $PATH
176+
###Response
177+
+OK
178+
-NOT_STREAMING_PATH
179+
###Examples
180+
>>END_STREAM /user/aturing
181+
<<-NOT_STREAMING_PATH
182+
>>BEGIN_STREAM /user/aturing
183+
>>END_STREAM /user/aturing
157184
<<+OK

0 commit comments

Comments
 (0)