Added technical details for controller developers regarding OTA bootloader

This commit is contained in:
ToSa27
2014-09-07 23:58:16 +02:00
committed by Patrick Fallberg
parent cd84e410fa
commit 1dbe7497bd
3 changed files with 50 additions and 6 deletions
+47 -1
View File
@@ -1 +1,47 @@
See NodeJsController/Readme.md for usage instructions...
See NodeJsController/Readme.md for usage instructions...
<h1>Technical details to write your own controller</h1>
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.
<h2>FirmwareConfig</h2>
<ul>
<li>the bootloader sends a FirmwareConfigRequest packet to the gateway to request information about the firmware it should execute:
<p>
typedef struct<br/>
{<br/>
&nbsp;uint16_t type;<br/>
&nbsp;uint16_t version;<br/>
} FirmwareConfigRequest;
</p>
<li>the gateway (the controller) responds with a FirmwareConfigResponse including details about the firmware the sensor should execute:
<p>
typedef struct<br/>
{<br/>
&nbsp;uint16_t type;<br/>
&nbsp;uint16_t version;<br/>
&nbsp;uint16_t blocks;<br/>
&nbsp;uint16_t crc;<br/>
} FirmwareConfigResponse;
</p>
</ul>
<h2>Firmware</h2>
<ul>
<li>the bootloader sends a FirmwareRequest packet to the gateway to request a specific subset (block) of the compiled firmware:
<p>
typedef struct<br/>
{<br/>
&nbsp;uint16_t type;<br/>
&nbsp;uint16_t version;<br/>
&nbsp;uint16_t block;<br/>
} FirmwareRequest;
</p>
<li>the gateway (the controller) responds with a FirmwareResponse including the specific block of the compiled firmware:
</ul>
<p>
typedef struct<br/>
{<br/>
&nbsp;uint16_t type;<br/>
&nbsp;uint16_t version;<br/>
&nbsp;uint16_t block;<br/>
&nbsp;uint8_t data[FIRMWARE_BLOCK_SIZE];<br/>
} FirmwareResponse;
</p>
+2 -2
View File
@@ -11,8 +11,8 @@ const dbAddress = '127.0.0.1';
const dbPort = 27017;
const dbName = 'MySensorsDb';
const fwSketches = [ '../libraries/MySensors/examples/DallasTemperatureSensor/DallasTemperatureSensor.ino' ];
const fwDefaultType = 0; // index of hex file from array above
const fwSketches = [ ];
const fwDefaultType = 0xFFFF; // index of hex file from array above (0xFFFF
const FIRMWARE_BLOCK_SIZE = 16;
const BROADCAST_ADDRESS = 255;
+1 -3
View File
@@ -290,10 +290,8 @@ ISP_MCU = m328p</p>
<h1>End-to-End Test</h1>
<h2>Add Firmware to Controller (here: DallasTemperatureSensor)</h2>
<ul>
<li>use Arduino IDE or codebender or whatever other way to compile your sketch
<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)
<li>nano ~/Arduino/NodeJsController/NodeJsController.js
<p>const fwHexFiles = [ <font color="#FF0000">'DallasTemperatureSensor.cpp.hex'</font> ];<br/>
<p>const fwHexFiles = [ <font color="#FF0000">'../libraries/MySensors/examples/DallasTemperatureSensor/DallasTemperatureSensor.ino'</font> ];<br/>
const fwDefaultType = <font color="#FF0000">0</font>;</p>
<li>sudo service mysensors restart (at this point stop/restart doesn't work. use "sudo killall node" followed by "sudo service mysensors start" instead)
</ul>