diff --git a/src/energenie/Devices_test.py b/src/energenie/Devices_test.py index c19f5e5..cd38e3e 100644 --- a/src/energenie/Devices_test.py +++ b/src/energenie/Devices_test.py @@ -8,41 +8,15 @@ import time from Devices import * -#hmm: need two addresses for legacy - use a tuple (house_address, index) - -#unless we have an adaptor class for air_interface which represents the -#collective house address for a house code. So if you use more than one -#house address, you create multiple air interface adaptors with different -#house codes, that just delegate to the same actual radio air interface? -#bit like a little local router? - -#legacy1 = AirInterface.create("OOK", address=0xC8C8C, energenie_radio) - -# Could also consider this a local network, with common parameters shared -# by all devices that use it. -#air2 = AirInterface.create("FSK", energenie_radio) - -# scheduling would then become -# scheduler = Scheduler(energenie_radio) -# legacy1 = AirInterface.create("OOK", address=0xC8C8C, scheduler) -# air2 = AirInterface.create("FSK", scheduler -# so that when a device tries to transmit, it gets air interface specific -# settings added to it as appropriate, then the scheduler decides when -# to send and receive - -# Somehow we need to associate devices with an air interface -# This might allow us to support multiple radios in the future too? -#legacy1.add(tv) - # cooperative loop could be energenie_radio.loop() # or wrap a thread around it with start() but beware of thread context # and thread safety. +import radio +radio.DEBUG = True def test_without_registry(): - ##TODO: Problem, some devices have air_interface, some have adaptor, some have nothing, - #so the DeviceFactory constructor (c) doesn't work correctly with all devices tv = DeviceFactory.get_device("GreenButton", device_id=(0xC8C8C, 1)) fan = DeviceFactory.get_device("AdaptorPlus", device_id=0x68b) diff --git a/src/energenie/Registry_test.py b/src/energenie/Registry_test.py index 29df23c..e28318c 100644 --- a/src/energenie/Registry_test.py +++ b/src/energenie/Registry_test.py @@ -10,6 +10,9 @@ import unittest from Registry import * +import radio + +radio.DEBUG=True class TestRegistry(unittest.TestCase): def setUp(self): @@ -18,8 +21,6 @@ registry.add(Devices.ENER002(device_id=(0xC8C8C, 1)), "fan") # test the auto create mechanism - #import sys - #registry.auto_create(sys.modules[__name__]) registry.auto_create(self) def test_capabilities(self): diff --git a/src/energenie/radio.py b/src/energenie/radio.py index 4a2d287..dcaf44c 100644 --- a/src/energenie/radio.py +++ b/src/energenie/radio.py @@ -28,6 +28,8 @@ from os import path mydir = path.dirname(path.abspath(__file__)) +DEBUG = False + libradio = ctypes.cdll.LoadLibrary(mydir + "/" + LIBNAME) radio_init_fn = libradio["radio_init"] radio_reset_fn = libradio["radio_reset"] @@ -110,7 +112,8 @@ #Note, this optionally does a mode change before and after #extern void radio_transmit(uint8_t* payload, uint8_t len, uint8_t repeats); - ##print("***TX %s" % payload) + if DEBUG: + print("***TX %s" % payload) ##import OpenThings ##print(OpenThings.decode(payload))