Skip to content

Commit

Permalink
A little helper: decode ASCII payload
Browse files Browse the repository at this point in the history
  • Loading branch information
gotthardp committed Mar 1, 2018
1 parent 365f8e2 commit 12bc60f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/Handlers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions priv/admin/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 2 additions & 0 deletions src/lorawan_application_backend.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down

0 comments on commit 12bc60f

Please sign in to comment.