|
LoRaMesher Library
0.0.5
A LoRa Mesh library for the IoT
|
LoRaMesher Library. More...
#include <LoraMesher.h>
Public Member Functions | |
| void | begin (float freq=LM_BAND, float bw=LM_BANDWIDTH, uint8_t sf=LM_LORASF, uint8_t cr=LM_CODING_RATE, uint8_t syncWord=LM_SYNC_WORD, int8_t power=LM_POWER, uint16_t preambleLength=LM_PREAMBLE_LENGTH) |
| LoRaMesh initialization method. More... | |
| void | init (void(*receiverFunction)(void *)) |
| Initialize the LoraMesher object. More... | |
| void | start () |
| Start/Resume LoRaMesher. After calling begin(...) or standby() you can Start/resume the LoRaMesher. After Start/Resume LoRaMesher it will create and send a Routing Message. Do not abuse this function, it will prevent the duty cycle to function as intended. | |
| void | standby () |
| Standby LoRaMesher. Including tasks and reception and send packets. | |
| ~LoraMesher () | |
| Destroy the LoraMesher. | |
| void | setFrequency (float freq) |
| Set the Frequency. Allowed values range from 137.0 MHz to 525.0 MHz. More... | |
| void | setBandwidth (float bw) |
| Sets LoRa bandwidth. Allowed values are 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125, 250 and 500 kHz. More... | |
| void | setSpreadingFactor (uint8_t sf) |
| Sets LoRa spreading factor. Allowed values range from 6 to 12. More... | |
| void | setCodingRate (uint8_t cr) |
| Sets LoRa coding rate denominator. Allowed values range from 5 to 8. More... | |
| void | setOutputPower (int8_t power, bool useRfo=false) |
| Sets transmission output power. Allowed values range from -3 to 15 dBm (RFO pin) or +2 to +17 dBm (PA_BOOST pin). High power +20 dBm operation is also supported, on the PA_BOOST pin. More... | |
| void | setReceiveAppDataTaskHandle (TaskHandle_t ReceiveAppDataTaskHandle) |
| Set the Receive App Data Task Handle, every time a received packet for this node is detected, this task will be notified. More... | |
| LM_LinkedList< RouteNode > * | routingTableList () |
| Routing table List. | |
| template<typename T > | |
| void | createPacketAndSend (uint16_t dst, T *payload, uint8_t payloadSize) |
| Create a Packet And Send it. More... | |
| void | sendReliablePacket (uint16_t dst, uint8_t *payload, uint32_t payloadSize) |
| Send the payload reliable. It will wait for an ACK back from the destination to send the next packet. More... | |
| template<typename T > | |
| void | sendReliable (uint16_t dst, T *payload, uint32_t payloadSize) |
| Send the payload reliable. It will wait for an ack of the destination. More... | |
| size_t | getReceivedQueueSize () |
| Returns the number of packets inside the received packets queue. More... | |
| size_t | getSendQueueSize () |
| Get the Send Queue Size. Packets that are waiting to be send. More... | |
| template<typename T > | |
| AppPacket< T > * | getNextAppPacket () |
| Get the Next Application Packet. More... | |
| int | routingTableSize () |
| Returns the routing table size. More... | |
| uint16_t | getLocalAddress () |
| Get the Local Address. More... | |
| uint32_t | getReceivedDataPacketsNum () |
| Get the Received Data Packets Num. More... | |
| uint32_t | getSendPacketsNum () |
| Get the Send Packets Num. More... | |
| uint32_t | getReceivedHelloPacketsNum () |
| Get the Received Hello Packets Num. More... | |
| uint32_t | getSentHelloPacketsNum () |
| Get the Sent Hello Packets Num. More... | |
| uint32_t | getReceivedBroadcastPacketsNum () |
| Get the Received Broadcast Packets Num. More... | |
| uint32_t | getForwardedPacketsNum () |
| Get the Received Broadcast Packets Num. More... | |
| uint32_t | getDataPacketsForMeNum () |
| Get the Data Packets For Me Num. More... | |
| uint32_t | getReceivedIAmViaNum () |
| Get the Received I Am Via Num. More... | |
| uint32_t | getDestinyUnreachableNum () |
| Get the Destiny Unreachable Num. More... | |
| uint32_t | getReceivedNotForMe () |
| Get the Received Not For Me. More... | |
Static Public Member Functions | |
| static LoraMesher & | getInstance () |
| Get the Instance of the LoRaMesher. More... | |
| template<typename T > | |
| static void | deletePacket (AppPacket< T > *p) |
| Delete the packet from memory. More... | |
LoRaMesher Library.
| void LoraMesher::begin | ( | float | freq = LM_BAND, |
| float | bw = LM_BANDWIDTH, |
||
| uint8_t | sf = LM_LORASF, |
||
| uint8_t | cr = LM_CODING_RATE, |
||
| uint8_t | syncWord = LM_SYNC_WORD, |
||
| int8_t | power = LM_POWER, |
||
| uint16_t | preambleLength = LM_PREAMBLE_LENGTH |
||
| ) |
LoRaMesh initialization method.
| freq | Carrier frequency in MHz. Allowed values range from 137.0 MHz to 1020.0 MHz. |
| bw | LoRa bandwidth in kHz. Allowed values are 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125, 250 and 500 kHz. |
| sf | LoRa spreading factor. Allowed values range from 6 to 12. |
| cr | LoRa coding rate denominator. Allowed values range from 5 to 8. |
| syncWord | LoRa sync word. Can be used to distinguish different networks. Note that value 0x34 is reserved for LoRaWAN networks. |
| power | Transmission output power in dBm. Allowed values range from 2 to 17 dBm. |
| preambleLength | Length of LoRa transmission preamble in symbols. The actual preamble length is 4.25 symbols longer than the set number. Allowed values range from 6 to 65535. |
Example of usage:
Then initialize:
Then for receiving app packets:
RadioLib reference begin code
|
inline |
Create a Packet And Send it.
| T |
| dst | Destination |
| payload | Payload of type T |
| payloadSize | Length of the payload in T |
|
inlinestatic |
Delete the packet from memory.
| T | Type of packet |
| p | Packet to delete |
|
inline |
Get the Data Packets For Me Num.
|
inline |
Get the Destiny Unreachable Num.
|
inline |
Get the Received Broadcast Packets Num.
|
inlinestatic |
Get the Instance of the LoRaMesher.
| uint16_t LoraMesher::getLocalAddress | ( | ) |
Get the Local Address.
|
inline |
Get the Next Application Packet.
| T | Type to be converted |
|
inline |
Get the Received Broadcast Packets Num.
|
inline |
Get the Received Data Packets Num.
|
inline |
Get the Received Hello Packets Num.
|
inline |
Get the Received I Am Via Num.
|
inline |
Get the Received Not For Me.
| size_t LoraMesher::getReceivedQueueSize | ( | ) |
Returns the number of packets inside the received packets queue.
End Region Routing Table Region PacketQueue
|
inline |
Get the Send Packets Num.
| size_t LoraMesher::getSendQueueSize | ( | ) |
Get the Send Queue Size. Packets that are waiting to be send.
|
inline |
Get the Sent Hello Packets Num.
| void LoraMesher::init | ( | void(*)(void *) | receiverFunction | ) |
Initialize the LoraMesher object.
| receiverFunction | Receiver function. It will be notified when data for the user is available. Example of usage: void processReceivedPackets(void* parameters) {
for (;;) {
//Wait for the notification of processReceivedPackets and enter blocking
ulTaskNotifyTake(pdPASS, portMAX_DELAY);
// Get the receivedAppPackets and get all the elements
while (radio.getReceivedQueueSize() > 0) {
//Get the first element inside the Received User Packets FiFo
AppPacket<DataPacket>* packet = radio.getNextAppPacket<DataPacket>();
//Do something with the packet, ex: print(packetReceived);
//Then delete the packet
radio.deletePacket(packet);
}
}
}
|
Then initialize:
| int LoraMesher::routingTableSize | ( | ) |
Returns the routing table size.
End Region Packet Service Region Routing Table
|
inline |
Send the payload reliable. It will wait for an ack of the destination.
| T |
| dst | Destination |
| payload | Payload of type T |
| payloadSize | Length of the payload in T |
| void LoraMesher::sendReliablePacket | ( | uint16_t | dst, |
| uint8_t * | payload, | ||
| uint32_t | payloadSize | ||
| ) |
Send the payload reliable. It will wait for an ACK back from the destination to send the next packet.
| dst | destination address |
| payload | payload to send |
| payloadSize | payload size to be send in Bytes |
|
inline |
Sets LoRa bandwidth. Allowed values are 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125, 250 and 500 kHz.
| bw | LoRa bandwidth to be set in kHz. |
|
inline |
Sets LoRa coding rate denominator. Allowed values range from 5 to 8.
| cr | LoRa coding rate denominator to be set. |
|
inline |
Set the Frequency. Allowed values range from 137.0 MHz to 525.0 MHz.
| freq | Frequency to be set in MHz |
|
inline |
Sets transmission output power. Allowed values range from -3 to 15 dBm (RFO pin) or +2 to +17 dBm (PA_BOOST pin). High power +20 dBm operation is also supported, on the PA_BOOST pin.
| power | Transmission output power in dBm. |
| useRfo | Whether to use the RFO (true) or the PA_BOOST (false) pin for the RF output. Defaults to PA_BOOST. |
|
inline |
Set the Receive App Data Task Handle, every time a received packet for this node is detected, this task will be notified.
| ReceiveAppDataTaskHandle | Task handle which will be notified every time a packet for the application is detected. |
|
inline |
Sets LoRa spreading factor. Allowed values range from 6 to 12.
| sf | LoRa spreading factor to be set. |