Site Tools


webos

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
webos [2019/08/23 02:32]
Seokhee
webos [2020/03/06 00:38] (current)
27.122.242.71
Line 360: Line 360:
 {{:​client_post_result.jpg?​1000|}} {{:​client_post_result.jpg?​1000|}}
 Result of POST RESOURCE Result of POST RESOURCE
 +
 +==== Execute sample webOS JavaScript service ====
 +
 +Execute the sample JavaScript service for server by below command.
 +
 +<​code>#​ luna-send -i -f luna://​com.example.service.iotivity.server/​startServer '​{"​subscribe":​true}'​ </​code>​
 +Return will be
 +<​code>​
 +{
 +    "​subscribed":​ true,
 +    "​returnValue":​ true,
 +    "​response":​ [
 +    ]
 +}
 +</​code>​
 +In 2nd shell, create binaryswitch with following command:
 +<​code>​
 +# luna-send -n 1 -f luna://​com.example.service.iotivity.server/​createResource '​{"​uri":"/​binaryswitch","​types":"​oic.r.switch.binary","​observable":​true}'​
 +</​code>​
 +In 1st shell, the return will be:
 +<​code>​
 +{
 +    "​subscribed":​ true,
 +    "​returnValue":​ true,
 +    "​response":​ [
 +        {
 +            "​interfaces":​ [
 +                "​oic.if.baseline",​
 +                "​oic.if.a"​
 +            ],
 +            "​types":​ [
 +                "​oic.r.switch.binary"​
 +            ],
 +            "​uri":​ "/​binaryswitch"​
 +        }
 +    ]
 +}
 +</​code>​
 +In 1st shell for server, trigger resource monitoring in server side as follows:
 +<​code>​
 +# luna-send -i -f luna://​com.example.service.iotivity.server/​observeBinarySwitchValue '​{"​subscribe":​true}'​
 +</​code>​
 +
 +Then the server is ready for client connection.
 +Now, client can find to the server and operate the binaryswitch resource in client side like:
 +
 +<​code>​
 +# luna-send -n 1 -f luna://​com.example.service.iotivity.client/​discoverResources '​{}'​
 +# luna-send -n 1 -f luna://​com.example.service.iotivity.client/​getResource '​{"​uri":​ "/​binaryswitch",​ "​eps":​[{"​tps":"​coaps","​addr":"​192.168.1.12","​family":​80,"​port":​32863,"​pri":​1},​{"​tps":"​coaps","​addr":"​fe80::​dea6:​32ff:​fe02:​87a3%25eth0","​family":​48,"​port":​45421,"​pri":​1}],​ "​destination":​ {"​adapter":​ 1,"​flags":​ 32,"​ifindex":​ 2, "​port":​ 50183,"​addr":​ "​fe80::​dea6:​32ff:​fe02:​87a3%eth0"​}}'​
 +# luna-send -i -f luna://​com.example.service.iotivity.client/​observeResource '​{"​uri":​ "/​binaryswitch",​ "​eps":​[{"​tps":"​coaps","​addr":"​192.168.1.12","​family":​80,"​port":​32863,"​pri":​1},​{"​tps":"​coaps","​addr":"​fe80::​dea6:​32ff:​fe02:​87a3%25eth0","​family":​48,"​port":​45421,"​pri":​1}],​ "​destination":​ {"​adapter":​ 1,"​flags":​ 32,"​ifindex":​ 2, "​port":​ 50183,"​addr":​ "​fe80::​dea6:​32ff:​fe02:​87a3%eth0"​},​ "​subscribe":​true}'​
 +# luna-send -n 1 -f luna://​com.example.service.iotivity.client/​postResource '​{"​uri":​ "/​binaryswitch",​ "​eps":​[{"​tps":"​coaps","​addr":"​192.168.1.12","​family":​80,"​port":​32863,"​pri":​1},​{"​tps":"​coaps","​addr":"​fe80::​dea6:​32ff:​fe02:​87a3%25eth0","​family":​48,"​port":​45421,"​pri":​1}],​ "​destination":​ {"​adapter":​ 1,"​flags":​ 32,"​ifindex":​ 2, "​port":​ 50183,"​addr":​ "​fe80::​dea6:​32ff:​fe02:​87a3%eth0"​},​ "​key":"​value","​value":"​true"​}'​
 +</​code> ​
 +
 ===== Customize Build Option ===== ===== Customize Build Option =====
  
webos.txt ยท Last modified: 2020/03/06 00:38 by 27.122.242.71