upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Classes | Public Member Functions | Static Public Attributes | List of all members

API for the SX1276 LoRa/FSK modem. More...

Detailed Description

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

Classes

class  ACFREF_BITS_T
 
class  ACGTHRESH1_BITS_T
 
class  ACGTHRESH2_BITS_T
 
class  ACGTHRESH3_BITS_T
 
class  ADDRESSFILTERING_T
 
class  AFCFEI_BITS_T
 
class  AUTORESTARTMODE_T
 
class  BITRATEFRAC_BITS_T
 
class  BW_T
 
class  CLKOUT_T
 
class  CODINGRATE_T
 
class  DCFREE_T
 
class  DETECTIONOPTIMIZE_T
 
class  DETECTOPTIMIZE_BITS_T
 
class  DIOMAPPING1_BITS_T
 
class  DIOMAPPING2_BITS_T
 
class  DIOMAPPING_T
 
class  FEIMSB_BITS_T
 
class  FIFOTHRESH_BITS_T
 
class  FROMPACKETRECEIVED_T
 
class  FROMRECEIVE_T
 
class  FROMRXTIMEOUT_T
 
class  FROMSTART_T
 
class  FSK_MODULATION_TYPE_T
 
class  HOPCHANNEL_BITS_T
 
class  IMAGECAL_BITS_T
 
class  INVERTIQ_BITS_T
 
class  IRQFLAGS1_BITS_T
 
class  IRQFLAGS2_BITS_T
 
class  LNA_BITS_T
 
class  LNABOOSTHF_T
 
class  LNABOOSTLF_T
 
class  LNAGAIN_T
 
class  LOR_DETECTIONTHRESHOLD_T
 
class  LOR_IRQFLAG_BITS_T
 
class  LOWBAT_BITS_T
 
class  LOWBATTRIM_T
 
class  MODE_T
 
class  MODEMCONFIG1_BITS_T
 
class  MODEMCONFIG2_BITS_T
 
class  MODEMCONFIG3_BITS_T
 
class  MODEMSTAT_BITS_T
 
class  MODSHAPING_T
 
class  OCP_BITS_T
 
class  OOKAVG_BITS_T
 
class  OOKAVGOFFSET_T
 
class  OOKAVGTHRESHFILT_T
 
class  OOKPEAK_BITS_T
 
class  OOKPEAKTHRESHDEC_T
 
class  OOKPEAKTHRESHSTEP_T
 
class  OOKTHRESHTYPE_T
 
class  OPMODE_BITS_T
 
class  OSC_BITS_T
 
class  PACKETCONFIG1_BITS_T
 
class  PACKETCONFIG2_BITS_T
 
class  PACONFIG_BITS_T
 
class  PADAC_BITS_T
 
class  PADAC_T
 
class  PARAMP_BITS_T
 
class  PARAMP_T
 
class  PLLHOP_BITS_T
 
class  PREAMBLEDETECT_BITS_T
 
class  PREAMBLEDETECTORSIZE_T
 
class  RADIO_EVENT_T
 
class  RADIO_MODEM_T
 
class  RSSICONFIG_BITS_T
 
class  RSSISMOOTHING_T
 
class  RXBW_BITS_T
 
class  RXBWEXP_T
 
class  RXBWMANT_T
 
class  RXCONFIG_BITS_T
 
class  SEQCONFIG1_BITS_T
 
class  SEQCONFIG2_BITS_T
 
class  SPREADINGFACTOR_T
 
class  SX1276_REGS_T
 
class  SYNCCONFIG_BITS_T
 
class  TCXO_BITS_T
 
class  TEMPTHRESHOLD_T
 
class  TIMERRESOL_BITS_T
 
class  TIMERRESOLUTION_T
 

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 ()
 

Static Public Attributes

static final short chipRevision = javaupm_sx1276JNI.SX1276_chipRevision_get()
 
static final double FXOSC_FREQ = javaupm_sx1276JNI.SX1276_FXOSC_FREQ_get()
 
static final double FXOSC_STEP = javaupm_sx1276JNI.SX1276_FXOSC_STEP_get()
 
static final int FIFO_SIZE = javaupm_sx1276JNI.SX1276_FIFO_SIZE_get()
 
static final int RF_MID_BAND_THRESH = javaupm_sx1276JNI.SX1276_RF_MID_BAND_THRESH_get()
 
static final int LOR_RSSI_OFFSET_HF = javaupm_sx1276JNI.SX1276_LOR_RSSI_OFFSET_HF_get()
 
static final int LOR_RSSI_OFFSET_LF = javaupm_sx1276JNI.SX1276_LOR_RSSI_OFFSET_LF_get()
 

Constructor & Destructor Documentation

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.

Parameters
chipRevchip revision, default is 0x12
busspi bus to use
csGPIO pin to use as SPI Chip Select
resetGPIO pin to use as reset (A0=GPIO14)
dio0GPIO pin to use as reset DIO0 intr
dio1GPIO pin to use as reset DIO1 intr
dio2GPIO pin to use as reset DIO2 intr
dio3GPIO pin to use as reset DIO3 intr
dio4GPIO pin to use as reset DIO4 intr
dio5GPIO pin to use as reset DIO5 intr

Member Function Documentation

short getChipVersion ( )

return the chip revision

Returns
the chip revision (usually 0x12)
short getRSSI ( SX1276.RADIO_MODEM_T  modem)

Return the current Received Signal Strength Indicator for the given modem

Parameters
modemOne of the MODEM_T values
String getRxBufferStr ( )

Upon a successful receive, this method can be used to retrieve the received packet.

Returns
The received buffer in a std::string
int getRxLen ( )

Upon a successful receive, this method can be used to retrieve the number of bytes received.

Returns
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.

Returns
RSSI value
int getRxSNR ( )

Upon a successful receive, this method can be used to retrieve the received packet's Signal to Noise (SNR) value.

Returns
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.

Parameters
modemOne of the MODEM_T values
freqThe channel to check
rssiThresholdThe RSSI threshold, over which the channel os considerd in use.
short readReg ( short  reg)

read a register

Parameters
regthe register to read
Returns
the value of the register
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().

Parameters
bufferThe buffer to send
timeoutThe timeout in milliseconds
Returns
one of the RADIO_EVENT_T values
void setChannel ( long  freq)

Set the frequency to transmit and receive on

Parameters
freqThe 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.

Parameters
modemOne of the MODEM_T values
void setOpMode ( SX1276.MODE_T  opMode)

Set the operating mode

Parameters
opModeOne 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.

Parameters
timeoutThe timeout in milliseconds
Returns
one of the RADIO_EVENT_T values
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.

Parameters
modemOne of the MODEM_T values
bandwidthThe bandwidth to use. Valid values are FSK : >= 2600 and <= 250000 Hz LoRa: [125 kHz, 250 kHz, 500 kHz]
datarateSets the Datarate FSK : 600..300000 bits/s LoRa: [6: 64, 7: 128, 8: 256, 9: 512, 10: 1024, 11: 2048, 12: 4096 chips]
coderateSets the coding rate (LoRa only) FSK : N/A ( set to 0 ) LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
bandwidthAfcSets the AFC Bandwidth (FSK only) FSK : >= 2600 and <= 250000 Hz LoRa: N/A ( set to 0 )
preambleLenSets the Preamble length FSK : Number of bytes LoRa: Length in symbols (the hardware adds 4 more symbols)
symbTimeoutSets the RxSingle timeout value (LoRa only) FSK : N/A ( set to 0 ) LoRa: timeout in symbols
fixLenFixed length packets [false: variable, true: fixed]
payloadLenSets payload length when fixed lenght is used
crcOnEnables/Disables the CRC [false: OFF, true: ON]
FreqHopOnEnables disables the intra-packet frequency hopping FSK : N/A ( set to 0 ) LoRa: [false: OFF, true: ON]
HopPeriodNumber of symbols bewteen each hop FSK : N/A ( set to 0 ) LoRa: Number of symbols
iqInvertedInverts IQ signals (LoRa only) FSK : N/A ( set to 0 ) LoRa: [false: not inverted, true: inverted]
rxContinuousSets 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.

Parameters
modemOne of the MODEM_T values
powerSets the output power [dBm]
fdevSets the frequency deviation (FSK only) FSK : [Hz] LoRa: 0
bandwidthSets the bandwidth (LoRa only) FSK : 0 LoRa: [125 kHz, 250 kHz, or 500 kHz]
datarateSets the Datarate FSK : 600..300000 bits/s LoRa: [6: 64, 7: 128, 8: 256, 9: 512, 10: 1024, 11: 2048, 12: 4096 chips]
coderateSets the coding rate (LoRa only) FSK : N/A ( set to 0 ) LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
preambleLenSets the preamble length FSK : Number of bytes LoRa: Length in symbols (the hardware adds 4 more symbols)
fixLenFixed length packets [false: variable, true: fixed]
crcOnEnables disables the CRC [false: OFF, true: ON]
FreqHopOnEnables disables the intra-packet frequency hopping FSK : N/A ( set to 0 ) LoRa: [false: OFF, true: ON]
HopPeriodNumber of symbols bewteen each hop FSK : N/A ( set to 0 ) LoRa: Number of symbols
iqInvertedInverts 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

Parameters
regthe register to write to
valthe value to write
Returns
true if successful, false otherwise

The documentation for this class was generated from the following file: