Skip to main content

SenseCAP M2 Multi-Platform Gateway LNS Configuration

Gateway Configuration

Configure the gateway via the Web UI, please check the Quick Start to log into Luci.

Channel Plan Settings

Navigate to LoRaChannel Plan

pir

Select the Region and Frequency plan.

pir

After setting, click Save&Apply

Local Network Server Configuration

Navigate to LoRaLoRa Network

pir

Set Mode to Local Network Server, add your MQTT info (Broker Host/Port/User/Password), other parameters can keep the default value.

pir

Click Save&Apply to apply your settings.

Note

It will take about 1 min to start the process , then you can access the GUI configuration.

ChirpStack GUI Configuration

Login to the ChirpStack GUI via http://localhost:8080.

pir

The default account and password: admin.

pir

Then you will see the dashboard page.

pir

Check the Regions

Navigate to Network Server > Regions.

There should be a Region ID, click it and confirm the info, it should be same as your settings in the previous step.

pir

pir

Add Device Profile

Navigate to Tenant > Device Profiles, and click Add Profile.

pir

MAC version: LoRaWAN 1.0.3

Regional parameters reversion: A

ADR algorithm: Default ADR algorithm(LoRa only)

Expected uplink interval: Customize, default 3600s

pir

Navigate to Codec, and select JavaScript functions, copy the SenseCAP Decoder for TTN and submit it.

pir

Add Gateway

Navigate to Gateway, and click Add Gateway.

pir

Define the Name and Gateway ID(you can click to randomly generate the ID), then submit it.

pir

Add Device

Navigate to Tenant > Application, and click Add Application.

Name your application and submit it.

pir

Navigate to your application, and click Add device.

pir

Paste your device EUI and select the device profile we added before, then submit it.

pir

Paste the Application key and click submit.

pir

Check the device status

Check the Events of your device, you will get the join packet when the device joins the network.

pir

You can also check the packet details.

pir

Integrations

This chapter is for cloud service development, the following guideline is for reference.

MQTT

Topic

The MQTT integration exposes all events as documented by Event types.

The default event topic is:

application/APPLICATION\_ID/device/DEV\_EUI/event/EVENT

Check Event Types for more details.

You can find the Application id on your application tab:

pir

  • Event types
upUplink event
statusMargin and battery status
joinDevice join event
ackConfirmed downlink (n)ack
txackDownlink transmission ack
logLog (or error) event
locationLocation event
integrationIntegration event
Note

+ means to receive all messages

Example:

  • To receive uplink messages from all devices under a certain gateway:
gateway/<GATEWAY\_EUI>/device/+/event/up
  • To receive all messages from all devices under the application:
application/+/device/+/event/+
  • To receive all device messages from all gateways:
gateway/+/device/+/event/+

You can check the gatewayid to distinguish the gateways.

pir

Payload

When the object.valid is true, means the data analysis is successful, then you can traverse the object.messages, and extract the data type you need.

pir

1) Up event for SenseCAP LoRaWAN S210X Sensors payload example description:

pir

  • upload\_battery: Battery
  • upload\_interval: upload interval, unit: Second
  • upload\_version: Hardware/Firmware Version
  • report\_telemetry: Measurement value

The measurementId in the ‘report_telemetry’ message please check SenseCAP Measurement ID for more details.

pir

1) Up event for SenseCAP Data logger payload example description:

pir

The measurementId in the ‘report_telemetry’ message please check SenseCAP Measurement ID for more details.

HTTP

Click + in the HTTP tab to add a new HTTP integration.

LNS will send messages as POST to the configured URL.

pir

Submit your URL info.

Note

Support http only, not https.

pir

The HTTP integration will make POST requests to the configured event endpoint or endpoints (multiple URLs can be configured, comma separated). The event URL query parameter indicates the type of the event.

The HTTP integration exposes all events as documented by Event Type.

Example:

(main.py)

from http.server import HTTPServer, BaseHTTPRequestHandler 

from urllib.parse import urlparse, parse\_qs

from chirpstack\_api import integration

from google.protobuf.json\_format import Parse

class Handler(BaseHTTPRequestHandler):

\# True - JSON marshaler

\# False - Protobuf marshaler (binary)

json = False

def do\_POST(self):

self.send\_response(200)

self.end\_headers()

query\_args = parse\_qs(urlparse(self.path).query)

content\_len = int(self.headers.get('Content-Length', 0))

body = self.rfile.read(content\_len)

if query\_args["event"][0] == "up":

self.up(body)

elif query\_args["event"][0] == "join":

self.join(body)

else:

print("handler for event %s is not implemented" % query\_args["event"][0])

def up(self, body):

up = self.unmarshal(body, integration.UplinkEvent())

print("Uplink received from: %s with payload: %s" % (up.device\_info.dev\_eui, up.data.hex()))

def join(self, body):

join = self.unmarshal(body, integration.JoinEvent())

print("Device: %s joined with DevAddr: %s" % (join.device\_info.dev\_eui, join.dev\_addr))

def unmarshal(self, body, pl):

if self.json:

return Parse(body, pl)

pl.ParseFromString(body)

return pl

httpd = HTTPServer(('', 8090), Handler)

httpd.serve\_forever()

Downlink message:

info

It’s recommended to mark the downlink as retained, Then the command will not be executed repeatedly.

The default Topic is:application/APPLICATION\_ID/device/DEV\_EUI/command/down

command: Please check the downlink command in Device User Manual for more details.

Topicapplication/APPLICATION_ID/device/DEV_EUI/command/down
devEUIDevice EUI
confirmedtrue/false(whether the payload must be sent as confirmed data down or not)
fPortFPort to use (must be > 0)
database64 encoded data (plaintext, will be encrypted by ChirpStack)

Example:

1) Reboot SenseCAP S210x LoRaWAN Sensors:

Topic:

application/dbf6\*\*\*\*6c92/device/2CF7F1C2\*\*\*/command/down Json:

{

"devEui":"2CF7F1C2\*\*\*",

"confirmed":true,

"fPort":2,

"data":"AMgAAAAAACsm"

}

1) Set the upload interval of the SenseCAP S210x LoRaWAN Sensors to 1min :

Topic

application/dbf6\*\*\*\*6c92/device/2CF7F1C2\*\*\*/command/down

Json

{

"devEui":"2CF7F1C2\*\*\*",

"confirmed":true,

"fPort":2,

"data":"AIkAESIBAJBQ

"
}
Loading Comments...