diff --git a/doc/branch_ook_radio_config.txt b/doc/branch_ook_radio_config.txt index 3b9a8af..4b1a937 100644 --- a/doc/branch_ook_radio_config.txt +++ b/doc/branch_ook_radio_config.txt @@ -18,16 +18,17 @@ (which is actually ook_interface, which is a OnAir.TwoBitAirInterface instance). -3. OnAir.TwoBitAirInterface.send() +DONE 3. OnAir.TwoBitAirInterface.send() Needs to read out these radio config parameters and override the defaults passed to radio.transmit() -4. defaults are presently outer_times=1, inner_times=8, outer_delay=0, modulation=ook. +FINE 4. defaults are presently outer_times=1, inner_times=8, outer_delay=0, modulation=ook. -5. OnAir.TwoBitInterface.send() +DONE 5. OnAir.TwoBitInterface.send() Needs default radio parameters that are overriden by any radio parameters passed into it (so that if no parameters are provided, sensible defaults are used). +6. Need to use the TxDefaults() structure to get good reuse across the class hierarcy FUTURE WORK diff --git a/src/energenie/OnAir.py b/src/energenie/OnAir.py index 13f3868..f4f4148 100644 --- a/src/energenie/OnAir.py +++ b/src/energenie/OnAir.py @@ -48,7 +48,7 @@ timeout = 1000 #ms self.rx_defaults = RxDefaults() - @log_method + ##@log_method def send(self, payload, radio_config=None): # payload is a pydict suitable for OpenThings # radio_params is an overlay on top of radio tx defaults @@ -116,11 +116,10 @@ timeout = 1000 #ms self.rx_defaults = RxDefaults() - @log_method + ##@log_method def send(self, payload, radio_config=None): # payload is just a list of bytes, or a byte buffer # radio_config is an overlay on top of radio tx defaults - print("SEND payload %s config %s inner_times %s" % (payload, str(radio_config), radio_config.inner_times)) house_address = payload["house_address"] device_index = payload["device_index"] @@ -128,11 +127,25 @@ bytes = TwoBit.encode_switch_message(state, device_index, house_address) radio.modulation(ook=True) - #TODO: merge radio_params with self.tx_defaults + # temporary hard-coded defaults + #TODO: Use self.tx_defaults instead outer_times = 1 outer_delay = 0 inner_times = 8 + # Merge any wanted radio params, if provided + if radio_config != None: + try: + outer_times = radio_config.outer_times + except AttributeError: pass + try: + outer_delay = radio_config.outer_delay + except AttributeError: pass + try: + inner_times = radio_config.inner_times + except AttributeError: pass + + print("Will use inner_times %s" % str(inner_times)) radio.transmit(bytes, outer_times=outer_times, inner_times=inner_times, outer_delay=outer_delay) # radio auto-pops to state before transmit