LoPy - Raw Lora mode for connecting TTN
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:
from network import LoRa
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():
print('Not yet joined...')
print ("Joined the network")
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
s.setsockopt(socket.SOL_LORA, socket.SO_DR, 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)
Thanks and Regards,
@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.
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
joinas that’s part of LoRaWAN...
Just use LoRaWAN mode and you should be all set...