Skip to content

Commit 0036c5f

Browse files
committed
Added technical details for controller developers regarding OTA bootloader
1 parent 42c82fd commit 0036c5f

File tree

3 files changed

+50
-6
lines changed

3 files changed

+50
-6
lines changed

Bootloader/Readme.md

+47-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,47 @@
1-
See NodeJsController/Readme.md for usage instructions...
1+
See NodeJsController/Readme.md for usage instructions...
2+
3+
<h1>Technical details to write your own controller</h1>
4+
All initialization the bootloader does (finding parent / requesting nodeId on first start) uses the same packets as a normal MySensors sketch. There is no need for the controller to distinguish between packets from the bootloader and packets from normal sketch execution. The controller only needs to care about two additional request/response communications. All communication is binary.
5+
<h2>FirmwareConfig</h2>
6+
<ul>
7+
<li>the bootloader sends a FirmwareConfigRequest packet to the gateway to request information about the firmware it should execute:
8+
<p>
9+
typedef struct<br/>
10+
{<br/>
11+
&nbsp;uint16_t type;<br/>
12+
&nbsp;uint16_t version;<br/>
13+
} FirmwareConfigRequest;
14+
</p>
15+
<li>the gateway (the controller) responds with a FirmwareConfigResponse including details about the firmware the sensor should execute:
16+
<p>
17+
typedef struct<br/>
18+
{<br/>
19+
&nbsp;uint16_t type;<br/>
20+
&nbsp;uint16_t version;<br/>
21+
&nbsp;uint16_t blocks;<br/>
22+
&nbsp;uint16_t crc;<br/>
23+
} FirmwareConfigResponse;
24+
</p>
25+
</ul>
26+
<h2>Firmware</h2>
27+
<ul>
28+
<li>the bootloader sends a FirmwareRequest packet to the gateway to request a specific subset (block) of the compiled firmware:
29+
<p>
30+
typedef struct<br/>
31+
{<br/>
32+
&nbsp;uint16_t type;<br/>
33+
&nbsp;uint16_t version;<br/>
34+
&nbsp;uint16_t block;<br/>
35+
} FirmwareRequest;
36+
</p>
37+
<li>the gateway (the controller) responds with a FirmwareResponse including the specific block of the compiled firmware:
38+
</ul>
39+
<p>
40+
typedef struct<br/>
41+
{<br/>
42+
&nbsp;uint16_t type;<br/>
43+
&nbsp;uint16_t version;<br/>
44+
&nbsp;uint16_t block;<br/>
45+
&nbsp;uint8_t data[FIRMWARE_BLOCK_SIZE];<br/>
46+
} FirmwareResponse;
47+
</p>

NodeJsController/NodeJsController.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const dbAddress = '127.0.0.1';
1111
const dbPort = 27017;
1212
const dbName = 'MySensorsDb';
1313

14-
const fwSketches = [ '../libraries/MySensors/examples/DallasTemperatureSensor/DallasTemperatureSensor.ino' ];
15-
const fwDefaultType = 0; // index of hex file from array above
14+
const fwSketches = [ ];
15+
const fwDefaultType = 0xFFFF; // index of hex file from array above (0xFFFF
1616

1717
const FIRMWARE_BLOCK_SIZE = 16;
1818
const BROADCAST_ADDRESS = 255;

NodeJsController/Readme.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,8 @@ ISP_MCU = m328p</p>
290290
<h1>End-to-End Test</h1>
291291
<h2>Add Firmware to Controller (here: DallasTemperatureSensor)</h2>
292292
<ul>
293-
<li>use Arduino IDE or codebender or whatever other way to compile your sketch
294-
<li>copy the compiled DallasTemperatureSensor.cpp.hex file to the NodeJsController directory (if using the Arduino IDE, enable verbose logging in preferences and then watch the compilation process to find the temp directory where the output is stored)
295293
<li>nano ~/Arduino/NodeJsController/NodeJsController.js
296-
<p>const fwHexFiles = [ <font color="#FF0000">'DallasTemperatureSensor.cpp.hex'</font> ];<br/>
294+
<p>const fwHexFiles = [ <font color="#FF0000">'../libraries/MySensors/examples/DallasTemperatureSensor/DallasTemperatureSensor.ino'</font> ];<br/>
297295
const fwDefaultType = <font color="#FF0000">0</font>;</p>
298296
<li>sudo service mysensors restart (at this point stop/restart doesn't work. use "sudo killall node" followed by "sudo service mysensors start" instead)
299297
</ul>

0 commit comments

Comments
 (0)