Data mapping for LoRaWAN

IMPACT supports data mapping capability for devices on a LoRaWAN® (Low Power Wide Area Networks) network when using a Protocol Adapter to integrate with the LoRaWAN network.

You can write a custom script and custom logic for decoding the encrypted data. See Creating data mapping scripts.

For an example script for this type of data mapping, see nordicmeterscript.js script.

The following are examples when a device uses a Protocol Adapter to send and receive the payload data from IMPACT.

  • For device boot:

    The following payload is received from the device through the Protocol Adapter.

    resourcePath: "uplinkMsg/0/meta"
    value: {
    "type": "uplink",
    "meta":
    { "network": "a653ee9da56a43b9ab308c3b2f06eb81", "packet_hash": "00c8455348893131a71db24740846146", "application": "0000000000000100", "device_addr": "0001dec5", "time": 1617967553.360951, "device": "f80332020001dec5", "packet_id": "272abb89b77b2eeccad0d728cdc6cef0", "gateway": "00001c497be16b8e" } ,
    "params":
    { "rx_time": 1617967553.3218427, "port":*99*, "duplicate": false, "counter_up": 1593, "payload": "*ABYBEkwAAQIQ*", "encrypted_payload": "OBl9efO7cJ+8bs4WiTs8xL4zJObg+KeDADZ1LS0B45fEZQL5151x3g==" } }

    This payload is mapped to the following data which is sent to IMPACT.

    • Device/0/Firmware = 0.1.2
    • Device/0/BootReason = 10

    After the device is registered, the following is used to read the meter.

    resourcePath: "uplinkMsg/0/meta"
    value: {
    "type": "uplink",
    "meta":
    {     "network": "a653ee9da56a43b9ab308c3b2f06eb81",     "packet_hash": "00c8455348893131a71db24740846146",     "application": "0000000000000100",     "device_addr": "0001dec5",     "time": 1617967553.360951,     "device": "f80332020001dec5",     "packet_id": "272abb89b77b2eeccad0d728cdc6cef0",     "gateway": "00001c497be16b8e"   }
    ,
    "params":
    {     "rx_time": 1617967553.3218427,     "port":14,     "duplicate": false,     "counter_up": 1593,     "payload": "gAoAAA==",     "encrypted_payload": "OBl9efO7cg=="   }
    }

    This payload is mapped to the following data which is sent to IMPACT.

    Water/0/UsageinLiters = 2688
  • To downlink data to a device :

    IMPACT initiates the downlink with "Water/0/ReportingInterval"= 600.

    The following data is sent to the Protocol Adapter:
    Method: PUT
    URL: m2m/endpoints/<device>/downlinkMsg/0/data
    Payload: {“resourceValue”:”confirmed:false,pending:false,fport:50,payload:AVgCAAA=”}
  • To write data to a device :

    IMPACT initiates the write data with "Water/0/ReportingInterval"= 600.

    The script manipulates the value to send the following payload:

    { “correlatorId”:”asdfehdga” "write":[ { "resources":"DownlinkMsg/0/data", "endPointClientNames": "T0001dec5", “string”:”AVgCAAA=”, }}
    The adapter resonds with { “correlatorId”:”asdfehdga” "writeResponse":
     { “requestStatus”:0, “responseCode”:0, } } }
  • To read all data from a device :

    IMPACT initiates the read data.

    The following data is sent to the Protocol Adapter:

    GET /Devices/T0001dec5
    The Protocol Adapter can:
    • respond immediately in case of a synchronous read

      or

      accept the response and reply later in case of an asynchronous read

    The Protocol Adapter sends the following in response to the read data:

    { "details":
     { "uplinkMsg/0/meta":”confirmed:false,pending:false,fport:24,payload:-EQAAAE4kAARA”}} 
    This is translated to the following resources which map to:
    • Water/0/UsageinLiters = 17
    • Device/0/mV = 1.248
    • Water/0/Temperature = 24
    • Water/0/Temp Detection = 1
    • Water/0/UserTriggered = 1
    • Water/0/IsAlert = 0
  • To read a single resource from a device:

    IMPACT initiates the following read request.

    The following data is sent to read the millivolts.

    Read device/0/mV
    All data is stored as a blob in the Protocol Adapter so the script translates this to:
    { “correlatorId”:”the correlator value” "read":[ { "resources":"downlinkMsg/0/meta", "endPointClientNames": ["TT0001dec5"]
    The Protocol Adapter responds as follows.
    { “correlatorId”:”the correlator value”, “requestStatus”:0, “responseCode”:0, "response":[ { "uplinkMsg/0/meta": 
     "type": "uplink",
     "meta":
     { "network": "a653ee9da56a43b9ab308c3b2f06eb81", "packet_hash": "00c8455348893131a71db24740846146", "application": "0000000000000100", "device_addr": "0001dec5", "time": 1617967553.360951, "device": "f80332020001dec5", "packet_id": "272abb89b77b2eeccad0d728cdc6cef0", "gateway": "00001c497be16b8e"} ,
     "params":
     { "rx_time": 1617967553.3218427, "port":24, "duplicate": false, "counter_up": 1593, "payload": "gAoAAA==", "encrypted_payload": "OBl9efO7cg==" } }

    The following data is returned to the caller.

    • Device/0/mV = 1.248