Restfull server for microcontrollers
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
api
board
doc
it
program
.gitignore
DEVELOP.txt
README.md
pom.xml

README.md

RestMcu is a generic program for micro-controllers (arduino only for the moment) with a network interface.

It provides through a restfull (json only) interface :

  • static board configuration (description, list of lines, ...)
  • dynamic board configuration (ip, port, line notify url)
  • static line configuration (based on electronic line wiring) : analog/digital, input,output, ...
  • dynamic line name and notification conditions
  • notify a server of line change based on condition set on lines
  • support of hmac-sha256 security between board and server
  • keep states of lines in eeprom is case of power failure

The electronic wiring configuration is provided by a simple C file used during compilation

Feature that can be enabled

You can enable some feature at compilation time :

  • HMAC : enable security using hmac-sha1 signature on calls
  • DEBUG : enable debug through serial

Build dependencies

Building the Java part

To build the JAVA part you will need maven 3

Building the C part

On Linux : # sudo apt-get install avr-libc binutils-avr gcc-avr avrdude

On Mac OS X :

Change the following environment variables

export AVRPACK_HOME=/your/crosspack/install/path
export AVR_TOOLS_PATH=$AVRPACK_HOME/bin/
export AVR_LIB_PATH=$AVRPACK_HOME/avr
export AVRDUDE_PATH=$AVRPACK_HOME/bin/
export AVRDUDE_CONF=$AVRPACK_HOME/etc/avrdude.conf

On Windows :

Change the following environment variables (in bashrc if you use cygwin or mintty) :

 export AVRPACK_HOME=/your/winavr/install/path  
 export AVR_TOOLS_PATH=$AVRPACK_HOME/bin/  
export AVR_LIB_PATH=$AVRPACK_HOME/avr  
export AVRDUDE_PATH=$AVRPACK_HOME/bin/  
export AVRDUDE_CONF=$AVRPACK_HOME/bin/avrdude.conf

Build and deploy the program on your board

Go to the 'program' folder
Create a new configuration file based on config.cpp file

Then run the following command :

make MCU=atmega1280 CONFIG=YOUR_BOARD_CONFIGURATION_FILE.cpp clean upload

Or with hmac security :

make MCU=atmega1280 CONFIG=YOUR_BOARD_CONFIGURATION_FILE.cpp FEATURE=-DHMAC clean upload

Available goals for the Makefile

clean, package, upload

Well known board

Arduino 2560 : make PORT=/dev/ttyACM0 MCU=atmega2560 UPLOAD_RATE=115200 AVRDUDE_PROGRAMMER=stk500v2 CONFIG=myconfig.cpp clean upload

Code verification with board

The IT project can test the program directly on a board. The wiring of the board can be found in the 'it/wiring/' folder

to test it yourself :

  • wire a board like the schema 'it/wiring/TestBoardWiring.fzz' (open it with http://fritzing.org/)
  • plug the board to the network (for tests) and the usb (to program the board)
  • run the command and replace the type of board AND the ip address with a free one in your network :
MCU=atmega1280 mvn -Dboard.host=192.168.42.244 -Dboard.port=80 -Dboard.path=/ -Pboard clean verify

Resources

on board:

  • GET / : read static board configuration
  • GET /settings : read dynamic board settings
  • PUT /settings : update dynamic board settings
  • GET /line/{lineId} : get static line configuration
  • GET /line/{lineId}/settings : get dynamic line settings
  • PUT /line/{lineId}/settings : update dynamic line settings

on server:

  • GET /time : get posix timestamp from server (used in hmac-sha1)
  • PUT /board : notification of board (boot and test)
  • PUT /line : notification of line change based on line settings

TODO

  • keep-alive
  • support of encj28j60 (currently half-implemented)
  • dhcp
  • dns ?
  • fit in 328p (almost done)
  • constrain between pins