I have altered the code in node-thing-client and node-taas-client to be able to toggle the value of a global variable, and thereafter, the output of a GPIO to a switch.
The perform section of thing-client looks like this:
One thing I am unsure about in this code is the parameter value "switch toggled". I put that in there just because there was something there before I eddited it, but I don't know where this value is used or where it get received.
Anyway, the problem comes when I try to run taas-client after successfully running thing-client.
This is the ouput of the thing-client:
>>> recv: {"path":"/api/v1/thing/perform","requestID":"6","tasks":{"39512110":{"perform":"toggle","parameter":"\"switch toggled\"","testOnly":false}}}
{ path: '/api/v1/thing/perform',
requestID: '6',
tasks:
{ '39512110':
{ perform: 'toggle',
parameter: '"switch toggled"',
testOnly: false } } }
/home/debian/node_modules/thing-client/beagle1.js:533
f(thing, thingID, message);
^
ReferenceError: thingID is not defined
at null.<anonymous> (/home/debian/node_modules/thing-client/beagle1.js:533:14)
at EventEmitter.emit (events.js:117:20)
at WebSocket.<anonymous> (/home/debian/node_modules/thing-client/thing-client.js:183:37)
at WebSocket.EventEmitter.emit (events.js:98:17)
at Receiver.self._receiver.ontext (/home/debian/node_modules/thing-client/node_modules/ws/lib/WebSocket.js:647:10)
at Receiver.opcodes.1.finish (/home/debian/node_modules/thing-client/node_modules/ws/lib/Receiver.js:397:14)
at Receiver.expectHandler (/home/debian/node_modules/thing-client/node_modules/ws/lib/Receiver.js:384:31)
at Receiver.add (/home/debian/node_modules/thing-client/node_modules/ws/lib/Receiver.js:93:24)
at CleartextStream.firstHandler (/home/debian/node_modules/thing-client/node_modules/ws/lib/WebSocket.js:627:22)
at CleartextStream.EventEmitter.emit (events.js:95:17)
This is the output of the taas-client:
debian@steward:~/node_modules/taas-client$ sudo node test3.js
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister>
console
{ event: 'establish', url: 'wss://steward.local.:8888/console' }
open console
ready console data=["developer"]
open management
ready management data={"role":"monitor"}
ready, set, go!
{ requestID: '2',
actors: { 'device/4': { status: 'success' } } }
And this is the Steward log from immediately before running the taas-client:
I tested with the original thing-client and taas-client. It works fine. But with mine, I get this problem with thingID. I'm sure its probably a small syntax error, but I've been searching for a while and can't see anything.
Nevermind, finally found it. It was just a syntax error. The function getToWork was passing variable (thingIDswitch) "my own code". so it "wasn't defined".
I have altered the code in node-thing-client and node-taas-client to be able to toggle the value of a global variable, and thereafter, the output of a GPIO to a switch.
The perform section of thing-client looks like this:
The idea is to toggle the value of a global variable which will then be used inside the interval function to set the value of the output GPIO.
The relevant section in taas-client looks like this:
One thing I am unsure about in this code is the parameter value "switch toggled". I put that in there just because there was something there before I eddited it, but I don't know where this value is used or where it get received.
Anyway, the problem comes when I try to run taas-client after successfully running thing-client.
This is the ouput of the thing-client:
This is the output of the taas-client:
And this is the Steward log from immediately before running the taas-client:
I tested with the original thing-client and taas-client. It works fine. But with mine, I get this problem with thingID. I'm sure its probably a small syntax error, but I've been searching for a while and can't see anything.
Thanks in advance.