Giter Club home page Giter Club logo

iotivity-node's Introduction

iotivity-node

DISCONTINUATION OF PROJECT. This project will no longer be maintained by Intel. Intel will not provide or guarantee development of or support for this project, including but not limited to, maintenance, bug fixes, new releases or updates. Patches to this project are no longer accepted by Intel. If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the community, please create your own fork of the project.

To create a fork of this project it is best not to use GitHub's "Fork" feature, because that restricts one's ability to maintain issues and a Wiki. Nevertheless, these steps may be followed:

  1. Create a new, empty GitHub repository of which you are the owner.
  2. Clone this archived repository.
  3. Change directories into the clone.
    cd iotivity-node
  4. Push to the empty repository you created:
    git push -f [email protected]:<your-organization>/<your-repository> master
  5. Maintain your fork at `https://github.com// complete with issues, PRs, and a Wiki.

Description

This project provides a Javascript API for OCF functionality. The API follows a maintained specification and is implemented as a native addon using iotivity as its backend.

Status

Windows Build Status Posix Build Status Coverage Status

Installation

  • On Linux and OSX
  1. Make sure node version 0.12 or later is up and running. This means that
    1. the command node runs node version 0.12 or later, and that
    2. the directory in which the node binary can be found is listed in the PATH environment variable so that the command node somescript.js is enough to execute somescript.js using node version 0.12 or later.
  2. Install the following packages, which your distribution should provide:
    1. unzip, scons (version 2.51), git, and make
    2. Development headers for libuuid, and glib2
    3. A C compiler and a C++ compiler (gcc-5 or later)
  3. Clone this repository.
  4. cd iotivity-node
  5. Run npm install.
  1. Install node 4 or later. As with Linux and OSX, make sure that node is called node and that it is on your PATH.

  2. In a PowerShell running as Administrator, run npm install -g --production windows-build-tools. This will install Python and the toolchain necessary for building iotivity-node. While this command runs, you can perform some of the following steps.

  3. Install git

  4. Install 7-Zip

  5. The installation of the windows-build-tools package eventually indicates that it has installed Python. After that message appears, you can perform some of the steps below.

  6. In a command prompt, append the python folder, the python scripts folder, and the 7-Zip folder to your PATH. The paths you append are based on your Windows user name, so replace "yourusernamehere" in the example below with your actual Windows user name.

    setx PATH "%PATH%;c:\Users\yourusernamehere\.windows-build-tools\python27;c:\Users\yourusernamehere\.windows-build-tools\python27\scripts;c:\Program Files\7-Zip"
    
  7. Close the command prompt and reopen it.

  8. In the command prompt, run pip install --egg "scons<3.0.0" to install scons (a python package)

  9. Wait for the installation of the windows-build-tools to complete. Afterwards, you can perform the remaining steps.

  10. Clone this repository and the change directory into it

  11. Run npm install to build iotivity-node.

  12. After the successful completion of the above command, you are ready to use iotivity-node. You can use the usual npm process of adding iotivity-node to the dependencies section of your package's package.json file.

After installation using the steps above, you may want to run the iotivity-node test suite. To do so, perform the following steps from the iotivity-node repository root. The steps apply to all platforms:

  1. Run npm -g install grunt-cli
  2. Run grunt test

The file appveyor.yml provides an example of the commands necessary for setting up a Windows environment, and the file .travis.yml provides an example of the commands necessary for setting up the Linux and OSX environments.

In more detail:

iotivity-node depends on iotivity proper. It has been tested against 1.3.0. The above installation instructions cover the dependencies for both iotivity-node and iotivity.

iotivity-node requires a compiler that implements the C++11 standard.

During compilation, iotivity-node downloads iotivity from its git repository, builds it, and links against it. If you wish to build iotivity separately, set the environment variable OCTBSTACK_CFLAGS to contain the compiler arguments necessary for building against iotivity, and also set the environment variable OCTBSTACK_LIBS to contain the linker arguments necessary for linking against iotivity. If both variables are set to non-empty values, iotivity-node will skip the step of downloading and building iotivity from sources. If you choose to build iotivity separately, you can use the following procedure:

  1. Grab a snapshot of iotivity from its git repository and unpack it locally.

  2. Make sure a build toolchain, scons (a build tool), and the headers for the above-mentioned library dependencies are installed. Your distribution should provide all these tools and libraries.

  3. cd iotivity

  4. If you're building against version 1.3.0 of iotivity on OSX or Windows, you will first need to apply all the downstream patches which iotivity-node provides in the patches/ subdirectory except the patch which removes the boost dependency. The latter patch serves only to improve build time by eliminating the ability to build targets which require boost. You can apply the patches with git apply <path-to-patch>. All these patches except the boost elmination patch are on track to appear in later versions of iotivity, so they will disappear from later versions of iotivity-node.

  5. scons has the concept of targets just like make. You can get a list of targets contained in the iotivity repository, as well as a listing of recognized build flags via scons --help. The only targets you need for the node.js bindings are octbstack and json2cbor if you are building in SECURED=1 mode. Thus, run scons SECURED=1 json2cbor octbstack to build these targets or scons octbstack if you do not require SECURED=1 mode.

    On OSX you need more targets than just octbstack and json2cbor because on that platform iotivity does not build octbstack as a shared library, but rather as an archive. Thus, you need to build all targets that correspond to archives that go into the Linux liboctbstack shared library:

    • c_common
    • coap
    • connectivity_abstraction
    • logger
    • ocsrm
    • octbstack
    • routingmanager
  6. Now that iotivity is built, clone this repository and change directory into it.

  7. Set the following environment variables:

    • OCTBSTACK_CFLAGS - this should contain the compiler flags for locating the iotivity include files. For example, the value of this variable can be -I/home/nix/iot/iotivity/resource/csdk/stack/include.
    • OCTBSTACK_LIBS - this should contain the linker flags necessary for locating liboctbstack.so both at compile time and at runtime. Its value can be as simple as -loctbstack if liboctbstack is in /usr/lib, but may need to be as complex as -L/home/nix/iot/iotivity/out/linux/x86/release -loctbstack -Wl,-rpath=/home/nix/iot/iotivity/out/linux/x86/release if liboctbstack.so is located on an unusual path.
  8. Run npm install with these environment variables set.

Provisioning and device ID persistence

The high-level JS API provides a means for persisting the device ID across instantiations of a script according to the iotivity wiki. This mechanism is also responsible for initially creating the configuration file that stores security-related information for a given script. It does so by creating a directory ${HOME}/.iotivity-node. Thereunder, it creates directories whose name is the sha256 checksum of the absolute path of the given script. Thus, if you write a script located in /home/user/myscript.js that uses the high-level JS API, its persistent state will be stored in the directory

/home/user/.iotivity-node/1abfb1b70eaa1ccc17a42990723b153a0d4b913a8b15161f8043411fc7f24fb1

in a file named oic_svr_db.dat. The file initially contains enough information to persist the device ID used whenever you run /home/user/myscript.js. You can add more information to the file in accordance with the iotivity wiki, and using the json2cbor tool. The tool is located in iotivity-installed/bin off the root of this repository, or, if you have chosen to build iotivity externally, then in the output directory created by the iotivity build process.

Examples

The JavaScript examples are located in js/ and come in pairs of one client and one server, each illustrating a basic aspect of iotivity. To run them, open two terminals and change directory to the root of the iotivity-node repository in both. Always launch the server before the client. For example, in one terminal you can run node js/server.discoverable.js and in the other terminal you can run node js/client.discovery.js.

Make sure no firewall is running (or one is properly configured to allow iotivity-related traffic and especially multicast traffic) on the machine(s) where these applications are running.

iotivity-node's People

Contributors

alshafi avatar bramwelt avatar dbkinder avatar dbrody avatar gvancuts avatar hansmbakker avatar miaobin avatar rzr avatar ttzeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iotivity-node's Issues

Failed to get properties of the interface OicDevice

Accord to the spec, all properties of the interface OicDevice should exist and can get the default value by following command:

var oic = require('iotivity-node')('client');
var oicDevice = oic.device;
console.log(oicDevice.uuid);
console.log(oicDevice.url);
console.log(oicDevice.name);
console.log(oicDevice.dataModels);
console.log(oicDevice.coreSpecVersion);
console.log(oicDevice.role);

Actually, the properties uuid and role exist in the interface OicDevice and the other properties are undefined.
A part of OicPlatform properties are defined that is similar as OicDevice.

force push to master

@gabrielschulhof apparently you just did a force push to master, wiping out all references to the previous released versions.

Was that intentional?

Which revision of iotivity-node should meta-iot-web use now?

client.findResources() is failing to discover the resources

Step1: Run client which calles client.findResources() periodically.

var device = require( "iotivity-node" )();

device.configure( {
    role: "client",
    connectionMode: "acked"
} ).then(
    function() {
        discoverResources();
    },
    function( error ) {
        console.log( "Client: device.configure() failed with " + error );
    } );


device.client.addEventListener( "resourcefound", function( event ) {
    console.log( "Discovered resource(s) via the following event:\n" +
        JSON.stringify( event, null, 4 ) );
} );

function discoverResources() {
    device.client.findResources().then(
        function() {
            console.log( "Client: findResources() successful" );
        },
        function( error ) {
            console.log( "Client: findResources() failed with " + error +
                " and result " + error.result );
        } );
    notifyObserversTimeoutId = setTimeout(discoverResources, 5000);
}

Step2: Run the server without resource registration.

var device = require( "iotivity-node" )();

device.configure( {
        role: "server",
        connectionMode: "acked",
        info: {
            uuid: "Test Server",
            name: "server-example",
            manufacturerName: "Intel",
            firmwareVersion: "0.0.1",
        }
} );

Step 3(optional): Run an another server that register the resource.
e.g. https://github.com/otcshare/iotivity-node/blob/master/js/high-level-server-example.js

Outcome: Check the output at client side

Client: findResources() failed with Error: findResources: failed to cancel previous handle and result 255

Issues with PUT

have a resource hosted on a native (C++) OCF server, which has R W property.

Trying to change it using iotvity node (PUT)

OicClient.update() method.

The resource object received when we discover - was saved and reused in the call.

Why does PUT fail in this case.

Mac build fails

node-gyp rebuild on Mac because 1) the pkg-config commands are not honored. Instead, one needs to use a "xcode_settings" variable and 2) the .so library is not build only the individual .a files. The below hack fixes the issues.

The proper fix is to create OSX dylib file with the content matching the Linux .so file. That is IoTivity issue.

diff --git a/binding.gyp b/binding.gyp
index 099a98c..e543a98 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -3,8 +3,11 @@
                "include_dirs": [
                        "<!(node -e \"require('nan')\")"
                ],
-               "libraries": [ '<!(pkg-config --libs octbstack)' ],
-               "cflags": [ '<!(pkg-config --cflags octbstack)' ]
+               "libraries": [ '<!@(pkg-config --libs octbstack)' ],
+               "cflags": [ '<!(pkg-config --cflags octbstack)' ],
+               "xcode_settings": {
+                       "OTHER_CFLAGS": ['<!(pkg-config --cflags octbstack)']
+               }
        },
        "targets": [
                {
@@ -36,28 +39,52 @@
                        "type": "executable",
                        "sources": [ "c/client.c" ],
                        "libraries": [ '<!(pkg-config --libs glib-2.0)' ],
-                       "cflags": [ '<!(pkg-config --cflags glib-2.0)' ]
+                       "cflags": [ '<!(pkg-config --cflags glib-2.0)' ],
+                       "xcode_settings": {
+                               "OTHER_CFLAGS": ['<!(pkg-config --cflags glib-2.0)'],
+                               "OTHER_LDFLAGS": [
+                                       '-loctbstack', '-lconnectivity_abstraction', '-lc_common', '-lcoap'
+                               ]
+                       }
                },
                {
                        "target_name": "client.observe",
                        "type": "executable",
                        "sources": [ "c/client.observe.c" ],
                        "libraries": [ '<!(pkg-config --libs glib-2.0)' ],
-                       "cflags": [ '<!(pkg-config --cflags glib-2.0)' ]
+                       "cflags": [ '<!(pkg-config --cflags glib-2.0)' ],
+                       "xcode_settings": {
+                               "OTHER_CFLAGS": ['<!(pkg-config --cflags glib-2.0)'],
+                               "OTHER_LDFLAGS": [
+                                       '-loctbstack', '-lconnectivity_abstraction', '-lc_common', '-lcoap'
+                               ]
+                       }
                },
                {
                        "target_name": "server",
                        "type": "executable",
                        "sources": [ "c/server.c" ],
                        "libraries": [ '<!(pkg-config --libs glib-2.0)' ],
-                       "cflags": [ '<!(pkg-config --cflags glib-2.0)' ]
+                       "cflags": [ '<!(pkg-config --cflags glib-2.0)' ],
+                       "xcode_settings": {
+                               "OTHER_CFLAGS": ['<!(pkg-config --cflags glib-2.0)'],
+                               "OTHER_LDFLAGS": [
+                                       '-loctbstack', '-lconnectivity_abstraction', '-lc_common', '-lcoap'
+                               ]
+                       }
                },
                {
                        "target_name": "server.observable",
                        "type": "executable",
                        "sources": [ "c/server.observable.c" ],
                        "libraries": [ '<!(pkg-config --libs glib-2.0)' ],
-                       "cflags": [ '<!(pkg-config --cflags glib-2.0)' ]
+                       "cflags": [ '<!(pkg-config --cflags glib-2.0)' ],
+                       "xcode_settings": {
+                               "OTHER_CFLAGS": ['<!(pkg-config --cflags glib-2.0)'],
+                               "OTHER_LDFLAGS": [
+                                       '-loctbstack', '-lconnectivity_abstraction', '-lc_common', '-lcoap'
+                               ]
+                       }
                }
        ]
 }

Opens for building iotivity-node on host

Follow the README.md(https://github.com/otcshare/iotivity-node/blob/master/README.md) to set up iotivity-node:

  1. Run the steps 1 to 5, grab a snapshot of iotivity from https://gerrit.iotivity.org/gerrit/gitweb?p=iotivity.git;a=tree;hb=1.0.0
  2. Set up the environment(steps 6):
$ export OCTBSTACK_CFLAGS="-I/home/nix/iot/iotivity/resource/csdk/stack/include"
$ export OCTBSTACK_LIBS="-L/home/nix/iot/iotivity/out/linux/x86/release -loctbstack -Wl,-rpath=/home/nix/iot/iotivity/out/linux/x86/release"
$ npm install
$ ./dish.sh

But failed to run command $ node-gyp rebuild in file dish.sh, then I update the environment path

$ export OCTBSTACK_CFLAGS="-I/home/nix/iot/iotivity/resource/csdk/stack/include"

to

$ export OCTBSTACK_CFLAGS="-I/home/nix/iot/iotivity/resource/csdk/stack/include 
-I/home/hj/iot/eg/iotivity-node-test/iotivity/resource/c_common 
-I/home/hj/iot/eg/iotivity-node-test/iotivity/resource/csdk/ocrandom/include/"

Rerun command $ node-gyp rebuild, build successfully.
3. Run the examples in the README.md

$ node js/server.discoverable.js

Open one new terminal

$ node js/client.discovery.js

Show some json format data after run the client script:

{
    "devAddr": {
        "adapter": 1,
        "flags": 32,
        "interface": 2,
        "port": 44131,
        "addr": [
            102,
            101,
            56,
            48,
            58,
            58,
            57,
            97,
            57,
            48,
            58,
            57,
            54,
            102,
            102,
            58,
            102,
            101,
            98,
            98,
            58,
            100,
            97,
            100,
            50,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0
        ]
    },
    "connType": 0,
    "result": 65568,
    "sequenceNumber": 0,
    "rcvdVendorSpecificHeaderOptions": []
}

Should I update the environment path when set up the environment for iotivity-node on PC host?
Is the result right about the examples "server/client.discovery.js" of repo iotivity-node?

All properties of interface OicPresence are undefined

Accord to the spec, get the interface by running command var oicPresence = require('iotivity-node')('client');, all properties of the interface OicPresence should exist and can invoke the method or event.
Actually, the methods subscribe(), unsubscribe() and ondevicechange are undefined in interface OicPresence.

Build failure caused by tinycbor

During installation , I get

out/linux/x86_64/release/resource/csdk/stack/src/ocpayloadparse.os: In functionOCParseStringLL':
ocpayloadparse.c:(.text+0xaf): undefined reference to _cbor_value_dup_string' out/linux/x86_64/release/resource/csdk/stack/src/ocpayloadparse.os: In functionOCParseSingleRepPayload':
ocpayloadparse.c:(.text+0x3d1): undefined reference to _cbor_value_dup_string' ocpayloadparse.c:(.text+0x557): undefined reference to_cbor_value_dup_string'
ocpayloadparse.c:(.text+0x59c): undefined reference to _cbor_value_dup_string' out/linux/x86_64/release/resource/csdk/stack/src/ocpayloadparse.os: In functionOCParseArrayFillArray':
ocpayloadparse.c:(.text+0xa58): undefined reference to _cbor_value_dup_string' out/linux/x86_64/release/resource/csdk/stack/src/ocpayloadparse.os:ocpayloadparse.c:(.text+0xa9e): more undefined references to_cbor_value_dup_stri
ng' follow`

Which causes scons to fail. I think the problem is due to this intel/tinycbor@4ce5669 commit.

Any ideas? Thanks

Sensor server implementation should know the size of observers list

server.notify call is there to notify observers with data and state changes, but there is no way to check
whether the observers list is empty or not.

Provide an event to check the size of observers list, so that we can make sure that 'server.notify' is called only when the observers list is not empty.

Build errors building against iotivity master

Here's my output:

tripzero@tripzero-desktop:/src/iotivity-node (master _)% export OCTBSTACK_CFLAGS="-I/home/tripzero/src/iotivity/resource/csdk/stack/include ." tripzero@tripzero-desktop:/src/iotivity-node (master *)% export OCTBSTACK_LIBS="-L/home/tripzero/src/iotivity/out/linux/x86_64/release -loctbstack -Wl,-rpath=/home/tripzer/src/iotivity/out/linux/x86_64/release"
tripzero@tripzero-desktop:~/src/iotivity-node (master *)% ~/.nvm/versions/node/v0.12.5/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js rebuild gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info spawn python2
gyp info spawn args [ '/home/tripzero/.nvm/versions/node/v0.12.5/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/home/tripzero/src/iotivity-node/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/tripzero/.nvm/versions/node/v0.12.5/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/tripzero/.node-gyp/0.12.5/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/tripzero/.node-gyp/0.12.5',
gyp info spawn args '-Dmodule_root_dir=/home/tripzero/src/iotivity-node',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/tripzero/src/iotivity-node/build'
CC(target) Release/obj.target/client.observe/c/client.observe.o
In file included from /usr/include/glib-2.0/glib.h:62:0,
from ../c/client.observe.c:4:
../c/client.observe.c: In function ‘dumpResponse’:
../c/client.observe.c:24:55: error: ‘OCDevAddr’ has no member named ‘size’
g_message( "client: ->addr->size: %d", response->addr->size );
^
../c/client.observe.c: In function ‘discoverCb’:
../c/client.observe.c:110:2: warning: implicit declaration of function ‘OCDevAddrToIPv4Addr’ [-Wimplicit-function-declaration]
if ( OC_STACK_OK == OCDevAddrToIPv4Addr( response->addr, &a, &b, &c, &d ) ) {
^
../c/client.observe.c:116:2: warning: implicit declaration of function ‘OCDevAddrToPort’ [-Wimplicit-function-declaration]
if ( OC_STACK_OK == OCDevAddrToPort( response->addr, &port ) ) {
^
../c/client.observe.c: In function ‘addDiscoverCallback’:
../c/client.observe.c:159:4: error: ‘OC_ALL’ undeclared (first use in this function)
OC_ALL,
^
../c/client.observe.c:159:4: note: each undeclared identifier is reported only once for each function it appears in
client.observe.target.mk:94: recipe for target 'Release/obj.target/client.observe/c/client.observe.o' failed
make: *_* [Release/obj.target/client.observe/c/client.observe.o] Error 1
make: Leaving directory '/home/tripzero/src/iotivity-node/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/tripzero/.nvm/versions/node/v0.12.5/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Linux 3.19.0-15-generic
gyp ERR! command "node" "/home/tripzero/.nvm/versions/node/v0.12.5/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/tripzero/src/iotivity-node
gyp ERR! node -v v0.12.5
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok

Failed to run example in the spec iot-js-spec.md on Ostro image#449

As the spec content that the command var oic = require('oic'); should work well on target device, but failed.

Step to reproduce

root@edison:~# node
> var oic = require('oic');
Error: Cannot find module 'oic'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at repl:1:11
    at REPLServer.defaultEval (repl.js:262:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:427:12)
    at emitOne (events.js:82:20)
> 

Board information

Target OS and platform:Edison and Ostro image#449(https://download.ostroproject.org/builds/ostro-os/2016-05-15_04-51-11-build-449/images/edison/ostro-image-swupd-dev-edison.toflash.tar.bz2)

De-dupe discovered devices/resources

Some asserts of the test API Presence are failed on recent GT images(from build#157 to build#164), but they are passed on build#154.
We checked the iotivity-node source code version is 1.1.0-4-r0 in image from build#157.

The test steps:

  1. Enter the test device and get the source code by command:
    git clone https://github.com/otcshare/iotivity-node.git
  2. Copy some necessary files to "/usr/lib/node_modules/iotivity-node"
    File list:Gruntfiles.js, .jscsrc, grunt-build and tests
  3. Install the node modules that defined in file "package.json" and "grunt-cli"
    cd /usr/lib/node_modules/iotivity-node; npm install; npm install grunt-cli
  4. Run a single test via below command:
    ./node_modules/grunt-cli/bin/grunt test --suites="API Presence"

Test Environment:

Tuchuck with build#157(using the image named like: ostro-xt-image-noswupd-benchmark-qa-intel-corei7-64-2016-07-25_07-09-15-build-157.dsk.xz ).
Failure log:

root@intel-corei7-64:/usr/lib/node_modules/iotivity-node# ./node_modules/grunt-cli/bin/grunt test --suites="API Presence"
Running "jshint:nonlib" (jshint) task
>> 65 files lint free.

Running "jshint:lib" (jshint) task
>> 8 files lint free.

Running "jscs:js" (jscs) task
>> 73 files without code style errors.

Running "testsuite" task

API Presence
✓ @       964: Server 1: device configured successfully
✓ @       994: Server 1: device.register() successful
✓ @      1403: Server 2: device configured successfully
✓ @      1405: Server 2: device.register() successful
✓ @      2778: subscribe has defined
✓ @      2782: subscribe is a function
✓ @      2784: unsubscribe has defined
✓ @      2786: unsubscribe is a function
✓ @      2788: ondevicechange has defined
✓ @      3331: Server 1: disablePresence()
✓ @      3367: Server 2: disablePresence()
✓ @      6539: Client: No events upon disablePresence() while not subscribed
✓ @      6977: Server 1: enablePresence()
✓ @      7026: Server 2: enablePresence()
✗ @     10194: Client: No events upon enablePresence() while not subscribed
Actual:
[
  [
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36376632-3338-3064-2d31-3165632d3462\"}}",
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36376632-3338-3064-2d31-3165632d3462\"}}"
  ],
  [
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}",
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}"
  ]
]
Expected:
[
  [],
  []
]
✓ @     10733: Server 2: disablePresence()
✓ @     14632: Server 1: disablePresence()
✓ @     14636: Client: Events upon disablePresence() of both servers while subscribed are as expected
✓ @     14984: Server 2: enablePresence()
✓ @     15132: Server 1: enablePresence()
✗ @     18040: Client: Events upon enablePresence() of both servers while subscribed are as expected
Actual:
[
  [
    "{\"event\":\"devicechange\",\"changeType\":\"added\",\"source\":{\"deviceId\":\"36376632-3338-3064-2d31-3165632d3462\"}}",
    "{\"event\":\"devicefound\",\"source\":{\"deviceId\":\"36376632-3338-3064-2d31-3165632d3462\"}}",
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36376632-3338-3064-2d31-3165632d3462\"}}",
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36376632-3338-3064-2d31-3165632d3462\"}}",
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36376632-3338-3064-2d31-3165632d3462\"}}"
  ],
  [
    "{\"event\":\"devicechange\",\"changeType\":\"added\",\"source\":{\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}",
    "{\"event\":\"devicefound\",\"source\":{\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}",
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}",
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}",
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}"
  ]
]
Expected:
[
  [
    "{\"event\":\"devicechange\",\"changeType\":\"added\",\"source\":{\"deviceId\":\"36376632-3338-3064-2d31-3165632d3462\"}}",
    "{\"event\":\"devicefound\",\"source\":{\"deviceId\":\"36376632-3338-3064-2d31-3165632d3462\"}}",
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36376632-3338-3064-2d31-3165632d3462\"}}"
  ],
  [
    "{\"event\":\"devicechange\",\"changeType\":\"added\",\"source\":{\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}",
    "{\"event\":\"devicefound\",\"source\":{\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}",
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}"
  ]
]
✓ @     18505: Server 2: disablePresence()
✓ @     18584: Server 1: disablePresence()
✓ @     21719: Client: Events upon disablePresence() with one server not subscribed are as expected
✓ @     22237: Server 2: enablePresence()
✓ @     22306: Server 1: enablePresence()
✗ @     25465: Client: Events upon enablePresence() with one server not subscribed are as expected
Actual:
[
  [
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36376632-3338-3064-2d31-3165632d3462\"}}",
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36376632-3338-3064-2d31-3165632d3462\"}}"
  ],
  [
    "{\"event\":\"devicechange\",\"changeType\":\"added\",\"source\":{\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}",
    "{\"event\":\"devicefound\",\"source\":{\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}",
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}",
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}",
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}"
  ]
]
Expected:
[
  [],
  [
    "{\"event\":\"devicechange\",\"changeType\":\"added\",\"source\":{\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}",
    "{\"event\":\"devicefound\",\"source\":{\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}",
    "{\"event\":\"resourcefound\",\"source\":{\"path\":\"/a/e6d68f66-6f4e-4ff1-8fef-5459062d8375\",\"deviceId\":\"36643233-3566-3531-2d35-3539612d3462\"}}"
  ]
]
✓ @     25902: Server 2: device.unregister() successful
✓ @     25919: Server 1 exited successfully (0)
✓ @     26277: Server 1 did not segfault
✓ @     26542: Server 1 exited successfully (0)
✓ @     26548: Server 1 did not segfault
✓ @     26551: Client exited successfully (0)
✓ @     26553: Client did not segfault
✓ @     26562: Server 1: device.unregister() successful
Total assertions: ( 32 + 3 ) / 35
Warning: Task "testsuite" failed. Use --force to continue.

Aborted due to warnings.
root@intel-corei7-64:/usr/lib/node_modules/iotivity-node#

Unable to test with native server.

No resources are reported when testing with version 1.0.1 of iotivity.
OCF Server version 1.0.1
Nodejs iotivity client built with OCTBSTACK LIBS AND CFLAGS set to same version.
The client is able to discover the server
BUT, no resources are reported.

What do I do to make this work?

Adding an empty server to the network prevents discovery of resources on other servers

  1. Write a client that does a discovery every two seconds:

    var device = require( "./index" )();
    
    function throwError( error ) {
        throw error;
    }
    
    function resourceFound( resource ) {
        console.log( "resourceFound: " + JSON.stringify( resource, null, 4 ) );
    }
    
    function repeatedDiscovery() {
        device.client.addEventListener( "resourcefound", resourceFound );
        setInterval( function() {
            console.log( "Calling findResources()" );
            device.client.findResources().catch( throwError );
        }, 2000 );
    }
    
    device.configure( {
        role: "client",
        connectionMode: "acked"
    } ).then( repeatedDiscovery, throwError );
  2. Run node js/server.discoverable.js and observe as the client repeatedly discovers the server

  3. Write an empty server and run it:

    var device = require( "./index" )();
    
    device.configure( {
        role: "server",
        connectionMode: "acked"
    } );
  4. Watch the output of the client

Expected: The client keeps discovering the one resource presented by js/server.discoverable.js

Actual: No resources are discovered until you kill the empty server

Failed to complete run iotivity-node tests on device

Using grunt to run the test of this repo on device
  1. Set up the command grunt can run normally on test device:
root@intel-corei7-64:/usr/lib/node_modules/iotivity-node# grunt
-sh: grunt: command not found

Failed to run command grunt because of lack of modules grunt-cli under the directory iotivity-node/node_modules, so I copy the module grunt-cli from desktop to test device:

$ scp -r grunt-cli root@test-device-ip:/usr/lib/node_modules/iotivity-node/node_modules
$ ssh root@test-device-ip
$ cd /usr/lib/node_modules/iotivity-node
$ ./node_modules/grunt-cli/bin/grunt -h

The command grunt can run normally
2. Copy all relevant files with test to device, but need to build file dlopennow.node at first on desktop.

$ scp -r .jscsrc Gruntfile.js grunt-build package.json tests root@test-device-ip:/usr/lib/node_modules/iotivity-node/
$ scp -r build/Release/dlopennow.node root@test-device-ip:/usr/lib/node_modules/iotivity-node/ build/Release/
$ ./node_modules/grunt-cli/bin/grunt test

Only show the part of output error message:

Resource Operations
✓ @      2738: OCInit successful
✓ @      2740: OCSetDeviceInfo successful
✓ @      2741: OCSetPlatformInfo successful
✓ @      2742: OCGetNumberOfResources(to establish initial count) successful
✓ @      2743: OCCreateResource(parent) successful
✓ @      2754: OCGetNumberOfResources successful
✓ @      2755: OCGetNumberOfResources reports an increase by one resource after OCCreateResource
✓ @      2756: OCGetResourceHandler initially returns the initial entity handler
✓ @      2760: OCBindResourceHandler successful
✓ @      2761: OCGetResourceHandler returns the alternate entity handler after setting it
✓ @      2763: OCGetResourceUri returns the correct URI
✓ @      2763: OCGetNumberOfResourceInterfaces successful
✓ @      2764: Initially there is only one interface on the resource
✓ @      2765: OCBindResourceInterfaceToResource successful
✓ @      2766: OCGetNumberOfResourceInterfaces successful
✓ @      2767: After adding an interface there are two interfaces on the resource
✓ @      2768: First interface is 'oic.if.baseline'
/usr/lib/node_modules/iotivity-node/tests/tests/Resource Operations.js:143
  iotivity.__compareResourceHandles( resourceHandleReceptacle.handle,
           ^
TypeError: undefined is not a function
    at Object.<anonymous> (/usr/lib/node_modules/iotivity-node/tests/tests/Resource Operations.js:143:11)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
✓ @      2769: Second interface is 'a.b.c'
✓ @      2771: OCBindResourceTypeToResource successful
✓ @      2771: OCGetNumberOfResourceTypes successful
✓ @      2772: After adding a type there are two types on the resource
✓ @      2773: First type is correct
✓ @      2774: Second type is correct
✓ @      2776: OCGetResourceProperties correctly returns properties set on resource
✗ @      2779: Test exited successfully (1)
Actual: 
false
Expected: 
true
✓ @      2793: Test did not segfault
✗ @      2810: Expected 35 assertions, but 26 were run
Actual: 
null
Expected: 
undefined
Total assertions: ( 319 + 4 ) / 323
Warning: Task "testsuite" failed. Use --force to continue.

Aborted due to warnings.

CLIENT vs CLIENT_SERVER discovery

OCInit - OCMode.OC_CLIENT vs OCMode.OC_CLIENT_SERVER mode

Discovery of devices lists all OCF resources in OC_CLIENT case
Discovery of devices lists only resources starting with URL /oic in CLIENT_SERVER case

Enable iotivity-node tests on device

Using grunt to run the test of this repo on device
  1. Set up the command grunt can run normally on test device:
root@intel-corei7-64:/usr/lib/node_modules/iotivity-node# grunt
-sh: grunt: command not found

Failed to run command grunt because of lack of modules grunt-cli under the directory iotivity-node/node_modules, so I copy the module grunt-cli from desktop to test device:

$ scp -r grunt-cli root@test-device-ip:/usr/lib/node_modules/iotivity-node/node_modules
$ ssh root@test-device-ip
$ cd /usr/lib/node_modules/iotivity-node
$ ./node_modules/grunt-cli/bin/grunt -h

The command grunt can run normally
2. Copy all relevant files with test to device

$ scp -r .jscsrc Gruntfile.js grunt-build package.json tests root@test-device-ip:/usr/lib/node_modules/iotivity-node/
$ ./node_modules/grunt-cli/bin/grunt test

Only show the part of output error message:

API Discovery
✓ @      2828: Server: device.configure() successful
✓ @      2837: Server: device.registerResource() successful
✓ @      5707: Client: open-ended resource discovery handle is initially undefined
✓ @      5716: Client: device.findResources() successful
✓ @      6019: Client: Resource found
✓ @      6022: Client: Resource present exactly once among resources
✓ @      6028: Client: open-ended resource discovery handle is set after one discovery
✗ @     30009: Test timed out
Actual:
null
Expected:
undefined
✗ @     30028: Expected 16 assertions, but 8 were run
Actual:
null
Expected:
undefined

Get Request
✓ @      2724: Server: OCInit successful
✓ @      2731: Server: OCCreateResource successful
✓ @      5457: Client: OCInit successful
✓ @      5463: Client: OCDoResource(discovery) successful
✓ @      5872: Client: Resource found
✓ @      5874: Client: OCDoResource(get) successful
✓ @      5961: Server: Incoming request has the correct flags
✓ @      5962: Server: Correct request received
✓ @      5965: Server: OCDoResponse successful
✓ @      5977: Client: Correct response received
✓ @      5980: Client: OCProcess succeeded 4 times
✓ @      5982: Client: OCStop successful
✓ @      5988: Client exited successfully (0)
✓ @      5990: Client did not segfault
✓ @      5993: Server: OCProcess succeeded 32 times
✓ @      5993: Server: OCDeleteResource successful
✓ @      6003: Server: OCStop successful
✓ @      6008: Server exited successfully (0)
✓ @      6008: Server did not segfault

Load Library
/usr/lib/node_modules/iotivity-node/node_modules/bindings/bindings.js:91
  throw err
        ^
Error: Could not locate the bindings file. Tried:
 → /usr/lib/node_modules/iotivity-node/build/dlopennow.node
 → /usr/lib/node_modules/iotivity-node/build/Debug/dlopennow.node
 → /usr/lib/node_modules/iotivity-node/build/Release/dlopennow.node
 → /usr/lib/node_modules/iotivity-node/out/Debug/dlopennow.node
 → /usr/lib/node_modules/iotivity-node/Debug/dlopennow.node
 → /usr/lib/node_modules/iotivity-node/out/Release/dlopennow.node
 → /usr/lib/node_modules/iotivity-node/Release/dlopennow.node
 → /usr/lib/node_modules/iotivity-node/build/default/dlopennow.node
 → /usr/lib/node_modules/iotivity-node/compiled/0.12.7/linux/x64/dlopennow.node
    at bindings (/usr/lib/node_modules/iotivity-node/node_modules/bindings/bindings.js:88:9)
    at Object.<anonymous> (/usr/lib/node_modules/iotivity-node/tests/tests/Load Library.js:2:35)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
✗ @       527: Test exited successfully (1)
Actual:
false
Expected:
true
✓ @       532: Test did not segfault
✗ @       546: Expected number of assertions to be defined, but expect() was not called.
Actual:
null
Expected:
undefined

Observation
✓ @      2729: Server: OCInit successful
✓ @      2736: Server: OCCreateResource successful
✓ @      5464: Client: OCInit successful
✓ @      5471: Client: OCDoResource(discovery) successful
✓ @      5881: Client: Resource found
✓ @      5884: Client: OCDoResource(observation) successful
✗ @      5959: Server: The first request has both the request and observe flags set
Actual:
{
  "OC_REQUEST_FLAG": true
}
Expected:
{
  "OC_OBSERVE_FLAG": true,
  "OC_REQUEST_FLAG": true
}
✓ @      5980: Server: Observation ID is not zero (18)
✓ @      5984: Server: Action is set to OC_OBSERVE_REGISTER
✓ @      5984: Server: OCDoResponse successful
✗ @      5985: Server: OCNotifyAllObservers(after 0 successful calls) successful
Actual:
"OC_STACK_NO_OBSERVERS"
Expected:
"OC_STACK_OK"
/usr/lib/node_modules/iotivity-node/tests/suite.js:191
              throw new Error( error );
                    ^
Error: Server requested teardown: Server: OCNotifyAllObservers(after 0 successful calls) failed
    at Object.spawnOptions.teardown (/usr/lib/node_modules/iotivity-node/tests/suite.js:191:14)
    at /usr/lib/node_modules/iotivity-node/tests/suite.js:82:13
    at arrayEach (/usr/lib/node_modules/iotivity-node/node_modules/lodash/index.js:1289:13)
    at Function.<anonymous> (/usr/lib/node_modules/iotivity-node/node_modules/lodash/index.js:3345:13)
    at Socket.serverStdoutData (/usr/lib/node_modules/iotivity-node/tests/suite.js:59:5)
    at Socket.emit (events.js:107:17)
    at readableAddChunk (_stream_readable.js:163:16)
    at Socket.Readable.push (_stream_readable.js:126:10)
    at Pipe.onread (net.js:538:20)
Warning: Task "testsuite" failed. Use --force to continue.

Aborted due to warnings.
root@intel-corei7-64:/usr/lib/node_modules/iotivity-node#

[REG] Iotivity-node doesn't work due to some changes of firewall in latest Ostro

Some asserts are failed due to the firewall setting, list all failed tests:

API Complex Payload
API Create Delete
API Device ID Persistence.js
API Device Information
API Device Rediscovery.js
API Discovery
API Error Propagation
API Observation
API Presence
API Query Parameters
API Retrieve
Complex Payload
Device Entity Handler
Discovery
Get Request
Multiple Observers
Observation
Presence

Reproduce Steps:

  1. Enter the test device and get the source code by command:
    git clone https://github.com/otcshare/iotivity-node.git
  2. Copy some necessary files to "/usr/lib/node_modules/iotivity-node"
    File list:Gruntfiles.js, .jscsrc, grunt-build and tests
  3. Install the node modules that defined in file "package.json" and "grunt-cli"
    cd /usr/lib/node_modules/iotivity-node; npm install; npm install grunt-cli
  4. Run tests via below command:
    ./node_modules/grunt-cli/bin/grunt test, some tests are failed and show timeout.
  5. Try to run a single tests with below commands:
$: node tests/tests/API\ Complex\ Payload/server.js 
{"assertionCount":3}
{"ready":true}
$: node tests/tests/API\ Complex\ Payload/client.js (Open a new terminal and run it)
{"assertionCount":1}
(Then the script will hang on this, no error message)

Test Environment:

Galileo with build#497.

Update resourse event

Hi, I am trying to update a resource however getting following error .
Error: update: OCDoResource response failed
following is my server / resource definition

var setpoint = 0;
device.register({
    id: { path: "/a/setpoint" },
    resourceTypes: [ "oic.r.switch.binary" ],
    interfaces: [ "oic.if.baseline" ],
    discoverable: true,
    observable: true,
    properties: { on: false }
  }).then((res) => {
    setpoint = res;
    device.addEventListener('observerequest', log);
    device.addEventListener('retrieverequest', log);
    device.addEventListener('updaterequest', log);
    console.log('setpoint register OK');
  }).catch(error => console.log(`error registering setpoint - ${error}`));

  function log(request) {
    console.log("setpoint: request " + request.type);
    request.sendResponse(setpoint);
  }

And following is the client

const client = require( "iotivity-node" )( "client" );
client.addEventListener( "resourcefound", function( event ) {
    if(event.resource.id.path === '/a/setpoint') {
        client.update({id: event.resource.id, setpoint: 10 })
        .then(() => console.log('changed setpoint'))
        .catch((error) => console.log(`unable to change setpoint - ${error}`));
    }
} );
client.findResources();

Use proper constructor

spoussa:iotivity-node$ gcc --version
gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2

../src/functions/oc-do-resource.cc: In function ‘void bind_OCDoResource(const v8::FunctionCallbackInfov8::Value&)’:
../src/functions/oc-do-resource.cc:86:75: error: in C++98 ‘data’ must be initialized by constructor, not by ‘{...}’
(OCClientContextDeleter)persistentJSCallback_free};

patch:

diff --git a/src/functions/oc-do-resource.cc b/src/functions/oc-do-resource.cc
index 90cdd04..49eff47 100644
--- a/src/functions/oc-do-resource.cc
+++ b/src/functions/oc-do-resource.cc
@@ -82,8 +82,8 @@ NAN_METHOD(bind_OCDoResource) {

OCHeaderOption *options = 0;
OCDoHandle handle;

  • OCCallbackData data = {0, defaultOCClientResponseHandler,
  •                     (OCClientContextDeleter)persistentJSCallback_free};
    
  • OCCallbackData data(0, defaultOCClientResponseHandler,
  •                     (OCClientContextDeleter)persistentJSCallback_free);
    

Interop with native OIC client and server

While trying to test nodejs js/client.get.js and running a simpleserver from resource/examples of iotivity - I get the following error.
resourceCount = resources.length ? resources.length : 0,
^
TypeError: Cannot read property 'length' of undefined
at /iotivity-node/js/client.get.js:40:29
at wrapper as _onTimeout
at Timer.listOnTimeout as ontimeout

I have matched the URI types to /a/light.

Kindly let us know how to test with native client and server.

device.onrequest not implemented

According to the spec the following should work but it does not:

device.registerResource({
    url: "/light/ambience/blue",
    deviceId: deviceId,
    connectionMode: connMode,
    resourceTypes: [ "Light" ],
    interfaces: [ "/oic/if/rw" ],
    discoverable: true,
    observable: true,
    properties: { color: "light-blue", dimmer: 0.2 }
  }).then((res) => {
    console.log("Resource " + res.id + " has been created.");
    lightResource = res;
    device.onrequest = requestHandler;
    device.enablePresence();
  })

The onrequest is newer called and you need to use:

resource._server.addEventListener( "request", requestHandler );

urlopen error occurs when npm install iotivity-node on Ostro

Hi,

I install iotivity-node via npm install iotivity-node on Ostro[1] after resolved dependencies in IoTivity-node, but SSL: CERTIFICATE_VERIFY_FAILED error occurs when scons download gtest.

 gtest_zip = env.Download(gtest_zip_file, gtest_url)

Error log:

scons: warning: Ignoring missing SConscript 'out/linux/x86_64/release/resource/csdk/connectivity/samples/linux/SConscript'
File "/usr/lib/node_modules/iotivity-node/depbuild/iotivity-1.1.0-3003bf3/resource/csdk/connectivity/SConscript", line 92, in <module>
*** Checking for installation of google unit test 1.7.0 ***
Download /usr/lib/node_modules/iotivity-node/depbuild/iotivity-1.1.0-3003bf3/extlibs/gtest/gtest-1.7.0.zip from https://googletest.googlecode.com/files/gtest-1.7.0.zip
Downloading ...
scons: *** <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> [https://googletest.googlecode.com/files/gtest-1.7.0.zip]  Stop.
+ cat config.log
file /usr/lib/node_modules/iotivity-node/depbuild/iotivity-1.1.0-3003bf3/build_common/SConscript,line 408:
        Configure(confdir = .sconf_temp)
scons: Configure: Checking for POSIX Thread Support...
.sconf_temp/conftest_0.c <-
  |
  |#if !defined(__GNUC__)
  |#  error "Not the GCC C compiler."
  |#endif
  |
  |int foo(void)
  |{
  |    return 0;
  |}
  |
Compiling .sconf_temp/conftest_0.o
.sconf_temp/conftest_1.c <-
  |
  |#include <unistd.h>
  |#include <pthread.h>
  |int main()
  |{
  |    #ifndef _POSIX_THREADS
  |    # error POSIX Threads support not available
  |    #endif
  |    return 0;
  |}
  |
Compiling .sconf_temp/conftest_1.o
scons: Configure: yes


file /usr/lib/node_modules/iotivity-node/depbuild/iotivity-1.1.0-3003bf3/resource/third_party_libs.scons,line 49:
        Configure(confdir = .sconf_temp)

file /usr/lib/node_modules/iotivity-node/depbuild/iotivity-1.1.0-3003bf3/resource/third_party_libs.scons,line 49:
        Configure(confdir = .sconf_temp)

file /usr/lib/node_modules/iotivity-node/depbuild/iotivity-1.1.0-3003bf3/resource/third_party_libs.scons,line 49:
        Configure(confdir = .sconf_temp)

file /usr/lib/node_modules/iotivity-node/depbuild/iotivity-1.1.0-3003bf3/resource/third_party_libs.scons,line 49:
        Configure(confdir = .sconf_temp)

file /usr/lib/node_modules/iotivity-node/depbuild/iotivity-1.1.0-3003bf3/resource/third_party_libs.scons,line 49:
        Configure(confdir = .sconf_temp)

file /usr/lib/node_modules/iotivity-node/depbuild/iotivity-1.1.0-3003bf3/resource/third_party_libs.scons,line 49:
        Configure(confdir = .sconf_temp)

+ exit 1
csdk.target.mk:13: recipe for target 'deps/iotivity' failed
make: *** [deps/iotivity] Error 1
make: Leaving directory '/usr/lib/node_modules/iotivity-node/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.4.12-yocto-standard
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/iotivity-node
gyp ERR! node -v v4.4.1
gyp ERR! node-gyp -v v3.3.0
gyp ERR! not ok 
npm ERR! Linux 4.4.12-yocto-standard
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "iotivity-node"
npm ERR! node v4.4.1
npm ERR! npm  v2.14.20
npm ERR! code ELIFECYCLE

Find an answer in http://stackoverflow.com/questions/27835619/ssl-certificate-verify-failed-error
Hope it would help.

[1] https://download.ostroproject.org/builds/ostro-os/2016-06-16_08-11-07-build-464/images/intel-corei7-64/ostro-image-swupd-dev-intel-corei7-64.dsk.zip

Is it possible to enable security?

Hello, I'm trying out IoTivity and as part of this I built a simple web GUI using Angular and Node (and this package). I did this without using any security and now I want to enable security on my devices and the client (the GUI). I have some C++ devices which can be secured but I cannot find the same option in this JS implementation. It is not implemented yet? I am using the high level API if that matters.

Error on calling client. updateResource(USVString resourceId, OicResourceInit resource)

Step1: Create a client example and call updateResource() on resoucefound event.

device.client.updateResource(event.resource.id, event.resource);

Step2: Create a server example and send response back when the update event is proceed.

      if ( request.type === "update" ) {
          request.sendResponse( null );
       }

Step3: Start server and client.

Actual outcome:

iotivity-node/lib/OicClient.js:291
            _.extend( this._resources[ id ].properties, resource.properties );
                                     ^
TypeError: Cannot read property 'id' of undefined
    at updateResourceFromResponse (iotivity-node/lib/OicClient.js:291:29)
    at oneShotRequestHandler (iotivity-node/lib/OicClient.js:70:31)
    at wrapper [as _onTimeout] (timers.js:274:14)
    at Timer.listOnTimeout (timers.js:119:15)

signed/unsigned char

When char == signed char, conversion to and from uint_8 fails in some
places. Started to happen recently in Ostro OS, perhaps because of a
compiler update. Exact root cause unknown, logs for example here:
https://ostroproject.org/jenkins/job/build_intel-corei7-64/1470/console

A patch fixing the problem is here:
pohly@abe2ce9

Beware, the commit is against the version currently used in Ostro OS and
also might not be the best solution to the problem (see commit
message). Please rebase and/or fix as you see fit.

I would have done a PR, but that failed because of the rebase master branch (issue #48).

Unable to retrieve (GET) resource.

Using high level API (OiCClient.js) to retrieve a resource.
It fails with the following error

Discovered resource:/a/b/cl

ID = { path: '/a/b/cl',
deviceId: 'some device id' }
Client: Retrieving failed Error: retrieve: device not found

device.retrieve(thing.id).then(
    function( resource ) {
        console.log("Client: Retrieving succeeded: " +  JSON.stringify( resource ) );
    },
    function( error ) {
        console.log("Client: Retrieving failed " + error);
    }

Found new crash on x86_64

Thread 1 "node" received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/x86_64/strlen.S:106
106 ../sysdeps/x86_64/strlen.S: No such file or directory.
(gdb) bt
#0 strlen () at ../sysdeps/x86_64/strlen.S:106
#1 0x0000000000857754 in v8::String::NewFromUtf8(v8::Isolate_, char const_, v8::NewStringType, int) ()
#2 0x00007fffe65f3e59 in js_OCPayload(OCPayload*) ()

from /home/dev/demo/iotivity/wsi/iotivity-node/build/Release/iotivity.node
#3 0x00007fffe65eb039 in js_OCClientResponse(OCClientResponse*) ()

from /home/dev/demo/iotivity/wsi/iotivity-node/build/Release/iotivity.node
#4 0x00007fffe65e0842 in defaultOCClientResponseHandler(void_, void_, OCClientResponse*) ()

from /home/dev/demo/iotivity/wsi/iotivity-node/build/Release/iotivity.node
#5 0x00007fffe639acb4 in OCHandleResponse ()

from /home/dev/demo/iotivity/out/linux/x86_64/release/liboctbstack.so
#6 0x00007fffe5f5ed0b in CAHandleRequestResponseCallbacks ()

from /home/dev/demo/iotivity/out/linux/x86_64/release/libconnectivity_abstraction.so
#7 0x00007fffe5f5de2e in CAHandleRequestResponse ()

from /home/dev/demo/iotivity/out/linux/x86_64/release/libconnectivity_abstraction.so
#8 0x00007fffe639bcc3 in OCProcess ()

from /home/dev/demo/iotivity/out/linux/x86_64/release/liboctbstack.so
#9 0x00007fffe65e640f in bind_OCProcess(Nan::FunctionCallbackInfov8::Value const&) ()

from /home/dev/demo/iotivity/wsi/iotivity-node/build/Release/iotivity.node
#10 0x00007fffe65d9825 in Nan::imp::FunctionCallbackWrapper(v8::FunctionCallbackInfov8::Value const&) () from /home/dev/demo/iotivity/wsi/iotivity-node/build/Release/iotivity.node
#11 0x0000000000870312 in v8::internal::FunctionCallbackArguments::Call(void ()(v8::FunctionCallbackInfov8::Value const&)) ()
#12 0x000000000089a301 in v8::internal::MaybeHandlev8::internal::Object v8::internal::HandleApiCallHelper(v8::internal::Isolate
, v8::internal::(anonymous namespace)::BuiltinArguments<(v8::internal::BuiltinExtraArguments)1>&) ()
#13 0x000000000089a75e in v8::internal::Builtin_HandleApiCall(int, v8::internal::Object*, v8::internal::Isolate) ()
#14 0x00000e27265068fb in ?? ()
#15 0x00000e2726506841 in ?? ()
#16 0x00007fffffffd3b0 in ?? ()
#17 0x00007fffffffd3f8 in ?? ()
#18 0x00000e272694eab3 in ?? ()
#19 0x00001b3734a96ba9 in ?? ()
#20 0x0000121793e450b1 in ?? ()
#21 0x00001b3734a96ba9 in ?? ()
#22 0x0000338423518721 in ?? ()

Change resourceId to deviceId and path

Currently the API spec is :

Client

retrieveResource(USVString resourceId);
updateResource(USVString resourceId, OicResourceInit resource);
deleteResource(USVString resourceId); 
startObserving(USVString resourceId); 

Server

unregisterResource(USVString resourceId);
notify(USVString resourceId, OicMethod method,

The resourceId is an internally generated ID which is passed around and made available during the discovery.

I would like the resourceId to be changed to tuple: device-id (di) and path (href), those are uniquely identifying the resources and can be passed to external entities as well like via REST API to the browser/cloud clients.

Mac tests fail

./dist

[...]
2 warnings generated.
CXX(target) Release/obj.target/iotivity/src/functions.o
CC(target) Release/obj.target/iotivity/src/callback-info.o
SOLINK_MODULE(target) Release/iotivity.node
ld: warning: could not create compact unwind for _ffi_call_unix64: does not use RBP or RSP based frame
SOLINK_MODULE(target) Release/iotivity.node: Finished
CC(target) Release/obj.target/server.observable/c/server.observable.o
LINK(target) Release/server.observable
LINK(target) Release/server.observable: Finished
CC(target) Release/obj.target/server/c/server.o
LINK(target) Release/server
LINK(target) Release/server: Finished

[email protected] test /Users/spoussa/src/iot/iotivity-node
node tests/suite.js

Simple client
18:01.325076000 INFO: OCStack: Entering OCInit
18:01.326822000 INFO: OCStack: Client mode: CAStartDiscoveryServer
✓ @ 11: OCInit in OC_CLIENT mode has succeeded
18:01.469310000 INFO: OCStack: Entering OCDoResource
✓ @ 153: OCDoResource for discovery has succeeded
✓ @ 154: The resulting handle contains a non-null property named "handle"
18:01.570349000 INFO: OCStack: Entering RequestPresence
18:01.674321000 INFO: OCStack: Entering RequestPresence
18:01.776218000 INFO: OCStack: Entering RequestPresence
18:01.876331000 INFO: OCStack: Entering RequestPresence
18:01.976455000 INFO: OCStack: Entering RequestPresence
18:02.79768000 INFO: OCStack: Entering RequestPresence
18:02.179916000 INFO: OCStack: Entering RequestPresence
18:02.282116000 INFO: OCStack: Entering RequestPresence
18:02.387360000 INFO: OCStack: Entering RequestPresence
18:02.387415000 INFO: OCStack: Enter HandleCARequests
18:02.492483000 INFO: OCStack: Entering RequestPresence
18:02.594795000 INFO: OCStack: Entering RequestPresence
18:02.594850000 INFO: OCStack: Enter HandleCAResponses
18:02.594881000 INFO: occlientcb: comparing tokens
18:02.594922000 INFO: occlientcb: 67 C6 69 73 51 FF 4A EC
18:02.594930000 INFO: occlientcb: 67 C6 69 73 51 FF 4A EC
18:02.594953000 DEBUG: OCStack: Response has the token g?isQ?J?
18:02.594963000 INFO: OCStackObserve: Observer node not found!!
18:02.594969000 INFO: OCStack: There is a cbNode associated with the response token
18:02.594974000 INFO: OCStack: This is a regular response, A client call back is found
18:02.594978000 INFO: OCStack: Calling into application address space
✓ @ 1279: OCDevAddrToIPv4Addr has succeeded
✓ @ 1279: OCDevAddrToPort has succeeded
✓ @ 1280: OCDoResource discovery handler was called
18:02.596388000 INFO: OCStack: Entering OCDoResource
18:02.596466000 INFO: occlientcb: deleting tokens
18:02.596481000 INFO: occlientcb: 67 C6 69 73 51 FF 4A EC
18:02.700079000 INFO: OCStack: Entering RequestPresence
18:02.700105000 INFO: OCStack: Enter HandleCAResponses
18:02.700109000 INFO: occlientcb: comparing tokens
18:02.700116000 INFO: occlientcb: 29 CD BA AB F2 FB E3 46
18:02.700121000 INFO: occlientcb: 29 CD BA AB F2 FB E3 46
18:02.700124000 DEBUG: OCStack: Response has the token )ͺ????F
18:02.700128000 INFO: OCStackObserve: Observer node not found!!
18:02.700131000 INFO: OCStack: There is a cbNode associated with the response token
18:02.700134000 INFO: OCStack: This is a regular response, A client call back is found
18:02.700137000 INFO: OCStack: Calling into application address space
/Users/spoussa/src/iot/iotivity-node/tests/tests/simple-client.js:127
JSON.parse( response.resJSONPayload ).oc[ 0 ],
^
TypeError: Cannot read property '0' of undefined
at /Users/spoussa/src/iot/iotivity-node/tests/tests/simple-client.js:127:51
at null. (/Users/spoussa/src/iot/iotivity-node/tests/test-utils.js:31:29)
at wrapper as _onTimeout
at Timer.listOnTimeout (timers.js:110:15)
/Users/spoussa/src/iot/iotivity-node/tests/suite.js:32
throw new Error( error.test + " exited with code " +
^
Error: /Users/spoussa/src/iot/iotivity-node/tests/tests/simple-client.js exited with code 1 and signal null.
at /Users/spoussa/src/iot/iotivity-node/tests/suite.js:32:12
at /Users/spoussa/src/iot/iotivity-node/node_modules/async/lib/async.js:148:21
at ChildProcess. (/Users/spoussa/src/iot/iotivity-node/tests/suite.js:21:7)
at ChildProcess.emit (events.js:110:17)
at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
npm ERR! Test failed. See above for more details.
Repair build first.

Test file and directory names have spaces

The test file and directory under tests/tests have spaces. This makes parsing testing results hard, and JavaScript file naming convention inconsistent.

Actually there are no common file/directory naming convention guide in jquery [1], node [2] community. Only find Google JavaScript guide [3] that suggests filenameslikethis.js. I wonder whether it is possible to use this naming rule for naming test files and directories.


  1. http://contribute.jquery.org/style-guide/js/#naming-conventions
  2. https://github.com/felixge/node-style-guide
  3. https://google.github.io/styleguide/javascriptguide.xml#Naming

addEventListeners seems really complicated when you want to expose multiple sensors at the same time

Instead of

    oic.addEventListener("updaterequest", onLightUpdate);
    oic.addEventListener("observerequest", onLightObserve);
    oic.addEventListener("deleterequest", onLightDelete);
    ...

and handling all sensors inside each method, wouldn't it not be better to give it an object instead, like Bleno does with Characteristics. That also allows you to easily share objects/value for each sensor instead of relying on global variables. And it allows you to inherit from common objects when they are very similar in spirit.

pseudocode (ignore naming) [the *Callback methods are modelled after latest ES6 compatible Custom Elements spec]:

class BlueLED extends oic.Resource {
  constructor() {
    this._value = 0.5;
    this._onlyGrow = true;

    super({
      deviceId: oic.device.uuid,
      path: "/light/ambience/blue",
      resourceTypes: [ "light" ],
      interfaces: [ "/oic/if/rw" ],

      discoverable: true,
      observable: true,

      properties: { 
        color: "blue",
        dimmer: this._value;
      }
    })
  }

  updateRequestCallback(value) {
     if (this._onlyGrow)
       this._value = Math.max(this._value, value);
  }

  deleteRequestCallback() {
  }
}

function startServer() {
  oic.registerResource(new BlueLED())
  .catch(function(err) { 
    console.log(err)
  });
}

Failed to construct Oic server object by "var oic = require('iotivity-node')"

According to the spec , when the constructor is invoked without parameters, the device is started in the default (server) role. However the Oic object with parameter "server" is different from the one without parameters.

The result of the constructor is invoked without parameters:

> var Oic = require('iotivity-node');
> Oic
{ [Function: OicDevice]
  super_: 
   { [Function: EventEmitter]
     EventEmitter: [Circular],
     usingDomains: true,
     defaultMaxListeners: 10,
     init: [Function],
     listenerCount: [Function] } }

The result of the constructor is invoked with parameter "server":

> var OicServer = require('iotivity-node')('server');
> OicServer
OicDevice {
  onobserverequest: [Getter/Setter],
  onunobserverequest: [Getter/Setter],
  onretrieverequest: [Getter/Setter],
  ondeleterequest: [Getter/Setter],
  oncreaterequest: [Getter/Setter],
  onupdaterequest: [Getter/Setter],
  onresourcefound: [Getter/Setter],
  ondevicefound: [Getter/Setter],
  ondiscoveryerror: [Getter/Setter],
  device: [Getter/Setter],
  platform: [Getter/Setter],
  _OCProcessIntervalId: 
   { _called: true,
     _idleTimeout: 100,
     _idlePrev: 
      Timer {
        '0': [Function: listOnTimeout],
        _idleNext: [Circular],
        _idlePrev: [Circular],
        msecs: 100 },
     _idleNext: 
      Timer {
        '0': [Function: listOnTimeout],
        _idleNext: [Circular],
        _idlePrev: [Circular],
        msecs: 100 },
     _idleStart: 61093,
     _onTimeout: [Function: wrapper],
     _repeat: [Function],
     domain: 
      Domain {
        domain: null,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        members: [] } } }

So I am not sure I have understood correctly about the spec description.

Objects in payload values are not parsed correctly

-> Create a payload value with an array objects like below and pass it to the OCDoResource GET request.

var test_payload = {
  Event:'Add',
  Type:'Light',
  att:{on_off: true}
};

payload = {
  type: iotivity.OCPayloadType.PAYLOAD_TYPE_REPRESENTATION,
    values: {
    }
  };
payload.values = test_payload;

-> Check the actual outcome:

"payload": {
        "type": 4,
        "values": {
            "Event": "Add",
            "Type": "Light",
            "att": {
                "type": 4
            }
        }
    }

Unable to test high level client and server examples.

Promise object is available only in later versions of v8.
The one packaged with Ubuntu 15.10 is 3.14.5 (which is quite common in our development environment)
Can we please update build instructions to download and install an appropriate version of libv8 in order for the tests to work ?

Failed to require ('iotivity-node')('server') on Ostro image#449

Steps to reproduce

All upstream tests can run normally on Ostro image#449.

Connect the test device and run command:

root@edison:~# cd /usr/lib/node_modules/iotivity-node/tests/tests/
root@edison:~# node
> require('iotivity-node')('server');
> require('../../index')('server');

Board information

Target OS and platform:Edison and Ostro image#449(https://download.ostroproject.org/builds/ostro-os/2016-05-15_04-51-11-build-449/images/edison/ostro-image-swupd-dev-edison.toflash.tar.bz2)

Logs

root@edison:~# node
> require('iotivity-node')('server');
TypeError: Cannot read property 'length' of undefined
    at Sha256.Hash.update (/usr/lib/node_modules/iotivity-node/node_modules/sha.js/hash.js:16:28)
    at new StorageHandler (/usr/lib/node_modules/iotivity-node/lib/StorageHandler.js:56:20)
    at _.extend._startStack (/usr/lib/node_modules/iotivity-node/lib/OicDevice.js:149:49)
    at _.extend._startStack (/usr/lib/node_modules/iotivity-node/lib/OicServer.js:105:11)
    at _.extend._construct (/usr/lib/node_modules/iotivity-node/lib/OicDevice.js:51:8)
    at _.extend._construct (/usr/lib/node_modules/iotivity-node/lib/OicClient.js:43:18)
    at _.extend._construct (/usr/lib/node_modules/iotivity-node/lib/OicServer.js:96:18)
    at new OicDevice (/usr/lib/node_modules/iotivity-node/lib/OicDevice.js:24:8)
    at OicDevice (/usr/lib/node_modules/iotivity-node/lib/OicDevice.js:21:11)
    at repl:1:25  
> require(‘../../index')('server');
TypeError: Cannot read property 'length' of undefined
    at Sha256.Hash.update (/usr/lib/node_modules/iotivity-node/node_modules/sha.js/hash.js:16:28)
    at new StorageHandler (/usr/lib/node_modules/iotivity-node/lib/StorageHandler.js:56:20)
    at _.extend._startStack (/usr/lib/node_modules/iotivity-node/lib/OicDevice.js:149:49)
    at _.extend._startStack (/usr/lib/node_modules/iotivity-node/lib/OicServer.js:105:11)
    at _.extend._construct (/usr/lib/node_modules/iotivity-node/lib/OicDevice.js:51:8)
    at _.extend._construct (/usr/lib/node_modules/iotivity-node/lib/OicClient.js:43:18)
    at _.extend._construct (/usr/lib/node_modules/iotivity-node/lib/OicServer.js:96:18)
    at new OicDevice (/usr/lib/node_modules/iotivity-node/lib/OicDevice.js:24:8)
    at OicDevice (/usr/lib/node_modules/iotivity-node/lib/OicDevice.js:21:11)
    at repl:1:25  

But it's work well when run require('iotivity-node')('client').
I find the code var oic = require( "../../../index" )( "server" ); is used in the server.js of upstream tests.

Failed to run iotivity-node tests with latest commit 3908662

Follow the steps #36 to run iotivity-node tests with latest commit 3908662:

Run below command:

$ cd /usr/lib/node_modules/iotivity-node
$ ./node_modules/grunt-cli/bin/grunt test

Show error message:

root@edison:/usr/lib/node_modules/iotivity-node# ./node_modules/grunt-cli/bin/grunt test
Running "jshint:nonlib" (jshint) task
>> 60 files lint free.

Running "jshint:lib" (jshint) task
>> 8 files lint free.

Running "jscs:js" (jscs) task
>> 68 files without code style errors.

Running "testsuite" task

API Complex Payload
/usr/lib/node_modules/iotivity-node/tests/suite.js:196
                            throw new Error( error );
                            ^

Error: Server requested teardown: Server: Constructing OicResource: malformed id, result: undefined
    at Object.spawnOptions.teardown (/usr/lib/node_modules/iotivity-node/tests/suite.js:196:14)
    at /usr/lib/node_modules/iotivity-node/tests/suite.js:96:13
    at arrayEach (/usr/lib/node_modules/iotivity-node/node_modules/lodash/index.js:1289:13)
    at Function.<anonymous> (/usr/lib/node_modules/iotivity-node/node_modules/lodash/index.js:3345:13)
    at Socket.serverStdoutData (/usr/lib/node_modules/iotivity-node/tests/suite.js:73:5)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:153:18)
    at Socket.Readable.push (_stream_readable.js:111:10)
    at Pipe.onread (net.js:529:20)
Warning: Task "testsuite" failed. Use --force to continue.

Aborted due to warnings.

Try to reset one commit using below command:

$ git reset --hard HEAD^1
HEAD is now at 545195f README.md: Document install.sh environment variable named "SOURCE"

Then rerun the tests using above command, there is the similar error as reset commit id before, only show the part of output error message:

API Query Parameters
/usr/lib/node_modules/iotivity-node/tests/suite.js:196
                            throw new Error( error );
                            ^

Error: Server requested teardown: Failed to register resource: Error: Constructing OicResource: malformed id
    at Object.spawnOptions.teardown (/usr/lib/node_modules/iotivity-node/tests/suite.js:196:14)
    at /usr/lib/node_modules/iotivity-node/tests/suite.js:96:13
    at arrayEach (/usr/lib/node_modules/iotivity-node/node_modules/lodash/index.js:1289:13)
    at Function.<anonymous> (/usr/lib/node_modules/iotivity-node/node_modules/lodash/index.js:3345:13)
    at Socket.serverStdoutData (/usr/lib/node_modules/iotivity-node/tests/suite.js:73:5)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:153:18)
    at Socket.Readable.push (_stream_readable.js:111:10)
    at Pipe.onread (net.js:529:20)
Warning: Task "testsuite" failed. Use --force to continue.

Aborted due to warnings.
root@edison:/usr/lib/node_modules/iotivity-node#

If I reset one commit id again, the error is not reproduced.

node-gyp rebuild fails against local iotivity build

Hello,

First of all, thanks for the work putting this package together. I'm trying to build against my local development branch of iotivity. I followed the instructions in the README, read the issues, and I think I'm seeing something unreported.

#node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/root/iotivity-node/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/root/.node-gyp/6.2.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/root/.node-gyp/6.2.1',
gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=/root/iotivity-node',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/root/iotivity-node/build'
  TOUCH Release/obj.target/csdk.stamp
  ACTION Generating constants generated/constants.cc
  TOUCH Release/obj.target/generateconstants.stamp
  ACTION Generating enums generated/enums.cc
  TOUCH Release/obj.target/generateenums.stamp
  CXX(target) Release/obj.target/iotivity/generated/constants.o
../generated/constants.cc:100:17: warning: extra tokens at end of #ifdef directive
 #ifdef OC_UNUSED(x)
                 ^
In file included from ../generated/constants.cc:20:0:
../generated/constants.cc: In function 'void InitConstants(v8::Handle<v8::Object>)':
../generated/constants.cc:101:42: error: 'x' was not declared in this scope
   SET_CONSTANT_NUMBER(exports, OC_UNUSED(x));
                                          ^
/root/iotivity-node/src/enums.h:26:27: note: in definition of macro 'SET_CONSTANT_NUMBER'
                 Nan::New((name)),                                \
                           ^
../generated/constants.cc:101:32: note: in expansion of macro 'OC_UNUSED'
   SET_CONSTANT_NUMBER(exports, OC_UNUSED(x));
                                ^
make: *** [Release/obj.target/iotivity/generated/constants.o] Error 1
iotivity.target.mk:127: recipe for target 'Release/obj.target/iotivity/generated/constants.o' failed
make: Leaving directory '/root/iotivity-node/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2

Here is a docker file to reproduce my environment. I have the npm install step commented out in the Buildscript so that it's easy to intervene and test on a fresh pull from your repo. I have tried both the install.sh method, as well as the manual env variable assignment method.
https://github.com/jspark311/IoTivityNodeSecDocker

I don't think this is actually a problem with iotivity-node. But I'm not sure.
If this is iotivity's fault, it was introduced April 11:
https://github.com/iotivity/iotivity/blob/master/resource/csdk/stack/include/octypes.h#L348

iotivity/iotivity@c9a7bb4

Have you seen any problems with this macro? Am I doing it wrong? Any guidance would be appreciated.

iotivity-node on iotivity 1.2.0-RC2

Made the following changes to make iotivity-node work on iotivity 1.2.0-RC2
Platform : artik

diff --git a/src/structures/oc-dev-addr.cc b/src/structures/oc-dev-addr.cc
index ebe26c6..eb7b03a 100644
--- a/src/structures/oc-dev-addr.cc
+++ b/src/structures/oc-dev-addr.cc
@@ -30,7 +30,7 @@ Local js_OCDevAddr(OCDevAddr *address) {

SET_VALUE_ON_OBJECT(returnValue, Number, address, adapter);
SET_VALUE_ON_OBJECT(returnValue, Number, address, flags);

  • SET_VALUE_ON_OBJECT(returnValue, Number, address, interface);
  • SET_VALUE_ON_OBJECT(returnValue, Number, address, ifindex);
    SET_VALUE_ON_OBJECT(returnValue, Number, address, port);

// addr.addr
@@ -53,7 +53,7 @@ bool c_OCDevAddr(Local jsDevAddr, OCDevAddr *address) {
false, jsDevAddr, Uint32Value);
VALIDATE_AND_ASSIGN(local, flags, OCTransportFlags, IsUint32, "addr", false,
jsDevAddr, Uint32Value);

  • VALIDATE_AND_ASSIGN(local, interface, uint32_t, IsUint32, "addr", false,
  • VALIDATE_AND_ASSIGN(local, ifindex, uint32_t, IsUint32, "addr", false,
    jsDevAddr, Uint32Value);
    VALIDATE_AND_ASSIGN(local, port, uint16_t, IsUint32, "addr", false, jsDevAddr,
    Uint32Value);
    diff --git a/src/structures/oc-payload.cc b/src/structures/oc-payload.cc
    index 688a935..128590a 100644
    --- a/src/structures/oc-payload.cc
    +++ b/src/structures/oc-payload.cc
    @@ -237,10 +237,10 @@ static Local js_OCLinksPayload(OCLinksPayload *payload) {
    ADD_STRING_ARRAY(returnValue, payload, itf);
    SET_STRING_IF_NOT_NULL(returnValue, payload, rel);
    Nan::Set(returnValue, Nan::New("obs").ToLocalChecked(),
  •       Nan::New(payload->obs));
    
  •       Nan::New(payload->p & 0x2));
    
    SET_STRING_IF_NOT_NULL(returnValue, payload, title);
  • SET_STRING_IF_NOT_NULL(returnValue, payload, uri);
  • ADD_STRING_ARRAY(returnValue, payload, mt);
  • SET_STRING_IF_NOT_NULL(returnValue, payload, anchor);
  • ADD_STRING_ARRAY(returnValue, payload, type);
  • return returnValue;
    }

    Devices are discovered but no resources are reported.

    Insecure mode.

    Native client works fine.

Less noise, please

There is way too much debug info on the console. Make it so that it only prints when something happens (the transactions).

Code does not build against latest iotivity master

../src/enums.cc: In function ‘v8::Localv8::Object bind_OCEntityHandlerFlag()’:
../src/enums.cc:14:40: error: ‘OC_INIT_FLAG’ was not declared in this scope
NanNew(OC_INIT_FLAG),

because of e6c822769277ad9a71252bd7e24f3dc9011b9399

../src/enums.cc: In function ‘v8::Localv8::Object bind_OCConnectivityType()’:
../src/enums.cc:300:40: error: ‘OC_ETHERNET’ was not declared in this scope
NanNew(OC_ETHERNET),
^
../src/enums.cc:302:67: error: ‘OC_WIFI’ was not declared in this scope
returnValue->ForceSet(NanNew("OC_WIFI"), NanNew(OC_WIFI),

because of d147b9150542047ee42d7f622524ec0bf3b34128

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.