Skip to content
No description, website, or topics provided.
C++
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
src
.gitignore
LICENSE
README.md
library.properties

README.md

leuville-arduino-lmic-easy

Various programming utilities for Arduino devices designed to send and receive LoRaWAN messages with LMIC library. LMICWrapper is a base class for LoRaWAN endnodes built on top of LMIC library. ProtobufEndnode is a subclass of LMICWrapper which uses ProtocolBuffer to serialize/deserialize LoRaWAN messages.

The classes in this library are normally intended to be used inside a class that overrides one or more of the virtual methods.

Required libraries

Contents

LMICWrapper

LMICWrapper is a base class for LoRaWAN endnodes built on top of LMIC library. It has been tested with two LMIC implementations (see Required libraries section).

LMICWrapper stores LoRaWAN messages into a deque object (STL) which acts as a FIFO list of messages waiting to be sent. Each time runloopOnce() is called (typically from main loop), a LMIC callback job is registered to send first back object of this deque. When the callback job is performed, the first-out message is sent and removed from the deque if isTxCompleted() returns true. By this way, LoRaWAN messages are not lost if the radio or the network are not available.

ProtobufEndnode<>

ProtobufEndnode is a subclass of LMICWrapper which uses ProtocolBuffer to serialize/deserialize LoRaWAN messages.

ProtobufEndnode is a template class parametrized by ProtocolBuffer message types generated by Nanopb implementation from .proto description. It behaves the same as LMICWrapper, except it encodes/decodes messages.

Example 1: TestLMICWrapper.ino

This example builds a LoRaWAN device as a subclass of LMICWrapper, with:

  1. a callback set on button connected to A0 pin. This callback sends a "CLICK" message each time the button is pressed.
  2. a timer to send a "TIMEOUT" message each 5 mn
  3. a standby mode feature

Example 2: TestProtobufEndnode.ino

This example shows how to serialize/deserialize LoRaWAN messages with ProtocolBuffer. The endnode device is the same as the one built in TestLMICWrapper.ino sample.

The message sent by the device is defined with a .proto file like this one:

syntax = "proto3";

package leuville;

enum Type {
	PING 	= 0;
	BUTTON 	= 1;
}

message Uplink {		
	Type	type			= 1;
	uint32	battery 		= 2;
}

message Downlink {
	uint32	pingDelay		= 1;	// seconds
}

In this example, the LoRaWAN uplink message is encoded with these data:

  1. A type which may be PING or BUTTON. PING is sent on timed regular basis, BUTTON is sent when an interrupt occurs.
  2. The battery level in range 0..100

A LoRaWAN downlink message may be sent by the server to the device. In this example, it contains the delay to use by the device to separate two PING messages.

The .proto file may have options. In our case it is:

leuville.Uplink.battery		int_size:8
leuville.Downlink.pingDelay	int_size:16

These definitions have to be compiled with Nanopb protoc compiler. It generates .h and .c files.

Then the endnode is defined as a template class based on protobuf generated types:

using Base = ProtobufEndnode<
	leuville_Uplink, leuville_Uplink_size, leuville_Uplink_fields,
	leuville_Downlink, leuville_Downlink_size, leuville_Downlink_fields
>;

/*
 * LoraWan + ProtocolBuffer endnode with:
 * - a timer to trigger a PING message each 5 mn
 * - a callback set on button connected to A0 pin, which triggers a BUTTON message
 * - standby mode capacity
 */
class EndNode : public Base, ISRTimer, ISRWrapper<A0>, StandbyMode { // ... };
You can’t perform that action at this time.