LoPy - Raw Lora mode for connecting TTN



  • Hello,

    I am trying to change the parameters of my LoRa node by configuring the node is raw mode i.e (LoRa(mode=LoRa.LORA)). But I am getting following error

    {

    Traceback (most recent call last):
    File "<stdin>", line 25, in <module>
    OSError: the requested operation is not possible

    Pycom MicroPython 1.18.1.r1 [v1.8.6-849-b0520f1] on 2018-08-29; LoPy4 with ESP32
    Type "help()" for more information.

    }

    My sample code is as follows:

    {

    import time
    import pycom
    import network
    from network import LoRa
    import struct
    import ubinascii
    import binascii
    import socket
    import pycom
    import time

    lora = LoRa(mode=LoRa.LORA, frequency=868100000, power_mode=LoRa.ALWAYS_ON, tx_power=14, bandwidth=LoRa.BW_250KHZ, sf=7, preamble=8, coding_rate=LoRa.CODING_4_5, tx_iq=False, rx_iq=False)

    lora.init(mode=LoRa.LORA, frequency=868100000, power_mode=LoRa.ALWAYS_ON, tx_power=14, bandwidth=LoRa.BW_250KHZ, sf=7, preamble=8, coding_rate=LoRa.CODING_4_5, tx_iq=False, rx_iq=False)

    app_eui = ubinascii.unhexlify('xxxxxxxxxxxxxxxxxxxxxxx')
    app_key = ubinascii.unhexlify('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')

    lora.join(activation=LoRa.OTAA, auth=(app_eui, app_key), timeout=0)
    while not lora.has_joined():
    time.sleep(2.5)
    print('Not yet joined...')
    if lora.has_joined():
    time.sleep(2.5)
    print ("Joined the network")
    s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5)

    pycom.heartbeat(False)
    while True:
    s.setblocking(True)
    s.send("30")
    time.sleep(1.5)
    }

    I would like to know if it is even possible to configure the node in raw Lora mode for connecting it to TTN network server?

    If yes where am I going wrong ?

    (Note: I am using a multichannel gateway)

    Please help

    Thanks and Regards,
    Aniket



  • @aniket_yeole you can change some of the parameters (including SF) using setsockopt. To change the frequency you’ll need to remove all channels and re-add channels with your chosen frequency. But beware, the network can change those settings via MAC commands.



  • @jcaron
    I wanted to change the parameters like BW, Spreading Factor, Transmitting Power and to transmit on particular frequency manually. How to enforce the lopy to do it in LoRaWAN mode?



  • @aniket_yeole what exactly are you trying to achieve? Connecting to the network means using LoRaWAN, so why would you want/need to use raw LoRa? That would require you to re-implement the LoRaWAN stack yourself.

    By definition, if you use raw LoRa, you can’t use join as that’s part of LoRaWAN...

    Just use LoRaWAN mode and you should be all set...



Pycom on Twitter