until they fixed the APIās sending more the n1 packet still fails ā¦ no further updates from pycom so no idea when a fix is provided
no, ofc not you will needto add the DevAddr assign to you by TTN. Adding the HEX to valid int works for me ā¦ IF you run the latest firmware, older firmwares will not work.
But if I convert the DevAddr assigned by TTN to INT it results in 2590387051 and this also gives an error:
>>> # create an ABP authentication tuple (NwkSKey, AppSKey, DevAddr)
>>> auth = (bytes([0x58, 0xB9, 0x47, 0x74, 0xAF, 0x6F, 0x97, 0x43, 0xEA, 0x0C, 0x58, 0xC5, 0x12, 0xA1, 0xDE, 0x68]), bytes([0x32, 0x83, 0xB1, 0xD7, 0x99, 0x05, 0x83, 0x29, 0x8F, 0xE5, 0xE4, 0xE8, 0x1A, 0xE7, 0x0E, 0xD6]), 2590387051)
>>>
>>> # join a network using ABP (Activation By Personalization)
>>> lora.join(activation=LoRa.ABP, auth=auth, timeout=0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: overflow converting long int to machine word
Just experimented a little: Values up to 0x7FFFFFFF are OK but 0x80000000 and higher raise an overflow
My guess is that a signed type was used instead of an unsigned type to represent the dev-addr
You can work around this by choosing a dev-addr that is below 0x80000000
But As @kruisdraad mentions ABP isnāt working yet, only the first package arrivĆ©s, but if that feels like an achievement, just go ahead
A few things seem to be missing from the code?
import pycom
setting of GREEN to 0x00FF00
Thanks for your tipsā¦
Indeed the code was missing some lines
But one more question: in ABP I cannot choose my own dev-addr as far a I know? So how should I choose one below 0x7FFFFFFF ?
Use the ttnctl command like mentioned here by @arjanvanb
And please change your keys because now they are known to the world
Thank you so muchā¦finally I got my first message through!!!
Now time for my sodaq
(and yes, I will change those keys
Yes I hope so, I reported the problem on the Pycom forum. But at least there is a workaround by choosing your device address when using the ttnctl command as mentioned above. So itās not as blocking as the 1 packet issue.
I probably donāt need it if I donāt know what it isābut Iām curious and canāt help asking. Whatās ABP?
This topic is probably a good starter for your question.
For more information please refer to this nice starting point:
Hi all, Daniel Campora is working on a guide for using TTN with LoPy. You can find the current draft at:
https://www.thethingsnetwork.org/docs/draft/lopy/
If you have corrections or suggestions, just use the edit button to do a quick PR!
as long as stuff aint working, i am not spending another minute on the LoPy
That includes building docs
think there has been an update !
think its still not working, not even the new examples
Cant get the wifi working wither to be able to upload files to the LoPy with the new firmware. When I setup wifi to be a station it crashes
posted a working example using a Lopy with the latest firmware using OTAA and a Pi3 gateway in this topic:
The LoPy Works. Upgrade to latest PyMakr and firmware from the website and you can use the following example:
from network import LoRa
from time import sleep
import socket
import binascii
import struct
# Initialize LoRa in LORAWAN mode.
lora = LoRa(mode=LoRa.LORAWAN, sf=7, tx_power=14)
lora.BW_125KHZ
lora.CODING_4_5
# create an ABP authentication params
dev_addr = struct.unpack(">l", binascii.unhexlify('XX XX XX XX'.replace(' ','')))[0]
nwk_swkey = binascii.unhexlify('XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX'.replace(' ',''))
app_swkey = binascii.unhexlify('XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX'.replace(' ',''))
# 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, 5)
# make the socket blocking.
s.setblocking(True)
while True:
#Do you stuff make data and then send in a loop
print("sending")
s.send('hello')
print("done")
sleep(5)
Hi, I see a couple of likes but can anyone confirm they have this code working?
try it, it works fine ā¦ as long as you donāt want to change the DR/SF