Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support "event" sensor and sending "events" to the host #53

Merged
merged 16 commits into from
Jan 29, 2020
Merged

Conversation

papr
Copy link
Contributor

@papr papr commented Jan 29, 2020

This PR adds support for receiving published "events" (alternatively triggers or annotations).

event sensor

  • NDSI sensor type event
  • Supports data subscription
  • Header:
    • timestamp: int64, little endian, nanoseconds since unix epoch
    • body length: uint32, little endian, number of bytes in body
    • encoding: uint32, little endian, integer value representing encoding used to encode body
      • Currently only 0 (utf-8) is supported.
  • Body:
    • body length bytes representing a string encoded with encoding

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`

@papr papr merged commit 37364aa into master Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants