What is the best way to send downlink data?
-
To set the time on a node (without wifi) I have made a small Python script. It sends the date/time as a string, like '201712101458'. Is this the preferred way to send data, or is there a better way?
I have included some code below. I could not find a way to format the code in a codeblock. so sorry for the formatting.
Here is the simple Python script to send the data:
import requests
from datetime import datetimenu = datetime.now()
datum = nu.strftime('%Y%m%d%H%M')
payload = datum.encode('base64')
r = requests.post("https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/f4ce46a550ec/12?key=ttn-account-v2.-<removed>",
json={
"dev_id": "<removed>", # The device ID
"port": 1, # LoRaWAN FPort
"confirmed": False, # Whether the downlink should be confirmed by the device
"payload_raw": payload # Base64 encoded payload
})
print(r.status_code, r.reason)On the node I set the time this way:
rtc.init((int(rx[0:4]),int(rx[4:6]),int(rx[6:8]),int(rx[8:10]),int(rx[10:12])))
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login