This repository has been archived by the owner on Jun 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Hub device APIs (and corresponding schema/translators) #7
Comments
Problem statements
We would like feedback on whether the problem statement is captured accurately above. Proposal
SummaryI think the only real technical change is #5 (in terms of a small metadata change in the onboarding type). Other than that, the rest is completely in line with our existing thinking… as long as we remember “hubs are things too”. Updated Wink Hub Onboarding (Proposed)Current version is at https://github.com/openT2T/onboarding/blob/master/org.OpenT2T.Onboarding.WinkHub/org.OpenT2T.Onboarding.WinkHub.xml <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://standards.freedesktop.org/dbus/introspect-1.0.dtd"[]>
<!-- This is the metadata for a category of things that are connected via the Wink Hub. -->
<node>
<interface name="com.OpenT2T.Onboarding.WinkHub">
<!-- Defines the metadata required to start onboarding.
These input parameters are unique to a particular device type that supports this onboarding type,
e.g. auth URLs, RF bands, regular expressions to find the device on a common bus, etc. -->
<method name="onboard">
<arg name="name" type="s" direction="in" />
<arg name="idKeyFilter" type="s" direction="in" />
</method>
<!-- Get the things required for this onboarding type (these are onboarded first, if not onboarded already) -->
<!-- This could return one or more hub devices required for any device with this onboarding type: e.g. translator-wink-hub -->
<method name="requiredThings">
<arg name="thingTranslators" type="s" direction="out" />
</method>
<!-- Defines the metadata returned by onboarding. This is converted to the props array on the device
object, which is passed in to translators that implement this onboarding type at runtime. -->
<signal name="success">
<arg name="access_token" type="s" direction="in" />
<arg name="id" type="s" direction="in" />
<arg name="message" type="s" direction="in" />
</signal>
<!-- Called when there is an error during onboarding -->
<signal name="error">
<arg name="type" type="s" direction="out"/>
<arg name="message" type="s" direction="out"/>
</signal>
</interface>
</node> New Hub Translator i.e. Hubs are also devices (Proposed)###1. Hub Schema (common to all hubs):** <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://standards.freedesktop.org/dbus/introspect-1.0.dtd"[]>
<node>
<interface name="org.OpenT2T.Sample.SuperPopular.Hub">
<!-- Sets the power state of the hub -->
<method name="setPowerState">
<arg name="state" type="b" direction="in" />
</method>
<!-- Gets the power state of the hub -->
<method name="getPowerState">
<arg name="state" type="b" direction="out" />
</method>
<!-- Enumerates devices connected to the hub -->
<method name="enumerateDevices">
<arg name="idKeyFilter" type="s" direction="in" />
</method>
<!-- Called when there is an error during usage of this translator -->
<signal name="error">
<arg name="type" type="s" direction="out"/>
<arg name="message" type="s" direction="out"/>
</signal>
</interface>
</node> 2. Package.json (for sample Wink Hub){
"name": "translator-wink-hub",
"version": "1.0.0",
"description": "",
"dependencies": {},
"devDependencies": {
"async": "~1.5.2",
"opent2t-onboarding-oauth2": "^1.0.1",
"optimist": "0.6.1"
},
"author": "",
"license": "MIT"
} 3. Translator Manifest (for sample Wink Hub)<?xml version="1.0" encoding="utf-8"?>
<manifest>
<!-- associated voice handler -->
<voice id="" />
<!-- associated schema -->
<schema id="org.OpenT2T.Sample.SuperPopular.Hub" />
<!-- associated onboarding module -->
<onboarding id="org.OpenT2T.Onboarding.OAuth2">
<arg name="name" value="" />
</onboarding>
</manifest> 4. Translator node script (for sample Wink Hub)'use strict';
// logs device state
function logDeviceState(device) {
if (typeof (device) !== 'undefined') {
console.log(' device.name : ' + device.name);
console.log(' device.props : ' + device.props);
} else {
console.log('device is undefined');
}
};
// module exports, implementing the schema
module.exports = {
device: null,
initDevice: function(dev) {
this.device = dev;
console.log('Javascript initialized.');
logDeviceState(this.device);
},
setPowerState: function() {
console.log('setPowerState called.');
// call the Wink API to set the power state of this hub.
},
getPowerState: function() {
console.log('getPowerState called.');
// call the Wink API to get the power state of this hub.
},
enumerateDevices: function(idKeyFilter) {
console.log('enumerateDevices called with value: ' + idKeyFilter);
// call the Wink API to enumerate all the devices connected to this hub.
},
disconnect: function() {
console.log('disconnect called.');
logDeviceState(this.device);
}
}; |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The device interaction APIs will need to be updated to support relationships between devices and their parent (hub) devices. (We may look to the OCF device relationship model for inspiration/alignment.) This is closely related to the onboarding framework task, in how we streamline the process of onboarding a hub with many attached devices. So the same person should own the design.
This includes prior discussion on "hub as a device", which I will paste below.
The text was updated successfully, but these errors were encountered: