| |
---|
| | 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 |
---|
| |
---|
| | |