Skip to content

Command tool Node RED application server example

matthieuantoine edited this page Oct 15, 2020 · 1 revision

Command tool - Use with Node-RED application server example

This page describes operations to send scan solve requests compatible with the Node-RED Application Server example. A GNSS assisted scan is used here as an example.

Introduction

The LR1110 Command Tool is not natively compatible with the Node-RED application server example as it features no more than the driver calls.

The missing point is the Tag-Length-Value (TLV) payload format used to send the scan results to the Application Server.

Building TLV payload

A TLV frame is built as follow:

Field name Size (byte) Content
Tag 1 One of the following tag value
Length 1 N
Value N Application dependant

The scan-related tags understood by the Application Server are the following:

Tag Value Scan source
0x05 GNSS (no specific antenna)
0x06 GNSS (PCB antenna)
0x07 GNSS (Patch antenna)
0x08 Wi-Fi

The Value content depends on the scan source.

  • For GNSS scan, the value is the NAV message. However, the very first byte reported from the NAV message (which is 0x01) must be removed.
  • For Wi-Fi scan, the Value field is built as follow for each MAC address scanned:
    • 1 byte corresponding to the RSSI
    • 6 bytes corresponding to the MAC address

To comply with the Application Server, all TLV frames must be sent as Stream.

Step-by-step

It is assumed here that you have the following:

  • a Node-RED Application Server up and running
  • a LoRa Basics Modem-E registered on a LNS server, and with commissioning already configured

After setting the commissioning information, join the network, initialize the stream service on port 199, and enable the ALC sync mode to receive the date from network:

>> SetJoin
Join success event
>> StreamInit 199
>> EnableAlcSyncMode
ALC sync update event

The GNSS assisted scan needs a rough Assistance Location - provide it using the following command:

>> SetAssistancePosition <LATITUDE> <LONGITUDE>

Where <LATITUDE> and <LONGITUDE> are provided in decimal degree, and must be a 150km estimation of the actual location of the device.

Then, you can start the GNSS assisted scan, and wait for the GNSS scan done event:

>> GnssScanAssisted best_effort 0x07 15
GNSS Scan Done:
  - NAV (<N> bytes): <NAV>

Where:

  • <N> is the length in bytes of the NAV message, reported in the GNSS Scan Done event
  • <NAV> is the content of the NAV message, starting with 0101

Now, the TLV payload is to be crafted as follows. The TLV will start with the tag 05 (the hexadecimal value for the scan source GNSS (no specific antenna)). The Length field will be populated with the hexadecimal representation of <N> - 1, <N> being the length in bytes reported by GNSS Scan Done event.

For instance, if the GNSS Scan Done event reported 112 bytes, the TLV will starts by 056F:

  • 05 is the tag for GNSS (no specific antenna)
  • 6F is the hexadecimal representation of 111 (ie 112-1)

Then, you append the NAV message returned by GNSS Scan Done event, removing the very first 01.

So, if the GNSS Scan Done event reported the following (this is NOT an actual real NAV message, it is just for explanation purpose):

GNSS Scan Done:
  - NAV (5 bytes): 01012F1A35

The corresponding TLV payload will be 0504012F1A35.

Now that you have the TLV payload, you can send it using the Stream service previously enabled with:

>> StreamData 199 <TLV_PAYLOAD>
Stream done event

Where:

  • 199 is the DAS message LoRaWan port
  • <TLV_PAYLOAD> is the TLV payload crafted following the previous procedure

At the end of this procedure, the Node-Red example Application Server should have called the DAS to recover the TLV frame from Stream service, and called the DAS to resolve the GNSS-based location of the device.

Clone this wiki locally