diff --git a/src/energenie/drv/radio.c b/src/energenie/drv/radio.c index 31d8dbe..a92ec56 100644 --- a/src/energenie/drv/radio.c +++ b/src/energenie/drv/radio.c @@ -251,8 +251,6 @@ void radio_modulation(RADIO_MODULATION mod) { - if (radio_data.modu == mod) return; - if (mod == RADIO_MODULATION_OOK) { _config(config_OOK, CONFIG_OOK_COUNT); @@ -382,12 +380,6 @@ { TRACE_FAIL("payload length>32\n"); } - if ((unsigned int)times * (unsigned int)len > 255) //TODO: make this an ASSERT() - { - // This is a temporary situation until the new 'indefinite transmit' - // scheme is implemented using fifolevel only, and ignoring packetsent. - TRACE_FAIL("times*payloadlen > 255, can't configure\n"); - } /* CONFIGURE: Setup the radio for transmit of the correct payload length */ TRACE_OUTS("config\n"); diff --git a/src/energenie/radio2.py b/src/energenie/radio2.py index f52c5b8..aa896c7 100644 --- a/src/energenie/radio2.py +++ b/src/energenie/radio2.py @@ -16,8 +16,8 @@ #TODO: Should really add parameter validation here, so that C code doesn't have to. #although it will be faster in C (C could be made optional, like an assert?) -#LIBNAME = "radio_rpi.so" -LIBNAME = "drv/radio_mac.so" # testing +LIBNAME = "radio_rpi.so" +#LIBNAME = "drv/radio_mac.so" # testing import ctypes from os import path diff --git a/src/energenie/radio2_test.py b/src/energenie/radio2_test.py index ed44ebf..1a13ceb 100644 --- a/src/energenie/radio2_test.py +++ b/src/energenie/radio2_test.py @@ -9,12 +9,11 @@ import time # How many times to repeat the OOK payload. -# NOTE: At the moment this is limited to 16*8<256 in the HRF module -# but that restriction will soon be removed. - - -TIMES = 8 - +# 4800bps*8*16=26ms per payload +# 75 payloads is 2 seconds +# 255 payloads is 6.8 seconds +TIMES = 75 +DELAY = 0.5 # The 'radio' module knows nothing about the Energenie (HS1527) bit encoding, # so this test code manually encodes the bits. @@ -55,12 +54,12 @@ print("Switch 1 ON") radio.transmit(enc_1on, TIMES) # auto returns to standby - time.sleep(1) + if DELAY!=0: time.sleep(DELAY) print("Switch 1 OFF") radio.transmit(enc_1off, TIMES) # auto returns to standby - time.sleep(1) + if DELAY!=0: time.sleep(DELAY) finally: radio.finished() @@ -69,4 +68,4 @@ if __name__ == "__main__": radio_test_ook() -# END \ No newline at end of file +# END diff --git a/src/energenie/radio_rpi.so b/src/energenie/radio_rpi.so index 3d4902a..05cefbf 100755 --- a/src/energenie/radio_rpi.so +++ b/src/energenie/radio_rpi.so Binary files differ diff --git a/src/legacy.py b/src/legacy.py index 04daa9c..cd11ee0 100644 --- a/src/legacy.py +++ b/src/legacy.py @@ -15,9 +15,12 @@ # How many times to repeat messages # Present version of driver limits to 15 # but this restriction will be lifted soon -REPEATS = 15 # 4800bps, burst transmit time at 15 repeats is 400mS -# 1 payload takes 26mS +# 1 payload takes 26ms +# 75 payloads takes 2s +TIMES = 15 + +DELAY = 1 #----- TEST APPLICATION ------------------------------------------------------- @@ -63,19 +66,19 @@ raw_input("press ENTER when LED is flashing") print("ON") - radio.send_payload(ON_MSGS[switch_no], REPEATS) - time.sleep(1) + radio.transmit(ON_MSGS[switch_no], TIMES) + time.sleep(DELAY) print("Device should now be programmed") print("Testing....") for i in range(4): - time.sleep(1) + time.sleep(DELAY) print("OFF") - radio.send_payload(OFF_MSGS[switch_no], REPEATS) - time.sleep(1) + radio.transmit(OFF_MSGS[switch_no], TIMES) + time.sleep(DELAY) print("ON") - radio.send_payload(ON_MSGS[switch_no], REPEATS) + radio.transmit(ON_MSGS[switch_no], TIMES) print("Test completed") @@ -87,24 +90,24 @@ # switch_no 0 is ALL, then 1=1, 2=2, 3=3, 4=4 # ON print("switch %d ON" % switch_no) - radio.send_payload(ON_MSGS[switch_no], REPEATS) - time.sleep(2) + radio.transmit(ON_MSGS[switch_no], TIMES) + time.sleep(DELAY) # OFF print("switch %d OFF" % switch_no) - radio.send_payload(OFF_MSGS[switch_no], REPEATS) - time.sleep(2) + radio.transmit(OFF_MSGS[switch_no], TIMES) + time.sleep(DELAY) def switch1_loop(): """Repeatedly turn switch 1 ON then OFF""" while True: print("Switch 1 ON") - radio.send_payload(ON_MSGS[1], REPEATS) - time.sleep(1) + radio.transmit(ON_MSGS[1], TIMES) + time.sleep(DELAY) print("Switch 1 OFF") - radio.send_payload(OFF_MSGS[1], REPEATS) - time.sleep(1) + radio.transmit(OFF_MSGS[1], TIMES) + time.sleep(DELAY) def pattern_test(): @@ -114,7 +117,7 @@ p = int(p, 16) msg = encoder.build_test_message(p) print("pattern %s payload %s" % (str(hex(p)), encoder.ashex(msg))) - radio.send_payload(msg, REPEATS) + radio.send_payload(msg, TIMES) if __name__ == "__main__": @@ -127,9 +130,9 @@ try: #pattern_test() - #legacy_learn_mode() - #legacy_switch_loop() - switch1_loop() + legacy_learn_mode() + legacy_switch_loop() + #switch1_loop() finally: radio.finished()