Changing LoRa parameters - Is necessary to restart device?
-
Hi all,
I'm working with lopy4 in raw LoRa mode. I've implemented methods to change the radio settings (SF, CR, BW, among others) and store the configuration in a JSON file. The fact is that those changes are not visible after I reset both node and gateway (My code is based on LoRa-MAC Nano-Gateway). Is that correct? invoking the method lora.sf([sf]) for example does not make any changes.
Here is my method implementation:def changeLoraSettings(self, lora_conf): # print('Changing LoRa configuration...') [lora_bw, lora_cr] = self.parseData(lora_conf) self.lora.frequency(lora_conf['frequency']) self.lora.tx_power(lora_conf['tx_power']) self.lora.bandwidth(lora_bw) self.lora.sf(lora_conf['sf']) self.lora.preamble(lora_conf['preamble']) self.lora.coding_rate(lora_cr) # print('done') def parseData(self, lora_conf): if(lora_conf['bandwidth'] == '125 KHZ'): lora_bw = LoRa.BW_125KHZ elif(lora_conf['bandwidth'] == '250 KHZ'): lora_bw = LoRa.BW_250KHZ elif(lora_conf['bandwidth'] == '500 KHZ'): lora_bw = LoRa.BW_500KHZ if(lora_conf['coding_rate'] == '4/5'): lora_cr = LoRa.CODING_4_5 if(lora_conf['coding_rate'] == '4/6'): lora_cr = LoRa.CODING_4_6 if(lora_conf['coding_rate'] == '4/7'): lora_cr = LoRa.CODING_4_7 if(lora_conf['coding_rate'] == '4/8'): lora_cr = LoRa.CODING_4_8 return [lora_bw, lora_cr]
lora_conf is a dictionary which is stored as a JSON file:
def lora_default_config(): lora_conf = {} lora_conf['region'] = 'AU915' lora_conf['frequency'] = 915000000 lora_conf['tx_power'] = 20 lora_conf['bandwidth'] = '125 KHZ' lora_conf['sf'] = 7 lora_conf['preamble'] = 8 lora_conf['coding_rate'] = '4/5' lora_conf_encoded = ujson.dumps(lora_conf) with open("/flash/lora.json", 'w') as conf_file: conf_file.write(lora_conf_encoded) conf_file.close()
I will provide any other information you shall need. Thanks in advance!