WellDone/MoMo-Firmware — pull request #77 by amcgee (2014-05-08 12:14:04+00:00)
Title: Autonomous sensing

This PR is based on the adaptive_reporting branch, PR #71 should be merged first.

## MultiSensor changes
The multi_sensor board now requests a periodic callback from the controller. After receiving the callback it starts counting pulses in half-second intervals until it reads 0 pulses during one interval, at which point it pushes an event to the controller (with the total pulse count, currently capped at 256 since there are SERIOUS issues with xc8 and 16-bit integers) and goes back to sleep. We need to deal with the 8-bit cap before production deployment.

Currently the callback frequency is every second, it might make sense to decrease this to save power.

## Controller changes
This pull request also introduces RPC callback scheduling.

To support this, I added a void* argument requirement to taskloop functions. Most tasks will not use this argument, but it can be very useful to save off an integer or pointer when adding the task to the taskloop. This is kind of ugly, but if we want to do better I think we'd have to be using C++.

An RPC callback can be scheduled by calling feature 43, command 0 on the controller with the following three integer arguments:

* The MIB address of the module to receive the callback (this is now accessible from mib12_api as mib_address)
* The combined feature and command for the callback with the form `( feature << 8 ) | ( command & 0xFF )`.
* The frequency with which this callback should be executed. The definitions of alarm intervals have been factored into alarm_repeat_times.h. Eventually this could also be packed with a multiplier so you could, say, specify that your callback should run every 3rd second.

NB: We may want to find a better way to support more than 3 8-bit integer parameters. Attempting to use more than 3 int parameters fails silently and results in unpredictable garbage at runtime, not a good dev experience.