Track the requested state so we can return it when asked
The original USB relay code can query the GPIO lines to see which relays
are enabled. We only have one way communication to the power sockets so
they might be in a different state to that requested, but store the
state we think we should have so when asked we can return it, rather
than always returning that everything is off.
Use serial number as base address + report in USB descriptor
Rather than hard coding the base Energenie address use the serial number
to encode it. Also report it as part of the USB descriptor making it
easier to match against for udev etc.
Add a wait before sending via the 433MHz transmitter
Rather than immediately entering the lengthy (24ms+) loop to send a
command allow a number of calls to usbPoll() to complete first. This
allows the usbrelay control program to successfully receive a response
to its hid_write() call before we stop responding to USB for a bit.
Use existing OSCCAL as starting point for calibration
If we're being loaded from micronucleus it will have already
performed calibration on OSCCAL, so use that as the starting point
for our recalibration. This seems to improve things on an older Dell
host that previously had issues enumerating the device.
Move to micronucleus assembly for OSCCAL calibration
Some issues have been observed with OSCCAL calibration on older Dell
hosts. The micronucleus firmware enumerates correctly, but the Riso
clone then fails. Move to the assembly calibration code from
micronucleus to try and improve the situation.