#include "SX1278.h"Initialize the library with the specified frequency.
loRa.begin(433775000);frequency- frequency in Hz (433E6,868E6,915E6)
Override the default NSS, NRESET, and DIO0 pins used by the library. Must be called before LoRa.begin().
loRa.setPins(channel, reset, DIO_0);
channel- new slave channel pin to use, defaults CE0 to0reset- new reset pin to use, defaults to0dio0- new DIO0 pin to use, defaults to22. Must be interrupt capable via wiringPiISR.
This call is optional and only needs to be used if you need to change the default pins used.
The dio0 pin can be used for channel activity detection callback, transmission finish callback and/or receiving callback, check onTxDone, and onRxDone.
Start the sequence of sending a packet.
loRa << beginPacket;Write data to the packet. Each packet can contain up to 255 bytes.
loRa << "Welcome LoRa";or
send(buffer, length)buffer- char* data to write to packetlength- int size of data to write
char buffer[] = "message";
loRa.send(buffer, sizeof(buffer));End the sequence of sending a packet.
loRa << beginPacket << "welcom LoRa" << endPacket;WARNING: TxDone callback uses the interrupt pin on the dio0 check setPins function!
Register a callback function for when a packet transmission finish.
loRa.onRxDone(callback_Tx);
void callback_Tx() {
// ...
}callback_Tx- function to call when a packet transmission finish.
WARNING: Receive callback uses the interrupt pin on the dio0, check setPins function!
Register a callback function for when a packet is received.
loRa.onTxDone(callback_Rx);
void callback_Rx(char* payload, int rssi, float snr) {
// ...
}callback_Rx- function to call when a packet is received.payloadthe char*rssithe averaged RSSI of the last received packet (dBm).snrthe estimated SNR of the received packet in dB.
Puts the radio in continuous receive mode.
loRa.continuous_receive();Change the spreading factor of the radio.
loRa.set_sf(sf);
sf- spreading factor, defaults toSF12
Supported values are between SF7 and SF12.
Change the signal bandwidth of the radio.
loRa.set_bandwidth(bw);
bw- signal bandwidth in Hz, defaults toBW125.
Supported values are BW7_8, BW10_4, BW15_6, BW20_8, BW31_25, BW41_7, BW62_5, BW125, BW250, and BW500.
Change the coding rate of the radio.
loRa.set_errorcrc(cr);;
cr- denominator of the coding rate, defaults toCR5
Supported values are between CR5,CR6, CR7 and CR8, these correspond to coding rates of 4/5 4/6 4/7 and 4/8. The coding rate numerator is fixed at 4.
Change the preamble length of the radio.
loRa.set_preamble(int preambleLen);;
preambleLen- preamble length in symbols, defaults to6
Supported values are between 6 and 65535.
Change the sync word of the radio.
loRa.set_syncw(word);
word- byte value to use as the sync word, defaults to0x12