|
|
@ -417,7 +417,7 @@ composer require guzzlehttp/guzzle |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
== IoT Server |
|
|
|
== IoT Swarm Server |
|
|
|
|
|
|
|
.Imaging a swarm |
|
|
|
image:./Swarming2.png[alt="Swarm"] |
|
|
@ -426,16 +426,16 @@ image:./Swarming2.png[alt="Swarm"] |
|
|
|
.Architecture of swarm communication |
|
|
|
image:./swarmlabn-1.png[alt="Swarm Gateway"] |
|
|
|
|
|
|
|
- Red Note: Sensor Node and Gateway Role |
|
|
|
- Black and Red Note: Sensor Node - Client |
|
|
|
- Red Node: Sensor Node and Gateway Role |
|
|
|
- Black and Red Node: Sensor Node - Client |
|
|
|
|
|
|
|
=== NodeJS |
|
|
|
|
|
|
|
==== Gateway |
|
|
|
|
|
|
|
Gateway forwards ore Client Data to the correct application - Server |
|
|
|
Gateway forwards our Client Data to the correct application - Server |
|
|
|
|
|
|
|
.NodeJS code in Raspberry Pi - Server Gateway |
|
|
|
.NodeJS code in Raspberry Pi - Gateway Role |
|
|
|
[source,c] |
|
|
|
---- |
|
|
|
// Setup basic express server |
|
|
@ -503,11 +503,15 @@ app.listen(9089, function () { |
|
|
|
|
|
|
|
==== Server - Broadcast |
|
|
|
|
|
|
|
|
|
|
|
Broadcast data to swarm clients |
|
|
|
|
|
|
|
The server receives data from its client and echoes its back. |
|
|
|
|
|
|
|
[NOTE] |
|
|
|
==== |
|
|
|
The Server may be inside or outside the swarm |
|
|
|
==== |
|
|
|
|
|
|
|
.NodeJS code in Raspberry Pi - Server broadcast |
|
|
|
[source,c] |
|
|
|
---- |
|
|
@ -562,7 +566,7 @@ io.on('connection', (socket) => { |
|
|
|
Swarm client recieves data |
|
|
|
|
|
|
|
|
|
|
|
.NodeJS code in Raspberry Pi - Client |
|
|
|
.NodeJS code in Raspberry Pi - Client Role |
|
|
|
[source,c] |
|
|
|
---- |
|
|
|
// Setup basic express server |
|
|
@ -597,6 +601,8 @@ io.on('connection', (socket) => { |
|
|
|
|
|
|
|
==== Client Connection - Web Server |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.Javascript code |
|
|
|
[source,c] |
|
|
|
---- |
|
|
|