pyndsi v1.1
This release is based on #53
event sensor
- NDSI sensor type
event
- Supports data subscription
- Header:
timestamp
:int64
, little endian, nanoseconds since unix epochbody length
:uint32
, little endian, number of bytes in bodyencoding
:uint32
, little endian, integer value representing encoding used to encode body- Currently only
0
(utf-8
) is supported.
- Currently only
- Body:
body length
bytes representing a string encoded withencoding
Sending "events" to the host
Hosts with an event
sensor support receiving external events from clients. This is implemented via ZRE whispers whose content is a json encoded object with the following fields:
"name"
: required, value is the event's title/label/name as a json string"timestamp"
: optional, value is the external event's timestamp in nanoseconds since Unix epoch as a json number. If this field is not provided, the host will use the reception time as timestamp.
Valid events received by the host will be published to the event
sensor. As a result, clients can receive an echo of their own events if they subscribe to the event
sensor.
This can be used by the client to calculate the round trip time and time offset to the host. The client procedure looks like this:
1. Connect and subscribe to `event` sensor
2. Save current client timestamp `t0`
3. Send `{"name": "<<time>>"}` event to host
4. On receiving the echo, save the current client timestamp `t1`
5. The echo includes the host's reception time `t_host`
6. Round trip time: `t1 - t0`
7. Client-host time difference: `(t0 + t1) / 2 - t_host`