Sending Downlink messages

  • 12 augustus 2016
  • 28 reacties
  • 5453 keer bekeken

Reputatie 2
Badge +1
This post has become obsolete as it was incorporated in the Setting up your Application Server topic.

[color=green]

Developer Portal

[/color]
Sending downlink messages
All downlink messages should be sent to:
https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage
and contain the following query parameters:

- DevEUI of your device
- FPort used within LoRa (developer portal only allows port 1)
- Payload formatted as hex
- AS_ID that identifies you. You can find your AS_ID at you profile in the developer portal.
- Timestamp formatted as ISO time

Example
DevEUI=000000000F1D8693&FPort=1&Payload=00&AS_ID=app1.sample.com&Time=2016-01-11T14:28:00

Also a token should be added by computing it from SHA-256
SHA 256(DevEUI=000000000F1D8693&FPort=1&Payload=00&AS_ID=app1.sample.com&Time=2016-01-11T14:28:0046ab678cd45df4a4e4b375Eacd096acc)
Remember that the can be found at you user profile in the developer portal and is 46ab678cd45df4a4e4b375Eacd096acc in this example.

The resulting is encoded as an hex string (e.g. b5a84fe9c8921e9de359e3041a37b76c4b122f6f9b83577b5596c842052f7e62) AND added at the end of the query parameters line

Complete example
https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage?DevEUI=000000000F1D8693&FPort=1&Payload=00&AS_ID=app1.sample.com&Time=2016-01-11T14:28:00&Token=b5a84fe9c8921e9de359e3041a37b76c4b122f6f9b83577b5596c842052f7e62

[color=green]

Thingpark

[/color]Developers can send downlink messages using the HTTPS Post API of Thingpark at https://api.kpn-lora.com/thingpark/lrc/rest/downlink.

Messages should contain the following query parameters:
  • DevEUI of your device
  • FPort used within LoRa
  • Payload formatted as hex
  • AS_ID that identifies you. You can find your AS_ID at you profile.
  • Time Time of your server formatted as outlined below
  • Token as a SHA 256 signature

The timestamp should be your server time in the following format:
code:
YYYY-MM-DDThh:mm:ss.fff+|-hh:mm (eg 2016-08-01T09:06:06.000+02:00)

Where:
- YYYY = four-digit year
- MM = two-digit month
- DD = two-digit day
- hh = two digits of hour (00 through 23)
- mm = two digits of minute (00 through 59)
- ss = two digits of second (00 through 59)
- fff = three digits of millisecond (000 through 999)
- +|-hh:mm = timezone designator (+hh:mm or –hh:mm)


It appears that there are a few inconsistencies in how Thingpark handles timezones. This will be solved in comming releases. Also the '+' in the querystring is sometimes ignored in some situations, creating problems with the SHA256 generation. The most straightforward method seems to use the UTC or ZULU timezone with this format:
code:
2016-08-01T09:06:06Z


Below is an example of a valid HTTPS POST message, note that you will have to use your own DevEUI and generate your own token with your LRC-AS key


When a downlink message is received succesfully, a HTTP response will tell you that the LRC queued your request.

Downlink Queue information
  • Messages are queued until next uplink frame, there is no time limit.
  • 5 messages can be queued PER DEVICE. The oldest is removed if a new one is queued.
  • Queue cannot be changed or viewed by the customer.

Example
The IoT Academy Github contains a step-by-step explanation about how to implement an application server in NodeRed: https://github.com/iotacademy/NodeRed_KPN_LoRa/wiki .

[color=green]

Useful links

[/color]- [color=#094ab1]LoRa:[/color] Starters Guide
- [color=#094ab1]LoRa:[/color] Forum and Manuals
- [color=#094ab1]LoRa:[/color] Geolocation
- [color=#094ab1]LoRa:[/color] Dictionary & Definitions
- [color=green]FAQ:[/color] Frequently Asked Questions
- [color=green]Tools:[/color] www.LoRaTools.nl

28 reacties

Bovenstaand bericht is inconsistent. Er wordt een Time gevraagd in de vorm van 2016-02-20T12:00:00.000+01:00 Hier staat bij dat alle velden verplicht zijn.

In het voorbeeld staat 2016-01-11T14:28:00 . Dus zonder milliseconden en tijdzone informatie.

In de praktijk is gebleken dat versturen met informatie die zich aan het request voorbeeld houdt, werkt. Hierbij moet in localtime van de kpn server verstuurd worden. (hoe gaat dat dan rond zomer/wintertijd overgangen???)

Dit is al aangegeven in mondelinge feedback rond 7-7-2016 op document "Quick Start voor koppeling Applicatie Server met KPN LoRa".
Ik heb nog even voor de zekerheid gecheckt of dit niet een ervaring uit het verleden was:
https://api.kpn-lora.com/thingpark/lrc/rest/downlink?DevEUI=xxx&FPort=1&Payload=000F&AS_ID=xxx&Time=2016-08-18T11:42:46&Token=xxxx werd zojuist geaccepteerd.

https://api.kpn-lora.com/thingpark/lrc/rest/downlink?DevEUI=xxx&FPort=1&Payload=000D&AS_ID=xxx&Time=2016-08-18T11:41:45.633+02:00&Token=xxx werd zojuist verworpen.


Ik zou ook het gebruik van Timestamp in bovenstaande bericht vervangen door Time.
https://api.kpn-lora.com/thingpark/lrc/rest/downlink?DevEUI=xxx&FPort=1&Payload=0010&AS_ID=xxx&Timestamp=2016-08-18T11:52:03.042+02:00&Token=xxx werd zojuist ook verworpen.
Reputatie 2
Badge +1
@ASmit: Dank voor je feedback en terechte opmerkingen, ik zag ook al bij andere cases dat de timestamp check nog niet helemaal lekker gaat. Bovenstaande 'mandatory' variabelen zijn blijkbaar niet in alle gevallen mandatory en dus niet eenduidig. Ik ga aanvragen dit te fixen en terug te koppelen hoe dit wel moet werken.
Reputatie 2
Badge +1
Ik heb een aangepaste versie van de topic start geupload, hopelijk geeft dit wat meer duidelijkheid voor nu.
In aanvulling op mijn bericht van 18 augustus: Na 14:40 12-09-2016 moet de Time in UTC gegeven worden. De Z mag meegegeven worden.
Reputatie 2
Badge +1
In aanvulling op mijn bericht van 18 augustus: Na 14:40 12-09-2016 moet de Time in UTC gegeven worden. De Z mag meegegeven worden. Dank voor melden op het forum, je opmerking over UTC en optionele Z zijn correct.
Alles werkt voor "https://api.kpn-lora.com/thingpark/lrc/rest/downlink".

Werkt de downlink ook voor "https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage"" ??

Op mijn device zie ik wel de uplink, maar geen downlink data. Ik gebruik het voorbeeld van kpn van nodered (https://github.com/iotacademy/NodeRed_KPN_LoRa/wiki .)

De website geeft terug:Server Response {"UniqueID":"658"}, en de onderstaande downlink URL
https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage?DevEUI=0059AC0000180126&FPort=1&Payload=123456&AS_ID=Atus.Developer&Time=2016-11-07T10:20:24Z&Token=fc171cd304e0248bba52fd8cd51e72bf6a12dfe56b6889a04277597aa51f9842

Maar ik zie niet de gewenste payload data bij de RN2384 binnen komen.
Ik zie binnenkomen:
mac tx cnf 1 121234
ok
mac_tx_ok

Ik had iets verwacht als
mac tx cnf 1 121234
ok
mac_rx 123456
mac_tx_ok
Reputatie 2
Badge +1
Hi Rudolf,

Je doet alles goed, maar helaas zit er een bug in de downlink functionaliteit tussen developer portal en core netwerk. Deze wordt met de volgende release opgelost (enkele weken van nu), maar tot die tijd zal je inderdaad nog geen downlink verkeer bij je device zien aankomen.

Groet,

Michiel
Hi Michiel,

Kun je al wat meer zeggen over de tijdsplanning van deze nieuwe release (met downlink functionaliteit)?

Groet,

Ewout.
Reputatie 7
Badge +11
Dag Ewout,

De nieuwe release met downlink functionaliteit verwachten we op zeer korte termijn. Wanneer precies de nieuwe versie van de developer portal online komt weet ik nog niet te zeggen. uiterlijk einde van deze maand is de bedoeling! 🙂
Hoi, is deze functionaliteit ondertussen werkend via het dev-portal? Het lukt mij in ieder geval nog niet downlink berichten te laten aankomen. Er is wel al aangekondigd dat thingpark gaat stoppen maar dit is toch wel een issue dat voor die tijd opgelost moet zijn.
Reputatie 7
Badge +11
Hi Janno, the downlink functionality is available since the latest maintenance update in december.
Have you tried the feature that lets the LRR notify the LRC if a downlink frame has been sent or not? See more on this feature in this topic.
Is the downlink functionality still working ? No matter what I POST I always get an error:
"An existing connection was forcibly closed by the remote host" I try sending a POST from my ASP.NET application (through several ways, post the URL, or using a base URL with data, Nothing works...

The URL I post is as followed:
https://api.kpn-lora.com/thingpark/lrc/rest/downlink?DevEUI=0059AC00001XXXX&FPort=1&Payload=010E01&AS_ID=xxxx&Time=2017-02-03T15:37:15&Token=ViqxEB0Gd7c0kSQ4uky/v3RZA8tsiPACguUkxeohyZ4

Anybody a clue ?
Currently i'm working on my (C#) Application Server, when all downlink messages are used for the current hour (on the 4th msg) I get an exception (bad request(400) which is a http error) while trying to read the request stream like the request is refused, same happens when posting a message that is incorrect (like wrong token). Is it possible to have a useful response, describing what goes wrong from the KPN server?
like max downlink msg reached, token mismatch, ...
Hi persafe,

Can you send downlinkmessages using URL: https://api.kpn-lora.com/thingpark/lrc/rest/downlink ? Because I cannot send any...
currently using https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage?DevEUI=0059AC000xxxxx.... is used. there is one that went EOL last week don't know which one...
Reputatie 7
Badge +11
@andykalbvleesch & @persafe, the Thingpark test environment is indeed End of Life since feb 1st.

@persafe, 400 bad request means the URL you are using is not correct.
Hi Tim, i don't agree on this conclusion. Yes it might mean url is wrong. The only thing about it is that this url is used on any request from my server and the first 3 downlink msgs each hour (like 13:00, 14:00, 15:00) it works and a response is received (like {"UniqueID":"2158"})
so in my opinion:
- the url is right
- the token calculation is right
- the KPN / mendix server is refushing it through a http (400) bad request after my downlink msg are used
Persafe, thingpark works for clients with a subscription through either SIMPOINT or KPN and will continue to work as I just heard from KPN accountmanager. Do you have some sample code for downlink messages as I cannot send them at all... Any help would be highly appreciated... I also code in .Net

Thanx in advance.
"Queue cannot be changed or viewed by the customer."
Will this be possible in the near future?
Hi all,

It doesn't really matter what I enter as parameters, but if I try for example the following request (with all the "" correctly filled in), no downlink messages will be send:

https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage?DevEUI="DevEUI"&FPort=1&Payload=b0&AS_ID=""AS_ID"&Time=2017-10-30T13:36:33&Token=a4b9398b34fb7c25cb29f0b3b2272b56f1afc4e28bdf7f6ab6358b99fe52f216

Where the token is:
DevEUI="DevEUI"&Port=1&Payload=b0&AS_ID="AS_ID"&Time=2017-10-30T13:36:33"AS-KEY"

I always get the following response:
[
"https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage/184",
"https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage/358",
"https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage/359",
"https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage/362",
"https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage/363",
"https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage/561",
"https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage/562",
"https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage/563",
"https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage/564",
.
.
.
"https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage/25100",
"https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage/25103",
"https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage/25104",
"https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage/25110",
"https://loradeveloper.mendixcloud.com/rest/sendkpnloramessage/25111"
]

Does anyone know what is going on?
Reputatie 7
Badge +11
"Queue cannot be changed or viewed by the customer."
Will this be possible in the near future?
Hi Ruben, thanks for your question! Do you get this message in the Developer Portal or do you have a Thingpark account?
I have a thingpark account, however it wasn't a message from the thinpark, it was a quote of the first entry in this forum post.
@Tim
What I quoted:
""Downlink Queue information
* Messages are queued until next uplink frame, there is no time limit.
* 5 messages can be queued PER DEVICE. The oldest is removed if a new one is queued.
* Queue cannot be changed or viewed by the customer. "

It says that the queue cannot be changed or viewed by the customer, however that would be a very handy feature. So I was wondering if that feature will become available in the feature?
Because I would like to be able to edit/view the queue.
Reputatie 7
Badge +11
Hi @Ruben, KPN is developing a new portal to view and/or edit the queue. The feature will be available, but we can't say when exactly.
Is het mogelijk om berichten die in de Lora downlink queue klaarstaan, maar nog niet naar de node zijn verzonden, te annuleren/flushen? Of wordt deze functionaliteit op korte termijn verwacht?

Is de downlink queue altijd vijf berichten groot, ook bij betaalde abonnementen?

Reageer