Skip to content

Introduction

We use Protobuf (v3) definitions for all messages within the LNS.

Schemas

Schemas are defined in Protocol Documentation which are auto-generated.

Example Definition

A definition is a device specific protobuf definition. Definitions specify the device's uplink and downlink message schemas.

The C7221 is a fictional LoRaWAN device. It is a "smart button" device with 4 pressable buttons. Each button press issues a very small uplink payload containing the button that was pressed as well as the battery level at the time of pressing.

EX4550.proto
// Defines the EX4550 LoRaWAN device Uplink and Downlink message schemas.
syntax = "proto3";

package EX4550.v1;

enum Button {
    UNKNOWN = 0;
    BUTTON1 = 1;
    BUTTON2 = 2;
    BUTTON3 = 3;
    BUTTON4 = 4;
}

message Uplink {
    Button button = 1;              // Button value: 0-4
    int32 battv = 2;                // Battery Voltage: Milivolts
}

message Downlink {
    int32 fport = 1;                // LoRaWAN FPort
    bool adr = 2;                   // ADR - 0=disabled, 1=enabled
    int32 ttu = 3;                  // Seconds per uplink - 30-86400 (1 day)
}

This will create a file in src/protos:

EX4550_pb2.py
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: protos/EX4550.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import builder as _builder
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)

_sym_db = _symbol_database.Default()

# continued ...

When the message is contstructed, serialized, and encoded to a Base64 string

The C7221 is a fictional LoRaWAN device. It is a "smart button" device with 4 pressable buttons. Each button press issues a very small uplink containing the button that was pressed as well as the battery level at the time of pressing.

Generate the Python stub

Run buf generate in the command line.