<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Changing LoRa parameters - Is necessary to restart device?]]></title><description><![CDATA[<p dir="auto">Hi all,<br />
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 <strong>lora.sf([sf])</strong> for example does not make any changes.<br />
Here is my method implementation:</p>
<pre><code>    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]
</code></pre>
<p dir="auto"><strong>lora_conf</strong> is a dictionary which is stored as a JSON file:</p>
<pre><code>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(&quot;/flash/lora.json&quot;, 'w') as conf_file:
        conf_file.write(lora_conf_encoded)
        conf_file.close()
</code></pre>
<p dir="auto">I will provide any other information you shall need. Thanks in advance!</p>
]]></description><link>https://forum.pycom.io/topic/3332/changing-lora-parameters-is-necessary-to-restart-device</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 04:36:52 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/3332.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 04 Jun 2018 14:32:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Changing LoRa parameters - Is necessary to restart device? on Mon, 04 Jun 2018 14:32:29 GMT]]></title><description><![CDATA[<p dir="auto">Hi all,<br />
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 <strong>lora.sf([sf])</strong> for example does not make any changes.<br />
Here is my method implementation:</p>
<pre><code>    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]
</code></pre>
<p dir="auto"><strong>lora_conf</strong> is a dictionary which is stored as a JSON file:</p>
<pre><code>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(&quot;/flash/lora.json&quot;, 'w') as conf_file:
        conf_file.write(lora_conf_encoded)
        conf_file.close()
</code></pre>
<p dir="auto">I will provide any other information you shall need. Thanks in advance!</p>
]]></description><link>https://forum.pycom.io/post/20116</link><guid isPermaLink="true">https://forum.pycom.io/post/20116</guid><dc:creator><![CDATA[lsoria]]></dc:creator><pubDate>Mon, 04 Jun 2018 14:32:29 GMT</pubDate></item></channel></rss>