webofthings / wot-book Goto Github PK
View Code? Open in Web Editor NEWCode examples from "Building the Web of Things" @ Manning
Home Page: http://book.webofthings.io
License: Apache License 2.0
Code examples from "Building the Web of Things" @ Manning
Home Page: http://book.webofthings.io
License: Apache License 2.0
http://devices.webofthings.io does not work. Please fix.
On line 9 of auth.js, req.param('token')
should be req.params.token
as the former is deprecated.
I am working in Chapter 10 and am using the code from the wot-pi image. I changed Simulate to false for the LEDs. The problem is that only LED 1 can be changed using the UI.html app. I even switched GPIO assignments for LED 1 and 2 to confirm nothing was wrong with my pin or LED. When I did that, the LED assigned as LED 1 (gpio used to be assigned to LED 2) would work, but LED 2 still doesn't change. I monitor the traffic and the Action message is sent with the proper parameters, but the LED 2 is not affected. I am not sure where to start the troubleshooting with this one.
Hello,
I wanted to seek some help, in order to get things started for chapter 7, part1-2-direct-gateway nodejs server.
Till now what I get is (after installing some npm packages which it prompted were missing)
$ node wot-server.js
Simulated Passive Infrared sensor started!
/home/pi/Desktop/wot-book/chapter7-implementation/part1-2-direct-gateway/plugins/internal/ledsPlugin.js:32
Object.observe(what, function (changes) {
^
TypeError: Object.observe is not a function
at observe (/home/pi/Desktop/wot-book/chapter7-implementation/part1-2-direct-gateway/plugins/internal/ledsPlugin.js:32:10)
at Object.exports.start (/home/pi/Desktop/wot-book/chapter7-implementation/part1-2-direct-gateway/plugins/internal/ledsPlugin.js:13:3)
at Object.<anonymous> (/home/pi/Desktop/wot-book/chapter7-implementation/part1-2-direct-gateway/wot-server.js:14:12)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)
The thing worth noting is, the problem seems to be for the ledsPlugin particularly. When I comment the following line in wot-server.js
ledsPlugin.start({'simulate': true, 'frequency': 10000}); //#B
It seems to run perfectly!
$ node wot-server.js
Simulated Passive Infrared sensor started!
Simulated Temperature & Humidity sensor started!
HTTP server started...
WebSocket server started...
Your WoT Pi is up and running on port 8484
not anymore!
there is someone!
not anymore!
there is someone!
not anymore!
Temperature: 38 C, humidity 80 %
there is someone!
On lines 8 and 9 of proxy.js, the path to the private key and certificate files need to be fixed to
key: fs.readFileSync('../config/change_me_privateKey.pem', 'utf8'),
cert: fs.readFileSync('../config/change_me_caCert.pem', 'utf8'),
From: https://forums.manning.com/posts/list/39557.page
Hi Dom,
Really sorry for posting unrelated question in another thread.
I'm using Ubuntu 16.10. I have registered an EVRYTHNG account and got a operator API key.
Then in terminal when I run [ $ sh setup.sh XXX ], I've got an error "setup.sh: 9: setup.sh: Syntax error: "(" unexpected".
I tried again with [ $ ./setup.sh XXX ], It does steps 1-4 and also create action and redirect Url for me, and I also checked, project, product, thng has been created in my ERVYTHNG account and 5 times updated by setup.sh. But when I run
[ $ npm install ] //success
[ $ node simple-plug.js ]
The terminal just log with "Using Thng #YYY with API Key: XXX" and not updating my thng properties.
Thanks for replying soon.
The new changes of ws to 7.3.1 result in an error when running the code. Please reverse the dependency number back to 0.7.2
On line 50, it should read $.getJSON('http://devices.webofthings.io/pi/sensors/temperature/',
, instead of $.getJSON('http://devices.webofthings.io/pi/sensors/temperature/value',
In the script called simple-plug.js
(chapter 7), it'd be better to call setInterval()
instead of setTimeout
on line 18, so that updateProperties()
doesn't need to schedule a new timeout every time it is called.
Then in the closing logic, you could simply call clearInterval()
to clean it up properly.
hi and thanks for your good book.
I can start the server with "node wot.js" command in a secure mode correctly (I catch tocken key and use it with https).
but I don't know how can I use UI.html and bring figure 10.3 in chapter 10.
I think files such as UI.html and form-only.html is not embeded in the model, where I must accomodate them?
plz guide me
thank you in advance.
On line 38 of facebook.js, remove the irrelevant bullet #E
As per Yahoo weather developers site:
As of Thursday, Jan. 3, 2019, the weather.yahooapis.com and query.yahooapis.com for Yahoo Weather API will be retired.
To continue using our free Yahoo Weather APIs, use https://weather-ydn-yql.media.yahoo.com/forecastrss. Follow below instructions to get credentials and onboard to this free Yahoo Weather API service.
The mashup code uses yahoo API to compare temperature from a given location to Pi's location. Now it is easy for me fork the code and implement the newer or changed API but it requires an API key.
The current implementation of converter.js does not take into account the q
parameter of content-negotiation. E.g.,:
Accept: text/html,application/xhtml+xml,application/xml;q=0.7,image/webp,application/json;q=0.8
will return JSON not HTML.
I can change the status value by postman.
But it not worked when i use plug.html.
I can get the html response and I can see the Action on the dashboard of EVRYTHING.
but plug-with-control.js has not receive any message
On line 9 of auth.js, the Authorization
header should be in lowercase as request header names are always lowercased
Hello, guys!
I think the IoT camera from your website: http://devices.webofthings.io/camera/sensors/picture/ is not working. I am trying to gather an image from it and insert it into a web client using NodeJS but it never returns the image and if I try to access this URL http://devices.webofthings.io:9090/snapshot.cgi?user=snapshots&pwd=4MXfTSr0gH I always get "Connection timed out" or "This page can't be reached".
Thanks in advance!
The following piece of code is from here
var Gpio = require('onoff').Gpio,
sensor = new Gpio(17, 'in');
sensor.watch(function(err, value) {
if (err) exit(err);
console.log(value ? 'there is some one!' : 'not anymore!');
});
The watch
callback is probably never called because the Gpio constructors optional edge
parameter isn't used. The edge
parameter specifies whether "falling", "rising", or "both" types of edges on the GPIO input pin should trigger interrupts which in turn will result in the watch
callback being called. See here for more info.
For example, to detect interrupts on falling edges something like this would be used:
var Gpio = require('onoff').Gpio,
sensor = new Gpio(17, 'in', 'falling');
sensor.watch(function(err, value) {
if (err) exit(err);
console.log(value ? 'there is some one!' : 'not anymore!');
});
I am new to javascripct coding, so pardon me if this is a stupid issue because of lack of my knowledge. Every-time I run Wot-server.js with sudo su user (as sudo node doesn't work with nvm) I get an timeout error as following. Could you please see why this error is happening and how it can be resolved.
events.js:141
throw er; // Unhandled 'error' event
^
Error: No reply in 247s
at null._onTimeout (/home/pi/wot-pi/node_modules/coap/lib/retry_send.js:70:16)
at Timer.listOnTimeout (timers.js:92:15)
The code in GitHub is not the samw as in the book:
BOOK:
function prepareMessage(name, location, localTemp, piTemp) {
var diff = localTemp - piTemp;
var qualifier = ' > ';
if (diff < 0) {
qualifier = ' < ';
}
var result = name + '@' + location + qualifier + Math.abs(diff);
return result;
}
Populates co2
instead of value
Any chance of someone applying a fix for this, now that the official node LTS version is 6.9.1?
kevin
pi@raspberrypi:~/wot-book/chapter7-implementation/part1-2-direct-gateway$ node wot-server.js
Simulated Passive Infrared sensor started!
/home/pi/wot-book/chapter7-implementation/part1-2-direct-gateway/plugins/internal/ledsPlugin.js:29
Object.observe(what, function (changes) {
^
TypeError: Object.observe is not a function
at observe (/home/pi/wot-book/chapter7-implementation/part1-2-direct-gateway/plugins/internal/ledsPlugin.js:29:10)
On line 22 of facebook.js, bullet #C
should read #B
.
On line 25 of facebook.js, bullet #B
should read #C
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.