-
-
Notifications
You must be signed in to change notification settings - Fork 14
DigitalTwins
The webthing is served and can be queried using http client
git clone https://github.com/rzr/twins ; cd twins
make start
url=http://localhost:8888
curl ${url}/properties
#| {"torso":0,"shoulder":0,"arm":0,"hand":0}
curl -X PUT -d '{ "arm": 42 }' $url/properties/arm
#| {"arm":42}
VR view can be used alternatively:
cd twins/aframe
npm install
PORT=8088 npm start
Some params can be added to configure app:
Next the device can be connected to mozilla-iot Gateway
STM32F7 based MCU is running webthing-iotjs with IoTjs for NuttX (until TizenRT is supporting this board).
More details soon:
- https://github.com/pando-project/iotjs/pull/1884# (Merged)
- https://github.com/pando-project/iotjs/pull/1886# (Merged)
- https://bitbucket.org/nuttx/nuttx/pull-requests/494/generic-auto-romfs/diff
For instance target
url=http://192.100.0.243:8888
curl -X PUT -d '{ "arm": 42 }' $url/properties/arm
curl -X PUT -d '{ "arm": -42 }' $url/properties/arm
Once connected to mozilla gateway it can be controlled from the Web UI, or curl commands using JWT issued from security menu.
bearer='eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjQxNjFiY2M4LTg2MTgtNGZhNy1iNDFhLTgwNGMyZjJjY2JlZiJ9.eyJjbGllbnRfaWQiOiJsb2NhbC10b2tlbiIsInJvbGUiOiJhY2Nlc3NfdG9rZW4iLCJzY29wZSI6Ii90aGluZ3M6cmVhZHdyaXRlIiwiaWF0IjoxNTYyMTYxNzI0LCJpc3MiOiJodHRwczovL3Nvc2cubW96aWxsYS1pb3Qub3JnIn0.Qvya9ozJo4VogfEDL0Gs1EFQhe_DgFp_2GICmOk-swTjGbFzpOFyo5DMDEJF2qu5NT5zq0AHig5l_ktT7fP5Ig'
curl_args="-H \"Authorization: Bearer $bearer\""
url='https://sosg.mozilla-iot.org/things/http---192.100.0.13-8888-'
make demo curl_args="$curl_args" target_url="$url"
VR view can be used alternatively:
cd twins/aframe
npm install
PORT=8088 npm start
Websockets can be also used:
- http://localhost:8088/?url=https://sosg.mozilla-iot.org/things/http---192.100.0.13-8888-&bearer=eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjQxNjFiY2M4LTg2MTgtNGZhNy1iNDFhLTgwNGMyZjJjY2JlZiJ9.eyJjbGllbnRfaWQiOiJsb2NhbC10b2tlbiIsInJvbGUiOiJhY2Nlc3NfdG9rZW4iLCJzY29wZSI6Ii90aGluZ3M6cmVhZHdyaXRlIiwiaWF0IjoxNTYyMTYxNzI0LCJpc3MiOiJodHRwczovL3Nvc2cubW96aWxsYS1pb3Qub3JnIn0.Qvya9ozJo4VogfEDL0Gs1EFQhe_DgFp_2GICmOk-swTjGbFzpOFyo5DMDEJF2qu5NT5zq0AHig5l_ktT7fP5Ig&verbose=1&useWs=yes&wsUrl=wss://sosg.mozilla-iot.org/things/http---192.100.0.13-8888-
- http://rzr.github.io/twins/aframe/?url=https://sosg.mozilla-iot.org/things/http---192.100.0.13-8888-&verbose=yes&useWs=yes&wsUrl=wss://sosg.mozilla-iot.org/things/http---192.100.0.13-8888-&bearer=eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjQxNjFiY2M4LTg2MTgtNGZhNy1iNDFhLTgwNGMyZjJjY2JlZiJ9.eyJjbGllbnRfaWQiOiJsb2NhbC10b2tlbiIsInJvbGUiOiJhY2Nlc3NfdG9rZW4iLCJzY29wZSI6Ii90aGluZ3M6cmVhZHdyaXRlIiwiaWF0IjoxNTYyMTYxNzI0LCJpc3MiOiJodHRwczovL3Nvc2cubW96aWxsYS1pb3Qub3JnIn0.Qvya9ozJo4VogfEDL0Gs1EFQhe_DgFp_2GICmOk-swTjGbFzpOFyo5DMDEJF2qu5NT5zq0AHig5l_ktT7fP5Ig
Some settings should be set:
url:
https://sosg.mozilla-iot.org/things/http---192.100.0.13-8888-
wsUrl:
wss://sosg.mozilla-iot.org/things/http---192.100.0.13-8888-
bearer:
eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjQxNjFiY2M4LTg2MTgtNGZhNy1iNDFhLTgwNGMyZjJjY2JlZiJ9.eyJjbGllbnRfaWQiOiJsb2NhbC10b2tlbiIsInJvbGUiOiJhY2Nlc3NfdG9rZW4iLCJzY29wZSI6Ii90aGluZ3M6cmVhZHdyaXRlIiwiaWF0IjoxNTYyMTYxNzI0LCJpc3MiOiJodHRwczovL3Nvc2cubW96aWxsYS1pb3Qub3JnIn0.Qvya9ozJo4VogfEDL0Gs1EFQhe_DgFp_2GICmOk-swTjGbFzpOFyo5DMDEJF2qu5NT5zq0AHig5l_ktT7fP5Ig
-
http://purl.org/rzr/tmp/example Then config will stay in localstorage so direct link will work:
For development purposes app can run in cloud.
url=https://twins.glitch.me
curl -X PUT -d '{ "arm": 42 }' $url/properties/arm
- http://rzr.github.io/twins/aframe/# (on HTTP)
- https://twins.glitch.me/properties
- https://glitch.com/edit/#!/twins
Then twin can be visualized using:
I think this one is a good entry door, tell me if you’re able to replicate:
Once you have replicated the earlier example, this one is good about XR binding:
Last one about the REST API to define abstract things and deal with I/O (sensors etc):
For your curiosity other related subprojects, once you’re comfortable with ones I just mentioned above.
- https://github.com/rzr/twins
- https://github.com/rzr/generic-sensors-lite
- https://github.com/rzr/webthing-go
- https://github.com/rzr/iotjs-express
- https://github.com/rzr/color-sensor-js
- https://github.com/rzr/webthings-webapp
- https://github.com/rzr/mozilla-iot-generic-sensors-adapter
- https://github.com/rzr/mastodon-lite
Good luck
Check Concept page for overview, Gateway to get started, IotJs page to install runtime to build webthing as explained in Home page.
For further experiments check Social and Sensor, or Extra parts like WebApp (for Tizen or PWA) or MCU info about running on other microcontrollers not supported by TizenRT.
While Home focus mostly on using iotjs to build webthings (on GNU/Linux or TizenRT for ARTIK05X devices).
This document is still in draft state, but reviews are always welcome, if you try to replicate it and stuck on missing instructions I would appreciate that you file issues or even better make pull request (just edit in github) that insert "TODO marks" in following chapters, like:
- TODO: please explain more this chapter and then remove this TODO line
Community contributions are welcome at:
Support is also possible, ask in:
- https://github.com/rzr/webthing-iotjs
- irc://irc.mozilla.org/#iot
WARNING: Developement branches could break over time.
Instead of maintaining "quick and dirty" demo code, I decided to split demo in smaller independents parts (which can reused) and I am upstreaming the most I can.
Then support can be done on mainline branches (or released versions).
Note that, Upstreaming can be a slow process, so snapshots links will remain until 100% of code is upstreamed.
Licence:
Reference documentation is at:
-
Concept:
- Demo Concept and Architecture
-
Gateway:
- Getting started with Mozilla IoT gateway
-
IotJs:
- Install IoT.js needed to run webthings
-
Home:
- Welcome page to build WebThings using IotJs
-
Social:
- Notification service using Mastodon FLOSS
-
TizenRT:
- webthing-iotjs on ARTIK05x
-
Sensor: and Actuator
- Physical interactions
-
Extra hints:
- Docker: About running in container
- MCU: About microcontrollers (not supported by TizenRT)
- WebApp: Alternate browser (Tizen and PWA)
- GnuLinux: Article about Edison and other
- Raspbian: Article about RaspberryPi
- Arduino: Alt For atmel or Esprissif boards
- DigitalTwins : WiP experiments
- TODO: Work in progress