Hi @Hobo @Fomi
I installed the RAK831 Gateway as per the manual and the built in loRa server is installed.
I used the micropython code for the Lopy4 node mentioned below:
main.py – put your code here!
from network import LoRa
import socket
import binascii
import struct
import time
LORA_FREQUENCY = 915000000
LORA_NODE_DR = 5
initialize LoRa in LORAWAN mode.
Please pick the region that matches where you are using the device:
Asia = LoRa.AS923
Australia = LoRa.AU915
Europe = LoRa.EU868
United States = LoRa.US915
lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.AU915)
create an ABP authentication params
dev_addr = struct.unpack(">l", binascii.unhexlify(‘2601147D’))[0]
nwk_swkey = binascii.unhexlify(‘3C74F4F40CAEA021303BC24284FCF3AF’)
app_swkey = binascii.unhexlify(‘0FFA7072CC6FF69A102A0F39BEB0880F’)
remove all the non-default channels
for i in range(0, 72):
lora.remove_channel(i)
set the 3 default channels to the same frequency
lora.add_channel(0, frequency=LORA_FREQUENCY, dr_min=0, dr_max=5)
lora.add_channel(1, frequency=LORA_FREQUENCY, dr_min=0, dr_max=5)
lora.add_channel(2, frequency=LORA_FREQUENCY, dr_min=0, dr_max=5)
join a network using ABP (Activation By Personalization)
lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_swkey, app_swkey))
create a LoRa socket
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
set the LoRaWAN data rate
s.setsockopt(socket.SOL_LORA, socket.SO_DR, LORA_NODE_DR)
make the socket non-blocking
s.setblocking(False)
for i in range (200):
pkt = b’PKT #’ + bytes([i])
print(‘Sending:’, pkt)
s.send(pkt)
time.sleep(4)
rx, port = s.recvfrom(256)
if rx:
print(‘Received: {}, on port: {}’.format(rx, port))
time.sleep(6)
The above code is obtained from the Github. The node seems to send the packet but I don’t receive anything in the gateway. Your help would be appreciated. Or if you can guide me a simple code to run at the node to see if I can receive the packet in LoRa built-in server.
Sorry as I am very new to the subject.
Thank you