openT2T / translators

Repository for Open Translators to Things.
http://www.opentranslatorstothings.org
Other
29 stars 27 forks source link

Update Wink Doorbell translator and schema to support notifications #70

Open tjaffri opened 8 years ago

tjaffri commented 8 years ago

Let's use this issue to work on:

  1. How do we mark a property as notifyable in the RAML + JSON OCF schema
  2. We have some unit tests to actual emit events from the translator checked into the OpenT2T repo, we need to update the translator to use the same (e.g. EventEmitter etc)
  3. How do we use the Wink subscriptions to get an event back, and then raise the event. How do we register for a callback from wink inside the translator.
  4. How do we update our cloud sample to make this work end to end and send a push notification to a caller when the doorbell rings.
jasongin commented 8 years ago

According to the OCF spec, notifications are not represented anywhere in the RAML or JSON schemas. Reference section 5.3 RAML Definition OIC Resource Type Specification:

Notify is not part of an RAML definition but is defined in the Core specification. The semantics of a Notify are the same as the CRUDN Read value. All Resource Types defined in this specification support notification via the use of observe as defined in OIC Core Specification Section 11.4.2.

The linked section 11.4.2 describes abstractly the sequence for a NOTIFY operation, but does not metion how that is implemented with HTTP.

The OCF Core Specification section 12.2 Mapping of CRUDN to CoAP explains how the abstract CRUDN operations described in the spec are mapped to HTTP REST. (Note CoAP essentially means REST.) The NOTIFY operation mapping is not described inline, but references another spec:

A Device implementing CoAP shall conform to IETF draft-ietf-core-observe-16 to implement the CoAP Observe option.

I haven't had time to digest that spec yet.

jasongin commented 8 years ago

Also, there may be a problem with the way OpenT2T notifications are currently implemented in terms of properties. OCF notifications are at the resource level, and OpenT2T has mapped OCF resource endpoint+verb combinations to JavaScript methods. Currently translators that implement OCF schemas don't have any properties.