whaleygeek / pyenergenie

A python interface to the Energenie line of products
MIT License
82 stars 51 forks source link

Merging two separate shared object builds #39

Closed whaleygeek closed 8 years ago

whaleygeek commented 8 years ago

The spi_rpi.so and radio_rpi.so, while they have different code in them, do actually have identical versions of the gpio and spi modules.

Subject to further testing to make sure nothing else breaks, it makes sense to kill off the older spi_rpi.so build and bind the spi.py to radio_rpi.so, so that there is only one shared object to maintain.

This might seem a bit premature, but it means that it is possible to test all of the FSK code for the MiHome adaptors with the low level SPI code, and later finish the radio.c implementation of the FSK config table and tx/rx routines, hence less re-testing later.

Not strictly necessary, but it would reduce the build variants slightly at the lower end. In doing this, spi.py would be bound to radio_rpi.so rather than spi_rpi.so which would bring the bottom ends together a bit more. Because radio_rpi.so has both gpio and spi modules inside it, this should just work.

whaleygeek commented 8 years ago

This only really deprecates the rpi_spi.so and it's build process - the spi.py is still required temporarily so that the old FSK code will work.

A slightly closer temporary integration could involve pushing the spi.py code into radio2.py, and then killing off radio.py and bringing radio2.py on top of it. i.e. exposing both the radio.c and the raw spi.c interface via radio.py, so that there is a single route into all the driver code. Later the spi functions can be deprecated when the fsk transmit and receive code is written and tested inside radio.c

whaleygeek commented 8 years ago

I favour the suggestion of exposing the low level spi methods via radio2.py and killing off radio.py, as a temporary solution. This will at least mean there is a single C build that services everything, reducing the number of variants of code that need testing.

whaleygeek commented 8 years ago

Work on this has started on the unified_radio branch.

The old spi.py/spi_rpi.so has been deprecated and removed.

The spi functions and python ctype wrappers have been moved into radio2.py temporarily, and this exposes the same spi interface that is now embedded inside radio_rpi.so.

Tested on pi with monitor.py switch.py and legacy.py and everything still works.

whaleygeek commented 8 years ago

Next steps:

It will be easier to implement and test the transmitter first, as it is a small increment from the OOK transmittter, that already works using the infinite length payload transmitter. Receive can then be added after.

whaleygeek commented 8 years ago

The FSK transmitter is coded. Build and run tests done on Mac. Ready for testing on Raspberry Pi.

switch.py has been refactored into two parts, and the receiver turned off. A deviceid can be seeded into the Registry, and this will cause an on/off message to be sent to that device every 2 seconds. This is so that the FSK receiver can be implemented and tested independently of the transmitter.

whaleygeek commented 8 years ago

The FSK Transmitter is working with the new switch.py and a captured device address.

whaleygeek commented 8 years ago

Next step is to implement the receiver architecture:

whaleygeek commented 8 years ago

This work is now completed and tested on the unified_radio branch.

It is now possible to FSK tx, FSK rx and OOK tx from the same code (and the same in-memory driver).

This paves the way to a unified single app build that allows both FSK MiHome and OOK green buttons to interoperate in the same application.

I will close this issue when the unified_radio branch is merged back to master.

whaleygeek commented 8 years ago

unified_radio branch merged, this is now fixed in master.