From 12bc60f05f96164a846e6da4c2b4bfda1085c762 Mon Sep 17 00:00:00 2001 From: Petr Gotthard Date: Thu, 1 Mar 2018 19:20:19 +0100 Subject: [PATCH] A little helper: decode ASCII payload --- doc/Handlers.md | 5 +++++ priv/admin/admin.js | 1 + src/lorawan_application_backend.erl | 2 ++ 3 files changed, 8 insertions(+) diff --git a/doc/Handlers.md b/doc/Handlers.md index 5c77f0e0..e114d4d0 100644 --- a/doc/Handlers.md +++ b/doc/Handlers.md @@ -25,6 +25,7 @@ To create a new handler you need to set: - **Application** name - **Uplink Fields** that will be forwarded to the backend Connector - **Payload** format for automatic decoding + - **ASCII Text** - [**Cayenne LPP**](https://github.com/myDevicesIoT/cayenne-docs/blob/master/docs/LORA.md) - **Parse Uplink** function to extract additional data fields from the uplink frame - **Event Fields** that will be forwarded to the backend Connector @@ -149,6 +150,10 @@ The server can auto-parse some well-known data formats. To parse a custom format leave the *Payload* field undefined and write own *Parse Uplink* function. +### ASCII Text + +The payload will get stored into the `text` field as ASII characters. + ### Cayenne Low Power Payload (LPP) For each Data Channel *N* the server will create a `fieldN` with the parsed value. diff --git a/priv/admin/admin.js b/priv/admin/admin.js index a27c3f74..1470fa5f 100644 --- a/priv/admin/admin.js +++ b/priv/admin/admin.js @@ -813,6 +813,7 @@ myApp.config(['NgAdminConfigurationProvider', function (nga) { ]), nga.field('payload', 'choice') .choices([ + { value: 'ascii', label: 'ASCII Text' }, { value: 'cayenne', label: 'Cayenne LPP' } ]), nga.field('parse_uplink', 'text'), diff --git a/src/lorawan_application_backend.erl b/src/lorawan_application_backend.erl index 13fb4273..13539c3a 100644 --- a/src/lorawan_application_backend.erl +++ b/src/lorawan_application_backend.erl @@ -278,6 +278,8 @@ filter_group_responses(_AppID, List) -> end, ok, List). +parse_payload(<<"ascii">>, Data) -> + #{text => Data}; parse_payload(<<"cayenne">>, Data) -> cayenne_decode(Data); parse_payload(None, _Data) when None == <<>>; None == undefined ->