Firmware management

Prepare IntelHex firmware file (firmware.hex) and a respective patch for a unit (patch.txt).

  1. Firmware upload
    $ java -cp sensnet-cli-0.9.5-SNAPSHOT.jar cythres.sensnet.cli.FirmwareUpload \
        -u YOUR_USERNAME -p YOUR_PASSWORD -t https://snog.cythres.cz/sn/rest/admin -f firmware.hex \
        -n "John Rambo" -d "Killer firmware"
    OK. ID=31
  2. Assign the firmware (ID=31) to a unit (board number 500).
    $ java -cp sensnet-cli-0.9.5-SNAPSHOT.jar cythres.sensnet.cli.UnitFirmware \
         -u YOUR_USERNAME -p YOUR_PASSWORD -s 500 -t https://snog.cythres.cz/sn/rest/admin -i 31
  3. Patch upload for unit board 500.
    $ java -cp sensnet-cli-0.9.5-SNAPSHOT.jar cythres.sensnet.cli.UnitFirmware \
         -u YOUR_USERNAME -p YOUR_PASSWORD -s 500 -t https://snog.cythres.cz/sn/rest/admin -f patch.txt
  4. Repeat the last two steps for all units you want to run with the new firmware.

Documentation

Download *-bin.zip distribution archive from repository. Unzip the archive in a directory and within that directory issue the following commands to see actual help screens (this page may include obsolete dump of the screens):

$ java -cp sensnet-cli-0.9.5-SNAPSHOT.jar cythres.sensnet.cli.UnitFirmware
usage: cythres.sensnet.cli.UnitFirmware [-f <FILENAME>] [-help] [-i
       <NUMBER>] -p <NAME> -s <NUMBER> [-t <URL>] -u <NAME>
 -f,--file <FILENAME>        firmware patch (Vondracek format)
 -help                       print this message
 -i,--firmware <NUMBER>      firmware number
 -p,--password <NAME>        password
 -s,--unit-serial <NUMBER>   unit serial number
 -t,--target <URL>           DB URL, e.g.
                             jdbc:postgresql://localhost:5432/sensnet or
                             https://sensnet.cythres.cz/sn/rest/admin
 -u,--user <NAME>            username

$ java -cp sensnet-cli-0.9.5-SNAPSHOT.jar cythres.sensnet.cli.FirmwareUpload
usage: cythres.sensnet.cli.FirmwareUpload -d <TEXT> -f <FILENAME> [-help]
       -n <TEXT> -p <NAME> [-t <URL>] -u <NAME>
 -d,--fw-description <TEXT>   firmware description
 -f,--file <FILENAME>         firmware filename (IntelHex format)
 -help                        print this message
 -n,--fw-developer <TEXT>     firmware developer
 -p,--password <NAME>         password
 -t,--target <URL>            DB URL, e.g.
                              jdbc:postgresql://localhost:5432/sensnet or
                              https://sensnet.cythres.cz/sn/rest/admin
 -u,--user <NAME>             username

UnitFirmware

This utility allows you to assign a patch (-f option) or firmware (-i option) to a unit board (-s option). If you do not specify the patch or firmware, current state is printed out. For instance, if you have a direct access to the DB server, issue:

$ java -cp sensnet-cli-0.9.5-SNAPSHOT.jar cythres.sensnet.cli.UnitFirmware \
     -u YOUR_USERNAME -p YOUR_PASSWORD -s 500 -t jdbc:postgresql://localhost:5432/sensnet
Current firmware version: 29
CurrentUnitCatalogue{idUnit=50, serialNum=500, description=pod petkou}
:1010000000809943A0FF11FF332211FF77665544FA
:10101000332211000030C100009543414243444552
:03102000464748F8
:00000001FF

Firmware{id=29, developer=Local Developer, created=Mon Jun 29 18:52:26 CEST 2015, description=Description}
:100000003DEF00F0FF00FF00D9CF1EF0DACF1FF068
:10001000D8EFD3F0FF00FF00D8CF0BF0E8CF0CF003
...
...
:10A89000010C000CCDFC524516EFD1F00100FF0079
:10FFF000A0F582FF02F0FFF79BFEFFFE11F0F8F282
:00000001FF

CRC-CCITT = 0xae76

If you have a remote access via REST, issue:

$ java -cp sensnet-cli-0.9.5-SNAPSHOT.jar cythres.sensnet.cli.UnitFirmware \
     -u YOUR_USERNAME -p YOUR_PASSWORD -s 500 -t https://snog.cythres.cz/sn/rest/admin
:100000003DEF00F0FF00FF00D9CF1EF0DACF1FF068
:10001000D8EFD3F0FF00FF00D8CF0BF0E8CF0CF003
...
...
:10A89000010C000CCDFC524516EFD1F00100FF0079
:10FFF000A0F582FF02F0FFF79BFEFFFE11F0F8F282
:00000001FF

CRC-CCITT = 0xae76

REST access does not allow you to read a complete state of the firmware configuration.

FirmwareUpload

This utility allows you to upload a firmware (-f option). The system assigns a unique id to your new firmware, and this id is then assigned to concrete unit boards.For instance, if you have a direct access to the DB server, issue:

$ java -cp sensnet-cli-0.9.5-SNAPSHOT.jar cythres.sensnet.cli.FirmwareUpload \
     -u YOUR_USERNAME -p YOUR_PASSWORD -t jdbc:postgresql://localhost:5432/sensnet -f firmware007.hex \
     -n "John Rambo" -d "Killer firmware"
New firmware version: 30

RESTful version uses a respective URL of your gateway, e.g.

$ java -cp sensnet-cli-0.9.5-SNAPSHOT.jar cythres.sensnet.cli.FirmwareUpload \
     -u YOUR_USERNAME -p YOUR_PASSWORD -t https://snog.cythres.cz/sn/rest/admin -f firmware007.hex \
     -n "John Rambo" -d "Killer firmware"
OK. ID=31

Now you can easily assign the firmware to a unit

$ java -cp sensnet-cli-0.9.5-SNAPSHOT.jar cythres.sensnet.cli.UnitFirmware \
     -u YOUR_USERNAME -p YOUR_PASSWORD -s 500 -t https://snog.cythres.cz/sn/rest/admin -i 31
OK. Unit 500 is with firmware 31

Vondracek patch

Vondracek patch has a following format:

1000 0xff,0xfefe , 0xfdfdfdfd, 0x2cfcfcfcfcfcfcfc, -12.3f, "Bingo"
1100 "Another text", 0x00, "C-closed", 0x00, 0xdede
...
...

The line starts with a hex-address (offset) and continues with comma delimited values. A value can be hex-integer ("0x" prefix with byte/2, short/4, int/8, long/16 digits), float ("f" suffix), or a string. The values are stored at the offset (little-endian mode) one by one. The patch is applied onto the firmware address space only.

Length of lines in the Vondracek patch format is unlimited. Extra spaces (tabs, etc.) are eliminated, empty lines are skipped over.

Patching can be verified with UnitFirmware utility:

$ java -cp sensnet-cli-0.9.5-SNAPSHOT.jar cythres.sensnet.cli.UnitFirmware \
     -u YOUR_USERNAME -p YOUR_PASSWORD -s 500 -t https://snog.cythres.cz/sn/rest/admin
...
...
:10100000FFFEFEFDFDFDFDFCFCFCFCFCFCFC2CCD14
:08101000CC44C142696E676F18
:10110000416E6F74686572207465787400432D6356
:081110006C6F73656400DEDE04
...
...

Local access will give you more comfort, the output shows you the patch before its application:

Current firmware version: 30
CurrentUnitCatalogue{idUnit=50, serialNum=500, description=pod petkou}
:10100000FFFEFEFDFDFDFDFCFCFCFCFCFCFC2CCD14
:08101000CC44C142696E676F18
:10110000416E6F74686572207465787400432D6356
:081110006C6F73656400DEDE04
:00000001FF

Firmware{id=30, developer=John Rambo, created=Thu Jul 02 00:34:25 CEST 2015, description=Killer firmware}
...
...
:10100000FFFEFEFDFDFDFDFCFCFCFCFCFCFC2CCD14
...
...