inner_times now correctly set on both interfaces.
Tested in simulation
1 parent e3985f2 commit 279837d77980d0d6493aa74721caf54a3f65eacd
@David Whale David Whale authored on 5 Jun 2016
Showing 2 changed files
View
15
doc/branch_ook_radio_config.txt
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
DONE 6. Need to use the TxDefaults() structure to get good reuse across the class hierarchy
 
All tested in simulation and works.
 
Just need to test on real devices, before merge back to master.
 
 
FUTURE WORK
 
Not part of this change, but we should note somewhere that this will need
considering when the transmit scheduler is implemented.
 
Note also that when radio transmit parameters are changed, this changes the amount of time that the radio is
in transmit mode (and therefore alters the amount of time it is in receive mode, and ultimately how wide or
narrow the receive window is). There will eventually need to be some way for the radio module to pass back up
View
54
src/energenie/OnAir.py
class TxDefaults(RadioDefaults):
##power_level = 0
inner_times = 4
outer_delay = 0
outer_times = 0
outer_times = 1
self.tx_defaults = TxDefaults()
 
class RxDefaults(RadioDefaults):
poll_rate = 100 #ms
##@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
##print("SEND payload %s config %s" % (payload, radio_config))
p = OpenThings.encode(payload)
#TODO: Override self.tx_defaults with any settings in radio_config, if provided
outer_times = 1
outer_delay = 0
inner_times = 4
 
# Set radio defaults, if no override
outer_times = self.tx_defaults.outer_times
outer_delay = self.tx_defaults.outer_delay
inner_times = self.tx_defaults.inner_times
 
# 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
 
radio.transmitter(fsk=True)
##print("inner times %s" % inner_times)
radio.transmit(p, outer_times=outer_times, inner_times=inner_times, outer_delay=outer_delay)
# radio auto-returns to previous state after transmit completes
 
##@log_method
class TxDefaults(RadioDefaults):
power_level = 0
inner_times = 8
outer_delay = 0
outer_times = 0
outer_times = 1
self.tx_defaults = TxDefaults()
 
class RxDefaults(RadioDefaults):
poll_rate = 100 #ms
state = payload["on"]
bytes = TwoBit.encode_switch_message(state, device_index, house_address)
radio.modulation(ook=True)
 
# temporary hard-coded defaults
#TODO: Use self.tx_defaults instead
outer_times = 1
outer_delay = 0
inner_times = 8
# Set radio defaults, if no override
outer_times = self.tx_defaults.outer_times
outer_delay = self.tx_defaults.outer_delay
inner_times = self.tx_defaults.inner_times
 
# Merge any wanted radio params, if provided
if radio_config != None:
try:
try:
inner_times = radio_config.inner_times
except AttributeError: pass
 
print("Will use inner_times %s" % str(inner_times))
##print("inner times %s" % inner_times)
radio.transmit(bytes, outer_times=outer_times, inner_times=inner_times, outer_delay=outer_delay)
# radio auto-pops to state before transmit
 
##@log_method