Skip to content
This repository has been archived by the owner on Jun 13, 2019. It is now read-only.

Errors running EnviroPhat example #165

Open
dbkinder opened this issue Dec 28, 2017 · 9 comments
Open

Errors running EnviroPhat example #165

dbkinder opened this issue Dec 28, 2017 · 9 comments

Comments

@dbkinder
Copy link
Contributor

Following instructions at https://github.com/otcshare/iotivity-node/blob/master/js/envirophat/README.md went along OK through the command-line testing of the EnviroPhat LEDs. The next step failed:

pi@raspberrypi:~/workspace/iotivity-node/js $ node server.envirophat.ocf.js
module.js:487
    throw err;
    ^

Error: Cannot find module '/home/pi/workspace/iotivity-node/js/server.envirophat.ocf.js'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3

because the instructions put us in the wrong directory (should be down one more in the ~/workspace/iotivity-node/js/envirophat directory. But even if we're in the right directory, starting up the server fails:

pi@raspberrypi:~/workspace/iotivity-node/js $ cd envirophat/
pi@raspberrypi:~/workspace/iotivity-node/js/envirophat $ ls
client.envirophat.ocf.js  enviro_phat.py  README.md  server.envirophat.ocf.js
pi@raspberrypi:~/workspace/iotivity-node/js/envirophat $ node server.envirophat.ocf.js
[ main ]: Starting OCF stack in server mode
[ main ]: Registerign device and platform information
/home/pi/workspace/iotivity-node/js/envirophat/server.envirophat.ocf.js:175
	iotivity.OCSetDeviceInfo( deviceInfo );
	         ^

TypeError: iotivity.OCSetDeviceInfo is not a function
    at main (/home/pi/workspace/iotivity-node/js/envirophat/server.envirophat.ocf.js:175:11)
    at Object.<anonymous> (/home/pi/workspace/iotivity-node/js/envirophat/server.envirophat.ocf.js:183:1)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3

Not sure what to do now?

@dbkinder
Copy link
Contributor Author

Here's what I get in the client.get.js window when I run the server/client.get.js example:

pi@raspberrypi:~ $ cd ~/workspace/iotivity-node/js
pi@raspberrypi:~/workspace/iotivity-node/js $ node client.get.js 
Starting OCF stack in client mode
Issuing discovery request
Received response to DISCOVER request:
{
    "devAddr": {
        "adapter": 1,
        "flags": 98,
        "ifindex": 0,
        "port": 5683,
        "addr": "ff02::158"
    },
    "addr": {
        "adapter": 1,
        "flags": 98,
        "ifindex": 0,
        "port": 5683,
        "addr": "ff02::158"
    },
    "connType": 65634,
    "identity": [],
    "result": 29,
    "sequenceNumber": 0,
    "resourceUri": "/oic/res",
    "rcvdVendorSpecificHeaderOptions": []
}
Received response to DISCOVER request:
{
    "devAddr": {
        "adapter": 1,
        "flags": 32,
        "ifindex": 2,
        "port": 40833,
        "addr": "fe80::c7e5:1ab0:4459:479a%eth0"
    },
    "addr": {
        "adapter": 1,
        "flags": 32,
        "ifindex": 2,
        "port": 40833,
        "addr": "fe80::c7e5:1ab0:4459:479a%eth0"
    },
    "payload": {
        "type": 1,
        "sid": "5eda845f-d21f-5e91-9e7c-3f98e5841827",
        "resources": [
            {
                "uri": "/oic/sec/doxm",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.r.doxm"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coap",
                        "addr": "192.168.1.24",
                        "family": 64,
                        "port": 38630,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.24",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coap",
                        "addr": "fe80::c7e5:1ab0:4459:479a%25eth0",
                        "family": 32,
                        "port": 40833,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::c7e5:1ab0:4459:479a%25eth0",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/sec/pstat",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.r.pstat"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.24",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::c7e5:1ab0:4459:479a%25eth0",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/sec/acl2",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.r.acl2"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.24",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::c7e5:1ab0:4459:479a%25eth0",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/sec/cred",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.r.cred"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.24",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::c7e5:1ab0:4459:479a%25eth0",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/sec/crl",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.r.crl"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.24",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::c7e5:1ab0:4459:479a%25eth0",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/sec/csr",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.r.csr"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.24",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::c7e5:1ab0:4459:479a%25eth0",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/sec/roles",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.r.roles"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.24",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::c7e5:1ab0:4459:479a%25eth0",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/d",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.wk.d"
                ],
                "interfaces": [
                    "oic.if.baseline",
                    "oic.if.r"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coap",
                        "addr": "192.168.1.24",
                        "family": 64,
                        "port": 38630,
                        "pri": 1
                    },
                    {
                        "tps": "coap",
                        "addr": "fe80::c7e5:1ab0:4459:479a%25eth0",
                        "family": 32,
                        "port": 40833,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/p",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.wk.p"
                ],
                "interfaces": [
                    "oic.if.baseline",
                    "oic.if.r"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coap",
                        "addr": "192.168.1.24",
                        "family": 64,
                        "port": 38630,
                        "pri": 1
                    },
                    {
                        "tps": "coap",
                        "addr": "fe80::c7e5:1ab0:4459:479a%25eth0",
                        "family": 32,
                        "port": 40833,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/introspection",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.wk.introspection"
                ],
                "interfaces": [
                    "oic.if.baseline",
                    "oic.if.r"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.24",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::c7e5:1ab0:4459:479a%25eth0",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/a/iotivity-node-get-sample",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "core.fan"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coap",
                        "addr": "192.168.1.24",
                        "family": 64,
                        "port": 38630,
                        "pri": 1
                    },
                    {
                        "tps": "coap",
                        "addr": "fe80::c7e5:1ab0:4459:479a%25eth0",
                        "family": 32,
                        "port": 40833,
                        "pri": 1
                    }
                ]
            }
        ]
    },
    "connType": 65568,
    "identity": [],
    "result": 0,
    "sequenceNumber": 16777216,
    "resourceUri": "/oic/res",
    "rcvdVendorSpecificHeaderOptions": [
        {
            "protocolID": 2,
            "optionID": 12
        },
        {
            "protocolID": 2,
            "optionID": 2053
        }
    ]
}
Received response to DISCOVER request:
{
    "devAddr": {
        "adapter": 1,
        "flags": 64,
        "ifindex": 1,
        "port": 38630,
        "addr": "192.168.1.25"
    },
    "addr": {
        "adapter": 1,
        "flags": 64,
        "ifindex": 1,
        "port": 38630,
        "addr": "192.168.1.25"
    },
    "payload": {
        "type": 1,
        "sid": "5eda845f-d21f-5e91-9e7c-3f98e5841827",
        "resources": [
            {
                "uri": "/oic/sec/doxm",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.r.doxm"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coap",
                        "addr": "192.168.1.25",
                        "family": 64,
                        "port": 38630,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.25",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coap",
                        "addr": "fe80::b99f:10aa:ae8:c92%25lo",
                        "family": 32,
                        "port": 40833,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::b99f:10aa:ae8:c92%25lo",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/sec/pstat",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.r.pstat"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.25",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::b99f:10aa:ae8:c92%25lo",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/sec/acl2",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.r.acl2"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.25",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::b99f:10aa:ae8:c92%25lo",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/sec/cred",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.r.cred"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.25",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::b99f:10aa:ae8:c92%25lo",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/sec/crl",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.r.crl"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.25",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::b99f:10aa:ae8:c92%25lo",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/sec/csr",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.r.csr"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.25",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::b99f:10aa:ae8:c92%25lo",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/sec/roles",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.r.roles"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.25",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::b99f:10aa:ae8:c92%25lo",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/d",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.wk.d"
                ],
                "interfaces": [
                    "oic.if.baseline",
                    "oic.if.r"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coap",
                        "addr": "192.168.1.25",
                        "family": 64,
                        "port": 38630,
                        "pri": 1
                    },
                    {
                        "tps": "coap",
                        "addr": "fe80::b99f:10aa:ae8:c92%25lo",
                        "family": 32,
                        "port": 40833,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/oic/p",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.wk.p"
                ],
                "interfaces": [
                    "oic.if.baseline",
                    "oic.if.r"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coap",
                        "addr": "192.168.1.25",
                        "family": 64,
                        "port": 38630,
                        "pri": 1
                    },
                    {
                        "tps": "coap",
                        "addr": "fe80::b99f:10aa:ae8:c92%25lo",
                        "family": 32,
                        "port": 40833,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/introspection",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "oic.wk.introspection"
                ],
                "interfaces": [
                    "oic.if.baseline",
                    "oic.if.r"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coaps",
                        "addr": "192.168.1.25",
                        "family": 80,
                        "port": 44242,
                        "pri": 1
                    },
                    {
                        "tps": "coaps",
                        "addr": "fe80::b99f:10aa:ae8:c92%25lo",
                        "family": 48,
                        "port": 57806,
                        "pri": 1
                    }
                ]
            },
            {
                "uri": "/a/iotivity-node-get-sample",
                "anchor": "ocf://5eda845f-d21f-5e91-9e7c-3f98e5841827",
                "types": [
                    "core.fan"
                ],
                "interfaces": [
                    "oic.if.baseline"
                ],
                "bitmap": 1,
                "secure": false,
                "port": 0,
                "eps": [
                    {
                        "tps": "coap",
                        "addr": "192.168.1.25",
                        "family": 64,
                        "port": 38630,
                        "pri": 1
                    },
                    {
                        "tps": "coap",
                        "addr": "fe80::b99f:10aa:ae8:c92%25lo",
                        "family": 32,
                        "port": 40833,
                        "pri": 1
                    }
                ]
            }
        ]
    },
    "connType": 65600,
    "identity": [],
    "result": 0,
    "sequenceNumber": 16777216,
    "resourceUri": "/oic/res",
    "rcvdVendorSpecificHeaderOptions": [
        {
            "protocolID": 2,
            "optionID": 12
        },
        {
            "protocolID": 2,
            "optionID": 2053
        }
    ]
}
Received response to GET request:
{
    "devAddr": {
        "adapter": 1,
        "flags": 32,
        "ifindex": 2,
        "port": 40833,
        "addr": "fe80::c7e5:1ab0:4459:479a%eth0"
    },
    "addr": {
        "adapter": 1,
        "flags": 32,
        "ifindex": 2,
        "port": 40833,
        "addr": "fe80::c7e5:1ab0:4459:479a%eth0"
    },
    "connType": 65568,
    "identity": [],
    "result": 46,
    "sequenceNumber": 16777216,
    "resourceUri": "/a/iotivity-node-get-sample",
    "rcvdVendorSpecificHeaderOptions": [
        {
            "protocolID": 2,
            "optionID": 12
        },
        {
            "protocolID": 2,
            "optionID": 17
        },
        {
            "protocolID": 2,
            "optionID": 2049
        },
        {
            "protocolID": 2,
            "optionID": 2053
        }
    ]
}
Received response to GET request:
{
    "devAddr": {
        "adapter": 1,
        "flags": 64,
        "ifindex": 1,
        "port": 38630,
        "addr": "192.168.1.25"
    },
    "addr": {
        "adapter": 1,
        "flags": 64,
        "ifindex": 1,
        "port": 38630,
        "addr": "192.168.1.25"
    },
    "connType": 65600,
    "identity": [],
    "result": 46,
    "sequenceNumber": 16777216,
    "resourceUri": "/a/iotivity-node-get-sample",
    "rcvdVendorSpecificHeaderOptions": [
        {
            "protocolID": 2,
            "optionID": 12
        },
        {
            "protocolID": 2,
            "optionID": 17
        },
        {
            "protocolID": 2,
            "optionID": 2049
        },
        {
            "protocolID": 2,
            "optionID": 2053
        }
    ]
}

dbkinder added a commit to dbkinder/iotivity-node that referenced this issue Dec 28, 2017
Instructions still don't work correctly, but look better :)  (See Issue intel#165)
@gabrielschulhof
Copy link

OCSetDeviceInfo() is deprecated. I'll update the example to use OCSetPropertyValue(), and I'll ask you to try again, because I don't have the hardware to reproduce.

gabrielschulhof pushed a commit to gabrielschulhof/iotivity-node that referenced this issue Dec 29, 2017
Instructions still don't work correctly, but look better :)  (See Issue intel#165)

Closes intelgh-166
gabrielschulhof pushed a commit to gabrielschulhof/iotivity-node that referenced this issue Dec 29, 2017
gabrielschulhof pushed a commit to gabrielschulhof/iotivity-node that referenced this issue Dec 29, 2017
@gabrielschulhof
Copy link

@dbkinder could you please replace server.envirophat.ocf.js with this version and try again?

@dbkinder
Copy link
Contributor Author

Nope:

/home/pi/workspace/iotivity-node/js/envirophat/server.envirophat.ocf.js:169
		csdk.OC_RSRVD_DATA_MODEL_VERSION, "abc.0.0.1" ].join( "," ) );
		                                  ^^^^^^^^^^^

SyntaxError: missing ) after argument list
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:533:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3

Thinking the ].join( "," ) shouldn't be there, I removed that and tried again:

/home/pi/workspace/iotivity-node/js/envirophat/server.envirophat.ocf.js:169
		csdk.OC_RSRVD_DATA_MODEL_VERSION, "abc.0.0.1" );
		^

ReferenceError: csdk is not defined
    at main (/home/pi/workspace/iotivity-node/js/envirophat/server.envirophat.ocf.js:169:3)
    at Object.<anonymous> (/home/pi/workspace/iotivity-node/js/envirophat/server.envirophat.ocf.js:180:1)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3

@gabrielschulhof
Copy link

@dbkinder thanks for trying it out! I fixed the file now, and I added it to the linter script so I can avoid such syntax errors. Could you please grab the file again, and give it another whirl?

@dbkinder
Copy link
Contributor Author

That worked better. No syntax errors :)
But I don't think the sample is doing what's expected.
Here's the output from running the server in one terminal window:

pi@raspberrypi:~/workspace/iotivity-node/js/envirophat $ node server.envirophat.ocf.js
[ main ]: Starting OCF stack in server mode
[ main ]: Registering device and platform information
[ main ]: creating resources
[ createResources ]: Created resource with result: 0
[ main ]: Server ready

And then the client in another terminal window:

pi@raspberrypi:~/workspace/iotivity-node/js/envirophat $ node client.envirophat.ocf.js 
[InterfaceConfig] In
[main] Starting OCF stack in client mode
[main] Issuing discovery request
[discoverResources]: In
[discoveryReqCB] Received response to DISCOVER request:
[discoveryReqCB] Received response to DISCOVER request:
[discoveryReqCB]: found led resource
[discoveryReqCB]: enter 0,1,2,3,4 or Ctrl+c
[discoveryReqCB] Received response to DISCOVER request:
[discoveryReqCB]: found led resource
[discoveryReqCB]: enter 0,1,2,3,4 or Ctrl+c
[ProcessKey] key = 0
[InitPostRequest] key: 0
[payloadCreate] state: 0
[responseCallback] Received response to request with result: 46
undefined
[ProcessKey] key = 1
[InitPostRequest] key: 1
[payloadCreate] state: 1
[responseCallback] Received response to request with result: 46
undefined
[ProcessKey] key = 2
[InitGetRequest] key: 2
[payloadCreate] state: 2
[responseCallback] Received response to request with result: 46
undefined
[ProcessKey] key = 3
[InitGetRequest] key: 3
[payloadCreate] state: 3
[responseCallback] Received response to request with result: 46
undefined
[ProcessKey] key = 4
[InitGetRequest] key: 4
[payloadCreate] state: 4
[responseCallback] Received response to request with result: 46
undefined
[ProcessKey] key = �
[ProcessKey] SIGINT: Quitting the app gracefully...

I pressed 0, 1, 2, 3, and 4 and got the same response and no obvious changes to the EnviroPhat LEDs at any time. There was no output in the server window other than what's shown above.

So, the sample doesn't seem to be doing what's advertised.

@gabrielschulhof
Copy link

The requests are being denied. I'm guessing you're running version 1.3.1 of iotivity-node. Then you need to set up access control files before you can run the sample.

https://github.com/otcshare/iotivity-node/blob/master/js/README.md has instructions for creating the necessary files.

@dbkinder
Copy link
Contributor Author

I followed the instructions Rami provided here: https://github.com/otcshare/iotivity-node/tree/master/js/envirophat (no mention of the instructions you referenced). I see the first step of your instructions say, "In addition to iotivity-node, build iotivity with SECURED=1 and RD_MODE=all. Let the root of the iotivity repository be $iotivityRoot." but there are no command line instructions showing how to do that :(

@gabrielschulhof
Copy link

I modified the first instruction to point to https://wiki.iotivity.org/build. I also added a step to the envirophat instructions referring to the COAPS instructions.

Please have a look at

https://github.com/gabrielschulhof/iotivity-node/blob/gh-165/js/README.md

and

https://github.com/gabrielschulhof/iotivity-node/blob/gh-165/js/envirophat/README.md

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants