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 datetime

    nu = 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])))


Log in to reply
 

Pycom on Twitter

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.