upm
0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
|
API for the SX1276 LoRa/FSK modem. More...
The SX1276 is a FSK/OOK/LoRa modem capable of both Low Frequency and High Frequency communication.
It requires a 3.3v power supply, do not use 5v.
Frequency Hopping Spread Spectrum (FHSS) is not currently supported.
While not all of the functionality of this device is supported initially, methods and register definitions are provided that should allow an end user to implement whatever features are required.
FSK send/receive example
LORA send/receive example
Public Member Functions | |
synchronized void | delete () |
SX1276 (short chipRev, int bus, int cs, int resetPin, int dio0, int dio1, int dio2, int dio3, int dio4, int dio5) | |
SX1276 (short chipRev, int bus, int cs, int resetPin, int dio0, int dio1, int dio2, int dio3, int dio4) | |
SX1276 (short chipRev, int bus, int cs, int resetPin, int dio0, int dio1, int dio2, int dio3) | |
SX1276 (short chipRev, int bus, int cs, int resetPin, int dio0, int dio1, int dio2) | |
SX1276 (short chipRev, int bus, int cs, int resetPin, int dio0, int dio1) | |
SX1276 (short chipRev, int bus, int cs, int resetPin, int dio0) | |
SX1276 (short chipRev, int bus, int cs, int resetPin) | |
SX1276 (short chipRev, int bus, int cs) | |
SX1276 (short chipRev, int bus) | |
SX1276 (short chipRev) | |
short | readReg (short reg) |
boolean | writeReg (short reg, short val) |
short | getChipVersion () |
void | reset () |
void | readFifo (byte[] buffer) |
void | writeFifo (byte[] buffer) |
void | setChannel (long freq) |
void | setOpMode (SX1276.MODE_T opMode) |
void | setModem (SX1276.RADIO_MODEM_T modem) |
void | setSleep () |
void | setStandby () |
short | getRSSI (SX1276.RADIO_MODEM_T modem) |
boolean | isChannelFree (SX1276.RADIO_MODEM_T modem, long freq, short rssiThresh) |
SX1276.RADIO_EVENT_T | sendStr (String buffer, int timeout) |
void | setRxConfig (SX1276.RADIO_MODEM_T modem, long bandwidth, long datarate, short coderate, long bandwidthAfc, int preambleLen, int symbTimeout, boolean fixLen, short payloadLen, boolean crcOn, boolean freqHopOn, short hopPeriod, boolean iqInverted, boolean rxContinuous) |
void | setTxConfig (SX1276.RADIO_MODEM_T modem, byte power, long fdev, long bandwidth, long datarate, short coderate, int preambleLen, boolean fixLen, boolean crcOn, boolean freqHopOn, short hopPeriod, boolean iqInverted) |
SX1276.RADIO_EVENT_T | setRx (long timeout) |
String | getRxBufferStr () |
int | getRxRSSI () |
int | getRxSNR () |
int | getRxLen () |
SX1276 | ( | short | chipRev, |
int | bus, | ||
int | cs, | ||
int | resetPin, | ||
int | dio0, | ||
int | dio1, | ||
int | dio2, | ||
int | dio3, | ||
int | dio4, | ||
int | dio5 | ||
) |
SX1276 constructor
Since this is a shield, you will not have much choice as to what pins are used.
chipRev | chip revision, default is 0x12 |
bus | spi bus to use |
cs | GPIO pin to use as SPI Chip Select |
reset | GPIO pin to use as reset (A0=GPIO14) |
dio0 | GPIO pin to use as reset DIO0 intr |
dio1 | GPIO pin to use as reset DIO1 intr |
dio2 | GPIO pin to use as reset DIO2 intr |
dio3 | GPIO pin to use as reset DIO3 intr |
dio4 | GPIO pin to use as reset DIO4 intr |
dio5 | GPIO pin to use as reset DIO5 intr |
short getChipVersion | ( | ) |
return the chip revision
short getRSSI | ( | SX1276.RADIO_MODEM_T | modem | ) |
Return the current Received Signal Strength Indicator for the given modem
modem | One of the MODEM_T values |
String getRxBufferStr | ( | ) |
Upon a successful receive, this method can be used to retrieve the received packet.
int getRxLen | ( | ) |
Upon a successful receive, this method can be used to retrieve the number of bytes received.
int getRxRSSI | ( | ) |
Upon a successful receive, this method can be used to retrieve the received packet's Received Signal Strength Indicator (RSSI) value.
int getRxSNR | ( | ) |
Upon a successful receive, this method can be used to retrieve the received packet's Signal to Noise (SNR) value.
boolean isChannelFree | ( | SX1276.RADIO_MODEM_T | modem, |
long | freq, | ||
short | rssiThresh | ||
) |
Check to see if a given channel is free by comparing the RSSI to the supplied threshold.
modem | One of the MODEM_T values |
freq | The channel to check |
rssiThreshold | The RSSI threshold, over which the channel os considerd in use. |
short readReg | ( | short | reg | ) |
read a register
reg | the register to read |
void reset | ( | ) |
reset the modem
SX1276.RADIO_EVENT_T sendStr | ( | String | buffer, |
int | timeout | ||
) |
Send the supplied string. This writes the string into the FIFO and places the modem in transmit mode (via setTx()). This is a wrapper around send().
buffer | The buffer to send |
timeout | The timeout in milliseconds |
void setChannel | ( | long | freq | ) |
Set the frequency to transmit and receive on
freq | The frequency to set |
void setModem | ( | SX1276.RADIO_MODEM_T | modem | ) |
Set the modem to access. This can be either the LORA or KSK/OOK modem.
modem | One of the MODEM_T values |
void setOpMode | ( | SX1276.MODE_T | opMode | ) |
Set the operating mode
opMode | One of the MODE_T values |
SX1276.RADIO_EVENT_T setRx | ( | long | timeout | ) |
Start a receive operation. The method will return when completed, either successfully, or in error (crc, or other issue). If completed successfully, the returned buffer can be read via getRxBuffer() or getRxBufferStr(). In addition, values for RSSI and SNR (Lora only) can be retrieved.
timeout | The timeout in milliseconds |
void setRxConfig | ( | SX1276.RADIO_MODEM_T | modem, |
long | bandwidth, | ||
long | datarate, | ||
short | coderate, | ||
long | bandwidthAfc, | ||
int | preambleLen, | ||
int | symbTimeout, | ||
boolean | fixLen, | ||
short | payloadLen, | ||
boolean | crcOn, | ||
boolean | freqHopOn, | ||
short | hopPeriod, | ||
boolean | iqInverted, | ||
boolean | rxContinuous | ||
) |
Set the receive configuration for a modem. It is important that both the receive and transmit configurations match in order for communication to work between two radios.
modem | One of the MODEM_T values |
bandwidth | The bandwidth to use. Valid values are FSK : >= 2600 and <= 250000 Hz LoRa: [125 kHz, 250 kHz, 500 kHz] |
datarate | Sets the Datarate FSK : 600..300000 bits/s LoRa: [6: 64, 7: 128, 8: 256, 9: 512, 10: 1024, 11: 2048, 12: 4096 chips] |
coderate | Sets the coding rate (LoRa only) FSK : N/A ( set to 0 ) LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] |
bandwidthAfc | Sets the AFC Bandwidth (FSK only) FSK : >= 2600 and <= 250000 Hz LoRa: N/A ( set to 0 ) |
preambleLen | Sets the Preamble length FSK : Number of bytes LoRa: Length in symbols (the hardware adds 4 more symbols) |
symbTimeout | Sets the RxSingle timeout value (LoRa only) FSK : N/A ( set to 0 ) LoRa: timeout in symbols |
fixLen | Fixed length packets [false: variable, true: fixed] |
payloadLen | Sets payload length when fixed lenght is used |
crcOn | Enables/Disables the CRC [false: OFF, true: ON] |
FreqHopOn | Enables disables the intra-packet frequency hopping FSK : N/A ( set to 0 ) LoRa: [false: OFF, true: ON] |
HopPeriod | Number of symbols bewteen each hop FSK : N/A ( set to 0 ) LoRa: Number of symbols |
iqInverted | Inverts IQ signals (LoRa only) FSK : N/A ( set to 0 ) LoRa: [false: not inverted, true: inverted] |
rxContinuous | Sets the reception in continuous mode [false: single mode, true: continuous mode] |
void setSleep | ( | ) |
Place the SX1276 into sleep mode
void setStandby | ( | ) |
Place the SX1276 into standby mode
void setTxConfig | ( | SX1276.RADIO_MODEM_T | modem, |
byte | power, | ||
long | fdev, | ||
long | bandwidth, | ||
long | datarate, | ||
short | coderate, | ||
int | preambleLen, | ||
boolean | fixLen, | ||
boolean | crcOn, | ||
boolean | freqHopOn, | ||
short | hopPeriod, | ||
boolean | iqInverted | ||
) |
Set the transmit configuration for a modem. It is important that both the receive and transmit configurations match in order for communication to work between two radios.
modem | One of the MODEM_T values |
power | Sets the output power [dBm] |
fdev | Sets the frequency deviation (FSK only) FSK : [Hz] LoRa: 0 |
bandwidth | Sets the bandwidth (LoRa only) FSK : 0 LoRa: [125 kHz, 250 kHz, or 500 kHz] |
datarate | Sets the Datarate FSK : 600..300000 bits/s LoRa: [6: 64, 7: 128, 8: 256, 9: 512, 10: 1024, 11: 2048, 12: 4096 chips] |
coderate | Sets the coding rate (LoRa only) FSK : N/A ( set to 0 ) LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] |
preambleLen | Sets the preamble length FSK : Number of bytes LoRa: Length in symbols (the hardware adds 4 more symbols) |
fixLen | Fixed length packets [false: variable, true: fixed] |
crcOn | Enables disables the CRC [false: OFF, true: ON] |
FreqHopOn | Enables disables the intra-packet frequency hopping FSK : N/A ( set to 0 ) LoRa: [false: OFF, true: ON] |
HopPeriod | Number of symbols bewteen each hop FSK : N/A ( set to 0 ) LoRa: Number of symbols |
iqInverted | Inverts IQ signals (LoRa only) FSK : N/A ( set to 0 ) LoRa: [false: not inverted, true: inverted] |
boolean writeReg | ( | short | reg, |
short | val | ||
) |
write to a register
reg | the register to write to |
val | the value to write |