Firmware for an ad-hoc mesh network of Internet-of-Things devices based on LoRa (Long Range radio) that can be deployed quickly and cheaply.
DuckLora Class Reference

Internal LoRa chip abstraction. More...

#include <DuckLora.h>

Public Member Functions

int setupLoRa (LoraConfigParams config, String deviceId)
 Initialize the LoRa chip. More...
 
int handlePacket ()
 Handle a Duck LoRa packet. More...
 
String getPacketData (int pSize)
 Get the last received LoRa packet. More...
 
int sendPayloadStandard (String msg="", String topic="", String senderId="", String messageId="", String path="")
 Send a message out into the LoRa mesh network. More...
 
Packet getLastPacket ()
 Get the last received LoRa packet. More...
 
void couple (byte byteCode, String outgoing)
 Append a chunk to the packet. More...
 
bool idInPath (String path)
 Determine if a Duck device_id is present in the path. More...
 
bool loraPacketReceived ()
 Check if a received packet is available for processing. More...
 
int startReceive ()
 Set the Duck to be ready to recieve LoRa packets. More...
 
int transmitData ()
 Set the Duck to be ready to transmit LoRa packets. More...
 
int getRSSI ()
 Get the current RSSI value. More...
 
void resetPacketIndex ()
 Reset the index of the received Packet buffer. More...
 
int getPacketIndex ()
 Get the current packet buffer index. More...
 
byte * getTransmissionBuffer ()
 Get the transmission buffer. More...
 
byte getTransmitedByte (int index)
 Get the transmited byte at the given index in the transmission buffer. More...
 
int ping ()
 Transmit a ping message. More...
 
int standBy ()
 Set the LoRa chip in standby mode. More...
 
void resetTransmissionBuffer ()
 Clear and Reset the transmission buffer. More...
 

Static Public Member Functions

static DuckLoragetInstance ()
 Get a singletom instance of the DuckLora class,. More...
 

Detailed Description

Internal LoRa chip abstraction.

Provides internal access to the LoRa chip driver. This class is used by other components of the CDP implementation.

Member Function Documentation

◆ couple()

void DuckLora::couple ( byte  byteCode,
String  outgoing 
)

Append a chunk to the packet.

A chunk is part of the Duck LoRa packet and is formated as [tag][length][payload] where a tag is a single byte identifying the chunk. Currently supported tags:

sender_id
topic
message_id
payload
iamhere
Parameters
byteCodeidentifies the tag to append
outgoingthe payload for the tag to be appended to the LoRa packet

◆ getInstance()

static DuckLora* DuckLora::getInstance ( )
static

Get a singletom instance of the DuckLora class,.

Returns
A pointer to a DuckLora object

◆ getLastPacket()

Packet DuckLora::getLastPacket ( )

Get the last received LoRa packet.

Returns
A Packet object containing the last received message.

◆ getPacketData()

String DuckLora::getPacketData ( int  pSize)

Get the last received LoRa packet.

Parameters
pSizesize of the packet
Returns
A string representing the last received message.

◆ getPacketIndex()

int DuckLora::getPacketIndex ( )
inline

Get the current packet buffer index.

Returns
Current index in the transmission buffer.

◆ getRSSI()

int DuckLora::getRSSI ( )

Get the current RSSI value.

Returns
An integer representing the rssi value.

◆ getTransmissionBuffer()

byte* DuckLora::getTransmissionBuffer ( )
inline

Get the transmission buffer.

Returns
An array of bytes containing the transmission packet

◆ getTransmitedByte()

byte DuckLora::getTransmitedByte ( int  index)
inline

Get the transmited byte at the given index in the transmission buffer.

Parameters
indexposition in the transmission buffer
Returns
The byte value in the transmission buffer at the given index.

◆ handlePacket()

int DuckLora::handlePacket ( )

Handle a Duck LoRa packet.

Returns
0 if handling was successful, an error code otherwise.

◆ idInPath()

bool DuckLora::idInPath ( String  path)

Determine if a Duck device_id is present in the path.

Parameters
pathpath retrieved from the LoRa packet
Returns
true if the id is in the path, false otherwise.

◆ loraPacketReceived()

bool DuckLora::loraPacketReceived ( )

Check if a received packet is available for processing.

Returns
true if a packet was available, false otherwise.

◆ ping()

int DuckLora::ping ( )

Transmit a ping message.

Returns
0 if the message was sent sucessfully, an error code otherwise.

◆ resetPacketIndex()

void DuckLora::resetPacketIndex ( )
inline

Reset the index of the received Packet buffer.

◆ resetTransmissionBuffer()

void DuckLora::resetTransmissionBuffer ( )

Clear and Reset the transmission buffer.

◆ sendPayloadStandard()

int DuckLora::sendPayloadStandard ( String  msg = "",
String  topic = "",
String  senderId = "",
String  messageId = "",
String  path = "" 
)

Send a message out into the LoRa mesh network.

Parameters
msgpayload representing the message
topicthe message topic
senderIdthe device_id of the sender
messageIdthe id of the message
patha comma separated list of devide ids having seens the message
Returns
DUCK_ERR_NONE if the message was sent successfully, an error code otherwise.

◆ setupLoRa()

int DuckLora::setupLoRa ( LoraConfigParams  config,
String  deviceId 
)

Initialize the LoRa chip.

Parameters
configlora configurstion parameters
deviceIddevice id
Returns
0 if initialization was successful, an error code otherwise.

◆ standBy()

int DuckLora::standBy ( )

Set the LoRa chip in standby mode.

Returns
DUCK_ERR_NONE if the chip is sucessfuly set in standby mode, an error code otherwise.

◆ startReceive()

int DuckLora::startReceive ( )

Set the Duck to be ready to recieve LoRa packets.

Returns
DUCK_ERR_NONE if the call was successful, an error code otherwise.

◆ transmitData()

int DuckLora::transmitData ( )

Set the Duck to be ready to transmit LoRa packets.

Returns
DUCK_ERR_NONE if the call was successful, an error code otherwise.

The documentation for this class was generated from the following file:
DuckLora::ping
int ping()
Transmit a ping message.