Upgrade RadioLib to 5.50
This commit is contained in:
parent
6bde2fb5f1
commit
6301fa4734
208 changed files with 15925 additions and 10099 deletions
|
|
@ -1 +0,0 @@
|
|||
{"type": "library", "name": "RadioLib", "version": "4.0.6", "spec": {"owner": "jgromes", "id": 5795, "name": "RadioLib", "requirements": null, "url": null}}
|
||||
|
|
@ -52,7 +52,7 @@ It is very easy to write code that machine can read. It is much harder to write
|
|||
// build a temporary buffer (first block)
|
||||
uint8_t* data = new uint8_t[len + 1];
|
||||
if(!data) {
|
||||
return(ERR_MEMORY_ALLOCATION_FAILED);
|
||||
return(RADIOLIB_ERR_MEMORY_ALLOCATION_FAILED);
|
||||
}
|
||||
|
||||
// read the received data (second block)
|
||||
|
|
@ -73,12 +73,12 @@ Sometimes, RadioLib might be used in critical applications where dynamic memory
|
|||
|
||||
```c++
|
||||
// build a temporary buffer
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
#if defined(RADIOLIB_STATIC_ONLY)
|
||||
uint8_t data[RADIOLIB_STATIC_ARRAY_SIZE + 1];
|
||||
#else
|
||||
uint8_t* data = new uint8_t[length + 1];
|
||||
if(!data) {
|
||||
return(ERR_MEMORY_ALLOCATION_FAILED);
|
||||
return(RADIOLIB_ERR_MEMORY_ALLOCATION_FAILED);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ Sometimes, RadioLib might be used in critical applications where dynamic memory
|
|||
readData(data, length);
|
||||
|
||||
// deallocate temporary buffer
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
#if !defined(RADIOLIB_STATIC_ONLY)
|
||||
delete[] data;
|
||||
#endif
|
||||
```
|
||||
|
|
@ -98,7 +98,7 @@ During development, it can be useful to have access to the low level drivers, su
|
|||
class Module {
|
||||
void publicMethod();
|
||||
|
||||
#ifndef RADIOLIB_GODMODE
|
||||
#if defined(RADIOLIB_GODMODE)
|
||||
private:
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -2,20 +2,18 @@
|
|||
|
||||
### _One radio library to rule them all!_
|
||||
|
||||
## Universal wireless communication library for Arduino
|
||||
## Universal wireless communication library for embedded devices
|
||||
|
||||
## See the [Wiki](https://github.com/jgromes/RadioLib/wiki) for further information. See the [GitHub Pages](https://jgromes.github.io/RadioLib) for detailed and up-to-date API reference.
|
||||
|
||||
RadioLib allows its users to integrate all sorts of different wireless communication modules, protocols and even digital modes into a single consistent system.
|
||||
Want to add a Bluetooth interface to your LoRa network? Sure thing! Do you just want to go really old-school and play around with radio teletype, slow-scan TV, or even Hellschreiber using nothing but a cheap radio module? Why not!
|
||||
|
||||
RadioLib was originally created as a driver for [__RadioShield__](https://github.com/jgromes/RadioShield), but it can be used to control as many different wireless modules as you like - or at least as many as your Arduino can handle!
|
||||
RadioLib was originally created as a driver for [__RadioShield__](https://github.com/jgromes/RadioShield), but it can be used to control as many different wireless modules as you like - or at least as many as your microcontroller can handle!
|
||||
|
||||
### Supported modules:
|
||||
* __CC1101__ FSK radio module
|
||||
* __ESP8266__ WiFi module
|
||||
* __HC05__ Bluetooth module
|
||||
* __JDY08__ BLE module
|
||||
* __LLCC68__ LoRa module
|
||||
* __nRF24L01__ 2.4 GHz module
|
||||
* __RF69__ FSK/OOK radio module
|
||||
* __RFM2x__ series FSK modules (RFM22, RM23)
|
||||
|
|
@ -25,14 +23,9 @@ RadioLib was originally created as a driver for [__RadioShield__](https://github
|
|||
* __SX127x__ series LoRa modules (SX1272, SX1273, SX1276, SX1277, SX1278, SX1279)
|
||||
* __SX128x__ series LoRa/GFSK/BLE/FLRC modules (SX1280, SX1281, SX1282)
|
||||
* __SX1231__ FSK/OOK radio module
|
||||
* __XBee__ modules (S2B)
|
||||
|
||||
### Supported protocols and digital modes:
|
||||
* __MQTT__ for modules:
|
||||
ESP8266
|
||||
* __HTTP__ for modules:
|
||||
ESP8266
|
||||
* __AX.25__ using 2-FSK or AFSK for modules:
|
||||
* [__AX.25__](https://www.sigidwiki.com/wiki/PACKET) using 2-FSK or AFSK for modules:
|
||||
SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, RFM2x and Si443x
|
||||
* [__RTTY__](https://www.sigidwiki.com/wiki/RTTY) using 2-FSK or AFSK for modules:
|
||||
SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x
|
||||
|
|
@ -42,8 +35,12 @@ SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x
|
|||
SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, RFM2x and Si443x
|
||||
* [__Hellschreiber__](https://www.sigidwiki.com/wiki/Hellschreiber) using 2-FSK or AFSK for modules:
|
||||
SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x
|
||||
* [__APRS__](https://www.sigidwiki.com/wiki/APRS) using AFSK for modules:
|
||||
SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x
|
||||
* [__POCSAG__](https://www.sigidwiki.com/wiki/POCSAG) using 2-FSK for modules:
|
||||
SX127x, RFM9x, RF69, SX1231, CC1101, nRF24L01, RFM2x and Si443x
|
||||
|
||||
### Supported platforms:
|
||||
### Supported Arduino platforms:
|
||||
* __Arduino__
|
||||
* [__AVR__](https://github.com/arduino/ArduinoCore-avr) - Arduino Uno, Mega, Leonardo, Pro Mini, Nano etc.
|
||||
* [__mbed__](https://github.com/arduino/ArduinoCore-mbed) - Arduino Nano 33 BLE and Arduino Portenta H7
|
||||
|
|
@ -69,12 +66,25 @@ SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x
|
|||
* [__STM32__ (official core)](https://github.com/stm32duino/Arduino_Core_STM32) - STM32 Nucleo, Discovery, Maple, BluePill, BlackPill etc.
|
||||
* [__STM32__ (unofficial core)](https://github.com/rogerclarkmelbourne/Arduino_STM32) - STM32F1 and STM32F4-based boards
|
||||
|
||||
The list above is by no means exhaustive. Most of RadioLib code is independent of the used platform, so as long as your board is running some Arduino-compatible core, RadioLib should work. Compilation of all examples is tested for all platforms prior to releasing new version.
|
||||
* __MCUdude__
|
||||
* [__MegaCoreX__](https://github.com/MCUdude/MegaCoreX) - megaAVR-0 series (ATmega4809, ATmega3209 etc.)
|
||||
* [__MegaCore__](https://github.com/MCUdude/MegaCore) - AVR (ATmega1281, ATmega640 etc.)
|
||||
|
||||
* __Raspberry Pi__
|
||||
* [__RP2040__](https://github.com/arduino/ArduinoCore-mbed) - Raspberry Pi Pico and Arduino Nano RP2040 Connect
|
||||
* [__Raspberry Pi__](https://github.com/me-no-dev/RasPiArduino) - Arduino framework for RaspberryPI
|
||||
|
||||
* __Heltec__
|
||||
* [__CubeCell__](https://github.com/HelTecAutomation/CubeCell-Arduino) - ASR650X series (CubeCell-Board, CubeCell-Capsule, CubeCell-Module etc.)
|
||||
|
||||
* __PJRC__
|
||||
* [__Teensy__](https://github.com/PaulStoffregen/cores) - Teensy 2.x, 3.x and 4.x boards
|
||||
|
||||
The list above is by no means exhaustive - RadioLib code is independent of the used platform! Compilation of all examples is tested for all platforms officially supported prior to releasing new version.
|
||||
|
||||
### In development:
|
||||
* __SIM800C__ GSM module
|
||||
* __AX5243__ FSK module
|
||||
* __LoRaWAN__ protocol for SX127x, RFM9x and SX126x modules
|
||||
* __APRS__ protocol for all the modules that can transmit AX.25
|
||||
* ___and more!___
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
|
@ -86,4 +96,4 @@ First of all, take a look at the [examples](https://github.com/jgromes/RadioLib/
|
|||
The fastest way to get help is by creating an [issue](https://github.com/jgromes/RadioLib/issues/new/choose) using the appropriate template. It is also highly recommended to try running the examples first - their functionality is tested from time to time and they should work. Finally, RadioLib is still under development, which means that sometimes, backwards-incompatible changes might be introduced. Though these are kept at minimum, sometimes it is unavoidable. You can check the [release changelog](https://github.com/jgromes/RadioLib/releases) to find out if there's been such a major change recently.
|
||||
|
||||
### RadioLib doesn't support my module! What should I do?
|
||||
Start by creating new issue (if it doesn't exist yet). If you have some experience with Arduino and C/C++ in general, you can try to add the support yourself! Use the template files in `/extras/` folder to get started. This is by far the fastest way to implement new modules into RadioLib, since I can't be working on everything all the time. If you don't trust your programming skills enough to have a go at it yourself, don't worry. I will try to implement all requested modules, but it will take me a while.
|
||||
Start by creating new issue (if it doesn't exist yet). If you have some experience with microcontrollers and C/C++ in general, you can try to add the support yourself! Use the template files in `/extras/` folder to get started. This is by far the fastest way to implement new modules into RadioLib, since I can't be working on everything all the time. If you don't trust your programming skills enough to have a go at it yourself, don't worry. I will try to implement all requested modules, but it will take me a while.
|
||||
|
|
|
|||
|
|
@ -51,7 +51,18 @@ void setup() {
|
|||
// (RF69, CC1101,, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize AFSK client
|
||||
Serial.print(F("[AFSK] Initializing ... "));
|
||||
state = audio.begin();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
|
|||
|
|
@ -95,16 +95,16 @@
|
|||
#define NOTE_DS8 4978
|
||||
#define REST 0
|
||||
|
||||
// notes of the moledy followed by the duration.
|
||||
// notes of the melody followed by the duration.
|
||||
// a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on
|
||||
// !!negative numbers are used to represent dotted notes,
|
||||
// so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!!
|
||||
int melody[] = {
|
||||
|
||||
// Darth Vader theme (Imperial March) - Star wars
|
||||
|
||||
// Darth Vader theme (Imperial March) - Star wars
|
||||
// Score available at https://musescore.com/user/202909/scores/1141521
|
||||
// The tenor saxophone part was used
|
||||
|
||||
|
||||
NOTE_A4,-4, NOTE_A4,-4, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_F4,8, REST,8,
|
||||
NOTE_A4,-4, NOTE_A4,-4, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_F4,8, REST,8,
|
||||
NOTE_A4,4, NOTE_A4,4, NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16,
|
||||
|
|
@ -112,17 +112,17 @@ int melody[] = {
|
|||
NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16, NOTE_A4,2,//4
|
||||
NOTE_E5,4, NOTE_E5,4, NOTE_E5,4, NOTE_F5,-8, NOTE_C5,16,
|
||||
NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16, NOTE_A4,2,
|
||||
|
||||
NOTE_A5,4, NOTE_A4,-8, NOTE_A4,16, NOTE_A5,4, NOTE_GS5,-8, NOTE_G5,16, //7
|
||||
|
||||
NOTE_A5,4, NOTE_A4,-8, NOTE_A4,16, NOTE_A5,4, NOTE_GS5,-8, NOTE_G5,16, //7
|
||||
NOTE_DS5,16, NOTE_D5,16, NOTE_DS5,8, REST,8, NOTE_A4,8, NOTE_DS5,4, NOTE_D5,-8, NOTE_CS5,16,
|
||||
|
||||
NOTE_C5,16, NOTE_B4,16, NOTE_C5,16, REST,8, NOTE_F4,8, NOTE_GS4,4, NOTE_F4,-8, NOTE_A4,-16,//9
|
||||
NOTE_C5,4, NOTE_A4,-8, NOTE_C5,16, NOTE_E5,2,
|
||||
|
||||
NOTE_A5,4, NOTE_A4,-8, NOTE_A4,16, NOTE_A5,4, NOTE_GS5,-8, NOTE_G5,16, //7
|
||||
NOTE_A5,4, NOTE_A4,-8, NOTE_A4,16, NOTE_A5,4, NOTE_GS5,-8, NOTE_G5,16, //7
|
||||
NOTE_DS5,16, NOTE_D5,16, NOTE_DS5,8, REST,8, NOTE_A4,8, NOTE_DS5,4, NOTE_D5,-8, NOTE_CS5,16,
|
||||
|
||||
NOTE_C5,16, NOTE_B4,16, NOTE_C5,16, REST,8, NOTE_F4,8, NOTE_GS4,4, NOTE_F4,-8, NOTE_A4,-16,//9
|
||||
NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16, NOTE_A4,2,
|
||||
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,10 +46,21 @@ void setup() {
|
|||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for AFSK
|
||||
// (RF69, CC1101,, Si4432 etc.), use the basic begin() method
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize AFSK client
|
||||
Serial.print(F("[AFSK] Initializing ... "));
|
||||
state = audio.begin();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -61,12 +72,14 @@ void setup() {
|
|||
void loop() {
|
||||
// AFSKClient can be used to transmit tones,
|
||||
// same as Arduino tone() function
|
||||
|
||||
|
||||
// 400 Hz tone
|
||||
Serial.print(F("[AFSK] 400 Hz tone ... "));
|
||||
audio.tone(400);
|
||||
delay(1000);
|
||||
|
||||
// silence
|
||||
Serial.println(F("done!"));
|
||||
audio.noTone();
|
||||
delay(1000);
|
||||
|
||||
|
|
|
|||
101
lib/RadioLib/examples/AFSK/AFSK_Tone_AM/AFSK_Tone_AM.ino
Normal file
101
lib/RadioLib/examples/AFSK/AFSK_Tone_AM/AFSK_Tone_AM.ino
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
RadioLib AM-modulated AFSK Example
|
||||
|
||||
This example shows hot to send AM-modulated
|
||||
audio FSK tones using SX1278's OOK modem.
|
||||
|
||||
Other modules that can be used for AFSK:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
SX1278 radio = new Module(10, 2, 9);
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// this requires connection to the module direct
|
||||
// input pin, here connected to Arduino pin 5
|
||||
// SX127x/RFM9x: DIO2
|
||||
// RF69: DIO2
|
||||
// SX1231: DIO2
|
||||
// CC1101: GDO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for AFSK
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize AFSK client
|
||||
Serial.print(F("[AFSK] Initializing ... "));
|
||||
state = audio.begin();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// after that, set mode to OOK
|
||||
Serial.print(F("[SX1278] Switching to OOK ... "));
|
||||
state = radio.setOOK(true);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// AFSKClient can be used to transmit tones,
|
||||
// same as Arduino tone() function
|
||||
|
||||
// 400 Hz tone
|
||||
Serial.print(F("[AFSK] 400 Hz tone ... "));
|
||||
audio.tone(400);
|
||||
delay(1000);
|
||||
|
||||
// silence
|
||||
Serial.println(F("done!"));
|
||||
audio.noTone();
|
||||
delay(1000);
|
||||
|
||||
// AFSKClient can also be used to transmit HAM-friendly
|
||||
// RTTY, Morse code, Hellschreiber, SSTV and AX.25.
|
||||
// Details on how to use AFSK are in the example
|
||||
// folders for each of the above modes.
|
||||
|
||||
// CAUTION: Unlike standard AFSK, the result when using OOK
|
||||
// must be demodulated as AM!
|
||||
}
|
||||
111
lib/RadioLib/examples/APRS/APRS_MicE/APRS_MicE.ino
Normal file
111
lib/RadioLib/examples/APRS/APRS_MicE/APRS_MicE.ino
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
RadioLib APRS Mic-E Example
|
||||
|
||||
This example sends APRS position reports
|
||||
encoded in the Mic-E format using SX1278's
|
||||
FSK modem. The data is modulated as AFSK
|
||||
at 1200 baud using Bell 202 tones.
|
||||
|
||||
DO NOT transmit in APRS bands unless
|
||||
you have a ham radio license!
|
||||
|
||||
Other modules that can be used for APRS:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- nRF24
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
// create AX.25 client instance using the AFSK instance
|
||||
AX25Client ax25(&audio);
|
||||
|
||||
// create APRS client instance using the AX.25 client
|
||||
APRSClient aprs(&ax25);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278
|
||||
// NOTE: moved to ISM band on purpose
|
||||
// DO NOT transmit in APRS bands without ham radio license!
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for AX.25
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize AX.25 client
|
||||
Serial.print(F("[AX.25] Initializing ... "));
|
||||
// source station callsign: "N7LEM"
|
||||
// source station SSID: 0
|
||||
// preamble length: 8 bytes
|
||||
state = ax25.begin("N7LEM");
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize APRS client
|
||||
Serial.print(F("[APRS] Initializing ... "));
|
||||
// symbol: '>' (car)
|
||||
state = aprs.begin('>');
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[APRS] Sending Mic-E position ... "));
|
||||
int state = aprs.sendMicE(49.1945, 16.6000, 120, 10, RADIOLIB_APRS_MIC_E_TYPE_EN_ROUTE);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// wait one minute before transmitting again
|
||||
delay(60000);
|
||||
}
|
||||
123
lib/RadioLib/examples/APRS/APRS_Position/APRS_Position.ino
Normal file
123
lib/RadioLib/examples/APRS/APRS_Position/APRS_Position.ino
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
RadioLib APRS Position Example
|
||||
|
||||
This example sends APRS position reports
|
||||
using SX1278's FSK modem. The data is
|
||||
modulated as AFSK at 1200 baud using Bell
|
||||
202 tones.
|
||||
|
||||
DO NOT transmit in APRS bands unless
|
||||
you have a ham radio license!
|
||||
|
||||
Other modules that can be used for APRS:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- nRF24
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
// create AX.25 client instance using the AFSK instance
|
||||
AX25Client ax25(&audio);
|
||||
|
||||
// create APRS client instance using the AX.25 client
|
||||
APRSClient aprs(&ax25);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278
|
||||
// NOTE: moved to ISM band on purpose
|
||||
// DO NOT transmit in APRS bands without ham radio license!
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK(434.0);
|
||||
|
||||
// when using one of the non-LoRa modules for AX.25
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize AX.25 client
|
||||
Serial.print(F("[AX.25] Initializing ... "));
|
||||
// source station callsign: "N7LEM"
|
||||
// source station SSID: 0
|
||||
// preamble length: 8 bytes
|
||||
state = ax25.begin("N7LEM");
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize APRS client
|
||||
Serial.print(F("[APRS] Initializing ... "));
|
||||
// symbol: '>' (car)
|
||||
state = aprs.begin('>');
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[APRS] Sending position ... "));
|
||||
|
||||
// send a location without message or timestamp
|
||||
int state = aprs.sendPosition("N0CALL", 0, "4911.67N", "01635.96E");
|
||||
delay(500);
|
||||
|
||||
// send a location with message and without timestamp
|
||||
state |= aprs.sendPosition("N0CALL", 0, "4911.67N", "01635.96E", "I'm here!");
|
||||
delay(500);
|
||||
|
||||
// send a location with message and timestamp
|
||||
state |= aprs.sendPosition("N0CALL", 0, "4911.67N", "01635.96E", "I'm here!", "093045z");
|
||||
delay(500);
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// wait one minute before transmitting again
|
||||
delay(60000);
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ void setup() {
|
|||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -72,7 +72,7 @@ void setup() {
|
|||
// source station SSID: 0
|
||||
// preamble length: 8 bytes
|
||||
state = ax25.begin("N7LEM");
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -90,14 +90,14 @@ void loop() {
|
|||
// control field: UI, P/F not used, unnumbered frame
|
||||
// protocol identifier: no layer 3 protocol implemented
|
||||
// information field: "Hello World!"
|
||||
AX25Frame frameUI("NJ7P", 0, "N7LEM", 0, AX25_CONTROL_U_UNNUMBERED_INFORMATION |
|
||||
AX25_CONTROL_POLL_FINAL_DISABLED | AX25_CONTROL_UNNUMBERED_FRAME,
|
||||
AX25_PID_NO_LAYER_3, "Hello World (unnumbered)!");
|
||||
AX25Frame frameUI("NJ7P", 0, "N7LEM", 0, RADIOLIB_AX25_CONTROL_U_UNNUMBERED_INFORMATION |
|
||||
RADIOLIB_AX25_CONTROL_POLL_FINAL_DISABLED | RADIOLIB_AX25_CONTROL_UNNUMBERED_FRAME,
|
||||
RADIOLIB_AX25_PID_NO_LAYER_3, "Hello World (unnumbered)!");
|
||||
|
||||
// send the frame
|
||||
Serial.print(F("[AX.25] Sending UI frame ... "));
|
||||
int state = ax25.sendFrame(&frameUI);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
@ -116,8 +116,8 @@ void loop() {
|
|||
// source station callsign: "N7LEM"
|
||||
// source station SSID: 0
|
||||
// control field: RR, P/F not used, supervisory frame
|
||||
AX25Frame frameRR("NJ7P", 0, "N7LEM", 0, AX25_CONTROL_S_RECEIVE_READY |
|
||||
AX25_CONTROL_POLL_FINAL_DISABLED | AX25_CONTROL_SUPERVISORY_FRAME);
|
||||
AX25Frame frameRR("NJ7P", 0, "N7LEM", 0, RADIOLIB_AX25_CONTROL_S_RECEIVE_READY |
|
||||
RADIOLIB_AX25_CONTROL_POLL_FINAL_DISABLED | RADIOLIB_AX25_CONTROL_SUPERVISORY_FRAME);
|
||||
|
||||
// set receive sequence number (0 - 7)
|
||||
frameRR.setRecvSequence(0);
|
||||
|
|
@ -125,7 +125,7 @@ void loop() {
|
|||
// send the frame
|
||||
Serial.print(F("[AX.25] Sending RR frame ... "));
|
||||
state = ax25.sendFrame(&frameRR);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
@ -146,8 +146,8 @@ void loop() {
|
|||
// control field: P/F not used, information frame
|
||||
// protocol identifier: no layer 3 protocol implemented
|
||||
// information field: "Hello World (numbered)!"
|
||||
AX25Frame frameI("NJ7P", 0, "N7LEM", 0, AX25_CONTROL_POLL_FINAL_DISABLED |
|
||||
AX25_CONTROL_INFORMATION_FRAME, AX25_PID_NO_LAYER_3,
|
||||
AX25Frame frameI("NJ7P", 0, "N7LEM", 0, RADIOLIB_AX25_CONTROL_POLL_FINAL_DISABLED |
|
||||
RADIOLIB_AX25_CONTROL_INFORMATION_FRAME, RADIOLIB_AX25_PID_NO_LAYER_3,
|
||||
"Hello World (numbered)!");
|
||||
|
||||
// set receive sequence number (0 - 7)
|
||||
|
|
@ -159,7 +159,7 @@ void loop() {
|
|||
// send the frame
|
||||
Serial.print(F("[AX.25] Sending I frame ... "));
|
||||
state = ax25.sendFrame(&frameI);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -44,14 +44,13 @@ void setup() {
|
|||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 1.2 kbps (1200 baud 2-FSK AX.25)
|
||||
// frequency deviation: 0.5 kHz (1200 baud 2-FSK AX.25)
|
||||
int state = radio.beginFSK(434.0, 1.2, 0.5);
|
||||
int state = radio.beginFSK(434.0, 1.2);
|
||||
|
||||
// when using one of the non-LoRa modules for AX.25
|
||||
// (RF69, CC1101,, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -65,7 +64,7 @@ void setup() {
|
|||
// source station SSID: 0
|
||||
// preamble length: 8 bytes
|
||||
state = ax25.begin("N7LEM");
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -80,7 +79,7 @@ void loop() {
|
|||
// destination station callsign: "NJ7P"
|
||||
// destination station SSID: 0
|
||||
int state = ax25.transmit("Hello World!", "NJ7P");
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void setup() {
|
|||
// (RF69, CC1101,, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -67,13 +67,29 @@ void setup() {
|
|||
// source station SSID: 0
|
||||
// preamble length: 8 bytes
|
||||
state = ax25.begin("N7LEM");
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// Sometimes, it may be required to adjust audio
|
||||
// frequencies to match the expected 1200/2200 Hz tones.
|
||||
// The following method will offset mark frequency by
|
||||
// 100 Hz up and space frequency by 100 Hz down
|
||||
/*
|
||||
Serial.print(F("[AX.25] Setting correction ... "));
|
||||
state = ax25.setCorrection(100, -100);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
|
@ -82,7 +98,7 @@ void loop() {
|
|||
// destination station callsign: "NJ7P"
|
||||
// destination station SSID: 0
|
||||
int state = ax25.transmit("Hello World!", "NJ7P");
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ void setup() {
|
|||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -58,7 +58,7 @@ void loop() {
|
|||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
@ -77,7 +77,11 @@ void loop() {
|
|||
Serial.print(F("[CC1101] LQI:\t\t"));
|
||||
Serial.println(radio.getLQI());
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void setup() {
|
|||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -51,7 +51,7 @@ void setup() {
|
|||
// 0xFF will be used.
|
||||
Serial.print(F("[CC1101] Setting node address ... "));
|
||||
state = radio.setNodeAddress(0x01, 1);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -65,7 +65,7 @@ void setup() {
|
|||
/*
|
||||
Serial.print(F("[CC1101] Disabling address filtering ... "));
|
||||
state == radio.disableAddressFiltering();
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -88,7 +88,7 @@ void loop() {
|
|||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ void loop() {
|
|||
Serial.print(F("[CC1101] LQI:\t\t"));
|
||||
Serial.println(radio.getLQI());
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ void setup() {
|
|||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -54,7 +54,7 @@ void setup() {
|
|||
// start listening for packets
|
||||
Serial.print(F("[CC1101] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -82,6 +82,9 @@ volatile bool enableInterrupt = true;
|
|||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
|
|
@ -112,7 +115,7 @@ void loop() {
|
|||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[CC1101] Received packet!"));
|
||||
|
||||
|
|
@ -131,7 +134,7 @@ void loop() {
|
|||
Serial.print(F("[CC1101] LQI:\t\t"));
|
||||
Serial.println(radio.getLQI());
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ CC1101 radio1 = new Module(10, 2, RADIOLIB_NC, 3);
|
|||
// GDO0 pin: 4
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 5 (optional)
|
||||
CC1101 radio2 = new Module(9, 4, RADIOLIB_NC, 53);
|
||||
CC1101 radio2 = new Module(9, 4, RADIOLIB_NC, 5);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
|
|
@ -45,7 +45,7 @@ void setup() {
|
|||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
int state = radio1.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -62,7 +62,7 @@ void setup() {
|
|||
// output power: 7 dBm
|
||||
// preamble length: 32 bits
|
||||
state = radio2.begin(434.0, 32.0, 60.0, 250.0, 7, 32);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -74,42 +74,42 @@ void setup() {
|
|||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 433.5 MHz
|
||||
if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||
if (radio1.setFrequency(433.5) == RADIOLIB_ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("[CC1101] Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bit rate to 100.0 kbps
|
||||
state = radio1.setBitRate(100.0);
|
||||
if (state == ERR_INVALID_BIT_RATE) {
|
||||
if (state == RADIOLIB_ERR_INVALID_BIT_RATE) {
|
||||
Serial.println(F("[CC1101] Selected bit rate is invalid for this module!"));
|
||||
while (true);
|
||||
} else if (state == ERR_INVALID_BIT_RATE_BW_RATIO) {
|
||||
} else if (state == RADIOLIB_ERR_INVALID_BIT_RATE_BW_RATIO) {
|
||||
Serial.println(F("[CC1101] Selected bit rate to bandwidth ratio is invalid!"));
|
||||
Serial.println(F("[CC1101] Increase receiver bandwidth to set this bit rate."));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set receiver bandwidth to 250.0 kHz
|
||||
if (radio1.setRxBandwidth(250.0) == ERR_INVALID_RX_BANDWIDTH) {
|
||||
if (radio1.setRxBandwidth(250.0) == RADIOLIB_ERR_INVALID_RX_BANDWIDTH) {
|
||||
Serial.println(F("[CC1101] Selected receiver bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set allowed frequency deviation to 10.0 kHz
|
||||
if (radio1.setFrequencyDeviation(10.0) == ERR_INVALID_FREQUENCY_DEVIATION) {
|
||||
if (radio1.setFrequencyDeviation(10.0) == RADIOLIB_ERR_INVALID_FREQUENCY_DEVIATION) {
|
||||
Serial.println(F("[CC1101] Selected frequency deviation is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set output power to 5 dBm
|
||||
if (radio1.setOutputPower(5) == ERR_INVALID_OUTPUT_POWER) {
|
||||
if (radio1.setOutputPower(5) == RADIOLIB_ERR_INVALID_OUTPUT_POWER) {
|
||||
Serial.println(F("[CC1101] Selected output power is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// 2 bytes can be set as sync word
|
||||
if (radio1.setSyncWord(0x01, 0x23) == ERR_INVALID_SYNC_WORD) {
|
||||
if (radio1.setSyncWord(0x01, 0x23) == RADIOLIB_ERR_INVALID_SYNC_WORD) {
|
||||
Serial.println(F("[CC1101] Selected sync word is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
// CS pin: 10
|
||||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
// GDO2 pin: 3
|
||||
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
|
||||
// or using RadioShield
|
||||
|
|
@ -34,7 +34,7 @@ void setup() {
|
|||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -55,11 +55,11 @@ void loop() {
|
|||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 64 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void setup() {
|
|||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -51,7 +51,7 @@ void setup() {
|
|||
// 0xFF will be used.
|
||||
Serial.print(F("[CC1101] Setting node address ... "));
|
||||
state = radio.setNodeAddress(0x01, 1);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -65,7 +65,7 @@ void setup() {
|
|||
/*
|
||||
Serial.print(F("[CC1101] Disabling address filtering ... "));
|
||||
state == radio.disableAddressFiltering();
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -87,11 +87,11 @@ void loop() {
|
|||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 255 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
// CS pin: 10
|
||||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
// GDO2 pin: 3
|
||||
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
|
||||
// or using RadioShield
|
||||
|
|
@ -30,7 +30,7 @@ CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
|
|||
//CC1101 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = ERR_NONE;
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
|
@ -38,7 +38,7 @@ void setup() {
|
|||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -48,7 +48,10 @@ void setup() {
|
|||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
radio.setGdo0Action(setFlag);
|
||||
// NOTE: Unlike other modules (such as SX127x),
|
||||
// different GDOx pins are used for
|
||||
// transmit and receive interrupts!
|
||||
radio.setGdo2Action(setFlag);
|
||||
|
||||
// start transmitting the first packet
|
||||
Serial.print(F("[CC1101] Sending first packet ... "));
|
||||
|
|
@ -75,6 +78,9 @@ volatile bool enableInterrupt = true;
|
|||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
|
|
@ -95,7 +101,7 @@ void loop() {
|
|||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == ERR_NONE) {
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
|
|
@ -109,6 +115,11 @@ void loop() {
|
|||
|
||||
}
|
||||
|
||||
// clean up after transmission is finished
|
||||
// this will ensure transmitter is disabled,
|
||||
// RF switch is powered down etc.
|
||||
radio.finishTransmit();
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
|
|
|
|||
142
lib/RadioLib/examples/FSK4/FSK4_Transmit/FSK4_Transmit.ino
Normal file
142
lib/RadioLib/examples/FSK4/FSK4_Transmit/FSK4_Transmit.ino
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
RadioLib FSK4 Transmit Example
|
||||
|
||||
This example sends an example FSK-4 'Horus Binary' message
|
||||
using SX1278's FSK modem.
|
||||
|
||||
This signal can be demodulated using a SSB demodulator (SDR or otherwise),
|
||||
and horusdemodlib: https://github.com/projecthorus/horusdemodlib/wiki
|
||||
|
||||
Other modules that can be used for FSK4:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- SX126x
|
||||
- nRF24
|
||||
- Si443x/RFM2x
|
||||
- SX128x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create FSK4 client instance using the FSK module
|
||||
FSK4Client fsk4(&radio);
|
||||
|
||||
// An encoded Horus Binary telemetry packet.
|
||||
// Refer here for packet format information:
|
||||
// https://github.com/projecthorus/horusdemodlib/wiki/2---Modem-Details#horus-binary-v1-mode-4-fsk
|
||||
// After demodulation, deinterleaving, and descrambling, this results in a packet:
|
||||
// 00000001172D0000000000000000D20463010AFF2780
|
||||
// This decodes to the Habitat-compatible telemetry string:
|
||||
// $$4FSKTEST,0,01:23:45,0.00000,0.00000,1234,99,1,10,5.00*ABCD
|
||||
int horusPacketLen = 45;
|
||||
byte horusPacket[] = {
|
||||
0x45, 0x24, 0x24, 0x48, 0x2F, 0x12, 0x16, 0x08, 0x15, 0xC1,
|
||||
0x49, 0xB2, 0x06, 0xFC, 0x92, 0xEB, 0x93, 0xD7, 0xEE, 0x5D,
|
||||
0x35, 0xA0, 0x91, 0xDA, 0x8D, 0x5F, 0x85, 0x6B, 0x63, 0x03,
|
||||
0x6B, 0x60, 0xEA, 0xFE, 0x55, 0x9D, 0xF1, 0xAB, 0xE5, 0x5E,
|
||||
0xDB, 0x7C, 0xDB, 0x21, 0x5A, 0x19
|
||||
};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for FSK4
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize FSK4 client
|
||||
// NOTE: FSK4 frequency shift will be rounded
|
||||
// to the nearest multiple of frequency step size.
|
||||
// The exact value depends on the module:
|
||||
// SX127x/RFM9x - 61 Hz
|
||||
// RF69 - 61 Hz
|
||||
// CC1101 - 397 Hz
|
||||
// SX126x - 1 Hz
|
||||
// nRF24 - 1000000 Hz
|
||||
// Si443x/RFM2x - 156 Hz
|
||||
// SX128x - 198 Hz
|
||||
Serial.print(F("[FSK4] Initializing ... "));
|
||||
// low ("space") frequency: 434.0 MHz
|
||||
// frequency shift: 270 Hz
|
||||
// baud rate: 100 baud
|
||||
state = fsk4.begin(434.0, 270, 100);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// sometimes, it may be needed to set some manual corrections
|
||||
// this can be done for tone frequencies,
|
||||
// as well as tone lengths
|
||||
/*
|
||||
// set frequency shift offsets to -120, 60, 0 and 60 Hz and decrease tone length to 95%
|
||||
int offsets[4] = { -120, -60, 0, 60 };
|
||||
Serial.print(F("[FSK4] Setting corrections ... "));
|
||||
state = fsk4.setCorrection(offsets, 0.95);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[FSK4] Sending FSK4 data packet ... "));
|
||||
|
||||
// send out idle condition for 1000 ms
|
||||
fsk4.idle();
|
||||
delay(1000);
|
||||
|
||||
// FSK4Client supports binary write methods
|
||||
|
||||
// send some bytes as a preamble
|
||||
for(int i = 0; i < 8; i++) {
|
||||
fsk4.write(0x1B);
|
||||
}
|
||||
|
||||
// now send the encoded packet
|
||||
fsk4.write(horusPacket, horusPacketLen);
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
RadioLib FSK4 Transmit AFSK Example
|
||||
|
||||
This example sends an example FSK-4 'Horus Binary' message
|
||||
using SX1278's FSK modem. The data is modulated as AFSK.
|
||||
|
||||
This signal can be demodulated using an FM demodulator (SDR or otherwise),
|
||||
and horusdemodlib: https://github.com/projecthorus/horusdemodlib/wiki
|
||||
|
||||
Other modules that can be used for FSK4:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
// create FSK4 client instance using the AFSK instance
|
||||
FSK4Client fsk4(&audio);
|
||||
|
||||
// An encoded Horus Binary telemetry packet.
|
||||
// Refer here for packet format information:
|
||||
// https://github.com/projecthorus/horusdemodlib/wiki/2---Modem-Details#horus-binary-v1-mode-4-fsk
|
||||
// After demodulation, deinterleaving, and descrambling, this results in a packet:
|
||||
// 00000001172D0000000000000000D20463010AFF2780
|
||||
// This decodes to the Habitat-compatible telemetry string:
|
||||
// $$4FSKTEST,0,01:23:45,0.00000,0.00000,1234,99,1,10,5.00*ABCD
|
||||
int horusPacketLen = 45;
|
||||
byte horusPacket[] = {
|
||||
0x45, 0x24, 0x24, 0x48, 0x2F, 0x12, 0x16, 0x08, 0x15, 0xC1,
|
||||
0x49, 0xB2, 0x06, 0xFC, 0x92, 0xEB, 0x93, 0xD7, 0xEE, 0x5D,
|
||||
0x35, 0xA0, 0x91, 0xDA, 0x8D, 0x5F, 0x85, 0x6B, 0x63, 0x03,
|
||||
0x6B, 0x60, 0xEA, 0xFE, 0x55, 0x9D, 0xF1, 0xAB, 0xE5, 0x5E,
|
||||
0xDB, 0x7C, 0xDB, 0x21, 0x5A, 0x19
|
||||
};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for RTTY
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize FSK4 client
|
||||
// NOTE: Unlike FSK FSK4, AFSK requires no rounding of
|
||||
// the frequency shift.
|
||||
Serial.print(F("[FSK4] Initializing ... "));
|
||||
// low ("space") frequency: 434.0 MHz
|
||||
// frequency shift: 270 Hz
|
||||
// baud rate: 100 baud
|
||||
state = fsk4.begin(400, 270, 100);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// sometimes, it may be needed to set some manual corrections
|
||||
// this can be done for tone frequencies,
|
||||
// as well as tone lengths
|
||||
/*
|
||||
// set audio tone offsets to -10, 20, 0 and 5 Hz and decrease tone length to 95%
|
||||
int offsets[4] = { -10, 20, 0, 5 };
|
||||
Serial.print(F("[FSK4] Setting corrections ... "));
|
||||
state = fsk4.setCorrection(offsets, 0.95);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[FSK4] Sending FSK4 data packet ... "));
|
||||
|
||||
// send out idle condition for 500 ms
|
||||
fsk4.idle();
|
||||
delay(1000);
|
||||
|
||||
// FSK4Client supports binary write methods
|
||||
|
||||
// send some bytes as a preamble
|
||||
for(int i = 0; i < 8; i++) {
|
||||
fsk4.write(0x1B);
|
||||
}
|
||||
|
||||
// now send the encoded packet
|
||||
fsk4.write(horusPacket, horusPacketLen);
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
RadioLib HC05 Example
|
||||
|
||||
This example sends data using HC05 Bluetooth module.
|
||||
HC05 works exactly like a Serial line, data are sent to the paired device.
|
||||
The default pairing code for HC05 is 1234 or 1111.
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// HC05 has the following connections:
|
||||
// TX pin: 9
|
||||
// RX pin: 8
|
||||
HC05 bluetooth = new Module(9, 8);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//HC05 bluetooth = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize HC05
|
||||
// baudrate: 9600 baud
|
||||
bluetooth.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// HC05 supports all methods of the Serial class
|
||||
// read data incoming from Serial port and write them to Bluetooth
|
||||
while (Serial.available() > 0) {
|
||||
bluetooth.write(Serial.read());
|
||||
}
|
||||
|
||||
// read data incoming from Bluetooth and write them to Serial port
|
||||
while (bluetooth.available() > 0) {
|
||||
Serial.write(bluetooth.read());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
RadioLib HTTP GET Example
|
||||
|
||||
This example sends HTTP GET request using ESP8266 WiFi module.
|
||||
|
||||
Please note that the response will be saved including header. HTTP header size
|
||||
can easily exceed Arduino resources and cause the program to behave erratically.
|
||||
|
||||
IMPORTANT: Before uploading this example, make sure that the ESP8266 module is running
|
||||
AT firmware (can be found in the /extras folder of the library)!
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// ESP8266 has the following connections:
|
||||
// TX pin: 9
|
||||
// RX pin: 8
|
||||
ESP8266 wifi = new Module(9, 8);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//ESP8266 wifi = RadioShield.ModuleA;
|
||||
|
||||
// create HTTP client instance using the wifi module
|
||||
// the default port used for HTTP is 80
|
||||
HTTPClient http(&wifi, 80);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize ESP8266
|
||||
Serial.print(F("[ESP8266] Initializing ... "));
|
||||
// baudrate: 9600 baud
|
||||
int state = wifi.begin(9600);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// join access point
|
||||
Serial.print(F("[ESP8266] Joining AP ... "));
|
||||
// name: SSID
|
||||
// password: password
|
||||
state = wifi.join("SSID", "password");
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// send HTTP GET request to www.httpbin.org/ip
|
||||
// the response will contain origin IP address of the request
|
||||
String response;
|
||||
Serial.print(F("[ESP8266] Sending HTTP GET request ... "));
|
||||
// URL: www.httpbin.org/ip
|
||||
int http_code = http.get("www.httpbin.org/ip", response);
|
||||
if (http_code > 0) {
|
||||
Serial.print(F("HTTP code "));
|
||||
Serial.println(http_code);
|
||||
Serial.print(F("[ESP8266] Response is "));
|
||||
Serial.print(response.length());
|
||||
Serial.println(F(" bytes long."));
|
||||
Serial.println(response);
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(http_code);
|
||||
}
|
||||
|
||||
// wait for a second before sending new request
|
||||
delay(1000);
|
||||
}
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
RadioLib HTTP POST Example
|
||||
|
||||
This example sends HTTP POST request using ESP8266 WiFi module.
|
||||
|
||||
Please note that the response will be saved including header. HTTP header size
|
||||
can easily exceed Arduino resources and cause the program to behave erratically.
|
||||
|
||||
IMPORTANT: Before uploading this example, make sure that the ESP8266 module is running
|
||||
AT firmware (can be found in the /extras folder of the library)!
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// ESP8266 has the following connections:
|
||||
// TX pin: 9
|
||||
// RX pin: 8
|
||||
ESP8266 wifi = new Module(9, 8);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//ESP8266 wifi = RadioShield.ModuleA;
|
||||
|
||||
// create HTTP client instance using the wifi module
|
||||
// the default port used for HTTP is 80
|
||||
HTTPClient http(&wifi, 80);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize ESP8266
|
||||
Serial.print(F("[ESP8266] Initializing ... "));
|
||||
// baudrate: 9600 baud
|
||||
int state = wifi.begin(9600);
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// join access point
|
||||
Serial.print(F("[ESP8266] Joining AP ... "));
|
||||
// name: SSID
|
||||
// password: password
|
||||
state = wifi.join("SSID", "password");
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// send HTTP POST request to www.httpbin.org/status/404
|
||||
// the server doesn't process the posted data, it just returns
|
||||
// response with the status code 404
|
||||
String response;
|
||||
Serial.print(F("[ESP8266] Sending HTTP POST request ... "));
|
||||
// URL: www.httpbin.org/status/404
|
||||
// content: str
|
||||
// content type: text/plain
|
||||
int http_code = http.post("www.httpbin.org/status/404", "str", response);
|
||||
if(http_code > 0) {
|
||||
Serial.print(F("HTTP code "));
|
||||
Serial.println(http_code);
|
||||
Serial.print(F("[ESP8266] Response is "));
|
||||
Serial.print(response.length());
|
||||
Serial.println(F(" bytes long."));
|
||||
Serial.println(response);
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(http_code);
|
||||
}
|
||||
|
||||
// wait for a second before sending new request
|
||||
delay(1000);
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ void setup() {
|
|||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -62,7 +62,7 @@ void setup() {
|
|||
// base frequency: 434.0 MHz
|
||||
// speed: 122.5 Baud ("Feld Hell")
|
||||
state = hell.begin(434.0);
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ void setup() {
|
|||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -65,7 +65,7 @@ void setup() {
|
|||
// AFSK tone frequency: 400 Hz
|
||||
// speed: 122.5 Baud ("Feld Hell")
|
||||
state = hell.begin(400);
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -90,6 +90,12 @@ void loop() {
|
|||
// string saved in flash
|
||||
hell.print(F("Flash String"));
|
||||
|
||||
// in AFSK mode, it is possible to invert the text colors
|
||||
// use white text on black background
|
||||
hell.setInversion(true);
|
||||
hell.print("Inverted String");
|
||||
hell.setInversion(false);
|
||||
|
||||
// character
|
||||
hell.print('c');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
RadioLib JDY08 Example
|
||||
|
||||
This example sends data using JDY08 Bluetooth module.
|
||||
JDY08 works exactly like a Serial line, data are sent to the paired device.
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// JDY08 has the following connections:
|
||||
// TX pin: 9
|
||||
// RX pin: 8
|
||||
JDY08 ble = new Module(9, 8);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//JDY08 ble = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize JDY08
|
||||
// baudrate: 9600 baud
|
||||
ble.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// JDY08 supports all methods of the Serial class
|
||||
// read data incoming from Serial port and write them to Bluetooth
|
||||
while (Serial.available() > 0) {
|
||||
ble.write(Serial.read());
|
||||
}
|
||||
|
||||
// read data incoming from Bluetooth and write them to Serial port
|
||||
while (ble.available() > 0) {
|
||||
Serial.write(ble.read());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
RadioLib MQTT Publish Example
|
||||
|
||||
This example publishes MQTT messages using ESP8266 WiFi module.
|
||||
|
||||
The messages are published to https://shiftr.io/try. You can use this namespace
|
||||
for testing purposes, but remember that it is publicly accessible!
|
||||
|
||||
IMPORTANT: Before uploading this example, make sure that the ESP8266 module is running
|
||||
AT firmware (can be found in the /extras folder of the library)!
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// ESP8266 has the following connections:
|
||||
// TX pin: 9
|
||||
// RX pin: 8
|
||||
ESP8266 wifi = new Module(9, 8);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//ESP8266 wifi = RadioShield.ModuleA;
|
||||
|
||||
// create MQTT client instance using the wifi module
|
||||
// the default port used for MQTT is 1883
|
||||
MQTTClient mqtt(&wifi, 1883);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize ESP8266
|
||||
Serial.print(F("[ESP8266] Initializing ... "));
|
||||
// baudrate: 9600 baud
|
||||
int state = wifi.begin(9600);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// join access point
|
||||
Serial.print(F("[ESP8266] Joining AP ... "));
|
||||
// name: SSID
|
||||
// password: password
|
||||
state = wifi.join("SSID", "password");
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// connect to MQTT server
|
||||
Serial.print(F("[ESP8266] Connecting to MQTT server ... "));
|
||||
// server URL: broker.shiftr.io
|
||||
// client ID: arduino
|
||||
// username: try
|
||||
// password: try
|
||||
state = mqtt.connect("broker.shiftr.io", "arduino", "try", "try");
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// publish MQTT message
|
||||
Serial.print(F("[ESP8266] Publishing MQTT message ... "));
|
||||
// topic name: hello
|
||||
// application message: world
|
||||
int state = mqtt.publish("hello", "world");
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// wait for a second before publishing again
|
||||
delay(1000);
|
||||
}
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
/*
|
||||
RadioLib MQTT Subscribe Example
|
||||
|
||||
This example subscribes to MQTT topic using ESP8266 WiFi module.
|
||||
|
||||
The messages are pulled from https://shiftr.io/try. You can use this namespace
|
||||
for testing purposes, but remember that it is publicly accessible!
|
||||
|
||||
IMPORTANT: Before uploading this example, make sure that the ESP8266 module is running
|
||||
AT firmware (can be found in the /extras folder of the library)!
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// ESP8266 has the following connections:
|
||||
// TX pin: 9
|
||||
// RX pin: 8
|
||||
ESP8266 wifi = new Module(9, 8);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//ESP8266 wifi = RadioShield.ModuleA;
|
||||
|
||||
// create MQTT client instance using the wifi module
|
||||
// the default port used for MQTT is 1883
|
||||
MQTTClient mqtt(&wifi, 1883);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize ESP8266
|
||||
Serial.print(F("[ESP8266] Initializing ... "));
|
||||
// baudrate: 9600 baud
|
||||
int state = wifi.begin(9600);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// join access point
|
||||
Serial.print(F("[ESP8266] Joining AP ... "));
|
||||
// name: SSID
|
||||
// password: password
|
||||
state = wifi.join("SSID", "password");
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// connect to MQTT server
|
||||
Serial.print(F("[ESP8266] Connecting to MQTT server ... "));
|
||||
// server URL: broker.shiftr.io
|
||||
// client ID: arduino
|
||||
// username: try
|
||||
// password: try
|
||||
state = mqtt.connect("broker.shiftr.io", "arduino", "try", "try");
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// subscribe to MQTT topic
|
||||
// after calling this method, server will send PUBLISH packets
|
||||
// to this client each time a new message was published at the topic
|
||||
Serial.print(F("[ESP8266] Subscribing to MQTT topic ... "));
|
||||
// topic name: hello
|
||||
state = mqtt.subscribe("hello");
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// unsubscribe from MQTT topic
|
||||
// after calling this method, server will stop sending PUBLISH packets
|
||||
Serial.print(F("[ESP8266] Unsubscribing from MQTT topic ... "));
|
||||
// topic filter: hello
|
||||
state = mqtt.unsubscribe("hello");
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
}
|
||||
|
||||
// create a function that will be called when a new PUBLISH packet
|
||||
// arrives from the server
|
||||
//
|
||||
// IMPORTANT: This function MUST have two C-strings as arguments!
|
||||
void onPublish(const char* topic, const char* message) {
|
||||
Serial.println(F("[ESP8266] Received packet from MQTT server: "));
|
||||
Serial.print(F("[ESP8266] Topic:\t"));
|
||||
Serial.println(topic);
|
||||
Serial.print(F("[ESP8266] Message:\t"));
|
||||
Serial.println(message);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check for new MQTT packets from server each time the loop() runs
|
||||
// this will also send a PING packet, restarting the keep alive timer
|
||||
int state = mqtt.check(onPublish);
|
||||
Serial.print(F("[ESP8266] MQTT check "));
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// the rest of your loop() code goes here
|
||||
// make sure that the maximum time the loop() runs is less than 1.5x keep alive,
|
||||
// otherwise the server will close the network connection
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
RadioLib SX127x Morse Receive AM Example
|
||||
|
||||
This example receives Morse code message using
|
||||
SX1278's FSK modem. The signal is expected to be
|
||||
modulated as OOK, to be demodulated in AM mode.
|
||||
|
||||
Other modules that can be used for Morse Code
|
||||
with AFSK modulation:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
// create Morse client instance using the AFSK instance
|
||||
MorseClient morse(&audio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// when using one of the non-LoRa modules for Morse code
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
// initialize Morse client
|
||||
Serial.print(F("[Morse] Initializing ... "));
|
||||
// AFSK tone frequency: 400 Hz
|
||||
// speed: 20 words per minute
|
||||
state = morse.begin(400);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// after that, set mode to OOK to emulate AM modulation
|
||||
Serial.print(F("[SX1278] Switching to OOK ... "));
|
||||
state = radio.setOOK(true);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// start direct mode reception
|
||||
radio.receiveDirect();
|
||||
}
|
||||
|
||||
// save symbol and length between loops
|
||||
byte symbol = 0;
|
||||
byte len = 0;
|
||||
|
||||
void loop() {
|
||||
// try to read a new symbol
|
||||
int state = morse.read(&symbol, &len);
|
||||
|
||||
// check if we have something to decode
|
||||
if(state != RADIOLIB_MORSE_INTER_SYMBOL) {
|
||||
// decode and print
|
||||
Serial.print(MorseClient::decode(symbol, len));
|
||||
|
||||
// reset the symbol buffer
|
||||
symbol = 0;
|
||||
len = 0;
|
||||
|
||||
// check if we have a complete word
|
||||
if(state == RADIOLIB_MORSE_WORD_COMPLETE) {
|
||||
// inter-word space, interpret that as a new line
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
RadioLib Morse Transmit AM Example
|
||||
|
||||
This example sends Morse code message using
|
||||
SX1278's FSK modem. The signal is modulated
|
||||
as OOK, and may be demodulated in AM mode.
|
||||
|
||||
Other modules that can be used for Morse Code
|
||||
with AM modulation:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
// create Morse client instance using the AFSK instance
|
||||
MorseClient morse(&audio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for Morse code
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize Morse client
|
||||
Serial.print(F("[Morse] Initializing ... "));
|
||||
// tone frequency: 400 Hz
|
||||
// speed: 20 words per minute
|
||||
state = morse.begin(400);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// after that, set mode to OOK to emulate AM modulation
|
||||
Serial.print(F("[SX1278] Switching to OOK ... "));
|
||||
state = radio.setOOK(true);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[Morse] Sending Morse data ... "));
|
||||
|
||||
// MorseClient supports all methods of the Serial class
|
||||
// NOTE: Characters that do not have ITU-R M.1677-1
|
||||
// representation will not be sent! Lower case
|
||||
// letters will be capitalized.
|
||||
|
||||
// send start signal first
|
||||
morse.startSignal();
|
||||
|
||||
// Arduino String class
|
||||
String aStr = "Arduino String";
|
||||
morse.print(aStr);
|
||||
|
||||
// character array (C-String)
|
||||
morse.print("C-String");
|
||||
|
||||
// string saved in flash
|
||||
morse.print(F("Flash String"));
|
||||
|
||||
// character
|
||||
morse.print('c');
|
||||
|
||||
// byte
|
||||
// formatting DEC/HEX/OCT/BIN is supported for
|
||||
// any integer type (byte/int/long)
|
||||
morse.print(255, HEX);
|
||||
|
||||
// integer number
|
||||
int i = 1000;
|
||||
morse.print(i);
|
||||
|
||||
// floating point number
|
||||
// NOTE: When using println(), the transmission will be
|
||||
// terminated with end-of-work signal (...-.-).
|
||||
float f = -3.1415;
|
||||
morse.println(f, 3);
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
RadioLib Morse Transmit AFSK Example
|
||||
|
||||
This example sends Morse code message using
|
||||
SX1278's FSK modem. The data is modulated
|
||||
as AFSK.
|
||||
SX1278's FSK modem. The signal is modulated
|
||||
as AFSK, and may be demodulated in FM mode.
|
||||
|
||||
Other modules that can be used for Morse Code
|
||||
with AFSK modulation:
|
||||
|
|
@ -36,7 +36,7 @@ SX1278 radio = new Module(10, 2, 9, 3);
|
|||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
AFSKClient audio(&radio, 10);
|
||||
|
||||
// create Morse client instance using the AFSK instance
|
||||
MorseClient morse(&audio);
|
||||
|
|
@ -52,7 +52,7 @@ void setup() {
|
|||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -62,10 +62,21 @@ void setup() {
|
|||
|
||||
// initialize Morse client
|
||||
Serial.print(F("[Morse] Initializing ... "));
|
||||
// AFSK tone frequency: 400 MHz
|
||||
// tone frequency: 400 Hz
|
||||
// speed: 20 words per minute
|
||||
state = morse.begin(400);
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// after that, set mode to OOK
|
||||
Serial.print(F("[SX1278] Switching to OOK ... "));
|
||||
state = radio.setOOK(true);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
/*
|
||||
RadioLib Morse Transmit Example
|
||||
RadioLib Morse Transmit SSB Example
|
||||
|
||||
This example sends Morse code message using
|
||||
SX1278's FSK modem.
|
||||
SX1278's FSK modem. The signal is an unmodulated
|
||||
carrier wave, and may be demodulated in SSB mode.
|
||||
|
||||
Other modules that can be used for Morse Code:
|
||||
- SX127x/RFM9x
|
||||
|
|
@ -49,7 +50,7 @@ void setup() {
|
|||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -59,10 +60,10 @@ void setup() {
|
|||
|
||||
// initialize Morse client
|
||||
Serial.print(F("[Morse] Initializing ... "));
|
||||
// base frequency: 434.0 MHz
|
||||
// carrier wave frequency: 434.0 MHz
|
||||
// speed: 20 words per minute
|
||||
state = morse.begin(434.0);
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
121
lib/RadioLib/examples/Pager/Pager_Receive/Pager_Receive.ino
Normal file
121
lib/RadioLib/examples/Pager/Pager_Receive/Pager_Receive.ino
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
RadioLib Pager (POCSAG) Receive Example
|
||||
|
||||
This example shows how to receive FSK packets without using
|
||||
SX127x packet engine.
|
||||
|
||||
This example receives POCSAG messages using SX1278's
|
||||
FSK modem in direct mode.
|
||||
|
||||
Other modules that can be used to receive POCSAG:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// DIO2 pin: 5
|
||||
const int pin = 5;
|
||||
|
||||
// create Pager client instance using the FSK module
|
||||
PagerClient pager(&radio);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// initialize Pager client
|
||||
Serial.print(F("[Pager] Initializing ... "));
|
||||
// base (center) frequency: 434.0 MHz
|
||||
// speed: 1200 bps
|
||||
state = pager.begin(434.0, 1200);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// start receiving POCSAG messages
|
||||
Serial.print(F("[Pager] Starting to listen ... "));
|
||||
// address of this "pager": 1234567
|
||||
state = pager.startReceive(pin, 1234567);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// the number of batches to wait for
|
||||
// 2 batches will usually be enough to fit short and medium messages
|
||||
if (pager.available() >= 2) {
|
||||
Serial.print(F("[Pager] Received pager data, decoding ... "));
|
||||
|
||||
// you can read the data as an Arduino String
|
||||
String str;
|
||||
int state = pager.readData(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
size_t numBytes = 0;
|
||||
int state = radio.receive(byteArr, &numBytes);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
|
||||
// print the received data
|
||||
Serial.print(F("[Pager] Data:\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else {
|
||||
// some error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
102
lib/RadioLib/examples/Pager/Pager_Transmit/Pager_Transmit.ino
Normal file
102
lib/RadioLib/examples/Pager/Pager_Transmit/Pager_Transmit.ino
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
RadioLib Pager (POCSAG) Transmit Example
|
||||
|
||||
This example sends POCSAG messages using SX1278's
|
||||
FSK modem.
|
||||
|
||||
Other modules that can be used to send POCSAG:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- SX126x
|
||||
- nRF24
|
||||
- Si443x/RFM2x
|
||||
- SX128x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create Pager client instance using the FSK module
|
||||
PagerClient pager(&radio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize Pager client
|
||||
Serial.print(F("[Pager] Initializing ... "));
|
||||
// base (center) frequency: 434.0 MHz
|
||||
// speed: 1200 bps
|
||||
state = pager.begin(434.0, 1200);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[Pager] Transmitting messages ... "));
|
||||
|
||||
// the simples form of "message" is just a tone on the destination pager
|
||||
int state = pager.sendTone(1234567);
|
||||
delay(500);
|
||||
|
||||
// next, transmit numeric (BCD) message to the destination pager
|
||||
// NOTE: Only characters 0123456789*U-() and space
|
||||
// can be sent in a BCD message!
|
||||
state |= pager.transmit("0123456789*U -()", 1234567);
|
||||
delay(500);
|
||||
|
||||
// finally, let's transmit an ASCII message now
|
||||
state |= pager.transmit("Hello World!", 1234567, RADIOLIB_PAGER_ASCII);
|
||||
delay(500);
|
||||
|
||||
// we can also send only a tone
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(3000);
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ void setup() {
|
|||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -57,7 +57,7 @@ void loop() {
|
|||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
@ -71,11 +71,11 @@ void loop() {
|
|||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ void setup() {
|
|||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -67,7 +67,7 @@ void loop() {
|
|||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
@ -75,11 +75,11 @@ void loop() {
|
|||
Serial.print(F("[RF69] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ void setup() {
|
|||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -46,7 +46,7 @@ void setup() {
|
|||
// address filtering (node address only)
|
||||
Serial.print(F("[RF69] Setting node address ... "));
|
||||
state = radio.setNodeAddress(0x02);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -59,7 +59,7 @@ void setup() {
|
|||
// address filtering (node or broadcast address)
|
||||
Serial.print(F("[RF69] Setting broadcast address ... "));
|
||||
state = radio.setBroadcastAddress(0xFF);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -73,7 +73,7 @@ void setup() {
|
|||
/*
|
||||
Serial.print(F("[RF69] Disabling address filtering ... "));
|
||||
state == radio.disableAddressFiltering();
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -96,7 +96,7 @@ void loop() {
|
|||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
@ -104,11 +104,11 @@ void loop() {
|
|||
Serial.print(F("[RF69] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ void setup() {
|
|||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -46,7 +46,7 @@ void setup() {
|
|||
// start listening for packets
|
||||
Serial.print(F("[RF69] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -74,6 +74,9 @@ volatile bool enableInterrupt = true;
|
|||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
|
|
@ -104,7 +107,7 @@ void loop() {
|
|||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[RF69] Received packet!"));
|
||||
|
||||
|
|
@ -118,7 +121,7 @@ void loop() {
|
|||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ void setup() {
|
|||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio1.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -60,7 +60,7 @@ void setup() {
|
|||
// output power: 17 dBm
|
||||
// preamble length: 32 bits
|
||||
state = radio2.begin(868.0, 300.0, 60.0, 250.0, 17, 32);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -72,17 +72,17 @@ void setup() {
|
|||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 433.5 MHz
|
||||
if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||
if (radio1.setFrequency(433.5) == RADIOLIB_ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("[RF69] Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bit rate to 100.0 kbps
|
||||
state = radio1.setBitRate(100.0);
|
||||
if (state == ERR_INVALID_BIT_RATE) {
|
||||
if (state == RADIOLIB_ERR_INVALID_BIT_RATE) {
|
||||
Serial.println(F("[RF69] Selected bit rate is invalid for this module!"));
|
||||
while (true);
|
||||
} else if (state == ERR_INVALID_BIT_RATE_BW_RATIO) {
|
||||
} else if (state == RADIOLIB_ERR_INVALID_BIT_RATE_BW_RATIO) {
|
||||
Serial.println(F("[RF69] Selected bit rate to bandwidth ratio is invalid!"));
|
||||
Serial.println(F("[RF69] Increase receiver bandwidth to set this bit rate."));
|
||||
while (true);
|
||||
|
|
@ -90,23 +90,23 @@ void setup() {
|
|||
|
||||
// set receiver bandwidth to 250.0 kHz
|
||||
state = radio1.setRxBandwidth(250.0);
|
||||
if (state == ERR_INVALID_RX_BANDWIDTH) {
|
||||
if (state == RADIOLIB_ERR_INVALID_RX_BANDWIDTH) {
|
||||
Serial.println(F("[RF69] Selected receiver bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
} else if (state == ERR_INVALID_BIT_RATE_BW_RATIO) {
|
||||
} else if (state == RADIOLIB_ERR_INVALID_BIT_RATE_BW_RATIO) {
|
||||
Serial.println(F("[RF69] Selected bit rate to bandwidth ratio is invalid!"));
|
||||
Serial.println(F("[RF69] Decrease bit rate to set this receiver bandwidth."));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set allowed frequency deviation to 10.0 kHz
|
||||
if (radio1.setFrequencyDeviation(10.0) == ERR_INVALID_FREQUENCY_DEVIATION) {
|
||||
if (radio1.setFrequencyDeviation(10.0) == RADIOLIB_ERR_INVALID_FREQUENCY_DEVIATION) {
|
||||
Serial.println(F("[RF69] Selected frequency deviation is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set output power to 2 dBm
|
||||
if (radio1.setOutputPower(2) == ERR_INVALID_OUTPUT_POWER) {
|
||||
if (radio1.setOutputPower(2) == RADIOLIB_ERR_INVALID_OUTPUT_POWER) {
|
||||
Serial.println(F("[RF69] Selected output power is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ void setup() {
|
|||
// NOTE: sync word must not contain any zero bytes
|
||||
// set sync word to 0x0123456789ABCDEF
|
||||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
||||
if (radio1.setSyncWord(syncWord, 8) == ERR_INVALID_SYNC_WORD) {
|
||||
if (radio1.setSyncWord(syncWord, 8) == RADIOLIB_ERR_INVALID_SYNC_WORD) {
|
||||
Serial.println(F("[RF69] Selected sync word is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ void setup() {
|
|||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -49,7 +49,7 @@ void setup() {
|
|||
/*
|
||||
Serial.print(F("[RF69] Setting high power module ... "));
|
||||
state = radio.setOutputPower(20, true);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -71,11 +71,11 @@ void loop() {
|
|||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 64 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ void setup() {
|
|||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -66,11 +66,11 @@ void loop() {
|
|||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 64 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ void setup() {
|
|||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -46,7 +46,7 @@ void setup() {
|
|||
// address filtering (node address only)
|
||||
Serial.print(F("[RF69] Setting node address ... "));
|
||||
state = radio.setNodeAddress(0x01);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -59,7 +59,7 @@ void setup() {
|
|||
// address filtering (node or broadcast address)
|
||||
Serial.print(F("[RF69] Setting broadcast address ... "));
|
||||
state = radio.setBroadcastAddress(0xFF);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -73,7 +73,7 @@ void setup() {
|
|||
/*
|
||||
Serial.print(F("[RF69] Disabling address filtering ... "));
|
||||
state = radio.disableAddressFiltering();
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -106,11 +106,11 @@ void loop() {
|
|||
int state = radio.transmit(byteArr, 8, 0xFF);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 64 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ RF69 radio = new Module(10, 2, 3);
|
|||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = ERR_NONE;
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
|
@ -37,7 +37,7 @@ void setup() {
|
|||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -57,7 +57,7 @@ void setup() {
|
|||
/*
|
||||
Serial.print(F("[RF69] Setting high power module ... "));
|
||||
state = radio.setOutputPower(20, true);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -91,6 +91,9 @@ volatile bool enableInterrupt = true;
|
|||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
|
|
@ -111,7 +114,7 @@ void loop() {
|
|||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == ERR_NONE) {
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
|
|
@ -125,6 +128,11 @@ void loop() {
|
|||
|
||||
}
|
||||
|
||||
// clean up after transmission is finished
|
||||
// this will ensure transmitter is disabled,
|
||||
// RF switch is powered down etc.
|
||||
radio.finishTransmit();
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ void setup() {
|
|||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -75,7 +75,7 @@ void setup() {
|
|||
// encoding: ASCII (7-bit)
|
||||
// stop bits: 1
|
||||
state = rtty.begin(434.0, 183, 45);
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -130,6 +130,9 @@ void loop() {
|
|||
float f = -3.1415;
|
||||
rtty.println(f, 3);
|
||||
|
||||
// turn the transmitter off
|
||||
rtty.standby();
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second before transmitting again
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ void setup() {
|
|||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -68,7 +68,7 @@ void setup() {
|
|||
// encoding: ASCII (7-bit)
|
||||
// stop bits: 1
|
||||
state = rtty.begin(400, 170, 45);
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -123,6 +123,9 @@ void loop() {
|
|||
float f = -3.1415;
|
||||
rtty.println(f, 3);
|
||||
|
||||
// turn the transmitter off
|
||||
rtty.standby();
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second before transmitting again
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ void setup() {
|
|||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -107,7 +107,16 @@ void setup() {
|
|||
Serial.print(F("[SSTV] Initializing ... "));
|
||||
// 0 Hz tone frequency: 434.0 MHz
|
||||
// SSTV mode: Wrasse (SC2-180)
|
||||
// correction factor: 0.95
|
||||
state = sstv.begin(434.0, Wrasse);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// set correction factor
|
||||
// NOTE: Due to different speeds of various platforms
|
||||
// supported by RadioLib (Arduino Uno, ESP32 etc),
|
||||
// and because SSTV is analog protocol, incorrect
|
||||
|
|
@ -116,8 +125,9 @@ void setup() {
|
|||
// to adjust the length of timing pulses
|
||||
// (lower number = shorter pulses).
|
||||
// The value is usually around 0.95 (95%).
|
||||
state = sstv.begin(434.0, Wrasse, 0.95);
|
||||
if(state == ERR_NONE) {
|
||||
Serial.print(F("[SSTV] Setting correction ... "));
|
||||
state = sstv.setCorrection(0.95);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ void setup() {
|
|||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -105,7 +105,16 @@ void setup() {
|
|||
// initialize SSTV client
|
||||
Serial.print(F("[SSTV] Initializing ... "));
|
||||
// SSTV mode: Wrasse (SC2-180)
|
||||
// correction factor: 0.95
|
||||
state = sstv.begin(Wrasse);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// set correction factor
|
||||
// NOTE: Due to different speeds of various platforms
|
||||
// supported by RadioLib (Arduino Uno, ESP32 etc),
|
||||
// and because SSTV is analog protocol, incorrect
|
||||
|
|
@ -114,8 +123,9 @@ void setup() {
|
|||
// to adjust the length of timing pulses
|
||||
// (lower number = shorter pulses).
|
||||
// The value is usually around 0.95 (95%).
|
||||
state = sstv.begin(Wrasse, 0.95);
|
||||
if(state == ERR_NONE) {
|
||||
Serial.print(F("[SSTV] Setting correction ... "));
|
||||
state = sstv.setCorrection(0.95);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ void setup() {
|
|||
// initialize SX1231 with default settings
|
||||
Serial.print(F("[SX1231] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -55,7 +55,7 @@ void loop() {
|
|||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
@ -63,11 +63,11 @@ void loop() {
|
|||
Serial.print(F("[SX1231] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ void setup() {
|
|||
// initialize SX1231 with default settings
|
||||
Serial.print(F("[SX1231] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -54,11 +54,11 @@ void loop() {
|
|||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 256 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -29,13 +29,16 @@ SX1262 radio = new Module(10, 2, 3, 9);
|
|||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -50,11 +53,11 @@ void loop() {
|
|||
// start scanning current channel
|
||||
int state = radio.scanChannel();
|
||||
|
||||
if (state == LORA_DETECTED) {
|
||||
if (state == RADIOLIB_LORA_DETECTED) {
|
||||
// LoRa preamble was detected
|
||||
Serial.println(F("detected!"));
|
||||
|
||||
} else if (state == CHANNEL_FREE) {
|
||||
} else if (state == RADIOLIB_CHANNEL_FREE) {
|
||||
// no preamble was detected, channel is free
|
||||
Serial.println(F("channel is free!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
RadioLib SX126x Channel Activity Detection Example
|
||||
|
||||
This example uses SX1262 to scan the current LoRa
|
||||
channel and detect ongoing LoRa transmissions.
|
||||
Unlike SX127x CAD, SX126x can detect any part
|
||||
of LoRa transmission, not just the preamble.
|
||||
|
||||
Other modules from SX126x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1262 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when LoRa packet or timeout is detected
|
||||
radio.setDio1Action(setFlag);
|
||||
|
||||
// start scanning the channel
|
||||
Serial.print(F("[SX1262] Starting scan for LoRa preamble ... "));
|
||||
state = radio.startChannelScan();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was detected or CAD timed out
|
||||
volatile bool scanFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// something happened, set the flag
|
||||
scanFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the flag is set
|
||||
if(scanFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
scanFlag = false;
|
||||
|
||||
// check CAD result
|
||||
int state = radio.getChannelScanResult();
|
||||
|
||||
if (state == RADIOLIB_LORA_DETECTED) {
|
||||
// LoRa packet was detected
|
||||
Serial.println(F("[SX1262] Packet detected!"));
|
||||
|
||||
} else if (state == RADIOLIB_CHANNEL_FREE) {
|
||||
// channel is free
|
||||
Serial.println(F("[SX1262] Channel is free!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("[SX1262] Failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// start scanning the channel again
|
||||
Serial.print(F("[SX1262] Starting scan for LoRa preamble ... "));
|
||||
state = radio.startChannelScan();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -30,13 +30,16 @@ SX1262 radio = new Module(10, 2, 3, 9);
|
|||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 FSK modem with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -61,7 +64,7 @@ void setup() {
|
|||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
state = radio.setSyncWord(syncWord, 8);
|
||||
if (state != ERR_NONE) {
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("Unable to set configuration, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
|
|
@ -94,11 +97,11 @@ void loop() {
|
|||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1262] Packet transmitted successfully!"));
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
Serial.println(F("[SX1262] Packet too long!"));
|
||||
} else if (state == ERR_TX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
|
||||
Serial.println(F("[SX1262] Timed out while transmitting!"));
|
||||
} else {
|
||||
Serial.println(F("[SX1262] Failed to transmit packet, code "));
|
||||
|
|
@ -112,11 +115,11 @@ void loop() {
|
|||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1262] Received packet!"));
|
||||
Serial.print(F("[SX1262] Data:\t"));
|
||||
Serial.println(str);
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
Serial.println(F("[SX1262] Timed out while waiting for packet!"));
|
||||
} else {
|
||||
Serial.println(F("[SX1262] Failed to receive packet, code "));
|
||||
|
|
@ -137,7 +140,7 @@ void loop() {
|
|||
state = radio.setNodeAddress(0x02);
|
||||
// set broadcast address to 0xFF
|
||||
state = radio.setBroadcastAddress(0xFF);
|
||||
if (state != ERR_NONE) {
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1262] Unable to set address filter, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
|
@ -147,7 +150,7 @@ void loop() {
|
|||
// node and broadcast address
|
||||
/*
|
||||
state = radio.disableAddressFiltering();
|
||||
if (state != ERR_NONE) {
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("Unable to remove address filter, code "));
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
162
lib/RadioLib/examples/SX126x/SX126x_PingPong/SX126x_PingPong.ino
Normal file
162
lib/RadioLib/examples/SX126x/SX126x_PingPong/SX126x_PingPong.ino
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
RadioLib SX126x Ping-Pong Example
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// uncomment the following only on one
|
||||
// of the nodes to initiate the pings
|
||||
//#define INITIATING_NODE
|
||||
|
||||
// SX1262 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
// save transmission states between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
// flag to indicate transmission or reception state
|
||||
bool transmitFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// flag to indicate that a packet was sent or received
|
||||
volatile bool operationDone = false;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is transmitted or received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we sent or received a packet, set the flag
|
||||
operationDone = true;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
radio.setDio1Action(setFlag);
|
||||
|
||||
#if defined(INITIATING_NODE)
|
||||
// send the first packet on this node
|
||||
Serial.print(F("[SX1262] Sending first packet ... "));
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
transmitFlag = true;
|
||||
#else
|
||||
// start listening for LoRa packets on this node
|
||||
Serial.print(F("[SX1262] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the previous operation finished
|
||||
if(operationDone) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
operationDone = false;
|
||||
|
||||
if(transmitFlag) {
|
||||
// the previous operation was transmission, listen for response
|
||||
// print the result
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(transmissionState);
|
||||
|
||||
}
|
||||
|
||||
// listen for response
|
||||
radio.startReceive();
|
||||
transmitFlag = false;
|
||||
|
||||
} else {
|
||||
// the previous operation was reception
|
||||
// print data and send another packet
|
||||
String str;
|
||||
int state = radio.readData(str);
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[SX1262] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[SX1262] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
Serial.print(F("[SX1262] RSSI:\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print SNR (Signal-to-Noise Ratio)
|
||||
Serial.print(F("[SX1262] SNR:\t\t"));
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
}
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
// send another one
|
||||
Serial.print(F("[SX1262] Sending another packet ... "));
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
transmitFlag = true;
|
||||
}
|
||||
|
||||
// we're ready to process more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -34,13 +34,16 @@ SX1262 radio = new Module(10, 2, 3, 9);
|
|||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -65,7 +68,7 @@ void loop() {
|
|||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
@ -85,11 +88,11 @@ void loop() {
|
|||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,16 @@ SX1262 radio = new Module(10, 2, 3, 9);
|
|||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -56,7 +59,7 @@ void setup() {
|
|||
// start listening for LoRa packets
|
||||
Serial.print(F("[SX1262] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -85,6 +88,9 @@ volatile bool enableInterrupt = true;
|
|||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
|
|
@ -115,7 +121,7 @@ void loop() {
|
|||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[SX1262] Received packet!"));
|
||||
|
||||
|
|
@ -133,7 +139,7 @@ void loop() {
|
|||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -45,13 +45,16 @@ SX1268 radio2 = new Module(8, 4, 5, 6);
|
|||
// https://github.com/jgromes/RadioShield
|
||||
//SX1261 radio3 = RadioShield.ModuleB;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1268 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio1.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -72,7 +75,7 @@ void setup() {
|
|||
// output power: 2 dBm
|
||||
// preamble length: 20 symbols
|
||||
state = radio2.begin(915.0, 500.0, 6, 5, 0x34, 20);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -84,56 +87,56 @@ void setup() {
|
|||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 433.5 MHz
|
||||
if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||
if (radio1.setFrequency(433.5) == RADIOLIB_ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bandwidth to 250 kHz
|
||||
if (radio1.setBandwidth(250.0) == ERR_INVALID_BANDWIDTH) {
|
||||
if (radio1.setBandwidth(250.0) == RADIOLIB_ERR_INVALID_BANDWIDTH) {
|
||||
Serial.println(F("Selected bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set spreading factor to 10
|
||||
if (radio1.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) {
|
||||
if (radio1.setSpreadingFactor(10) == RADIOLIB_ERR_INVALID_SPREADING_FACTOR) {
|
||||
Serial.println(F("Selected spreading factor is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set coding rate to 6
|
||||
if (radio1.setCodingRate(6) == ERR_INVALID_CODING_RATE) {
|
||||
if (radio1.setCodingRate(6) == RADIOLIB_ERR_INVALID_CODING_RATE) {
|
||||
Serial.println(F("Selected coding rate is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set LoRa sync word to 0xAB
|
||||
if (radio1.setSyncWord(0xAB) != ERR_NONE) {
|
||||
if (radio1.setSyncWord(0xAB) != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("Unable to set sync word!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set output power to 10 dBm (accepted range is -17 - 22 dBm)
|
||||
if (radio1.setOutputPower(10) == ERR_INVALID_OUTPUT_POWER) {
|
||||
if (radio1.setOutputPower(10) == RADIOLIB_ERR_INVALID_OUTPUT_POWER) {
|
||||
Serial.println(F("Selected output power is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set over current protection limit to 80 mA (accepted range is 45 - 240 mA)
|
||||
// NOTE: set value to 0 to disable overcurrent protection
|
||||
if (radio1.setCurrentLimit(80) == ERR_INVALID_CURRENT_LIMIT) {
|
||||
if (radio1.setCurrentLimit(80) == RADIOLIB_ERR_INVALID_CURRENT_LIMIT) {
|
||||
Serial.println(F("Selected current limit is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set LoRa preamble length to 15 symbols (accepted range is 0 - 65535)
|
||||
if (radio1.setPreambleLength(15) == ERR_INVALID_PREAMBLE_LENGTH) {
|
||||
if (radio1.setPreambleLength(15) == RADIOLIB_ERR_INVALID_PREAMBLE_LENGTH) {
|
||||
Serial.println(F("Selected preamble length is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// disable CRC
|
||||
if (radio1.setCRC(false) == ERR_INVALID_CRC_CONFIGURATION) {
|
||||
if (radio1.setCRC(false) == RADIOLIB_ERR_INVALID_CRC_CONFIGURATION) {
|
||||
Serial.println(F("Selected CRC is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
@ -141,7 +144,7 @@ void setup() {
|
|||
// Some SX126x modules have TCXO (temperature compensated crystal
|
||||
// oscillator). To configure TCXO reference voltage,
|
||||
// the following method can be used.
|
||||
if (radio1.setTCXO(2.4) == ERR_INVALID_TCXO_VOLTAGE) {
|
||||
if (radio1.setTCXO(2.4) == RADIOLIB_ERR_INVALID_TCXO_VOLTAGE) {
|
||||
Serial.println(F("Selected TCXO voltage is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
@ -150,7 +153,7 @@ void setup() {
|
|||
// this feature, the following method can be used.
|
||||
// NOTE: As long as DIO2 is configured to control RF switch,
|
||||
// it can't be used as interrupt pin!
|
||||
if (radio1.setDio2AsRfSwitch() != ERR_NONE) {
|
||||
if (radio1.setDio2AsRfSwitch() != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("Failed to set DIO2 as RF switch!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,13 +30,16 @@ SX1262 radio = new Module(10, 2, 3, 9);
|
|||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -71,7 +74,7 @@ void loop() {
|
|||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
@ -80,11 +83,11 @@ void loop() {
|
|||
Serial.print(radio.getDataRate());
|
||||
Serial.println(F(" bps"));
|
||||
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 256 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
} else if (state == ERR_TX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
|
||||
// timeout occured while transmitting packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,11 @@ SX1262 radio = new Module(10, 2, 3, 9);
|
|||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = ERR_NONE;
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
|
@ -40,7 +43,7 @@ void setup() {
|
|||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -77,6 +80,9 @@ volatile bool enableInterrupt = true;
|
|||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
|
|
@ -97,7 +103,7 @@ void loop() {
|
|||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == ERR_NONE) {
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
|
|
@ -111,6 +117,11 @@ void loop() {
|
|||
|
||||
}
|
||||
|
||||
// clean up after transmission is finished
|
||||
// this will ensure transmitter is disabled,
|
||||
// RF switch is powered down etc.
|
||||
radio.finishTransmit();
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ void setup() {
|
|||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -51,11 +51,11 @@ void loop() {
|
|||
// start scanning current channel
|
||||
int state = radio.scanChannel();
|
||||
|
||||
if (state == PREAMBLE_DETECTED) {
|
||||
if (state == RADIOLIB_PREAMBLE_DETECTED) {
|
||||
// LoRa preamble was detected
|
||||
Serial.println(F("detected preamble!"));
|
||||
|
||||
} else if (state == CHANNEL_FREE) {
|
||||
} else if (state == RADIOLIB_CHANNEL_FREE) {
|
||||
// no preamble was detected, channel is free
|
||||
Serial.println(F("channel is free!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
RadioLib SX127x Channel Activity Detection with Interrupts Example
|
||||
|
||||
This example scans the current LoRa channel and detects
|
||||
valid LoRa preambles. Preamble is the first part of
|
||||
LoRa transmission, so this can be used to check
|
||||
if the LoRa channel is free, or if you should start
|
||||
receiving a message.
|
||||
|
||||
Other modules from SX127x/RFM9x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
// Serial port speed must be high enough for this example
|
||||
Serial.begin(115200);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when LoRa preamble is not detected within CAD timeout period
|
||||
radio.setDio0Action(setFlagTimeout);
|
||||
|
||||
// set the function that will be called
|
||||
// when LoRa preamble is detected
|
||||
radio.setDio1Action(setFlagDetected);
|
||||
|
||||
// start scanning the channel
|
||||
Serial.print(F("[SX1278] Starting scan for LoRa preamble ... "));
|
||||
state = radio.startChannelScan();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
}
|
||||
|
||||
// flag to indicate that a preamble was not detected
|
||||
volatile bool timeoutFlag = false;
|
||||
|
||||
// flag to indicate that a preamble was detected
|
||||
volatile bool detectedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when no preamble
|
||||
// is detected within timeout period
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlagTimeout(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we timed out, set the flag
|
||||
timeoutFlag = true;
|
||||
}
|
||||
|
||||
// this function is called when LoRa preamble
|
||||
// is detected within timeout period
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlagDetected(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we got a preamble, set the flag
|
||||
detectedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if we need to restart channel activity detection
|
||||
if(detectedFlag || timeoutFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// check if we got a preamble
|
||||
if(detectedFlag) {
|
||||
// LoRa preamble was detected
|
||||
Serial.println(F("[SX1278] Preamble detected!"));
|
||||
} else {
|
||||
// nothing was detected
|
||||
Serial.println(F("[SX1278] Channel free!"));
|
||||
}
|
||||
|
||||
// start scanning the channel
|
||||
Serial.print(F("[SX1278] Starting scan for LoRa preamble ... "));
|
||||
|
||||
// start scanning current channel
|
||||
int state = radio.startChannelScan();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// reset flags
|
||||
timeoutFlag = false;
|
||||
detectedFlag = false;
|
||||
|
||||
// enable interrupts again
|
||||
enableInterrupt = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,226 @@
|
|||
/*
|
||||
RadioLib SX127x Receive after Channel Activity Detection Example
|
||||
|
||||
This example scans the current LoRa channel and detects
|
||||
valid LoRa preambles. Preamble is the first part of
|
||||
LoRa transmission, so this can be used to check
|
||||
if the LoRa channel is free, or if you should start
|
||||
receiving a message. If a preamble is detected,
|
||||
the module will switch to receive mode and receive the packet.
|
||||
|
||||
For most use-cases, it should be enough to just use the
|
||||
interrupt-driven reception described in the example
|
||||
"SX127x_Receive_Interrupt".
|
||||
|
||||
Other modules from SX127x/RFM9x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
// Serial port speed must be high enough for this example
|
||||
Serial.begin(115200);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when LoRa preamble is not detected within CAD timeout period
|
||||
// or when a packet is received
|
||||
radio.setDio0Action(setFlagTimeout);
|
||||
|
||||
// set the function that will be called
|
||||
// when LoRa preamble is detected
|
||||
radio.setDio1Action(setFlagDetected);
|
||||
|
||||
// start scanning the channel
|
||||
Serial.print(F("[SX1278] Starting scan for LoRa preamble ... "));
|
||||
state = radio.startChannelScan();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
}
|
||||
|
||||
// flag to indicate that a preamble was not detected
|
||||
volatile bool timeoutFlag = false;
|
||||
|
||||
// flag to indicate that a preamble was detected
|
||||
volatile bool detectedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// flag to indicate if we are currently receiving
|
||||
bool receiving = false;
|
||||
|
||||
// this function is called when no preamble
|
||||
// is detected within timeout period
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlagTimeout(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we timed out, set the flag
|
||||
timeoutFlag = true;
|
||||
}
|
||||
|
||||
// this function is called when LoRa preamble
|
||||
// is detected within timeout period
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlagDetected(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we got a preamble, set the flag
|
||||
detectedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if we need to restart channel activity detection
|
||||
if(detectedFlag || timeoutFlag) {
|
||||
int state = RADIOLIB_ERR_NONE;
|
||||
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// check ongoing reception
|
||||
if(receiving) {
|
||||
// DIO triggered while reception is ongoing
|
||||
// that means we got a packet
|
||||
|
||||
// reset flags first
|
||||
detectedFlag = false;
|
||||
timeoutFlag = false;
|
||||
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[SX1278] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[SX1278] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
Serial.print(F("[SX1278] RSSI:\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print SNR (Signal-to-Noise Ratio)
|
||||
Serial.print(F("[SX1278] SNR:\t\t"));
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
// print frequency error
|
||||
Serial.print(F("[SX1278] Frequency error:\t"));
|
||||
Serial.print(radio.getFrequencyError());
|
||||
Serial.println(F(" Hz"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("[SX1278] CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("[SX1278] Failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// reception is done now
|
||||
receiving = false;
|
||||
|
||||
}
|
||||
|
||||
// check if we got a preamble
|
||||
if(detectedFlag) {
|
||||
// LoRa preamble was detected
|
||||
Serial.print(F("[SX1278] Preamble detected, starting reception ... "));
|
||||
state = radio.startReceive(0, RADIOLIB_SX127X_RXSINGLE);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// set the flag for ongoing reception
|
||||
receiving = true;
|
||||
|
||||
} else if(!receiving) {
|
||||
// nothing was detected
|
||||
// do not print anything, it just spams the console
|
||||
|
||||
}
|
||||
|
||||
// if we're not receiving, start scanning again
|
||||
if(!receiving) {
|
||||
int state = radio.startChannelScan();
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("[SX1278] Starting new scan failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// reset flags
|
||||
timeoutFlag = false;
|
||||
detectedFlag = false;
|
||||
|
||||
// enable interrupts again
|
||||
enableInterrupt = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ SX1278 radio = new Module(10, 2, 9, 3);
|
|||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 fsk = RadioShield.ModuleA;
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
|
@ -36,7 +36,7 @@ void setup() {
|
|||
// initialize SX1278 FSK modem with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -61,7 +61,7 @@ void setup() {
|
|||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
state = radio.setSyncWord(syncWord, 8);
|
||||
if (state != ERR_NONE) {
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("Unable to set configuration, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
|
|
@ -74,7 +74,7 @@ void setup() {
|
|||
// setDataShapingOOK() to set the correct shaping!
|
||||
state = radio.setOOK(true);
|
||||
state = radio.setDataShapingOOK(1);
|
||||
if (state != ERR_NONE) {
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("Unable to change modulation, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
|
|
@ -95,11 +95,11 @@ void loop() {
|
|||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Packet transmitted successfully!"));
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
Serial.println(F("[SX1278] Packet too long!"));
|
||||
} else if (state == ERR_TX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
|
||||
Serial.println(F("[SX1278] Timed out while transmitting!"));
|
||||
} else {
|
||||
Serial.println(F("[SX1278] Failed to transmit packet, code "));
|
||||
|
|
@ -113,11 +113,11 @@ void loop() {
|
|||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Received packet!"));
|
||||
Serial.print(F("[SX1278] Data:\t"));
|
||||
Serial.println(str);
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
Serial.println(F("[SX1278] Timed out while waiting for packet!"));
|
||||
} else {
|
||||
Serial.println(F("[SX1278] Failed to receive packet, code "));
|
||||
|
|
@ -138,7 +138,7 @@ void loop() {
|
|||
state = radio.setNodeAddress(0x02);
|
||||
// set broadcast address to 0xFF
|
||||
state = radio.setBroadcastAddress(0xFF);
|
||||
if (state != ERR_NONE) {
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Unable to set address filter, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ void loop() {
|
|||
// node and broadcast address
|
||||
/*
|
||||
state = radio.disableAddressFiltering();
|
||||
if (state != ERR_NONE) {
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("Unable to remove address filter, code "));
|
||||
}
|
||||
*/
|
||||
|
|
@ -159,7 +159,7 @@ void loop() {
|
|||
|
||||
// activate direct mode transmitter
|
||||
state = radio.transmitDirect();
|
||||
if (state != ERR_NONE) {
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Unable to start direct transmission mode, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
|
@ -170,20 +170,21 @@ void loop() {
|
|||
// it is recommended to set data shaping to 0
|
||||
// (no shaping) when transmitting audio
|
||||
state = radio.setDataShaping(0.0);
|
||||
if (state != ERR_NONE) {
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Unable to set data shaping, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// tone() function is not available on ESP32 and Arduino Due
|
||||
#if !defined(ESP32) && !defined(_VARIANT_ARDUINO_DUE_X_)
|
||||
// transmit FM tone at 1000 Hz for 1 second
|
||||
// transmit FM tone at 1000 Hz for 1 second, then 500 Hz for 1 second
|
||||
// (DIO2 is connected to Arduino pin 4)
|
||||
// Note: tone() function is not available on Arduino Due and CubeCell
|
||||
// on these platforms, the following will do nothing
|
||||
#if !defined(RADIOLIB_TONE_UNSUPPORTED)
|
||||
tone(4, 1000);
|
||||
delay(1000);
|
||||
// transmit FM note at 500 Hz for 1 second
|
||||
tone(4, 500);
|
||||
delay(1000);
|
||||
noTone(4);
|
||||
#endif
|
||||
|
||||
// NOTE: after calling transmitDirect(), SX127x will start
|
||||
|
|
@ -194,7 +195,7 @@ void loop() {
|
|||
// direct mode transmissions can also be received
|
||||
// as bit stream on DIO1 (data) and DIO2 (clock)
|
||||
state = radio.receiveDirect();
|
||||
if (state != ERR_NONE) {
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Unable to start direct reception mode, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
|
|
|||
159
lib/RadioLib/examples/SX127x/SX127x_PingPong/SX127x_PingPong.ino
Normal file
159
lib/RadioLib/examples/SX127x/SX127x_PingPong/SX127x_PingPong.ino
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
RadioLib SX127x Ping-Pong Example
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// uncomment the following only on one
|
||||
// of the nodes to initiate the pings
|
||||
//#define INITIATING_NODE
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// NRST pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission states between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
// flag to indicate transmission or reception state
|
||||
bool transmitFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// flag to indicate that a packet was sent or received
|
||||
volatile bool operationDone = false;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is transmitted or received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we sent or received packet, set the flag
|
||||
operationDone = true;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
radio.setDio0Action(setFlag);
|
||||
|
||||
#if defined(INITIATING_NODE)
|
||||
// send the first packet on this node
|
||||
Serial.print(F("[SX1278] Sending first packet ... "));
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
transmitFlag = true;
|
||||
#else
|
||||
// start listening for LoRa packets on this node
|
||||
Serial.print(F("[SX1278] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the previous operation finished
|
||||
if(operationDone) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
operationDone = false;
|
||||
|
||||
if(transmitFlag) {
|
||||
// the previous operation was transmission, listen for response
|
||||
// print the result
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(transmissionState);
|
||||
|
||||
}
|
||||
|
||||
// listen for response
|
||||
radio.startReceive();
|
||||
transmitFlag = false;
|
||||
|
||||
} else {
|
||||
// the previous operation was reception
|
||||
// print data and send another packet
|
||||
String str;
|
||||
int state = radio.readData(str);
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[SX1278] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[SX1278] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
Serial.print(F("[SX1278] RSSI:\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print SNR (Signal-to-Noise Ratio)
|
||||
Serial.print(F("[SX1278] SNR:\t\t"));
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
}
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
// send another one
|
||||
Serial.print(F("[SX1278] Sending another packet ... "));
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
transmitFlag = true;
|
||||
}
|
||||
|
||||
// we're ready to process more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ void setup() {
|
|||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -65,7 +65,7 @@ void loop() {
|
|||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
@ -91,11 +91,11 @@ void loop() {
|
|||
Serial.print(radio.getFrequencyError());
|
||||
Serial.println(F(" Hz"));
|
||||
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
RadioLib SX127x Direct Receive Example
|
||||
|
||||
This example shows how to receive FSK packets without using
|
||||
SX127x packet engine.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// DIO2 pin: 5
|
||||
const int pin = 5;
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with FSK modem at 9600 bps
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK(434.0, 9.6, 20.0);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the direct mode sync word
|
||||
// the default RadioLib FSK sync word is 0x12AD
|
||||
// we can add in some preamble bits, to lower the chance
|
||||
// of false detection
|
||||
radio.setDirectSyncWord(0x555512AD, 32);
|
||||
|
||||
// set function that will be called each time a bit is received
|
||||
radio.setDirectAction(readBit);
|
||||
|
||||
// start direct mode reception
|
||||
radio.receiveDirect();
|
||||
}
|
||||
|
||||
// this function is called when a new bit is received
|
||||
void readBit(void) {
|
||||
// read the data bit
|
||||
radio.readBit(pin);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// we expect the packet to contain the string "Hello World!",
|
||||
// a length byte and 2 CRC bytes, that's 15 bytes in total
|
||||
if(radio.available() >= 15) {
|
||||
Serial.println("[SX1278] Received packet in direct mode!");
|
||||
while(radio.available()) {
|
||||
// read a byte
|
||||
byte b = radio.read();
|
||||
|
||||
// print it
|
||||
Serial.print(b, HEX);
|
||||
Serial.print('\t');
|
||||
Serial.write(b);
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
RadioLib SX127x Transmit with Frequency Hopping Example
|
||||
|
||||
This example transmits packets using SX1278 LoRa radio module.
|
||||
Each packet contains up to 256 bytes of data, in the form of:
|
||||
- Arduino String
|
||||
- null-terminated char array (C-string)
|
||||
- arbitrary binary data (byte array)
|
||||
|
||||
Other modules from SX127x/RFM9x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
|
||||
SX127x supports FHSS or Frequency Hopping Spread Spectrum.
|
||||
Once a hopping period is set and a transmission is started, the radio
|
||||
will begin triggering interrupts every hop period where the radio frequency
|
||||
is changed to the next channel.
|
||||
*/
|
||||
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
volatile bool receivedFlag = false;
|
||||
|
||||
// flag to indicate frequency must be changed
|
||||
volatile bool fhssChangeFlag = false;
|
||||
|
||||
// the channel frequencies can be generated randomly or hard coded
|
||||
// NOTE: The frequency list MUST be the same on both sides!
|
||||
float channels[] = { 433.0, 433.4, 433.2, 433.6, 434.0, 433.8 };
|
||||
int numberOfChannels = sizeof(channels) / sizeof(float);
|
||||
|
||||
// counter to keep track of how many frequency hops were performed
|
||||
int hopsCompleted = 0;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setRxFlag(void) {
|
||||
receivedFlag = true;
|
||||
}
|
||||
|
||||
// this function is called when FhssChangeChannel interrupt occurs
|
||||
// (at the beginning of each transmission)
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFHSSFlag(void) {
|
||||
fhssChangeFlag = true;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// begin radio on home channel
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin(channels[0]);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set hop period in symbols
|
||||
// this will also enable FHSS
|
||||
state = radio.setFHSSHoppingPeriod(9);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function to call when reception is finished
|
||||
radio.setDio0Action(setRxFlag);
|
||||
|
||||
// set the function to call when we need to change frequency
|
||||
radio.setDio1Action(setFHSSFlag);
|
||||
|
||||
// start listening for LoRa packets
|
||||
Serial.print(F("[SX1278] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the reception flag is set
|
||||
if (receivedFlag == true) {
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[SX1278] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[SX1278] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("[SX1278] CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("[SX1278] Failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// print the number of hops it took
|
||||
Serial.print(F("[SX1278] Hops completed: "));
|
||||
Serial.println(hopsCompleted);
|
||||
|
||||
// reset the counter
|
||||
hopsCompleted = 0;
|
||||
|
||||
// put the module back to listen mode
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets, clear the flag
|
||||
receivedFlag = false;
|
||||
}
|
||||
|
||||
// check if we need to do another frequency hop
|
||||
if (fhssChangeFlag == true) {
|
||||
// we do, change it now
|
||||
int state = radio.setFrequency(channels[radio.getFHSSChannel() % numberOfChannels]);
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("[SX1278] Failed to change frequency, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// increment the counter
|
||||
hopsCompleted++;
|
||||
|
||||
// clear the FHSS interrupt
|
||||
radio.clearFHSSInt();
|
||||
|
||||
// we're ready to do another hop, clear the flag
|
||||
fhssChangeFlag = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ void setup() {
|
|||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -56,7 +56,7 @@ void setup() {
|
|||
// start listening for LoRa packets
|
||||
Serial.print(F("[SX1278] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -85,6 +85,9 @@ volatile bool enableInterrupt = true;
|
|||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
|
|
@ -115,7 +118,7 @@ void loop() {
|
|||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[SX1278] Received packet!"));
|
||||
|
||||
|
|
@ -138,7 +141,7 @@ void loop() {
|
|||
Serial.print(radio.getFrequencyError());
|
||||
Serial.println(F(" Hz"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("[SX1278] CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ void setup() {
|
|||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio1.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -73,7 +73,7 @@ void setup() {
|
|||
// preamble length: 20 symbols
|
||||
// amplifier gain: 1 (maximum gain)
|
||||
state = radio2.begin(915.0, 500.0, 6, 5, 0x14, 2, 20, 1);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -85,32 +85,32 @@ void setup() {
|
|||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 433.5 MHz
|
||||
if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||
if (radio1.setFrequency(433.5) == RADIOLIB_ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bandwidth to 250 kHz
|
||||
if (radio1.setBandwidth(250.0) == ERR_INVALID_BANDWIDTH) {
|
||||
if (radio1.setBandwidth(250.0) == RADIOLIB_ERR_INVALID_BANDWIDTH) {
|
||||
Serial.println(F("Selected bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set spreading factor to 10
|
||||
if (radio1.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) {
|
||||
if (radio1.setSpreadingFactor(10) == RADIOLIB_ERR_INVALID_SPREADING_FACTOR) {
|
||||
Serial.println(F("Selected spreading factor is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set coding rate to 6
|
||||
if (radio1.setCodingRate(6) == ERR_INVALID_CODING_RATE) {
|
||||
if (radio1.setCodingRate(6) == RADIOLIB_ERR_INVALID_CODING_RATE) {
|
||||
Serial.println(F("Selected coding rate is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set LoRa sync word to 0x14
|
||||
// NOTE: value 0x34 is reserved for LoRaWAN networks and should not be used
|
||||
if (radio1.setSyncWord(0x14) != ERR_NONE) {
|
||||
if (radio1.setSyncWord(0x14) != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("Unable to set sync word!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
@ -118,20 +118,20 @@ void setup() {
|
|||
// set output power to 10 dBm (accepted range is -3 - 17 dBm)
|
||||
// NOTE: 20 dBm value allows high power operation, but transmission
|
||||
// duty cycle MUST NOT exceed 1%
|
||||
if (radio1.setOutputPower(10) == ERR_INVALID_OUTPUT_POWER) {
|
||||
if (radio1.setOutputPower(10) == RADIOLIB_ERR_INVALID_OUTPUT_POWER) {
|
||||
Serial.println(F("Selected output power is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set over current protection limit to 80 mA (accepted range is 45 - 240 mA)
|
||||
// NOTE: set value to 0 to disable overcurrent protection
|
||||
if (radio1.setCurrentLimit(80) == ERR_INVALID_CURRENT_LIMIT) {
|
||||
if (radio1.setCurrentLimit(80) == RADIOLIB_ERR_INVALID_CURRENT_LIMIT) {
|
||||
Serial.println(F("Selected current limit is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set LoRa preamble length to 15 symbols (accepted range is 6 - 65535)
|
||||
if (radio1.setPreambleLength(15) == ERR_INVALID_PREAMBLE_LENGTH) {
|
||||
if (radio1.setPreambleLength(15) == RADIOLIB_ERR_INVALID_PREAMBLE_LENGTH) {
|
||||
Serial.println(F("Selected preamble length is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
@ -139,7 +139,7 @@ void setup() {
|
|||
// set amplifier gain to 1 (accepted range is 1 - 6, where 1 is maximum gain)
|
||||
// NOTE: set value to 0 to enable automatic gain control
|
||||
// leave at 0 unless you know what you're doing
|
||||
if (radio1.setGain(1) == ERR_INVALID_GAIN) {
|
||||
if (radio1.setGain(1) == RADIOLIB_ERR_INVALID_GAIN) {
|
||||
Serial.println(F("Selected gain is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ void setup() {
|
|||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -71,7 +71,7 @@ void loop() {
|
|||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F(" success!"));
|
||||
|
||||
|
|
@ -80,11 +80,11 @@ void loop() {
|
|||
Serial.print(radio.getDataRate());
|
||||
Serial.println(F(" bps"));
|
||||
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 256 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
} else if (state == ERR_TX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
|
||||
// timeout occurred while transmitting packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,182 @@
|
|||
/*
|
||||
RadioLib SX127x Transmit with Frequency Hopping Example
|
||||
|
||||
This example transmits packets using SX1278 LoRa radio module.
|
||||
Each packet contains up to 256 bytes of data, in the form of:
|
||||
- Arduino String
|
||||
- null-terminated char array (C-string)
|
||||
- arbitrary binary data (byte array)
|
||||
|
||||
Other modules from SX127x/RFM9x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
|
||||
SX127x supports FHSS or Frequency Hopping Spread Spectrum.
|
||||
Once a hopping period is set and a transmission is started, the radio
|
||||
will begin triggering interrupts every hop period where the radio frequency
|
||||
is changed to the next channel.
|
||||
*/
|
||||
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
volatile bool transmittedFlag = false;
|
||||
|
||||
// flag to indicate frequency must be changed
|
||||
volatile bool fhssChangeFlag = false;
|
||||
|
||||
// the channel frequencies can be generated randomly or hard coded
|
||||
// NOTE: The frequency list MUST be the same on both sides!
|
||||
float channels[] = { 433.0, 433.4, 433.2, 433.6, 434.0, 433.8 };
|
||||
int numberOfChannels = sizeof(channels) / sizeof(float);
|
||||
|
||||
// counter to keep track of how many frequency hops were performed
|
||||
int hopsCompleted = 0;
|
||||
|
||||
// counter that increments with each sent packet
|
||||
int packetCounter = 0;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
// this is the packet that will be sent
|
||||
String longPacket = "Let's create a really long packet to trigger \
|
||||
lots of hop interrupts. A packet can be up to 256 bytes long. \
|
||||
This packet is 222 bytes so using sf = 9, bw = 125, timeOnAir is \
|
||||
1488ms. 1488ms / (9*4.10ms) = 40 hops. Counter: ";
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setTxFlag(void) {
|
||||
transmittedFlag = true;
|
||||
}
|
||||
|
||||
// this function is called when FhssChangeChannel interrupt occurs
|
||||
// (at the beginning of each transmission)
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFHSSFlag(void) {
|
||||
fhssChangeFlag = true;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// begin radio on home channel
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin(channels[0]);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set hop period in symbols
|
||||
// this will also enable FHSS
|
||||
state = radio.setFHSSHoppingPeriod(9);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function to call when transmission is finished
|
||||
radio.setDio0Action(setTxFlag);
|
||||
|
||||
// set the function to call when we need to change frequency
|
||||
radio.setDio1Action(setFHSSFlag);
|
||||
|
||||
// start transmitting the first packet
|
||||
Serial.print(F("[SX1278] Sending first packet ... "));
|
||||
String packet = longPacket + packetCounter;
|
||||
transmissionState = radio.startTransmit(packet);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the transmission flag is set
|
||||
if (transmittedFlag == true) {
|
||||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(transmissionState);
|
||||
|
||||
}
|
||||
|
||||
// The channel is automatically reset to 0 upon completion
|
||||
Serial.print(F("[SX1278] Radio is on channel: "));
|
||||
Serial.println(radio.getFHSSChannel());
|
||||
|
||||
// print the number of hops it took
|
||||
Serial.print(F("[SX1278] Hops completed: "));
|
||||
Serial.println(hopsCompleted);
|
||||
|
||||
// reset the counter
|
||||
hopsCompleted = 0;
|
||||
|
||||
// return to home channel before the next transaction
|
||||
radio.setFrequency(channels[radio.getFHSSChannel() % numberOfChannels]);
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
// increment the packet counter
|
||||
packetCounter++;
|
||||
|
||||
// send another packet
|
||||
Serial.print(F("[SX1278] Sending another packet ... "));
|
||||
String packet = longPacket + packetCounter;
|
||||
transmissionState = radio.startTransmit(packet);
|
||||
}
|
||||
|
||||
// check if we need to do another frequency hop
|
||||
if (fhssChangeFlag == true) {
|
||||
// we do, change it now
|
||||
int state = radio.setFrequency(channels[radio.getFHSSChannel() % numberOfChannels]);
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("[SX1278] Failed to change frequency, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// increment the counter
|
||||
hopsCompleted++;
|
||||
|
||||
// clear the FHSS interrupt
|
||||
radio.clearFHSSInt();
|
||||
|
||||
// we're ready to do another hop, clear the flag
|
||||
fhssChangeFlag = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ SX1278 radio = new Module(10, 2, 9, 3);
|
|||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = ERR_NONE;
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
|
@ -40,7 +40,7 @@ void setup() {
|
|||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -77,6 +77,9 @@ volatile bool enableInterrupt = true;
|
|||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
|
|
@ -97,7 +100,7 @@ void loop() {
|
|||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == ERR_NONE) {
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
|
|
@ -111,6 +114,11 @@ void loop() {
|
|||
|
||||
}
|
||||
|
||||
// clean up after transmission is finished
|
||||
// this will ensure transmitter is disabled,
|
||||
// RF switch is powered down etc.
|
||||
radio.finishTransmit();
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ void setup() {
|
|||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.beginBLE();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -59,13 +59,13 @@ void setup() {
|
|||
state = radio.setOutputPower(5);
|
||||
state = radio.setDataShaping(1.0);
|
||||
state = radio.setAccessAddress(0x12345678);
|
||||
if (state != ERR_NONE) {
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("Unable to set configuration, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
#warning "This sketch is just an API guide! Read the note at line 6."
|
||||
#warning "This sketch is just an API guide! Read the note at line 8."
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
|
@ -79,11 +79,11 @@ void loop() {
|
|||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Packet transmitted successfully!"));
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
Serial.println(F("[SX1280] Packet too long!"));
|
||||
} else if (state == ERR_TX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
|
||||
Serial.println(F("[SX1280] Timed out while transmitting!"));
|
||||
} else {
|
||||
Serial.print(F("[SX1280] Failed to transmit packet, code "));
|
||||
|
|
@ -97,11 +97,11 @@ void loop() {
|
|||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Received packet!"));
|
||||
Serial.print(F("[SX1280] Data:\t"));
|
||||
Serial.println(str);
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
Serial.println(F("[SX1280] Timed out while waiting for packet!"));
|
||||
} else {
|
||||
Serial.print(F("[SX1280] Failed to receive packet, code "));
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ void setup() {
|
|||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -48,11 +48,11 @@ void loop() {
|
|||
// start scanning current channel
|
||||
int state = radio.scanChannel();
|
||||
|
||||
if (state == LORA_DETECTED) {
|
||||
if (state == RADIOLIB_LORA_DETECTED) {
|
||||
// LoRa preamble was detected
|
||||
Serial.println(F("detected!"));
|
||||
|
||||
} else if (state == CHANNEL_FREE) {
|
||||
} else if (state == RADIOLIB_CHANNEL_FREE) {
|
||||
// no preamble was detected, channel is free
|
||||
Serial.println(F("channel is free!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ void setup() {
|
|||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.beginFLRC();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -58,7 +58,7 @@ void setup() {
|
|||
state = radio.setDataShaping(1.0);
|
||||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67};
|
||||
state = radio.setSyncWord(syncWord, 4);
|
||||
if (state != ERR_NONE) {
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("Unable to set configuration, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
|
|
@ -78,11 +78,11 @@ void loop() {
|
|||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Packet transmitted successfully!"));
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
Serial.println(F("[SX1280] Packet too long!"));
|
||||
} else if (state == ERR_TX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
|
||||
Serial.println(F("[SX1280] Timed out while transmitting!"));
|
||||
} else {
|
||||
Serial.println(F("[SX1280] Failed to transmit packet, code "));
|
||||
|
|
@ -96,11 +96,11 @@ void loop() {
|
|||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Received packet!"));
|
||||
Serial.print(F("[SX1280] Data:\t"));
|
||||
Serial.println(str);
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
Serial.println(F("[SX1280] Timed out while waiting for packet!"));
|
||||
} else {
|
||||
Serial.print(F("[SX1280] Failed to receive packet, code "));
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ void setup() {
|
|||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.beginGFSK();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -58,7 +58,7 @@ void setup() {
|
|||
state = radio.setDataShaping(RADIOLIB_SHAPING_1_0);
|
||||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89};
|
||||
state = radio.setSyncWord(syncWord, 5);
|
||||
if (state != ERR_NONE) {
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("Unable to set configuration, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
|
|
@ -78,11 +78,11 @@ void loop() {
|
|||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Packet transmitted successfully!"));
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
Serial.println(F("[SX1280] Packet too long!"));
|
||||
} else if (state == ERR_TX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
|
||||
Serial.println(F("[SX1280] Timed out while transmitting!"));
|
||||
} else {
|
||||
Serial.println(F("[SX1280] Failed to transmit packet, code "));
|
||||
|
|
@ -96,11 +96,11 @@ void loop() {
|
|||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Received packet!"));
|
||||
Serial.print(F("[SX1280] Data:\t"));
|
||||
Serial.println(str);
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
Serial.println(F("[SX1280] Timed out while waiting for packet!"));
|
||||
} else {
|
||||
Serial.print(F("[SX1280] Failed to receive packet, code "));
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ void setup() {
|
|||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -57,14 +57,14 @@ void loop() {
|
|||
int state = radio.range(false, 0x12345678);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// ranging finished successfully
|
||||
Serial.println(F("success!"));
|
||||
Serial.print(F("[SX1280] Distance:\t\t\t"));
|
||||
Serial.print(radio.getRangingResult());
|
||||
Serial.println(F(" meters"));
|
||||
|
||||
} else if (state == ERR_RANGING_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_RANGING_TIMEOUT) {
|
||||
// timed out waiting for ranging packet
|
||||
Serial.println(F("timed out!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ void setup() {
|
|||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -65,7 +65,7 @@ void loop() {
|
|||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
@ -85,11 +85,17 @@ void loop() {
|
|||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
// print the Frequency Error
|
||||
// of the last received packet
|
||||
Serial.print(F("[SX1280] Frequency Error:\t"));
|
||||
Serial.print(radio.getFrequencyError());
|
||||
Serial.println(F(" Hz"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ void setup() {
|
|||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -56,7 +56,7 @@ void setup() {
|
|||
// start listening for LoRa packets
|
||||
Serial.print(F("[SX1280] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -85,6 +85,9 @@ volatile bool enableInterrupt = true;
|
|||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
|
|
@ -115,7 +118,7 @@ void loop() {
|
|||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[SX1280] Received packet!"));
|
||||
|
||||
|
|
@ -133,7 +136,13 @@ void loop() {
|
|||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
// print the Frequency Error
|
||||
// of the last received packet
|
||||
Serial.print(F("[SX1280] Frequency Error:\t"));
|
||||
Serial.print(radio.getFrequencyError());
|
||||
Serial.println(F(" Hz"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ void setup() {
|
|||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio1.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -68,7 +68,7 @@ void setup() {
|
|||
// output power: 2 dBm
|
||||
// preamble length: 20 symbols
|
||||
state = radio2.begin(2450.0, 1625.0, 7, 5, 2, 20);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -80,43 +80,43 @@ void setup() {
|
|||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 2410.5 MHz
|
||||
if (radio1.setFrequency(2410.5) == ERR_INVALID_FREQUENCY) {
|
||||
if (radio1.setFrequency(2410.5) == RADIOLIB_ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bandwidth to 203.125 kHz
|
||||
if (radio1.setBandwidth(203.125) == ERR_INVALID_BANDWIDTH) {
|
||||
if (radio1.setBandwidth(203.125) == RADIOLIB_ERR_INVALID_BANDWIDTH) {
|
||||
Serial.println(F("Selected bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set spreading factor to 10
|
||||
if (radio1.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) {
|
||||
if (radio1.setSpreadingFactor(10) == RADIOLIB_ERR_INVALID_SPREADING_FACTOR) {
|
||||
Serial.println(F("Selected spreading factor is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set coding rate to 6
|
||||
if (radio1.setCodingRate(6) == ERR_INVALID_CODING_RATE) {
|
||||
if (radio1.setCodingRate(6) == RADIOLIB_ERR_INVALID_CODING_RATE) {
|
||||
Serial.println(F("Selected coding rate is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set output power to -2 dBm
|
||||
if (radio1.setOutputPower(-2) == ERR_INVALID_OUTPUT_POWER) {
|
||||
if (radio1.setOutputPower(-2) == RADIOLIB_ERR_INVALID_OUTPUT_POWER) {
|
||||
Serial.println(F("Selected output power is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set LoRa preamble length to 16 symbols (accepted range is 2 - 65535)
|
||||
if (radio1.setPreambleLength(16) == ERR_INVALID_PREAMBLE_LENGTH) {
|
||||
if (radio1.setPreambleLength(16) == RADIOLIB_ERR_INVALID_PREAMBLE_LENGTH) {
|
||||
Serial.println(F("Selected preamble length is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// disable CRC
|
||||
if (radio1.setCRC(false) == ERR_INVALID_CRC_CONFIGURATION) {
|
||||
if (radio1.setCRC(false) == RADIOLIB_ERR_INVALID_CRC_CONFIGURATION) {
|
||||
Serial.println(F("Selected CRC is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ void setup() {
|
|||
// preamble length: 12 symbols
|
||||
// CRC: enabled
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -78,11 +78,11 @@ void loop() {
|
|||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 256 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ SX1280 radio = new Module(10, 2, 3, 9);
|
|||
//SX1280 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = ERR_NONE;
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
|
@ -40,7 +40,7 @@ void setup() {
|
|||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -77,6 +77,9 @@ volatile bool enableInterrupt = true;
|
|||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
|
|
@ -97,7 +100,7 @@ void loop() {
|
|||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == ERR_NONE) {
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
|
|
@ -107,6 +110,11 @@ void loop() {
|
|||
|
||||
}
|
||||
|
||||
// clean up after transmission is finished
|
||||
// this will ensure transmitter is disabled,
|
||||
// RF switch is powered down etc.
|
||||
radio.finishTransmit();
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ void setup() {
|
|||
// initialize Si4432 with default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -59,7 +59,7 @@ void loop() {
|
|||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
@ -67,11 +67,11 @@ void loop() {
|
|||
Serial.print(F("[Si4432] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ void setup() {
|
|||
// initialize Si4432 with default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -48,7 +48,7 @@ void setup() {
|
|||
// start listening for packets
|
||||
Serial.print(F("[Si4432] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -76,6 +76,9 @@ volatile bool enableInterrupt = true;
|
|||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
|
|
@ -106,7 +109,7 @@ void loop() {
|
|||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[Si4432] Received packet!"));
|
||||
|
||||
|
|
@ -114,7 +117,7 @@ void loop() {
|
|||
Serial.print(F("[Si4432] Data:\t\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ void setup() {
|
|||
// initialize Si4432 with default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
int state = radio1.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -60,7 +60,7 @@ void setup() {
|
|||
// output power: 17 dBm
|
||||
// preamble length: 32 bits
|
||||
state = radio2.begin(868.0, 200.0, 60.0, 335.5, 17, 32);
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -72,17 +72,17 @@ void setup() {
|
|||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 433.5 MHz
|
||||
if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||
if (radio1.setFrequency(433.5) == RADIOLIB_ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("[Si4432] Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bit rate to 100.0 kbps
|
||||
state = radio1.setBitRate(100.0);
|
||||
if (state == ERR_INVALID_BIT_RATE) {
|
||||
if (state == RADIOLIB_ERR_INVALID_BIT_RATE) {
|
||||
Serial.println(F("[Si4432] Selected bit rate is invalid for this module!"));
|
||||
while (true);
|
||||
} else if (state == ERR_INVALID_BIT_RATE_BW_RATIO) {
|
||||
} else if (state == RADIOLIB_ERR_INVALID_BIT_RATE_BW_RATIO) {
|
||||
Serial.println(F("[Si4432] Selected bit rate to bandwidth ratio is invalid!"));
|
||||
Serial.println(F("[Si4432] Increase receiver bandwidth to set this bit rate."));
|
||||
while (true);
|
||||
|
|
@ -90,19 +90,19 @@ void setup() {
|
|||
|
||||
// set receiver bandwidth to 284.8 kHz
|
||||
state = radio1.setRxBandwidth(284.8);
|
||||
if (state == ERR_INVALID_RX_BANDWIDTH) {
|
||||
if (state == RADIOLIB_ERR_INVALID_RX_BANDWIDTH) {
|
||||
Serial.println(F("[Si4432] Selected receiver bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set frequency deviation to 10.0 kHz
|
||||
if (radio1.setFrequencyDeviation(10.0) == ERR_INVALID_FREQUENCY_DEVIATION) {
|
||||
if (radio1.setFrequencyDeviation(10.0) == RADIOLIB_ERR_INVALID_FREQUENCY_DEVIATION) {
|
||||
Serial.println(F("[Si4432] Selected frequency deviation is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set output power to 2 dBm
|
||||
if (radio1.setOutputPower(2) == ERR_INVALID_OUTPUT_POWER) {
|
||||
if (radio1.setOutputPower(2) == RADIOLIB_ERR_INVALID_OUTPUT_POWER) {
|
||||
Serial.println(F("[Si4432] Selected output power is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ void setup() {
|
|||
// up to 4 bytes can be set as sync word
|
||||
// set sync word to 0x01234567
|
||||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67};
|
||||
if (radio1.setSyncWord(syncWord, 4) == ERR_INVALID_SYNC_WORD) {
|
||||
if (radio1.setSyncWord(syncWord, 4) == RADIOLIB_ERR_INVALID_SYNC_WORD) {
|
||||
Serial.println(F("[Si4432] Selected sync word is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ void setup() {
|
|||
// initialize Si4432 with default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -60,15 +60,15 @@ void loop() {
|
|||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F(" success!"));
|
||||
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 256 bytes
|
||||
Serial.println(F(" too long!"));
|
||||
|
||||
} else if (state == ERR_TX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
|
||||
// timeout occured while transmitting packet
|
||||
Serial.println(F(" timeout!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ Si4432 radio = new Module(10, 2, 9);
|
|||
//Si4432 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = ERR_NONE;
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
|
@ -38,7 +38,7 @@ void setup() {
|
|||
// initialize Si4432 with default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -75,6 +75,9 @@ volatile bool enableInterrupt = true;
|
|||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
|
|
@ -95,7 +98,7 @@ void loop() {
|
|||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == ERR_NONE) {
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
|
|
@ -105,6 +108,11 @@ void loop() {
|
|||
|
||||
}
|
||||
|
||||
// clean up after transmission is finished
|
||||
// this will ensure transmitter is disabled,
|
||||
// RF switch is powered down etc.
|
||||
radio.finishTransmit();
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
|
|
|
|||
144
lib/RadioLib/examples/Stream/Stream_Receive/Stream_Receive.ino
Normal file
144
lib/RadioLib/examples/Stream/Stream_Receive/Stream_Receive.ino
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
RadioLib Stream Receive Example
|
||||
|
||||
This example shows how to receive data in "Stream" mode.
|
||||
In this mode, arbitrary length of data may be sent, up to
|
||||
"infinite" continuous transmission between two devices.
|
||||
|
||||
Caveats:
|
||||
- CRC of the payload is not supported
|
||||
- the length of the payload must be known in advance
|
||||
|
||||
Modules that can be used for Stream are:
|
||||
- SX127x/RFM9x (FSK mode only)
|
||||
- RF69
|
||||
- SX1231
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for Stream transmit
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when receive buffer is full
|
||||
radio.setFifoFullAction(fifoGet);
|
||||
|
||||
// fixed packet length mode is required
|
||||
radio.fixedPacketLengthMode(0);
|
||||
|
||||
// start listening for packets
|
||||
Serial.print(F("[SX1278] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
// radio.scanChannel();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
volatile bool receivedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// how many bytes are there in total
|
||||
const int totalLength = 512;
|
||||
|
||||
// counter to keep track of how many bytes have been received so far
|
||||
volatile int receivedLength = 0;
|
||||
|
||||
// buffer to save the received data into
|
||||
volatile uint8_t rxBuffer[totalLength + 1];
|
||||
|
||||
// this function is called when the radio receive buffer
|
||||
// is full and ready to be read
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void fifoGet(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// set the flag when we receive the full packet
|
||||
receivedFlag = radio.fifoGet(rxBuffer, totalLength, &receivedLength);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the flag is set
|
||||
if(receivedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// packet was successfully received
|
||||
Serial.println(F("[SX1278] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[SX1278] Data:\t\t"));
|
||||
Serial.println((char*)rxBuffer);
|
||||
|
||||
// reset flag
|
||||
receivedFlag = false;
|
||||
receivedLength = 0;
|
||||
|
||||
// put module back to listen mode
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
|
||||
}
|
||||
156
lib/RadioLib/examples/Stream/Stream_Transmit/Stream_Transmit.ino
Normal file
156
lib/RadioLib/examples/Stream/Stream_Transmit/Stream_Transmit.ino
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
RadioLib Stream Transmit Example
|
||||
|
||||
This example shows how to transmit data in "Stream" mode.
|
||||
In this mode, arbitrary length of data may be sent, up to
|
||||
"infinite" continuous transmission between two devices.
|
||||
|
||||
Caveats:
|
||||
- CRC of the payload is not supported
|
||||
- the length of the payload must be known in advance
|
||||
|
||||
Modules that can be used for Stream are:
|
||||
- SX127x/RFM9x (FSK mode only)
|
||||
- RF69
|
||||
- SX1231
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
// this packet is much longer than would normally fit
|
||||
// into SX1278's internal buffer
|
||||
String longPacket = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\
|
||||
Maecenas at urna ut nunc imperdiet laoreet. Aliquam erat volutpat.\
|
||||
Etiam mattis mauris vitae posuere tincidunt. In sit amet bibendum nisl,\
|
||||
a ultrices lorem. Duis hendrerit ultricies condimentum. Phasellus eget nisi\
|
||||
eget massa aliquam bibendum. Pellentesque ante neque, aliquam non diam non,\
|
||||
fringilla facilisis ipsum. Morbi in molestie orci. Vestibulum luctus\
|
||||
venenatis arcu sit amet pellentesque. Nulla posuere sit amet turpis\
|
||||
id pharetra. Curabitur nec.";
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for Stream transmit
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when transmit buffer is empty
|
||||
radio.setFifoEmptyAction(fifoAdd);
|
||||
|
||||
// fixed packet length mode is required
|
||||
radio.fixedPacketLengthMode(0);
|
||||
|
||||
// start transmitting the long packet
|
||||
Serial.print(F("[SX1278] Sending a very long packet ... "));
|
||||
transmissionState = radio.startTransmit(longPacket);
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was sent
|
||||
volatile bool transmittedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// how many bytes are there in total
|
||||
volatile int totalLength = longPacket.length();
|
||||
|
||||
// counter to keep track of how many bytes still need to be sent
|
||||
volatile int remLength = totalLength;
|
||||
|
||||
// this function is called when the radio transmit buffer
|
||||
// is empty and ready to be refilled
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void fifoAdd(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add more bytes to the transmit buffer
|
||||
uint8_t* txBuffPtr = (uint8_t*)longPacket.c_str();
|
||||
transmittedFlag = radio.fifoAdd(txBuffPtr, totalLength, &remLength);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the previous transmission finished
|
||||
if(transmittedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
// reset the counter
|
||||
remLength = totalLength;
|
||||
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
// NOTE: when using interrupt-driven transmit method,
|
||||
// it is not possible to automatically measure
|
||||
// transmission data rate using getDataRate()
|
||||
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(transmissionState);
|
||||
|
||||
}
|
||||
|
||||
// NOTE: in FSK mode, SX127x will not automatically
|
||||
// turn transmitter off after sending a packet
|
||||
// set mode to standby to ensure we don't jam others
|
||||
radio.standby();
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
// send another one
|
||||
Serial.print(F("[SX1278] Sending another long packet ... "));
|
||||
transmissionState = radio.startTransmit(longPacket);
|
||||
|
||||
// we're ready to send more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
RadioLib XBee API Receive Example
|
||||
|
||||
This example receives packets using XBee API mode.
|
||||
In API mode, many XBee modules can form a mesh network.
|
||||
|
||||
IMPORTANT: Before uploading this example, make sure that the XBee module
|
||||
is running API ROUTER/ENDPOINT firmware!
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// XBee has the following connections:
|
||||
// TX pin: 9
|
||||
// RX pin: 8
|
||||
// RESET pin: 3
|
||||
XBee bee = new Module(9, 8, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//XBee bee = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize XBee module with baudrate 9600
|
||||
Serial.print(F("[XBee] Initializing ... "));
|
||||
int state = bee.begin(9600);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set PAN ID to 0x0123456789ABCDEF
|
||||
Serial.print(F("[XBee] Setting PAN ID ... "));
|
||||
uint8_t panId[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
state = bee.setPanId(panId);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if XBee received some data
|
||||
if (bee.available() > 0) {
|
||||
// print source address
|
||||
Serial.print(F("[XBee] Packet source:\t"));
|
||||
Serial.println(bee.getPacketSource());
|
||||
|
||||
// print data
|
||||
Serial.print(F("[XBee] Packet data:\t"));
|
||||
Serial.println(bee.getPacketData());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
RadioLib XBee API Transmit Example
|
||||
|
||||
This example transmits packets using XBee API mode.
|
||||
In API mode, many XBee modules can form a mesh network.
|
||||
|
||||
IMPORTANT: Before uploading this example, make sure that the XBee module
|
||||
is running API COORDINATOR firmware!
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// XBee has the following connections:
|
||||
// TX pin: 9
|
||||
// RX pin: 8
|
||||
// RESET pin: 3
|
||||
XBee bee = new Module(9, 8, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//XBee bee = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize XBee module with baudrate 9600
|
||||
Serial.print(F("[XBee] Initializing ... "));
|
||||
int state = bee.begin(9600);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set PAN ID to 0x0123456789ABCDEF
|
||||
Serial.print(F("[XBee] Setting PAN ID ... "));
|
||||
uint8_t panId[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
state = bee.setPanId(panId);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// transmit data to the destination module
|
||||
uint8_t dest[] = {0x00, 0x13, 0xA2, 0x00,
|
||||
0x40, 0xA5, 0x8A, 0x6B};
|
||||
Serial.print(F("[XBee] Transmitting message ... "));
|
||||
int state = bee.transmit(dest, "Hello World!");
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
/*
|
||||
RadioLib XBee Transparent Operation Example
|
||||
|
||||
This example transmits packets using XBee Transparent mode.
|
||||
In Transparent mode, two XBee modules act like a Serial line.
|
||||
Both modules must have the same PAN ID, and the destination
|
||||
addresses have to be set properly.
|
||||
|
||||
IMPORTANT: Before uploading this example, make sure that the XBee modules
|
||||
are running AT COORDINATOR and AT ROUTER firmware!
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// XBee has the following connections:
|
||||
// TX pin: 9
|
||||
// RX pin: 8
|
||||
// RESET pin: 3
|
||||
XBeeSerial bee = new Module(9, 8, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//XBeeSerial bee = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize XBee module with baudrate 9600
|
||||
Serial.print(F("[XBee] Initializing ... "));
|
||||
int state = bee.begin(9600);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set PAN ID to 0123456789ABCDEF
|
||||
Serial.print(F("[XBee] Setting PAN ID ... "));
|
||||
state = bee.setPanId("0123456789ABCDEF");
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set destination address to the address of the second module
|
||||
Serial.print(F("[XBee] Setting destination address ... "));
|
||||
state = bee.setDestinationAddress("0013A200", "40A58A5D");
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// XBeeSerial supports all methods of the Serial class
|
||||
// read data incoming from Serial port and write them to XBee
|
||||
while (Serial.available() > 0) {
|
||||
bee.write(Serial.read());
|
||||
}
|
||||
|
||||
// read data incoming from XBee and write them to Serial port
|
||||
while (bee.available() > 0) {
|
||||
Serial.write(bee.read());
|
||||
}
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ void setup() {
|
|||
// initialize nRF24 with default settings
|
||||
Serial.print(F("[nRF24] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -50,7 +50,7 @@ void setup() {
|
|||
Serial.print(F("[nRF24] Setting address for receive pipe 0 ... "));
|
||||
byte addr[] = {0x01, 0x23, 0x45, 0x67, 0x89};
|
||||
state = radio.setReceivePipe(0, addr);
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -75,7 +75,7 @@ void loop() {
|
|||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ void loop() {
|
|||
Serial.print(F("[nRF24] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
RadioLib nRF24 Receive Example
|
||||
|
||||
This example listens for FSK transmissions using nRF24 2.4 GHz radio module.
|
||||
Once a packet is received, an interrupt is triggered.
|
||||
To successfully receive data, the following settings have to be the same
|
||||
on both transmitter and receiver:
|
||||
- carrier frequency
|
||||
- data rate
|
||||
- transmit pipe on transmitter must match receive pipe
|
||||
on receiver
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#nrf24
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// nRF24 has the following connections:
|
||||
// CS pin: 10
|
||||
// IRQ pin: 2
|
||||
// CE pin: 3
|
||||
nRF24 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//nRF24 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize nRF24 with default settings
|
||||
Serial.print(F("[nRF24] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// set receive pipe 0 address
|
||||
// NOTE: address width in bytes MUST be equal to the
|
||||
// width set in begin() or setAddressWidth()
|
||||
// methods (5 by default)
|
||||
Serial.print(F("[nRF24] Setting address for receive pipe 0 ... "));
|
||||
byte addr[] = {0x01, 0x23, 0x45, 0x67, 0x89};
|
||||
state = radio.setReceivePipe(0, addr);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
radio.setIrqAction(setFlag);
|
||||
|
||||
// start listening
|
||||
Serial.print(F("[nRF24] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
volatile bool receivedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we got a packet, set the flag
|
||||
receivedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the flag is set
|
||||
if(receivedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
receivedFlag = false;
|
||||
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[nRF24] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[nRF24] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("[nRF24] Failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// put module back to listen mode
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ void setup() {
|
|||
// initialize nRF24 with default settings
|
||||
Serial.print(F("[nRF24] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -50,7 +50,7 @@ void setup() {
|
|||
byte addr[] = {0x01, 0x23, 0x45, 0x67, 0x89};
|
||||
Serial.print(F("[nRF24] Setting transmit pipe ... "));
|
||||
state = radio.setTransmitPipe(addr);
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
@ -66,20 +66,20 @@ void loop() {
|
|||
// 32 characters long
|
||||
int state = radio.transmit("Hello World!");
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 32 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
} else if (state == ERR_ACK_NOT_RECEIVED) {
|
||||
} else if (state == RADIOLIB_ERR_ACK_NOT_RECEIVED) {
|
||||
// acknowledge from destination module
|
||||
// was not received within 15 retries
|
||||
Serial.println(F("ACK not received!"));
|
||||
|
||||
} else if (state == ERR_TX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
|
||||
// timed out while transmitting
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
RadioLib nRF24 Transmit with Interrupts Example
|
||||
|
||||
This example transmits packets using nRF24 2.4 GHz radio module.
|
||||
Each packet contains up to 32 bytes of data, in the form of:
|
||||
- Arduino String
|
||||
- null-terminated char array (C-string)
|
||||
- arbitrary binary data (byte array)
|
||||
|
||||
Packet delivery is automatically acknowledged by the receiver.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#nrf24
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// nRF24 has the following connections:
|
||||
// CS pin: 10
|
||||
// IRQ pin: 2
|
||||
// CE pin: 3
|
||||
nRF24 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//nRF24 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize nRF24 with default settings
|
||||
Serial.print(F("[nRF24] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// set transmit address
|
||||
// NOTE: address width in bytes MUST be equal to the
|
||||
// width set in begin() or setAddressWidth()
|
||||
// methods (5 by default)
|
||||
byte addr[] = {0x01, 0x23, 0x45, 0x67, 0x89};
|
||||
Serial.print(F("[nRF24] Setting transmit pipe ... "));
|
||||
state = radio.setTransmitPipe(addr);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
radio.setIrqAction(setFlag);
|
||||
|
||||
// start transmitting the first packet
|
||||
Serial.print(F("[nRF24] Sending first packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 256 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was sent
|
||||
volatile bool transmittedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we sent a packet, set the flag
|
||||
transmittedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the previous transmission finished
|
||||
if(transmittedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
// NOTE: when using interrupt-driven transmit method,
|
||||
// it is not possible to automatically measure
|
||||
// transmission data rate using getDataRate()
|
||||
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(transmissionState);
|
||||
|
||||
}
|
||||
|
||||
// clean up after transmission is finished
|
||||
// this will ensure transmitter is disabled,
|
||||
// RF switch is powered down etc.
|
||||
radio.finishTransmit();
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
// send another one
|
||||
Serial.print(F("[nRF24] Sending another packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 256 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
// we're ready to send more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
}
|
||||
111
lib/RadioLib/extras/decoder/DebugDecoder.py
Normal file
111
lib/RadioLib/extras/decoder/DebugDecoder.py
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
import re, sys, argparse
|
||||
from pathlib import Path
|
||||
from argparse import RawTextHelpFormatter
|
||||
|
||||
|
||||
'''
|
||||
TODO list:
|
||||
1. Parse macro values (the names of bits in all registers in header file)
|
||||
2. Failed SPI write handling
|
||||
3. SX126x/SX128x handling
|
||||
'''
|
||||
|
||||
|
||||
def get_macro_name(value, macros):
|
||||
for macro in macros:
|
||||
if macro[1] == value:
|
||||
return macro[0]
|
||||
return 'UNKNOWN_VALUE'
|
||||
|
||||
|
||||
def get_macro_value(value):
|
||||
return ' 0x{0:02X}\n'.format(int(value, 16))
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(formatter_class=RawTextHelpFormatter, description='''
|
||||
RadioLib debug output decoder script. Turns RadioLib Serial dumps into readable text.
|
||||
|
||||
Step-by-step guid on how to use the decoder:
|
||||
1. Uncomment lines 312 (#define RADIOLIB_DEBUG) and 313 (#define RADIOLIB_VERBOSE) in RadioLib/src/BuildOpt.h
|
||||
2. Recompile and upload the failing Arduino sketch
|
||||
3. Open Arduino IDE Serial Monitor and enable timestamps
|
||||
4. Copy the Serial output and save it into a .txt file
|
||||
5. Run this script
|
||||
|
||||
Output will be saved in the file specified by --out and printed to the terminal
|
||||
''')
|
||||
parser.add_argument('file', metavar='file', type=str, help='Text file of the debug output')
|
||||
parser.add_argument('--out', metavar='out', default='./out.txt', type=str, help='Where to save the decoded file (defaults to ./out.txt)')
|
||||
args = parser.parse_args()
|
||||
|
||||
# open the log file
|
||||
log = open(args.file, 'r').readlines()
|
||||
|
||||
# find modules that are in use
|
||||
used_modules = []
|
||||
pattern_module = re.compile('(([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?.[0-9]{3} -> )?M\t')
|
||||
for entry in log:
|
||||
m = pattern_module.search(entry)
|
||||
if m != None:
|
||||
used_modules.append(entry[m.end():].rstrip())
|
||||
|
||||
# get paths to all relevant header files
|
||||
header_files = []
|
||||
for path in Path('../../src').rglob('*.h'):
|
||||
for module in used_modules:
|
||||
if module in path.name:
|
||||
header_files.append(path)
|
||||
|
||||
# extract names of address macros from the header files
|
||||
macro_addresses = []
|
||||
pattern_define = re.compile('#define \w* +\w*(\n| +\/\/){1}')
|
||||
for path in header_files:
|
||||
file = open(path, 'r').readlines()
|
||||
for line in file:
|
||||
m = pattern_define.search(line)
|
||||
if m != None:
|
||||
s = re.split(' +', m.group().rstrip())
|
||||
if (s.__len__() > 1) and ('_REG' in s[1]):
|
||||
macro_addresses.append([s[1], int(s[2], 0)])
|
||||
|
||||
'''
|
||||
# extract names of value macros for each adddress macro
|
||||
macro_values = []
|
||||
for path in header_files:
|
||||
file = open(path, 'r').readlines()
|
||||
for line in file:
|
||||
for module in used_modules:
|
||||
pattern_addr_macro = re.compile('\/\/ SI443X_REG_\w+'.format(module.capitalize()))
|
||||
'''
|
||||
|
||||
# parse every line in the log file
|
||||
out = []
|
||||
pattern_debug = re.compile('(([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?.[0-9]{3} -> )?[RWM]\t.+')
|
||||
for entry in log:
|
||||
m = pattern_debug.search(entry)
|
||||
if m != None:
|
||||
s = re.split('( |\t)+', entry.rstrip())
|
||||
cmd_len = int((s.__len__() - 7)/2)
|
||||
new_entry = s[0] + s[1] + s[2] + s[3]
|
||||
if s[4] == 'W':
|
||||
macro_address = int(s[6], 16)
|
||||
new_entry += 'write {0:>2} 0x{1:02X} {2}\n'.format(cmd_len, macro_address, get_macro_name(macro_address, macro_addresses))
|
||||
for i in range(cmd_len):
|
||||
new_entry += get_macro_value(s[8 + 2*i]);
|
||||
elif s[4] == 'R':
|
||||
macro_address = int(s[6], 16)
|
||||
new_entry += 'read {0:>2} 0x{1:02X} {2}\n'.format(cmd_len, macro_address, get_macro_name(macro_address, macro_addresses))
|
||||
for i in range(cmd_len):
|
||||
new_entry += get_macro_value(s[8 + 2*i]);
|
||||
elif s[4] == 'M':
|
||||
new_entry += 'module {}\n'.format(s[6])
|
||||
out.append(new_entry)
|
||||
else:
|
||||
out.append(entry)
|
||||
|
||||
# write the output file
|
||||
out_file = open(args.out, 'w')
|
||||
for line in out:
|
||||
print(line, end='')
|
||||
out_file.write(line)
|
||||
out_file.close()
|
||||
22
lib/RadioLib/extras/template/ModuleTemplate.cpp
Normal file
22
lib/RadioLib/extras/template/ModuleTemplate.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include "<module_name>.h"
|
||||
#if !defined(RADIOLIB_EXCLUDE_<module_name>)
|
||||
|
||||
<module_name>::<module_name>(Module* mod) {
|
||||
/*
|
||||
Constructor implementation MUST assign the provided "mod" pointer to the private "_mod" pointer.
|
||||
*/
|
||||
_mod = mod;
|
||||
}
|
||||
|
||||
int16_t <module_name>::begin() {
|
||||
/*
|
||||
"begin" method implementation MUST call the "init" method with appropriate settings.
|
||||
*/
|
||||
_mod->init();
|
||||
|
||||
/*
|
||||
"begin" method SHOULD implement some sort of mechanism to verify the connection between Arduino and the module.
|
||||
|
||||
For example, reading a version register
|
||||
*/
|
||||
}
|
||||
99
lib/RadioLib/extras/template/ModuleTemplate.h
Normal file
99
lib/RadioLib/extras/template/ModuleTemplate.h
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
RadioLib Module Template header file
|
||||
|
||||
Before opening pull request, please make sure that:
|
||||
1. All files MUST be compiled without errors using default Arduino IDE settings.
|
||||
2. All files SHOULD be compiled without warnings with compiler warnings set to "All".
|
||||
3. Example sketches MUST be working correctly and MUST be stable enough to run for prolonged periods of time.
|
||||
4. Writing style SHOULD be consistent.
|
||||
5. Comments SHOULD be in place for the most important chunks of code and SHOULD be free of typos.
|
||||
6. To indent, 2 spaces MUST be used.
|
||||
|
||||
If at any point you are unsure about the required style, please refer to the rest of the modules.
|
||||
*/
|
||||
|
||||
#if !defined(_RADIOLIB_<module_name>_H) && !defined(RADIOLIB_EXCLUDE_<module_name>)
|
||||
#if !defined(_RADIOLIB_<module_name>_H)
|
||||
#define _RADIOLIB_<module_name>_H
|
||||
|
||||
/*
|
||||
Header file for each module MUST include Module.h and TypeDef.h in the src folder.
|
||||
The header file MAY include additional header files.
|
||||
*/
|
||||
#include "../../Module.h"
|
||||
#include "../../TypeDef.h"
|
||||
|
||||
/*
|
||||
Only use the following include if the module implements methods for OSI physical layer control.
|
||||
This concerns only modules similar to SX127x/RF69/CC1101 etc.
|
||||
|
||||
In this case, your class MUST implement all virtual methods of PhysicalLayer class.
|
||||
*/
|
||||
//#include "../../protocols/PhysicalLayer/PhysicalLayer.h"
|
||||
|
||||
/*
|
||||
Register map
|
||||
Definition of SPI register map SHOULD be placed here. The register map SHOULD have two parts:
|
||||
|
||||
1 - Address map: only defines register names and addresses. Register names MUST match names in
|
||||
official documentation (datasheets etc.).
|
||||
2 - Variable map: defines variables inside register. This functions as a bit range map for a specific register.
|
||||
Bit range (MSB and LSB) as well as short description for each variable MUST be provided in a comment.
|
||||
|
||||
See RF69 and SX127x header files for examples of register maps.
|
||||
*/
|
||||
// <module_name> register map | spaces up to this point
|
||||
#define RADIOLIB_<module_name>_REG_<register_name> 0x00
|
||||
|
||||
// <module_name>_REG_<register_name> MSB LSB DESCRIPTION
|
||||
#define RADIOLIB_<module_name>_<register_variable> 0b00000000 // 7 0 <description>
|
||||
|
||||
|
||||
/*
|
||||
Module class definition
|
||||
|
||||
The module class MAY inherit from the following classes:
|
||||
|
||||
1 - PhysicalLayer: In case the module implements methods for OSI physical layer control (e.g. SX127x).
|
||||
2 - Common class: In case the module further specifies some more generic class (e.g. SX127x/SX1278)
|
||||
*/
|
||||
class <module_name> {
|
||||
public:
|
||||
/*
|
||||
Constructor MUST have only one parameter "Module* mod".
|
||||
The class MAY implement additional overloaded constructors.
|
||||
*/
|
||||
// constructor
|
||||
<module_name>(Module* mod);
|
||||
|
||||
/*
|
||||
The class MUST implement at least one basic method called "begin".
|
||||
The "begin" method MUST initialize the module and return the status as int16_t type.
|
||||
*/
|
||||
// basic methods
|
||||
int16_t begin();
|
||||
|
||||
/*
|
||||
The class MAY implement additional methods.
|
||||
All implemented methods SHOULD return the status as int16_t type.
|
||||
*/
|
||||
|
||||
#if !defined(RADIOLIB_GODMODE)
|
||||
private:
|
||||
#endif
|
||||
/*
|
||||
The class MUST contain private member "Module* _mod"
|
||||
*/
|
||||
Module* _mod;
|
||||
|
||||
/*
|
||||
The class MAY contain additional private variables and/or methods.
|
||||
Private member variables MUST have a name prefixed with "_" (underscore, ASCII 0x5F)
|
||||
|
||||
Usually, these are variables for saving module configuration, or methods that do not have to be exposed to the end user.
|
||||
*/
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -12,9 +12,7 @@ Module KEYWORD1
|
|||
|
||||
# modules
|
||||
CC1101 KEYWORD1
|
||||
ESP8266 KEYWORD1
|
||||
HC05 KEYWORD1
|
||||
JDY08 KEYWORD1
|
||||
LLCC68 KEYWORD1
|
||||
nRF24 KEYWORD1
|
||||
RF69 KEYWORD1
|
||||
RFM22 KEYWORD1
|
||||
|
|
@ -40,20 +38,18 @@ SX1279 KEYWORD1
|
|||
SX1280 KEYWORD1
|
||||
SX1281 KEYWORD1
|
||||
SX1282 KEYWORD1
|
||||
XBee KEYWORD1
|
||||
XBeeSerial KEYWORD1
|
||||
|
||||
# protocols
|
||||
MQTTClient KEYWORD1
|
||||
HTTPClient KEYWORD1
|
||||
RTTYClient KEYWORD1
|
||||
MorseClient KEYWORD1
|
||||
PagerClient KEYWORD1
|
||||
AX25Client KEYWORD1
|
||||
AX25Frame KEYWORD1
|
||||
SSTVClient KEYWORD1
|
||||
HellClient KEYWORD1
|
||||
AFSKClient KEYWORD1
|
||||
FSK4Client KEYWORD1
|
||||
APRSClient KEYWORD1
|
||||
PagerClient KEYWORD1
|
||||
|
||||
# SSTV modes
|
||||
Scottie1 KEYWORD1
|
||||
|
|
@ -91,8 +87,11 @@ setDio1Action KEYWORD2
|
|||
clearDio0Action KEYWORD2
|
||||
clearDio1Action KEYWORD2
|
||||
startTransmit KEYWORD2
|
||||
finishTransmit KEYWORD2
|
||||
startReceive KEYWORD2
|
||||
readData KEYWORD2
|
||||
startChannelScan KEYWORD2
|
||||
getChannelScanResult KEYWORD2
|
||||
setBandwidth KEYWORD2
|
||||
setSpreadingFactor KEYWORD2
|
||||
setCodingRate KEYWORD2
|
||||
|
|
@ -104,10 +103,14 @@ setPreambleLength KEYWORD2
|
|||
setGain KEYWORD2
|
||||
getFrequencyError KEYWORD2
|
||||
getRSSI KEYWORD2
|
||||
getAFCError KEYWORD2
|
||||
getSNR KEYWORD2
|
||||
getDataRate KEYWORD2
|
||||
setBitRate KEYWORD2
|
||||
setRxBandwidth KEYWORD2
|
||||
setAFCBandwidth KEYWORD2
|
||||
setAFC KEYWORD2
|
||||
setAFCAGCTrigger KEYWORD2
|
||||
setFrequencyDeviation KEYWORD2
|
||||
setNodeAddress KEYWORD2
|
||||
setBroadcastAddress KEYWORD2
|
||||
|
|
@ -131,6 +134,28 @@ setRfSwitchPins KEYWORD2
|
|||
forceLDRO KEYWORD2
|
||||
autoLDRO KEYWORD2
|
||||
getChipVersion KEYWORD2
|
||||
invertIQ KEYWORD2
|
||||
setOokThresholdType KEYWORD2
|
||||
setOokPeakThresholdDecrement KEYWORD2
|
||||
setOokFixedOrFloorThreshold KEYWORD2
|
||||
setOokPeakThresholdStep KEYWORD2
|
||||
setDirectSyncWord KEYWORD2
|
||||
setDirectAction KEYWORD2
|
||||
readBit KEYWORD2
|
||||
enableBitSync KEYWORD2
|
||||
disableBitSync KEYWORD2
|
||||
setFHSSHoppingPeriod KEYWORD2
|
||||
getFHSSHoppingPeriod KEYWORD2
|
||||
getFHSSChannel KEYWORD2
|
||||
clearFHSSInt KEYWORD2
|
||||
randomByte KEYWORD2
|
||||
getPacketLength KEYWORD2
|
||||
setFifoEmptyAction KEYWORD2
|
||||
clearFifoEmptyAction KEYWORD2
|
||||
setFifoFullAction KEYWORD2
|
||||
clearFifoFullAction KEYWORD2
|
||||
fifoAdd KEYWORD2
|
||||
fifoGet KEYWORD2
|
||||
|
||||
# RF69-specific
|
||||
setAESKey KEYWORD2
|
||||
|
|
@ -138,6 +163,10 @@ enableAES KEYWORD2
|
|||
disableAES KEYWORD2
|
||||
getTemperature KEYWORD2
|
||||
setAmbientTemperature KEYWORD2
|
||||
setLnaTestBoost KEYWORD2
|
||||
setOokFixedThreshold KEYWORD2
|
||||
enableContinuousModeBitSync KEYWORD2
|
||||
disableContinuousModeBitSync KEYWORD2
|
||||
|
||||
# CC1101-specific
|
||||
getLQI KEYWORD2
|
||||
|
|
@ -160,16 +189,8 @@ startReceiveDutyCycleAuto KEYWORD2
|
|||
setRegulatorLDO KEYWORD2
|
||||
setRegulatorDCDC KEYWORD2
|
||||
getCurrentLimit KEYWORD2
|
||||
|
||||
# ESP8266
|
||||
join KEYWORD2
|
||||
reset KEYWORD2
|
||||
|
||||
# XBee
|
||||
setDestinationAddress KEYWORD2
|
||||
setPanId KEYWORD2
|
||||
getPacketSource KEYWORD2
|
||||
getPacketData KEYWORD2
|
||||
getIrqStatus KEYWORD2
|
||||
getLastError KEYWORD2
|
||||
|
||||
# nRF24
|
||||
setIrqAction KEYWORD2
|
||||
|
|
@ -180,19 +201,6 @@ disablePipe KEYWORD2
|
|||
getStatus KEYWORD2
|
||||
setAutoAck KEYWORD2
|
||||
|
||||
# HTTP
|
||||
get KEYWORD2
|
||||
post KEYWORD2
|
||||
|
||||
# MQTT
|
||||
connect KEYWORD2
|
||||
disconnect KEYWORD2
|
||||
publish KEYWORD2
|
||||
subscribe KEYWORD2
|
||||
unsubscribe KEYWORD2
|
||||
ping KEYWORD2
|
||||
check KEYWORD2
|
||||
|
||||
# RTTY
|
||||
idle KEYWORD2
|
||||
byteArr KEYWORD2
|
||||
|
|
@ -200,22 +208,12 @@ byteArr KEYWORD2
|
|||
# Morse
|
||||
startSignal KEYWORD2
|
||||
|
||||
# TransportLayer
|
||||
openTransportConnection KEYWORD2
|
||||
closeTransportConnection KEYWORD2
|
||||
send KEYWORD2
|
||||
receive KEYWORD2
|
||||
getNumBytes KEYWORD2
|
||||
|
||||
# SIM800
|
||||
sendSMS KEYWORD2
|
||||
shutdown KEYWORD2
|
||||
|
||||
# AX.25
|
||||
setRepeaters KEYWORD2
|
||||
setRecvSequence KEYWORD2
|
||||
setSendSequence KEYWORD2
|
||||
sendFrame KEYWORD2
|
||||
setCorrection KEYWORD2
|
||||
|
||||
# SSTV
|
||||
sendHeader KEYWORD2
|
||||
|
|
@ -233,11 +231,24 @@ getRangingResult KEYWORD2
|
|||
|
||||
# Hellschreiber
|
||||
printGlyph KEYWORD2
|
||||
setInversion KEYWORD2
|
||||
|
||||
# AFSK
|
||||
tone KEYWORD2
|
||||
noTone KEYWORD2
|
||||
|
||||
# APRS
|
||||
sendPosition KEYWORD2
|
||||
sendMicE KEYWORD2
|
||||
|
||||
# Pager
|
||||
sendTone KEYWORD2
|
||||
|
||||
# PhysicalLayer
|
||||
dropSync KEYWORD2
|
||||
setTimerFlag KEYWORD2
|
||||
setInterruptSetup KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
|
@ -255,88 +266,80 @@ RADIOLIB_ENCODING_NRZ LITERAL1
|
|||
RADIOLIB_ENCODING_MANCHESTER LITERAL1
|
||||
RADIOLIB_ENCODING_WHITENING LITERAL1
|
||||
|
||||
ERR_NONE LITERAL1
|
||||
ERR_UNKNOWN LITERAL1
|
||||
RADIOLIB_BUILTIN_MODULE LITERAL1
|
||||
|
||||
ERR_CHIP_NOT_FOUND LITERAL1
|
||||
ERR_MEMORY_ALLOCATION_FAILED LITERAL1
|
||||
ERR_PACKET_TOO_LONG LITERAL1
|
||||
ERR_TX_TIMEOUT LITERAL1
|
||||
ERR_RX_TIMEOUT LITERAL1
|
||||
ERR_CRC_MISMATCH LITERAL1
|
||||
ERR_INVALID_BANDWIDTH LITERAL1
|
||||
ERR_INVALID_SPREADING_FACTOR LITERAL1
|
||||
ERR_INVALID_CODING_RATE LITERAL1
|
||||
ERR_INVALID_BIT_RANGE LITERAL1
|
||||
ERR_INVALID_FREQUENCY LITERAL1
|
||||
ERR_INVALID_OUTPUT_POWER LITERAL1
|
||||
PREAMBLE_DETECTED LITERAL1
|
||||
CHANNEL_FREE LITERAL1
|
||||
ERR_SPI_WRITE_FAILED LITERAL1
|
||||
ERR_INVALID_CURRENT_LIMIT LITERAL1
|
||||
ERR_INVALID_PREAMBLE_LENGTH LITERAL1
|
||||
ERR_INVALID_GAIN LITERAL1
|
||||
ERR_WRONG_MODEM LITERAL1
|
||||
ERR_INVALID_NUM_SAMPLES LITERAL1
|
||||
ERR_INVALID_RSSI_OFFSET LITERAL1
|
||||
ERR_INVALID_ENCODING LITERAL1
|
||||
RADIOLIB_MORSE_INTER_SYMBOL LITERAL1
|
||||
RADIOLIB_MORSE_CHAR_COMPLETE LITERAL1
|
||||
RADIOLIB_MORSE_WORD_COMPLETE LITERAL1
|
||||
|
||||
ERR_INVALID_BIT_RATE LITERAL1
|
||||
ERR_INVALID_FREQUENCY_DEVIATION LITERAL1
|
||||
ERR_INVALID_BIT_RATE_BW_RATIO LITERAL1
|
||||
ERR_INVALID_RX_BANDWIDTH LITERAL1
|
||||
ERR_INVALID_SYNC_WORD LITERAL1
|
||||
ERR_INVALID_DATA_SHAPING LITERAL1
|
||||
ERR_INVALID_MODULATION LITERAL1
|
||||
RADIOLIB_ERR_NONE LITERAL1
|
||||
RADIOLIB_ERR_UNKNOWN LITERAL1
|
||||
|
||||
ERR_AT_FAILED LITERAL1
|
||||
ERR_URL_MALFORMED LITERAL1
|
||||
ERR_RESPONSE_MALFORMED_AT LITERAL1
|
||||
ERR_RESPONSE_MALFORMED LITERAL1
|
||||
ERR_MQTT_CONN_VERSION_REJECTED LITERAL1
|
||||
ERR_MQTT_CONN_ID_REJECTED LITERAL1
|
||||
ERR_MQTT_CONN_SERVER_UNAVAILABLE LITERAL1
|
||||
ERR_MQTT_CONN_BAD_USERNAME_PASSWORD LITERAL1
|
||||
ERR_MQTT_CONN_NOT_AUTHORIZED LITERAL1
|
||||
ERR_MQTT_UNEXPECTED_PACKET_ID LITERAL1
|
||||
ERR_MQTT_NO_NEW_PACKET_AVAILABLE LITERAL1
|
||||
MQTT_SUBS_SUCCESS_QOS_0 LITERAL1
|
||||
MQTT_SUBS_SUCCESS_QOS_1 LITERAL1
|
||||
MQTT_SUBS_SUCCESS_QOS_2 LITERAL1
|
||||
ERR_MQTT_SUBS_FAILED LITERAL1
|
||||
RADIOLIB_ERR_CHIP_NOT_FOUND LITERAL1
|
||||
RADIOLIB_ERR_MEMORY_ALLOCATION_FAILED LITERAL1
|
||||
RADIOLIB_ERR_PACKET_TOO_LONG LITERAL1
|
||||
RADIOLIB_ERR_TX_TIMEOUT LITERAL1
|
||||
RADIOLIB_ERR_RX_TIMEOUT LITERAL1
|
||||
RADIOLIB_ERR_CRC_MISMATCH LITERAL1
|
||||
RADIOLIB_ERR_INVALID_BANDWIDTH LITERAL1
|
||||
RADIOLIB_ERR_INVALID_SPREADING_FACTOR LITERAL1
|
||||
RADIOLIB_ERR_INVALID_CODING_RATE LITERAL1
|
||||
RADIOLIB_ERR_INVALID_BIT_RANGE LITERAL1
|
||||
RADIOLIB_ERR_INVALID_FREQUENCY LITERAL1
|
||||
RADIOLIB_ERR_INVALID_OUTPUT_POWER LITERAL1
|
||||
RADIOLIB_PREAMBLE_DETECTED LITERAL1
|
||||
RADIOLIB_CHANNEL_FREE LITERAL1
|
||||
RADIOLIB_ERR_SPI_WRITE_FAILED LITERAL1
|
||||
RADIOLIB_ERR_INVALID_CURRENT_LIMIT LITERAL1
|
||||
RADIOLIB_ERR_INVALID_PREAMBLE_LENGTH LITERAL1
|
||||
RADIOLIB_ERR_INVALID_GAIN LITERAL1
|
||||
RADIOLIB_ERR_WRONG_MODEM LITERAL1
|
||||
RADIOLIB_ERR_INVALID_NUM_SAMPLES LITERAL1
|
||||
RADIOLIB_ERR_INVALID_RSSI_OFFSET LITERAL1
|
||||
RADIOLIB_ERR_INVALID_ENCODING LITERAL1
|
||||
|
||||
ERR_CMD_MODE_FAILED LITERAL1
|
||||
ERR_FRAME_MALFORMED LITERAL1
|
||||
ERR_FRAME_INCORRECT_CHECKSUM LITERAL1
|
||||
ERR_FRAME_UNEXPECTED_ID LITERAL1
|
||||
ERR_FRAME_NO_RESPONSE LITERAL1
|
||||
RADIOLIB_ERR_INVALID_BIT_RATE LITERAL1
|
||||
RADIOLIB_ERR_INVALID_FREQUENCY_DEVIATION LITERAL1
|
||||
RADIOLIB_ERR_INVALID_BIT_RATE_BW_RATIO LITERAL1
|
||||
RADIOLIB_ERR_INVALID_RX_BANDWIDTH LITERAL1
|
||||
RADIOLIB_ERR_INVALID_SYNC_WORD LITERAL1
|
||||
RADIOLIB_ERR_INVALID_DATA_SHAPING LITERAL1
|
||||
RADIOLIB_ERR_INVALID_MODULATION LITERAL1
|
||||
RADIOLIB_ERR_INVALID_OOK_RSSI_PEAK_TYPE LITERAL1
|
||||
|
||||
ASCII LITERAL1
|
||||
ASCII_EXTENDED LITERAL1
|
||||
ITA2 LITERAL1
|
||||
BCD LITERAL1
|
||||
ERR_INVALID_RTTY_SHIFT LITERAL1
|
||||
ERR_UNSUPPORTED_ENCODING LITERAL1
|
||||
RADIOLIB_ERR_INVALID_SYMBOL LITERAL1
|
||||
RADIOLIB_ERR_INVALID_MIC_E_TELEMETRY LITERAL1
|
||||
RADIOLIB_ERR_INVALID_MIC_E_TELEMETRY_LENGTH LITERAL1
|
||||
RADIOLIB_ERR_MIC_E_TELEMETRY_STATUS LITERAL1
|
||||
|
||||
ERR_INVALID_DATA_RATE LITERAL1
|
||||
ERR_INVALID_ADDRESS_WIDTH LITERAL1
|
||||
ERR_INVALID_PIPE_NUMBER LITERAL1
|
||||
ERR_ACK_NOT_RECEIVED LITERAL1
|
||||
RADIOLIB_ASCII LITERAL1
|
||||
RADIOLIB_ASCII_EXTENDED LITERAL1
|
||||
RADIOLIB_ITA2 LITERAL1
|
||||
RADIOLIB_ERR_INVALID_RTTY_SHIFT LITERAL1
|
||||
RADIOLIB_ERR_UNSUPPORTED_ENCODING LITERAL1
|
||||
|
||||
ERR_INVALID_NUM_BROAD_ADDRS LITERAL1
|
||||
RADIOLIB_ERR_INVALID_DATA_RATE LITERAL1
|
||||
RADIOLIB_ERR_INVALID_ADDRESS_WIDTH LITERAL1
|
||||
RADIOLIB_ERR_INVALID_PIPE_NUMBER LITERAL1
|
||||
RADIOLIB_ERR_ACK_NOT_RECEIVED LITERAL1
|
||||
|
||||
ERR_INVALID_CRC_CONFIGURATION LITERAL1
|
||||
LORA_DETECTED LITERAL1
|
||||
ERR_INVALID_TCXO_VOLTAGE LITERAL1
|
||||
ERR_INVALID_MODULATION_PARAMETERS LITERAL1
|
||||
ERR_SPI_CMD_TIMEOUT LITERAL1
|
||||
ERR_SPI_CMD_INVALID LITERAL1
|
||||
ERR_SPI_CMD_FAILED LITERAL1
|
||||
ERR_INVALID_SLEEP_PERIOD LITERAL1
|
||||
ERR_INVALID_RX_PERIOD LITERAL1
|
||||
RADIOLIB_ERR_INVALID_NUM_BROAD_ADDRS LITERAL1
|
||||
|
||||
ERR_INVALID_CALLSIGN LITERAL1
|
||||
ERR_INVALID_NUM_REPEATERS LITERAL1
|
||||
ERR_INVALID_REPEATER_CALLSIGN LITERAL1
|
||||
RADIOLIB_ERR_INVALID_CRC_CONFIGURATION LITERAL1
|
||||
RADIOLIB_LORA_DETECTED LITERAL1
|
||||
RADIOLIB_ERR_INVALID_TCXO_VOLTAGE LITERAL1
|
||||
RADIOLIB_ERR_INVALID_MODULATION_PARAMETERS LITERAL1
|
||||
RADIOLIB_ERR_SPI_CMD_TIMEOUT LITERAL1
|
||||
RADIOLIB_ERR_SPI_CMD_INVALID LITERAL1
|
||||
RADIOLIB_ERR_SPI_CMD_FAILED LITERAL1
|
||||
RADIOLIB_ERR_INVALID_SLEEP_PERIOD LITERAL1
|
||||
RADIOLIB_ERR_INVALID_RX_PERIOD LITERAL1
|
||||
|
||||
ERR_RANGING_TIMEOUT LITERAL1
|
||||
RADIOLIB_ERR_INVALID_CALLSIGN LITERAL1
|
||||
RADIOLIB_ERR_INVALID_NUM_REPEATERS LITERAL1
|
||||
RADIOLIB_ERR_INVALID_REPEATER_CALLSIGN LITERAL1
|
||||
|
||||
RADIOLIB_ERR_RANGING_TIMEOUT LITERAL1
|
||||
|
||||
RADIOLIB_ERR_INVALID_PAYLOAD LITERAL1
|
||||
RADIOLIB_ERR_ADDRESS_NOT_FOUND LITERAL1
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue