-
Notifications
You must be signed in to change notification settings - Fork 10
JSON Query by Example
FireStep/Arduino accepts serial command lines. Each command line must be a syntactically complete JSON string with no embedded line breaks. FireStep JSON commands are query by example, and each JSON response will match the structure of the corresponding JSON request.
A FireStep request consists of a single line of JSON. Attributes with empty string values are query placeholders:
{"sys":""}
A FireStep response is also a single line of JSON:
{"s":0,"r":{"sys":{"b":"7cc07fa08132","fr":1000,"li":false,"tc":12345,"v":1.0}},'t':0.05}
The top-level attributes of a FireStep response are:
Attribute | ✏️ | Value |
---|
s | -- | command [status code](https://github.com/firepick1/FireStep/blob/master/src/Status.h)
r | -- | response matching request structure
t | -- | total command processing time in seconds
The attributes of each response are patterned after the request. For more information, see the JSON Reference
Attribute | ✏️ | Value |
---|
fr | -- | least available free ram in bytes (may decrease after certain commands)
li | :pencil2: | invert limit (false:HIGH, true:LOW)
tc | -- | thread clock ticks (@64microseconds)
v | -- | version
We can be selective about the information we want:
{"sys":{"v":"","fr":""}}
In general, FireStep will scan your request and construct an identical response, only updating query placeholders (i.g., ""). Our response will look like:
{"s":0,"r":{"sys":{"v":1.0,"fr":1000},"t":0.05}}
For even greater brevity, FireStep accepts compound attributes. We can combine a primary attribute (e.g., "sys") with a secondary attribute (e.g., "v") to request a single value using a compound attribute (e.g., "sysv"):
{"sysv":""}
The FireStep response will match the request, and use the compound sysv attribute:
{"s":0,"r":{"sysv":1.0},"t":0.05}
You can update one or more values in a request, and even include query placeholders:
{"sysli":true, "sysv":""}
The response will have the same structure as the request:
{"s":0,"r":{"sysli":true, "sysv":1.0}}
Most FireStep values are updateable. Some, such as the system version, cannot be changed.