So after a lot of de-compiling i found the way to do ABP. Here by example code:
lora = LoRa(mode=LoRa.LORAWAN, sf=7, tx_power=14)
lora.BW_125KHZ
lora.CODING_4_5
create an OTAA authentication tuple (NWSkey, AppSKey, DevAddr)
auth = (bytes([0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX]), bytes([0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX]), 0x69128CD3 )
lora.join(activation=LoRa.ABP, auth=auth, timeout=0)
while not lora.has_joined():
print(‘Trying to join LoRa network’)
sleep(1)
pass
print(‘Joined LoRa Network’)
pycom.rgbled(GREEN)
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
s.setblocking(False)
while True:
print(‘Sending Packet’)
s.send(‘Hello from the LoPy’)
print(‘Done sending’)
sleep(2)
I dont think i need to explain the 16 byte keys, but the devAddr is a decimal address for your addresses. You can use the hex in 0xDevAddr or 1762823379 as the int of that using a calculator, but make sure you padd the 0’s if a hex did not yield a 8 bit value.
example : 69128CD3 = 0x69, 0x12, 0x8C, 0xD3
0x69 = 1101001 -> 01101001 (pad 1 zero)
0x12 = 10010 -> 00010010 (pad 3 zeros)
0x8C = 10001100
0xD3 = 11010011
Combine it all:
01101001000100101000110011010011
convert that to decimal should result it 1762823379, this is the INT you will need to use. Using the Bytes() method will just result in a error that it cannot be converted into a INT, so this way i am bypassing this problem (assuming bug here)
Now that said, the code will just continue looping and sending packets, but for some reason even when explicitly defining SF7 it will still be SF12 in addition it only sends out a single packet and then the radio just ‘dies’ and with dies i mean its no longer responding until you do a HARD reset. With a soft reset and running the code again it will just hang on lora.join