cordova-plugin-ocf-demo
This demo app requires the cordova-plugin-ocf packages, available at https://github.com/siovene/cordova-plugin-ocf/.
It show-cases the OCF Cordova Plugin for Android, but discoverying and listing properties of available resources on the current network.
Currently, the OCF Cordova Plugin for Android ships with a pre-built Iotivity 1.0.1 with a custom patch on top.
Dependencies
- nodejs v5 or above, v6.9.4 preferred (https://nodejs.org/en/download/package-manager/)
- the Android SDK, version 21 or above
- an ARM or x86 Android device (multicasting doesn't work on the Android emulator)
How to build
sudo apt-get install ruby-compass # Or install Compass somehow else
sudo npm install -g cordova grunt-cli bower # global npm packages
npm install # local npm packages
bower install # client js repositories
grunt platform:add:android # inits the platform and install plugins
grunt run:android # builds, installs and runs on the connected device
How to discover resources
This demo shows "Discovery devices..." after run it on Android device, it needs an OCF server which leverages OCF and IoTivity. They need to access the same network, so that this app could explore some resources and tranfer information between OCF server and OCF client. We recommend you to use it to create your own resource. Here is a guide about how to create a resource using Node.js on Ostro OS. There is a ready demo can be used to setup the OCF server.
Dependencies
Create resources on Edison
- Flash Edison device
- Boot up the Edison device, the image will auto-login as
root
now. - Remote ssh Access
- Connect to a WiFi network
- Download the latest release version sensor code at Host, such as 1.1.0-5, copy it to Edison, follow this file to connect the sensor to Edison, then start the sensor server(e.g.
temperature sensor
):
wget https://github.com/01org/SmartHome-Demo/archive/1.1.0-5.tar.gz
scp -r 1.1.0-5.tar.gz root@[device-ip]:~/
ssh root@[device-ip]
tar -xvf 1.1.0-5.tar.gz
cd SmartHome-Demo-1.1.0-5/ocf-servers/js-servers
export NODE_DEBUG=temperature
node temperature.js
Then you should see the following message on your console:
temperature: register OK
...
Discovery resource on Android device
- After running command
grunt run
, this demo will automatically launch and show Please enable discovery in the settings. - Press menu icon in the top of left, show OCF Demo, Devices, Resources and Settings, then press Settings and enable "Continuous discovery".
- Switch to Resources, show the temperature sensor's resource information, such as
Device ID
andPath
, press the resource, will show detail information, for exampleDevice ID
,Path
andTypes
. Thevalue
field ofProperties
can be edit. - Switch to Devices, show the temperature sensor's device information(e.g.
UUID
,URL
andName
).
Tips:
- The documentation for these resource servers in SmartHome-Demo is availabe in the
doc/
folder