Compare commits

..

No commits in common. "master" and "7.0.2" have entirely different histories.

257 changed files with 4603 additions and 8712 deletions

View file

@ -7,8 +7,8 @@ assignees: ''
--- ---
**IMPORTANT: Check the docs** **IMPORTANT: Check the wiki**
Before submitting new issue, please check the [Troubleshooting Guide](https://github.com/jgromes/RadioLib/wiki/Troubleshooting-Guide) Wiki page and the [API documentation](https://jgromes.github.io/RadioLib/). If you are seeing an error code, we have [online status code decoder](https://radiolib-org.github.io/status_decoder/decode.html). Before submitting new issue, please check the [Troubleshooting Guide](https://github.com/jgromes/RadioLib/wiki/Troubleshooting-Guide) Wiki page and the [API documentation](https://jgromes.github.io/RadioLib/). You might find a solution to your issue there.
**Describe the bug** **Describe the bug**
A clear and concise description of what the bug is. When applicable, please include [debug mode output](https://github.com/jgromes/RadioLib/wiki/Debug-mode) **using the appropriate debug mode**. A clear and concise description of what the bug is. When applicable, please include [debug mode output](https://github.com/jgromes/RadioLib/wiki/Debug-mode) **using the appropriate debug mode**.

View file

@ -7,8 +7,8 @@ assignees: ''
--- ---
**IMPORTANT: Check the docs** **IMPORTANT: Check the wiki**
Before submitting new issue, please check the [Troubleshooting Guide](https://github.com/jgromes/RadioLib/wiki/Troubleshooting-Guide) Wiki page and the [API documentation](https://jgromes.github.io/RadioLib/). If you are seeing an error code, we have [online status code decoder](https://radiolib-org.github.io/status_decoder/decode.html). Before submitting new issue, please check the [Troubleshooting Guide](https://github.com/jgromes/RadioLib/wiki/Troubleshooting-Guide) Wiki page and the [API documentation](https://jgromes.github.io/RadioLib/). You might find a solution to your issue there.
**Is your feature request related to a problem? Please describe.** **Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

View file

@ -9,7 +9,7 @@ assignees: ''
**IMPORTANT: Before submitting an issue, please check the following:** **IMPORTANT: Before submitting an issue, please check the following:**
1. **Read [CONTRIBUTING.md](https://github.com/jgromes/RadioLib/blob/master/CONTRIBUTING.md)!** Issues that do not follow this document will be closed/locked/deleted/ignored. 1. **Read [CONTRIBUTING.md](https://github.com/jgromes/RadioLib/blob/master/CONTRIBUTING.md)!** Issues that do not follow this document will be closed/locked/deleted/ignored.
2. RadioLib has a [Troubleshooting Guide](https://github.com/jgromes/RadioLib/wiki/Troubleshooting-Guide) Wiki page and an extensive [API documentation](https://jgromes.github.io/RadioLib/). If you are seeing an error code, we have [online status code decoder](https://radiolib-org.github.io/status_decoder/decode.html). 2. RadioLib has a [Troubleshooting Guide](https://github.com/jgromes/RadioLib/wiki/Troubleshooting-Guide) Wiki page and an extensive [API documentation](https://jgromes.github.io/RadioLib/). You might find a solution to your issue there.
3. Make sure you're using the latest release of the library! Releases can be found [here](https://github.com/jgromes/RadioLib/releases). 3. Make sure you're using the latest release of the library! Releases can be found [here](https://github.com/jgromes/RadioLib/releases).
4. Use [Arduino forums](https://forum.arduino.cc/) to ask generic questions about wireless modules, wiring, usage, etc. Only create issues for problems specific to RadioLib! 4. Use [Arduino forums](https://forum.arduino.cc/) to ask generic questions about wireless modules, wiring, usage, etc. Only create issues for problems specific to RadioLib!
5. Error codes, their meaning and how to fix them can be found on [this page](https://jgromes.github.io/RadioLib/group__status__codes.html). 5. Error codes, their meaning and how to fix them can be found on [this page](https://jgromes.github.io/RadioLib/group__status__codes.html).

View file

@ -9,7 +9,7 @@ assignees: ''
**IMPORTANT: Before submitting an issue, please check the following:** **IMPORTANT: Before submitting an issue, please check the following:**
1. **Read [CONTRIBUTING.md](https://github.com/jgromes/RadioLib/blob/master/CONTRIBUTING.md)!** Issues that do not follow this document will be closed/locked/deleted/ignored. 1. **Read [CONTRIBUTING.md](https://github.com/jgromes/RadioLib/blob/master/CONTRIBUTING.md)!** Issues that do not follow this document will be closed/locked/deleted/ignored.
2. RadioLib has a [Troubleshooting Guide](https://github.com/jgromes/RadioLib/wiki/Troubleshooting-Guide) Wiki page and an extensive [API documentation](https://jgromes.github.io/RadioLib/). If you are seeing an error code, we have [online status code decoder](https://radiolib-org.github.io/status_decoder/decode.html). 2. RadioLib has a [Troubleshooting Guide](https://github.com/jgromes/RadioLib/wiki/Troubleshooting-Guide) Wiki page and an extensive [API documentation](https://jgromes.github.io/RadioLib/). You might find a solution to your issue there.
3. Make sure you're using the latest release of the library! Releases can be found [here](https://github.com/jgromes/RadioLib/releases). 3. Make sure you're using the latest release of the library! Releases can be found [here](https://github.com/jgromes/RadioLib/releases).
4. Use [Arduino forums](https://forum.arduino.cc/) to ask generic questions about wireless modules, wiring, usage, etc. Only create issues for problems specific to RadioLib! 4. Use [Arduino forums](https://forum.arduino.cc/) to ask generic questions about wireless modules, wiring, usage, etc. Only create issues for problems specific to RadioLib!
5. Error codes, their meaning and how to fix them can be found on [this page](https://jgromes.github.io/RadioLib/group__status__codes.html). 5. Error codes, their meaning and how to fix them can be found on [this page](https://jgromes.github.io/RadioLib/group__status__codes.html).

View file

@ -54,7 +54,7 @@ jobs:
- name: Build example - name: Build example
run: run:
arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn arduino:avr:uno $PWD/examples/SX123x/SX123x_Transmit_Blocking/SX123x_Transmit_Blocking.ino --warnings=all arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn arduino:avr:uno $PWD/examples/SX126x/SX126x_Transmit_Blocking/SX126x_Transmit_Blocking.ino --warnings=all
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3 uses: github/codeql-action/analyze@v3

View file

@ -10,11 +10,12 @@ on:
id: id:
description: The ID of the platform on which the build is run description: The ID of the platform on which the build is run
required: true required: true
default: arduino:avr:mega default: arduino:avr:uno
type: choice type: choice
options: options:
- all - all
- none - none
- arduino:avr:uno
- arduino:avr:mega - arduino:avr:mega
- arduino:mbed:nano33ble - arduino:mbed:nano33ble
- arduino:mbed:envie_m4 - arduino:mbed:envie_m4
@ -26,6 +27,7 @@ on:
- esp32:esp32:esp32 - esp32:esp32:esp32
- esp8266:esp8266:generic - esp8266:esp8266:generic
- Intel:arc32:arduino_101 - Intel:arc32:arduino_101
- SparkFun:apollo3:sfe_artemis
- STMicroelectronics:stm32:GenF3:pnum=BLACKPILL_F303CC - STMicroelectronics:stm32:GenF3:pnum=BLACKPILL_F303CC
- STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_WL55JC1 - STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_WL55JC1
- stm32duino:STM32F1:mapleMini - stm32duino:STM32F1:mapleMini
@ -36,7 +38,6 @@ on:
- MegaCore:avr:1281 - MegaCore:avr:1281
- teensy:avr:teensy41 - teensy:avr:teensy41
- arduino:renesas_uno:minima - arduino:renesas_uno:minima
- SiliconLabs:silabs:xg24explorerkit
jobs: jobs:
build: build:
@ -44,6 +45,8 @@ jobs:
matrix: matrix:
# platform-dependent settings - extra board options, board index URLs, skip patterns etc. # platform-dependent settings - extra board options, board index URLs, skip patterns etc.
include: include:
- id: arduino:avr:uno
run: echo "skip-pattern=(STM32WL|SSTV|LoRaWAN|LR11x0_Firmware_Update|Pager|APRS|Morse)" >> $GITHUB_OUTPUT
- id: arduino:avr:mega - id: arduino:avr:mega
run: | run: |
echo "options=':cpu=atmega2560'" >> $GITHUB_OUTPUT echo "options=':cpu=atmega2560'" >> $GITHUB_OUTPUT
@ -83,16 +86,19 @@ jobs:
echo "skip-pattern=(STM32WL|LR11x0_Firmware_Update)" >> $GITHUB_OUTPUT echo "skip-pattern=(STM32WL|LR11x0_Firmware_Update)" >> $GITHUB_OUTPUT
echo "options=':xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K'" >> $GITHUB_OUTPUT echo "options=':xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K'" >> $GITHUB_OUTPUT
echo "index-url=--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json" >> $GITHUB_OUTPUT echo "index-url=--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json" >> $GITHUB_OUTPUT
- id: STMicroelectronics:stm32:GenF3 - id: SparkFun:apollo3:sfe_artemis
run: |
echo "skip-pattern=(STM32WL|LoRaWAN)" >> $GITHUB_OUTPUT
echo "warnings='none'" >> $GITHUB_OUTPUT
echo "index-url=--additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Apollo3/master/package_sparkfun_apollo3_index.json" >> $GITHUB_OUTPUT
- id: STMicroelectronics:stm32:GenF3:pnum=BLACKPILL_F303CC
run: | run: |
echo "options=':pnum=BLACKPILL_F303CC'" >> $GITHUB_OUTPUT
echo "index-url=--additional-urls https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/main/package_stmicroelectronics_index.json" >> $GITHUB_OUTPUT echo "index-url=--additional-urls https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/main/package_stmicroelectronics_index.json" >> $GITHUB_OUTPUT
echo "skip-pattern=(STM32WL|LR11x0_Firmware_Update)" >> $GITHUB_OUTPUT echo "skip-pattern=(STM32WL|LR11x0_Firmware_Update)" >> $GITHUB_OUTPUT
- id: STMicroelectronics:stm32:Nucleo_64 - id: STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_WL55JC1
run: | run: |
echo "options=':pnum=NUCLEO_WL55JC1'" >> $GITHUB_OUTPUT
# Do *not* skip STM32WL examples # Do *not* skip STM32WL examples
echo "skip-pattern=(LR11x0_Firmware_Update)" >> $GITHUB_OUTPUT echo "skip-pattern='LR11x0_Firmware_Update'" >> $GITHUB_OUTPUT
echo "index-url=--additional-urls https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/main/package_stmicroelectronics_index.json" >> $GITHUB_OUTPUT echo "index-url=--additional-urls https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/main/package_stmicroelectronics_index.json" >> $GITHUB_OUTPUT
- id: stm32duino:STM32F1:mapleMini - id: stm32duino:STM32F1:mapleMini
run: | run: |
@ -121,14 +127,11 @@ jobs:
- id: arduino:renesas_uno:minima - id: arduino:renesas_uno:minima
run: | run: |
echo "skip-pattern=(STM32WL|LoRaWAN|LR11x0_Firmware_Update)" >> $GITHUB_OUTPUT echo "skip-pattern=(STM32WL|LoRaWAN|LR11x0_Firmware_Update)" >> $GITHUB_OUTPUT
- id: SiliconLabs:silabs:xg24explorerkit
run: |
echo "index-url=--additional-urls https://siliconlabs.github.io/arduino/package_arduinosilabs_index.json" >> $GITHUB_OUTPUT
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: ${{ matrix.id }} name: ${{ matrix.id }}
env: env:
run-build: ${{ (inputs.id != 'none' && matrix.id == 'arduino:avr:mega') || contains(github.event.head_commit.message, 'CI_BUILD_ALL') || contains(github.event.head_commit.message, 'Bump version to') || contains(github.event.head_commit.message, format('{0}', matrix.id)) || inputs.id == 'all' || inputs.id == matrix.id }} run-build: ${{ (inputs.id != 'none' && matrix.id == 'arduino:avr:uno') || contains(github.event.head_commit.message, 'CI_BUILD_ALL') || contains(github.event.head_commit.message, 'Bump version to') || contains(github.event.head_commit.message, format('{0}', matrix.id)) || inputs.id == 'all' || inputs.id == matrix.id }}
steps: steps:
- name: Free Disk Space (Ubuntu) - name: Free Disk Space (Ubuntu)
@ -182,64 +185,28 @@ jobs:
if: ${{ env.run-build == 'true' }} if: ${{ env.run-build == 'true' }}
run: run:
| |
cd $PWD/extras/test/ci for example in $(find $PWD/examples -name '*.ino' | sort); do
./build_examples.sh ${{ matrix.id }} "${{ steps.prep.outputs.skip-pattern }}" ${{ steps.prep.outputs.options }} # check whether to skip this sketch
if [ ! -z '${{ steps.prep.outputs.skip-pattern }}' ] && [[ ${example} =~ ${{ steps.prep.outputs.skip-pattern }} ]]; then
# skip sketch
echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.outputs.skip-pattern }})\033[0m";
else
# apply special flags for LoRaWAN
if [[ ${example} =~ "LoRaWAN" ]]; then
flags="-DRADIOLIB_LORAWAN_DEV_ADDR=0 -DRADIOLIB_LORAWAN_FNWKSINT_KEY=0 -DRADIOLIB_LORAWAN_SNWKSINT_KEY=0 -DRADIOLIB_LORAWAN_NWKSENC_KEY=0 -DRADIOLIB_LORAWAN_APPS_KEY=0 -DRADIOLIB_LORAWAN_APP_KEY=0 -DRADIOLIB_LORAWAN_NWK_KEY=0 -DRADIOLIB_LORAWAN_DEV_EUI=0 -DARDUINO_TTGO_LORA32_V1"
fi
- name: Extract short commit hash # build sketch
id: short-hash echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m";
run: echo "::set-output name=short_sha::$(git rev-parse --short HEAD)" arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn ${{ matrix.id }}${{ steps.prep.outputs.options }} --build-property compiler.cpp.extra_flags="$flags" $example --warnings=${{ steps.prep.outputs.warnings }}
if [ $? -ne 0 ]; then
- name: Parse sizes echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n";
if: ${{ env.run-build == 'true' }} exit 1;
run: else
| echo -e "\033[1;32m${example##*/} build PASSED\033[0m\n";
cd $PWD/extras/test/ci fi
./parse_size.sh ${{ matrix.id }} fi
cat size_${{ steps.short-hash.outputs.short_sha }}_${{ steps.split.outputs._0 }}-${{ steps.split.outputs._1 }}-${{ steps.split.outputs._2 }}.csv done
- name: Upload size report as artifact
uses: actions/upload-artifact@v4
with:
name: size-file-${{ steps.split.outputs._0 }}-${{ steps.split.outputs._1 }}-${{ steps.split.outputs._2 }}
path: extras/test/ci/size_${{ steps.short-hash.outputs.short_sha }}_${{ steps.split.outputs._0 }}-${{ steps.split.outputs._1 }}-${{ steps.split.outputs._2 }}.csv
metrics:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master'
steps:
- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.ACTIONS_METRICS_DEPLOY_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
- name: Clone artifact repo
run:
|
cd $PWD/..
git clone git@github.com:radiolib-org/artifacts.git
cd artifacts
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: Download size artifacts
uses: actions/download-artifact@v4
with:
path: aggregated-sizes
- name: Push size files
run:
|
ls -R aggregated-sizes
mkdir -p $PWD/../artifacts/radiolib-ci/l0
cp aggregated-sizes/*/size_*.csv $PWD/../artifacts/radiolib-ci/l0/.
cd $PWD/../artifacts/radiolib-ci
git add .
COMMIT_URL="https://github.com/jgromes/RadioLib/commit/$GITHUB_SHA"
git commit -m "Push artifacts from $COMMIT_URL"
git push origin main
esp-build: esp-build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -289,11 +256,10 @@ jobs:
run: | run: |
cd $PWD/examples/NonArduino/Tock cd $PWD/examples/NonArduino/Tock
git clone https://github.com/tock/libtock-c.git git clone https://github.com/tock/libtock-c.git
cd libtock-c; git checkout c0202f9ab78da4a6e95f136cf5250701e3778f63; cd ../ cd libtock-c; git checkout dbee65a56d74b4bad166317f199e80b959f7c82c; cd ../
LIBTOCK_C_DIRECTORY="$(pwd)/libtock-c" ./build.sh LIBTOCK_C_DIRECTORY="$(pwd)/libtock-c" ./build.sh
rpi-build: rpi-build:
if: false # self-hosted runner temporarily disabled
runs-on: [self-hosted, ARM64] runs-on: [self-hosted, ARM64]
steps: steps:
- name: Checkout repository - name: Checkout repository
@ -325,7 +291,6 @@ jobs:
./build.sh ./build.sh
rpi-test: rpi-test:
if: false # self-hosted runner temporarily disabled
needs: rpi-build needs: rpi-build
runs-on: [self-hosted, ARM64] runs-on: [self-hosted, ARM64]
steps: steps:

View file

@ -1,37 +0,0 @@
name: "Release"
on: workflow_dispatch
jobs:
release:
name: Release RadioLib update
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout latest tag
run: git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install PlatformIO and ESP-IDF
run: |
pip install --upgrade platformio
pip install --upgrade idf-component-manager
- name: PlatformIO publish
env:
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }}
run: pio pkg publish --no-interactive
- name: ESP-IDF publish
env:
IDF_COMPONENT_API_TOKEN: ${{ secrets.IDF_COMPONENT_API_TOKEN }}
run: compote component upload --name RadioLib --namespace jgromes

View file

@ -1,48 +0,0 @@
name: "Unit test"
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
jobs:
unit-test:
name: Build and run unit test
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libboost-all-dev libfmt-dev lcov
- name: Run unit test
run: |
cd extras/test/unit
./test.sh
- name: Measure test coverage
run: |
cd extras/test/unit
./coverage.sh
- name: Upload coverage report as artifact
uses: actions/upload-artifact@v4
with:
name: coverage_report
path: extras/test/unit/lcov.report
- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: extras/test/unit/lcov.report
destination_dir: coverage
keep_files: true

7
.gitignore vendored
View file

@ -11,6 +11,13 @@
# Jetbrain IDEs # Jetbrain IDEs
.idea .idea
# Debug decoder
extras/decoder/log.txt
extras/decoder/out.txt
# Spectrum scan
extras/SX126x_Spectrum_Scan/out/*
# PlatformIO # PlatformIO
.pio* .pio*

View file

@ -36,7 +36,7 @@ target_include_directories(RadioLib
set_property(TARGET RadioLib PROPERTY CXX_STANDARD 20) set_property(TARGET RadioLib PROPERTY CXX_STANDARD 20)
# enable most warnings # enable most warnings
target_compile_options(RadioLib PRIVATE -Wall -Wextra -Wpedantic -Wdouble-promotion) target_compile_options(RadioLib PRIVATE -Wall -Wextra)
include(GNUInstallDirs) include(GNUInstallDirs)

View file

@ -4,6 +4,8 @@
## Universal wireless communication library for embedded devices ## Universal wireless communication library for embedded devices
## See the [Wiki](https://github.com/jgromes/RadioLib/wiki) and [FAQ](https://github.com/jgromes/RadioLib/wiki/Frequently-Asked-Questions) 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. 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! 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!
@ -11,13 +13,6 @@ RadioLib natively supports Arduino, but can run in non-Arduino environments as w
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! 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!
### Quick links:
* [__Wiki__](https://github.com/jgromes/RadioLib/wiki) - contains useful general information on using this library
* [__FAQ__](https://github.com/jgromes/RadioLib/wiki/Frequently-Asked-Questions) - frequently asked questions, and answers
* [__API Reference__](https://jgromes.github.io/RadioLib) - full API reference, automatically generated from the source code
* [__Status Code Decoder__](https://radiolib-org.github.io/status_decoder/decode.html) - decoder for status codes returned by RadioLib methods
* [__Debug Log Decoder__](https://radiolib-org.github.io/debug_decoder/decode.html) - decoder for RadioLib SPI debug logs
### Supported modules: ### Supported modules:
* __CC1101__ FSK radio module * __CC1101__ FSK radio module
* __LLCC68__ LoRa module * __LLCC68__ LoRa module
@ -48,13 +43,12 @@ SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x, LR11x0 and
SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x
* [__POCSAG__](https://www.sigidwiki.com/wiki/POCSAG) using 2-FSK for modules: * [__POCSAG__](https://www.sigidwiki.com/wiki/POCSAG) using 2-FSK for modules:
SX127x, RFM9x, RF69, SX1231, CC1101, nRF24L01, RFM2x and Si443x SX127x, RFM9x, RF69, SX1231, CC1101, nRF24L01, RFM2x and Si443x
* [__LoRaWAN__](https://lora-alliance.org/) using LoRa and FSK for modules: * [__LoRaWAN__](https://lora-alliance.org/) using LoRa for modules:
SX127x, RFM9x, SX126x, LR11x0 and SX128x SX127x, RFM9x, SX126x, LR11x0 and SX128x
### Supported Arduino platforms: ### Supported Arduino platforms:
* __Arduino__ * __Arduino__
* [__AVR__](https://github.com/arduino/ArduinoCore-avr) - Arduino Uno, Mega, Leonardo, Pro Mini, Nano etc. * [__AVR__](https://github.com/arduino/ArduinoCore-avr) - Arduino Uno, Mega, Leonardo, Pro Mini, Nano etc.
* NOTE: Arduino boards based on ATmega328 (Uno, Pro Mini, Nano etc.) and smaller are NOT recommended. This is because the ATmega328 MCU is very constrained in terms of program and memory size, so the library will end up taking most of the space available.
* [__mbed__](https://github.com/arduino/ArduinoCore-mbed) - Arduino Nano 33 BLE and Arduino Portenta H7 * [__mbed__](https://github.com/arduino/ArduinoCore-mbed) - Arduino Nano 33 BLE and Arduino Portenta H7
* [__megaAVR__](https://github.com/arduino/ArduinoCore-megaavr) - Arduino Uno WiFi Rev.2 and Nano Every * [__megaAVR__](https://github.com/arduino/ArduinoCore-megaavr) - Arduino Uno WiFi Rev.2 and Nano Every
* [__SAM__](https://github.com/arduino/ArduinoCore-sam) - Arduino Due * [__SAM__](https://github.com/arduino/ArduinoCore-sam) - Arduino Due
@ -94,7 +88,4 @@ SX127x, RFM9x, SX126x, LR11x0 and SX128x
* __PJRC__ * __PJRC__
* [__Teensy__](https://github.com/PaulStoffregen/cores) - Teensy 2.x, 3.x and 4.x boards * [__Teensy__](https://github.com/PaulStoffregen/cores) - Teensy 2.x, 3.x and 4.x boards
* __Silicon Labs__
* [__EFR32__](https://github.com/SiliconLabs/arduino) - Silicon Labs xG24, xG27 and other 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 addition, RadioLib includes an internal hardware abstraction layer, which allows it to be easily ported even to non-Arduino environments. 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 addition, RadioLib includes an internal hardware abstraction layer, which allows it to be easily ported even to non-Arduino environments.

View file

@ -35,13 +35,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create AFSK client instance using the FSK module // create AFSK client instance using the FSK module
// this requires connection to the module direct // this requires connection to the module direct

View file

@ -35,13 +35,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create AFSK client instance using the FSK module // create AFSK client instance using the FSK module
// this requires connection to the module direct // this requires connection to the module direct
@ -109,49 +105,32 @@ void setup() {
} }
void loop() { void loop() {
Serial.println(F("[APRS] Sending location reports")); Serial.print(F("[APRS] Sending position ... "));
// send a location without message or timestamp // send a location without message or timestamp
char destination[] = "N0CALL"; char destination[] = "N0CALL";
char latitude[] = "4911.67N"; char latitude[] = "4911.67N";
char longitude[] = "01635.96E"; char longitude[] = "01635.96E";
int state = aprs.sendPosition(destination, 0, latitude, longitude); int state = aprs.sendPosition(destination, 0, latitude, longitude);
if(state != RADIOLIB_ERR_NONE) {
Serial.print(F("[APRS] Failed to send location, code "));
Serial.println(state);
}
delay(500); delay(500);
// send a location with message and without timestamp // send a location with message and without timestamp
char message[] = "I'm here!"; char message[] = "I'm here!";
state = aprs.sendPosition(destination, 0, latitude, longitude, message); state |= aprs.sendPosition(destination, 0, latitude, longitude, message);
if(state != RADIOLIB_ERR_NONE) {
Serial.print(F("[APRS] Failed to send location and message code "));
Serial.println(state);
}
delay(500); delay(500);
// you can also set repeater callsigns and SSIDs
// up to 8 repeaters may be used
// sendPosition will be sent with "WIDE2-2" path
char* repeaterCallsigns[] = { "WIDE2" };
uint8_t repeaterSSIDs[] = { 2 };
aprs.useRepeaters(repeaterCallsigns, repeaterSSIDs, 1);
// send a location with message and timestamp // send a location with message and timestamp
char timestamp[] = "093045z"; char timestamp[] = "093045z";
state = aprs.sendPosition(destination, 0, latitude, longitude, message, timestamp); state |= aprs.sendPosition(destination, 0, latitude, longitude, message, timestamp);
if(state != RADIOLIB_ERR_NONE) {
Serial.print(F("[APRS] Failed to send location, message and timestamp code "));
Serial.println(state);
}
delay(500); delay(500);
// when repeaters are no longer needed, they can be dropped if(state == RADIOLIB_ERR_NONE) {
aprs.dropRepeaters(); Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
}
// wait one minute before transmitting again // wait one minute before transmitting again
Serial.println(F("[APRS] All done!"));
delay(60000); delay(60000);
} }

View file

@ -27,13 +27,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create APRS client instance using the LoRa radio // create APRS client instance using the LoRa radio
APRSClient aprs(&radio); APRSClient aprs(&radio);

View file

@ -38,13 +38,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create AX.25 client instance using the FSK module // create AX.25 client instance using the FSK module
AX25Client ax25(&radio); AX25Client ax25(&radio);

View file

@ -31,13 +31,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create AX.25 client instance using the FSK module // create AX.25 client instance using the FSK module
AX25Client ax25(&radio); AX25Client ax25(&radio);

View file

@ -32,13 +32,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create AFSK client instance using the FSK module // create AFSK client instance using the FSK module
// this requires connection to the module direct // this requires connection to the module direct

View file

@ -24,13 +24,9 @@
// GDO2 pin: 3 (optional) // GDO2 pin: 3 (optional)
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //CC1101 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -31,13 +31,9 @@
// GDO2 pin: 3 (optional) // GDO2 pin: 3 (optional)
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //CC1101 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -29,28 +29,9 @@
// GDO2 pin: 3 (optional) // GDO2 pin: 3 (optional)
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //CC1101 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// flag to indicate that a packet was received
volatile bool receivedFlag = false;
// 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) {
// we got a packet, set the flag
receivedFlag = true;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -91,6 +72,21 @@ void setup() {
// radio.readData(); // radio.readData();
} }
// flag to indicate that a packet was received
volatile bool receivedFlag = false;
// 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) {
// we got a packet, set the flag
receivedFlag = true;
}
void loop() { void loop() {
// check if the flag is set // check if the flag is set
if(receivedFlag) { if(receivedFlag) {

View file

@ -35,13 +35,9 @@ CC1101 radio1 = new Module(10, 2, RADIOLIB_NC, 3);
// GDO2 pin: 5 (optional) // GDO2 pin: 5 (optional)
CC1101 radio2 = new Module(9, 4, RADIOLIB_NC, 5); CC1101 radio2 = new Module(9, 4, RADIOLIB_NC, 5);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //CC1101 radio3 = RadioShield.ModuleB;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio3 = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -24,13 +24,9 @@
// GDO2 pin: 3 (optional) // GDO2 pin: 3 (optional)
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //CC1101 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -82,11 +78,10 @@ void setup() {
void loop() { void loop() {
Serial.print(F("[CC1101] Transmitting packet ... ")); Serial.print(F("[CC1101] Transmitting packet ... "));
// you can transmit C-string or Arduino string up to 255 characters long // you can transmit C-string or Arduino string up to 63 characters long
int state = radio.transmit("Hello World!"); int state = radio.transmit("Hello World!");
// you can also transmit byte array up to 255 bytes long // you can also transmit byte array up to 63 bytes long
// With some limitations see here: https://github.com/jgromes/RadioLib/discussions/1138
/* /*
byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
int state = radio.transmit(byteArr, 8); int state = radio.transmit(byteArr, 8);

View file

@ -2,7 +2,7 @@
RadioLib CC1101 Blocking Transmit Example RadioLib CC1101 Blocking Transmit Example
This example transmits packets using CC1101 FSK radio module. This example transmits packets using CC1101 FSK radio module.
Each packet contains up to 255 bytes of data with some limitations (https://github.com/jgromes/RadioLib/discussions/1138), in the form of: Each packet contains up to 64 bytes of data, in the form of:
- Arduino String - Arduino String
- null-terminated char array (C-string) - null-terminated char array (C-string)
- arbitrary binary data (byte array) - arbitrary binary data (byte array)
@ -28,13 +28,9 @@
// GDO2 pin: 3 // GDO2 pin: 3
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //CC1101 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -57,11 +53,11 @@ int count = 0;
void loop() { void loop() {
Serial.print(F("[CC1101] Transmitting packet ... ")); Serial.print(F("[CC1101] Transmitting packet ... "));
// you can transmit C-string or Arduino string up to 255 characters long // you can transmit C-string or Arduino string up to 63 characters long
String str = "Hello World! #" + String(count++); String str = "Hello World! #" + String(count++);
int state = radio.transmit(str); int state = radio.transmit(str);
// you can also transmit byte array up to 255 bytes long with some limitations; https://github.com/jgromes/RadioLib/discussions/1138 // you can also transmit byte array up to 63 bytes long
/* /*
byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
int state = radio.transmit(byteArr, 8); int state = radio.transmit(byteArr, 8);
@ -72,7 +68,7 @@ void loop() {
Serial.println(F("success!")); Serial.println(F("success!"));
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) { } else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
// the supplied packet was longer than 255 bytes // the supplied packet was longer than 64 bytes
Serial.println(F("too long!")); Serial.println(F("too long!"));
} else { } else {

View file

@ -3,7 +3,7 @@
This example transmits packets using CC1101 FSK radio module. This example transmits packets using CC1101 FSK radio module.
Once a packet is transmitted, an interrupt is triggered. Once a packet is transmitted, an interrupt is triggered.
Each packet contains up to 255 bytes of data with some limitations (https://github.com/jgromes/RadioLib/discussions/1138), in the form of: Each packet contains up to 64 bytes of data, in the form of:
- Arduino String - Arduino String
- null-terminated char array (C-string) - null-terminated char array (C-string)
- arbitrary binary data (byte array) - arbitrary binary data (byte array)
@ -25,32 +25,13 @@
// GDO2 pin: 3 // GDO2 pin: 3
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //CC1101 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// save transmission state between loops // save transmission state between loops
int transmissionState = RADIOLIB_ERR_NONE; int transmissionState = RADIOLIB_ERR_NONE;
// flag to indicate that a packet was sent
volatile bool transmittedFlag = false;
// 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) {
// we sent a packet, set the flag
transmittedFlag = true;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -73,12 +54,10 @@ void setup() {
Serial.print(F("[CC1101] Sending first packet ... ")); Serial.print(F("[CC1101] Sending first packet ... "));
// you can transmit C-string or Arduino string up to // you can transmit C-string or Arduino string up to
// 255 characters long // 64 characters long
transmissionState = radio.startTransmit("Hello World!"); transmissionState = radio.startTransmit("Hello World!");
// you can also transmit byte array up to 255 bytes long // you can also transmit byte array up to 64 bytes long
// When transmitting more than 64 bytes startTransmit blocks to refill the FIFO.
// Blocking ceases once the last bytes have been placed in the FIFO
/* /*
byte byteArr[] = {0x01, 0x23, 0x45, 0x56, byte byteArr[] = {0x01, 0x23, 0x45, 0x56,
0x78, 0xAB, 0xCD, 0xEF}; 0x78, 0xAB, 0xCD, 0xEF};
@ -86,6 +65,21 @@ void setup() {
*/ */
} }
// flag to indicate that a packet was sent
volatile bool transmittedFlag = false;
// 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) {
// we sent a packet, set the flag
transmittedFlag = true;
}
// counter to keep track of transmitted packets // counter to keep track of transmitted packets
int count = 0; int count = 0;
@ -121,11 +115,11 @@ void loop() {
Serial.print(F("[CC1101] Sending another packet ... ")); Serial.print(F("[CC1101] Sending another packet ... "));
// you can transmit C-string or Arduino string up to // you can transmit C-string or Arduino string up to
// 255 characters long // 256 characters long
String str = "Hello World! #" + String(count++); String str = "Hello World! #" + String(count++);
transmissionState = radio.startTransmit(str); transmissionState = radio.startTransmit(str);
// you can also transmit byte array up to 255 bytes long with limitations https://github.com/jgromes/RadioLib/discussions/1138 // you can also transmit byte array up to 256 bytes long
/* /*
byte byteArr[] = {0x01, 0x23, 0x45, 0x67, byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
0x89, 0xAB, 0xCD, 0xEF}; 0x89, 0xAB, 0xCD, 0xEF};

View file

@ -34,13 +34,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create FSK4 client instance using the FSK module // create FSK4 client instance using the FSK module
FSK4Client fsk4(&radio); FSK4Client fsk4(&radio);

View file

@ -32,13 +32,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create AFSK client instance using the FSK module // create AFSK client instance using the FSK module
// this requires connection to the module direct // this requires connection to the module direct

View file

@ -32,13 +32,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create Hellschreiber client instance using the FSK module // create Hellschreiber client instance using the FSK module
HellClient hell(&radio); HellClient hell(&radio);

View file

@ -31,13 +31,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create AFSK client instance using the FSK module // create AFSK client instance using the FSK module
// this requires connection to the module direct // this requires connection to the module direct

View file

@ -34,14 +34,6 @@
// BUSY pin: 9 // BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9); LR1110 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// set RF switch configuration for Wio WM1110 // set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching // Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different! // NOTE: other boards may be different!
@ -65,6 +57,10 @@ static const Module::RfSwitchMode_t rfswitch_table[] = {
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings // initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... ")); Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin(); int state = radio.begin();
@ -75,9 +71,6 @@ void setup() {
Serial.println(state); Serial.println(state);
while (true) { delay(10); } while (true) { delay(10); }
} }
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
} }
void loop() { void loop() {

View file

@ -29,14 +29,6 @@
// BUSY pin: 9 // BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9); LR1110 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// set RF switch configuration for Wio WM1110 // set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching // Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different! // NOTE: other boards may be different!
@ -57,24 +49,13 @@ static const Module::RfSwitchMode_t rfswitch_table[] = {
END_OF_MODE_TABLE, END_OF_MODE_TABLE,
}; };
// flag to indicate that a packet was detected or CAD timed out
volatile bool scanFlag = false;
// 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) {
// something happened, set the flag
scanFlag = true;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings // initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... ")); Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin(); int state = radio.begin();
@ -86,9 +67,6 @@ void setup() {
while (true) { delay(10); } while (true) { delay(10); }
} }
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// set the function that will be called // set the function that will be called
// when LoRa packet or timeout is detected // when LoRa packet or timeout is detected
radio.setIrqAction(setFlag); radio.setIrqAction(setFlag);
@ -104,6 +82,21 @@ void setup() {
} }
} }
// flag to indicate that a packet was detected or CAD timed out
volatile bool scanFlag = false;
// 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) {
// something happened, set the flag
scanFlag = true;
}
void loop() { void loop() {
// check if the flag is set // check if the flag is set
if(scanFlag) { if(scanFlag) {

View file

@ -48,13 +48,9 @@
// BUSY pin: 9 // BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9); LR1110 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //LR1110 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -26,13 +26,9 @@
// BUSY pin: 9 // BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9); LR1110 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //LR1110 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -1,182 +0,0 @@
/*
RadioLib LR11x0 GNSS Almanac Update Example
This example updates the LR11x0 GNSS almanac.
Almanac is a database of orbital predictions of
GNSS satellites, which allows the module to predict
when different satellites will appear in the sky,
and frequency of their signal.
Up-to-date almanac is necessary for operation!
After an update, data will remain valid for 30 days.
All GNSS examples require at least limited
visibility of the sky!
NOTE: This example will only work for LR11x0 devices
with sufficiently recent firmware!
LR1110: 4.1
LR1120: 2.1
If your device firmware reports older firmware,
update it using the LR11x0_Firmware_Update example.
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
// LR1110 has the following connections:
// NSS pin: 10
// DIO1 pin: 2
// NRST pin: 3
// BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different!
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6
{ LR11x0::MODE_STBY, { LOW, LOW } },
{ LR11x0::MODE_RX, { HIGH, LOW } },
{ LR11x0::MODE_TX, { HIGH, HIGH } },
{ LR11x0::MODE_TX_HP, { LOW, HIGH } },
{ LR11x0::MODE_TX_HF, { LOW, LOW } },
{ LR11x0::MODE_GNSS, { LOW, LOW } },
{ LR11x0::MODE_WIFI, { LOW, LOW } },
END_OF_MODE_TABLE,
};
// structure to save information about the GNSS almanac
LR11x0GnssAlmanacStatus_t almStatus;
void setup() {
Serial.begin(9600);
// initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... "));
int state = radio.beginGNSS(RADIOLIB_LR11X0_GNSS_CONSTELLATION_GPS);
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true) { delay(10); }
}
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// check the firmware version
Serial.print(F("[LR1110] Checking firmware version ... "));
state = radio.isGnssScanCapable();
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("check passed!"));
} else {
Serial.println(F("check failed, firmware update needed."));
while (true) { delay(10); }
}
// run GNSS scans until we get at least the time
// NOTE: Depending on visibility of satellites,
// this may take multiple attempts!
while(true) {
// run GNSS scan
Serial.print(F("[LR1110] Running GNSS scan ... "));
state = radio.gnssScan(NULL);
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true) { delay(10); }
}
// check almanac status
Serial.print(F("[LR1110] Checking GNSS almanac ... "));
state = radio.getGnssAlmanacStatus(&almStatus);
if (state != RADIOLIB_ERR_NONE) {
Serial.print(F("failed, code "));
Serial.println(state);
while (true) { delay(10); }
}
// we have the status, check if we have demodulated time
if(almStatus.gps.status < RADIOLIB_LR11X0_GNSS_ALMANAC_STATUS_UP_TO_DATE) {
Serial.println(F("time unknown, another scan needed."));
} else if(almStatus.gps.numUpdateNeeded > 0) {
Serial.print(almStatus.gps.numUpdateNeeded);
Serial.println(F(" satellites out-of-date."));
break;
} else {
Serial.println(F("no update needed!"));
while (true) { delay(10); }
}
}
}
void loop() {
// wait until almanac data is available in the signal
// multiple attempts are needed for this
Serial.print(F("[LR1110] Waiting for subframe ... "));
int state = radio.gnssDelayUntilSubframe(&almStatus, RADIOLIB_LR11X0_GNSS_CONSTELLATION_GPS);
if(state == RADIOLIB_ERR_GNSS_SUBFRAME_NOT_AVAILABLE) {
Serial.println(F("not enough time left."));
// wait until the next update window
delay(2000);
} else {
Serial.println(F("done!"));
// we have enough time to start the update
Serial.print(F("[LR1110] Starting update ... "));
state = radio.updateGnssAlmanac(RADIOLIB_LR11X0_GNSS_CONSTELLATION_GPS);
if(state != RADIOLIB_ERR_NONE) {
Serial.print(F("failed, code "));
Serial.println(state);
} else {
Serial.println(F("done!"));
}
}
// check whether another update is needed
Serial.print(F("[LR1110] Checking GNSS almanac ... "));
state = radio.getGnssAlmanacStatus(&almStatus);
if(state != RADIOLIB_ERR_NONE) {
Serial.print(F("failed, code "));
Serial.println(state);
while (true) { delay(10); }
}
// check if we have completed the update
if(almStatus.gps.numUpdateNeeded == 0) {
Serial.println(F("all satellites up-to-date!"));
while (true) { delay(10); }
} else {
Serial.print(almStatus.gps.numUpdateNeeded);
Serial.println(F(" satellites out-of-date."));
}
// wait a bit before the next update attempt
delay(1000);
}

View file

@ -1,134 +0,0 @@
/*
RadioLib LR11x0 GNSS Autonomous Position Example
This example performs GNSS scans and calculates
position of the device using autonomous mode.
In this mode, scan data does not need to be uploaded
to LoRaCloud, however, it requires up-to-date almanac
data. Run the LR11x0_Almanac_Update example to update
the device almanac.
NOTE: This example will only work for LR11x0 devices
with sufficiently recent firmware!
LR1110: 4.1
LR1120: 2.1
If your device firmware reports older firmware,
update it using the LR11x0_Firmware_Update example.
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
// LR1110 has the following connections:
// NSS pin: 10
// DIO1 pin: 2
// NRST pin: 3
// BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different!
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6
{ LR11x0::MODE_STBY, { LOW, LOW } },
{ LR11x0::MODE_RX, { HIGH, LOW } },
{ LR11x0::MODE_TX, { HIGH, HIGH } },
{ LR11x0::MODE_TX_HP, { LOW, HIGH } },
{ LR11x0::MODE_TX_HF, { LOW, LOW } },
{ LR11x0::MODE_GNSS, { LOW, LOW } },
{ LR11x0::MODE_WIFI, { LOW, LOW } },
END_OF_MODE_TABLE,
};
// structure to save information about the GNSS scan result
LR11x0GnssResult_t gnssResult;
// structure to save information about the calculated GNSS position
LR11x0GnssPosition_t gnssPosition;
void setup() {
Serial.begin(9600);
// initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... "));
int state = radio.beginGNSS(RADIOLIB_LR11X0_GNSS_CONSTELLATION_GPS);
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true) { delay(10); }
}
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// check the firmware version
Serial.print(F("[LR1110] Checking firmware version ... "));
state = radio.isGnssScanCapable();
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("check passed!"));
} else {
Serial.println(F("check failed, firmware update needed."));
while (true) { delay(10); }
}
Serial.println(F("Scan result\t| Latitude\t| Longitude\t| Accuracy\t| Number of satellites"));
}
void loop() {
// run GNSS scan
int state = radio.gnssScan(&gnssResult);
if(state == RADIOLIB_ERR_NONE) {
// success!
Serial.print(gnssResult.demodStat); Serial.print("\t\t| ");
// get the actual data
state = radio.getGnssPosition(&gnssPosition);
if(state == RADIOLIB_ERR_NONE) {
// print the position
Serial.print(gnssPosition.latitude, 6);
Serial.print("\t| ");
Serial.print(gnssPosition.longitude, 6);
Serial.print("\t| ");
Serial.print(gnssPosition.accuracy);
Serial.print("\t\t| ");
Serial.println(gnssPosition.numSatsUsed);
} else {
Serial.print(F("Failed to read result, code "));
Serial.print(state);
Serial.print(F(" (solver error "));
Serial.print(RADIOLIB_GET_GNSS_SOLVER_ERROR(state));
Serial.println(F(")"));
}
} else {
Serial.print(F("Scan failed, code "));
Serial.print(state);
Serial.print(F(" (demodulator error "));
Serial.print(RADIOLIB_GET_GNSS_DEMOD_ERROR(state));
Serial.println(F(")"));
}
// wait a bit before the next scan
delay(1000);
}

View file

@ -1,133 +0,0 @@
/*
RadioLib LR11x0 GNSS Satellites Example
This example performs GNSS scans and shows the satellites
currently in view. It is mostly useful to verify
visibility and antenna setup.
NOTE: This example will only work for LR11x0 devices
with sufficiently recent firmware!
LR1110: 4.1
LR1120: 2.1
If your device firmware reports older firmware,
update it using the LR11x0_Firmware_Update example.
For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#lr11x0---wifi-scan
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
// LR1110 has the following connections:
// NSS pin: 10
// DIO1 pin: 2
// NRST pin: 3
// BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different!
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6
{ LR11x0::MODE_STBY, { LOW, LOW } },
{ LR11x0::MODE_RX, { HIGH, LOW } },
{ LR11x0::MODE_TX, { HIGH, HIGH } },
{ LR11x0::MODE_TX_HP, { LOW, HIGH } },
{ LR11x0::MODE_TX_HF, { LOW, LOW } },
{ LR11x0::MODE_GNSS, { LOW, LOW } },
{ LR11x0::MODE_WIFI, { LOW, LOW } },
END_OF_MODE_TABLE,
};
// structure to save information about the GNSS scan result
LR11x0GnssResult_t gnssResult;
void setup() {
Serial.begin(9600);
// initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... "));
int state = radio.beginGNSS(RADIOLIB_LR11X0_GNSS_CONSTELLATION_GPS);
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true) { delay(10); }
}
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// check the firmware version
Serial.print(F("[LR1110] Checking firmware version ... "));
state = radio.isGnssScanCapable();
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("check passed!"));
} else {
Serial.println(F("check failed, firmware update needed."));
while (true) { delay(10); }
}
}
void loop() {
Serial.print(F("[LR1110] Running GNSS scan ... "));
int state = radio.gnssScan(&gnssResult);
if(state != RADIOLIB_ERR_NONE) {
// some error occurred
Serial.print(F("failed, code "));
Serial.print(state);
Serial.print(F(" (demodulator error "));
Serial.print(RADIOLIB_GET_GNSS_DEMOD_ERROR(state));
Serial.println(F(")"));
} else {
Serial.println(F("success!"));
// print the table header
Serial.print(F("[LR1110] Detected "));
Serial.print(gnssResult.numSatsDet);
Serial.println(F(" satellite(s):"));
Serial.println(F(" # | ID | C/N0 [dB]\t| Doppler [Hz]"));
// read all results at once
LR11x0GnssSatellite_t satellites[32];
state = radio.getGnssSatellites(satellites, gnssResult.numSatsDet);
if(state != RADIOLIB_ERR_NONE) {
Serial.print(F("Failed to read results, code "));
Serial.println(state);
} else {
// print all the results
for(int i = 0; i < gnssResult.numSatsDet; i++) {
if(i < 10) { Serial.print(" "); } Serial.print(i); Serial.print(" | ");
Serial.print(satellites[i].svId); Serial.print(" | ");
Serial.print(satellites[i].c_n0); Serial.print("\t\t| ");
Serial.println(satellites[i].doppler);
}
}
}
// wait for a second before scanning again
delay(1000);
}

View file

@ -27,13 +27,9 @@
// BUSY pin: 9 // BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9); LR1110 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //LR1110 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -62,8 +58,7 @@ void setup() {
3, // header count 3, // header count
0x13A); // hopping sequence seed 0x13A); // hopping sequence seed
state = radio.setOutputPower(10.0); state = radio.setOutputPower(10.0);
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67}; state = radio.setSyncWord(0x12345678);
state = radio.setSyncWord(syncWord, 4);
if (state != RADIOLIB_ERR_NONE) { if (state != RADIOLIB_ERR_NONE) {
Serial.print(F("Unable to set configuration, code ")); Serial.print(F("Unable to set configuration, code "));
Serial.println(state); Serial.println(state);

View file

@ -22,14 +22,6 @@
// BUSY pin: 9 // BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9); LR1110 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// set RF switch configuration for Wio WM1110 // set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching // Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different! // NOTE: other boards may be different!
@ -74,6 +66,10 @@ void setFlag(void) {
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings // initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... ")); Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin(); int state = radio.begin();
@ -85,9 +81,6 @@ void setup() {
while (true) { delay(10); } while (true) { delay(10); }
} }
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// set the function that will be called // set the function that will be called
// when new packet is received // when new packet is received
radio.setIrqAction(setFlag); radio.setIrqAction(setFlag);

View file

@ -39,14 +39,6 @@
// BUSY pin: 9 // BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9); LR1110 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// set RF switch configuration for Wio WM1110 // set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching // Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different! // NOTE: other boards may be different!
@ -70,6 +62,10 @@ static const Module::RfSwitchMode_t rfswitch_table[] = {
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings // initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... ")); Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin(); int state = radio.begin();
@ -80,9 +76,6 @@ void setup() {
Serial.println(state); Serial.println(state);
while (true) { delay(10); } while (true) { delay(10); }
} }
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
} }
void loop() { void loop() {

View file

@ -35,14 +35,6 @@
// BUSY pin: 9 // BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9); LR1110 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// set RF switch configuration for Wio WM1110 // set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching // Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different! // NOTE: other boards may be different!
@ -63,24 +55,13 @@ static const Module::RfSwitchMode_t rfswitch_table[] = {
END_OF_MODE_TABLE, END_OF_MODE_TABLE,
}; };
// flag to indicate that a packet was received
volatile bool receivedFlag = false;
// 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) {
// we got a packet, set the flag
receivedFlag = true;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings // initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... ")); Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin(); int state = radio.begin();
@ -92,9 +73,6 @@ void setup() {
while (true) { delay(10); } while (true) { delay(10); }
} }
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// set the function that will be called // set the function that will be called
// when new packet is received // when new packet is received
radio.setPacketReceivedAction(setFlag); radio.setPacketReceivedAction(setFlag);
@ -120,6 +98,21 @@ void setup() {
// radio.scanChannel(); // radio.scanChannel();
} }
// flag to indicate that a packet was received
volatile bool receivedFlag = false;
// 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) {
// we got a packet, set the flag
receivedFlag = true;
}
void loop() { void loop() {
// check if the flag is set // check if the flag is set
if(receivedFlag) { if(receivedFlag) {

View file

@ -30,14 +30,6 @@
// BUSY pin: 9 // BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9); LR1110 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// set RF switch configuration for Wio WM1110 // set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching // Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different! // NOTE: other boards may be different!
@ -61,6 +53,10 @@ static const Module::RfSwitchMode_t rfswitch_table[] = {
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings // initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... ")); Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin(); int state = radio.begin();
@ -72,9 +68,6 @@ void setup() {
delay(1000); delay(1000);
while (true) { delay(10); } while (true) { delay(10); }
} }
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
} }
// counter to keep track of transmitted packets // counter to keep track of transmitted packets

View file

@ -31,14 +31,6 @@
// BUSY pin: 9 // BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9); LR1110 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// set RF switch configuration for Wio WM1110 // set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching // Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different! // NOTE: other boards may be different!
@ -62,24 +54,13 @@ static const Module::RfSwitchMode_t rfswitch_table[] = {
// save transmission state between loops // save transmission state between loops
int transmissionState = RADIOLIB_ERR_NONE; int transmissionState = RADIOLIB_ERR_NONE;
// flag to indicate that a packet was sent
volatile bool transmittedFlag = false;
// 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) {
// we sent a packet, set the flag
transmittedFlag = true;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings // initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... ")); Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin(); int state = radio.begin();
@ -91,9 +72,6 @@ void setup() {
while (true) { delay(10); } while (true) { delay(10); }
} }
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// set the function that will be called // set the function that will be called
// when packet transmission is finished // when packet transmission is finished
radio.setPacketSentAction(setFlag); radio.setPacketSentAction(setFlag);
@ -113,6 +91,21 @@ void setup() {
*/ */
} }
// flag to indicate that a packet was sent
volatile bool transmittedFlag = false;
// 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) {
// we sent a packet, set the flag
transmittedFlag = true;
}
// counter to keep track of transmitted packets // counter to keep track of transmitted packets
int count = 0; int count = 0;

View file

@ -32,14 +32,6 @@
// BUSY pin: 9 // BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9); LR1110 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// set RF switch configuration for Wio WM1110 // set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching // Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different! // NOTE: other boards may be different!
@ -63,6 +55,10 @@ static const Module::RfSwitchMode_t rfswitch_table[] = {
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings // initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... ")); Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin(); int state = radio.begin();
@ -73,9 +69,6 @@ void setup() {
Serial.println(state); Serial.println(state);
while (true) { delay(10); } while (true) { delay(10); }
} }
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
} }
void loop() { void loop() {

View file

@ -32,14 +32,6 @@
// BUSY pin: 9 // BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9); LR1110 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// set RF switch configuration for Wio WM1110 // set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching // Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different! // NOTE: other boards may be different!
@ -60,23 +52,13 @@ static const Module::RfSwitchMode_t rfswitch_table[] = {
END_OF_MODE_TABLE, END_OF_MODE_TABLE,
}; };
// flag to indicate that a scan was completed
volatile bool scanFlag = false;
// this function is called when a scan is completed
// 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) {
// scan is complete, set the flag
scanFlag = true;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings // initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... ")); Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin(); int state = radio.begin();
@ -88,9 +70,6 @@ void setup() {
while (true) { delay(10); } while (true) { delay(10); }
} }
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// set the function that will be called // set the function that will be called
// when WiFi scan is complete // when WiFi scan is complete
radio.setIrqAction(setFlag); radio.setIrqAction(setFlag);
@ -106,6 +85,20 @@ void setup() {
} }
} }
// flag to indicate that a scan was completed
volatile bool scanFlag = false;
// this function is called when a scan is completed
// 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) {
// scan is complete, set the flag
scanFlag = true;
}
void loop() { void loop() {
// check if the flag is set // check if the flag is set
if(scanFlag) { if(scanFlag) {

View file

@ -41,11 +41,9 @@ const uint32_t uplinkIntervalSeconds = 5UL * 60UL; // minutes x seconds
// for the curious, the #ifndef blocks allow for automated testing &/or you can // for the curious, the #ifndef blocks allow for automated testing &/or you can
// put your EUI & keys in to your platformio.ini - see wiki for more tips // put your EUI & keys in to your platformio.ini - see wiki for more tips
// regional choices: EU868, US915, AU915, AS923, AS923_2, AS923_3, AS923_4, IN865, KR920, CN470 // regional choices: EU868, US915, AU915, AS923, AS923_2, AS923_3, AS923_4, IN865, KR920, CN500
const LoRaWANBand_t Region = EU868; const LoRaWANBand_t Region = EU868;
const uint8_t subBand = 0; // For US915, change this to 2, otherwise leave on 0
// subband choice: for US915/AU915 set to 2, for CN470 set to 1, otherwise leave on 0
const uint8_t subBand = 0;
// ============================================================================ // ============================================================================
// Below is to support the sketch - only make changes if the notes say so ... // Below is to support the sketch - only make changes if the notes say so ...

View file

@ -48,9 +48,6 @@ void setup() {
// Override the default join rate // Override the default join rate
uint8_t joinDR = 4; uint8_t joinDR = 4;
// Optionally provide a custom sleep function - see config.h
//node.setSleepFunction(customDelay);
// Setup the OTAA session information // Setup the OTAA session information
node.beginOTAA(joinEUI, devEUI, nwkKey, appKey); node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);
@ -71,7 +68,7 @@ void setup() {
// Manages uplink intervals to the TTN Fair Use Policy // Manages uplink intervals to the TTN Fair Use Policy
node.setDutyCycle(true, 1250); node.setDutyCycle(true, 1250);
// Update dwell time limits - 400ms is the limit for the US // Enable the dwell time limits - 400ms is the limit for the US
node.setDwellTime(true, 400); node.setDwellTime(true, 400);
Serial.println(F("Ready!\n")); Serial.println(F("Ready!\n"));

View file

@ -37,11 +37,9 @@ const uint32_t uplinkIntervalSeconds = 5UL * 60UL; // minutes x seconds
// for the curious, the #ifndef blocks allow for automated testing &/or you can // for the curious, the #ifndef blocks allow for automated testing &/or you can
// put your EUI & keys in to your platformio.ini - see wiki for more tips // put your EUI & keys in to your platformio.ini - see wiki for more tips
// regional choices: EU868, US915, AU915, AS923, AS923_2, AS923_3, AS923_4, IN865, KR920, CN470 // regional choices: EU868, US915, AU915, AS923, AS923_2, AS923_3, AS923_4, IN865, KR920, CN500
const LoRaWANBand_t Region = EU868; const LoRaWANBand_t Region = EU868;
const uint8_t subBand = 0; // For US915, change this to 2, otherwise leave on 0
// subband choice: for US915/AU915 set to 2, for CN470 set to 1, otherwise leave on 0
const uint8_t subBand = 0;
// ============================================================================ // ============================================================================
// Below is to support the sketch - only make changes if the notes say so ... // Below is to support the sketch - only make changes if the notes say so ...
@ -144,19 +142,4 @@ void arrayDump(uint8_t *buffer, uint16_t len) {
Serial.println(); Serial.println();
} }
// Custom delay function:
// Communication over LoRaWAN includes a lot of delays.
// By default, RadioLib will use the Arduino delay() function,
// which will waste a lot of power. However, you can put your
// microcontroller to sleep instead by customizing the function below,
// and providing it to RadioLib via "node.setSleepFunction".
// NOTE: You ahve to ensure that this function is timed precisely, and
// does actually wait for the amount of time specified!
// Failure to do so will result in missed downlinks or failed join!
void customDelay(RadioLibTime_t ms) {
// this is just an example, so we use the Arduino delay() function,
// but you can put your microcontroller to sleep here
::delay(ms);
}
#endif #endif

View file

@ -37,11 +37,9 @@ const uint32_t uplinkIntervalSeconds = 5UL * 60UL; // minutes x seconds
// for the curious, the #ifndef blocks allow for automated testing &/or you can // for the curious, the #ifndef blocks allow for automated testing &/or you can
// put your EUI & keys in to your platformio.ini - see wiki for more tips // put your EUI & keys in to your platformio.ini - see wiki for more tips
// regional choices: EU868, US915, AU915, AS923, AS923_2, AS923_3, AS923_4, IN865, KR920, CN470 // regional choices: EU868, US915, AU915, AS923, AS923_2, AS923_3, AS923_4, IN865, KR920, CN500
const LoRaWANBand_t Region = EU868; const LoRaWANBand_t Region = EU868;
const uint8_t subBand = 0; // For US915, change this to 2, otherwise leave on 0
// subband choice: for US915/AU915 set to 2, for CN470 set to 1, otherwise leave on 0
const uint8_t subBand = 0;
// ============================================================================ // ============================================================================
// Below is to support the sketch - only make changes if the notes say so ... // Below is to support the sketch - only make changes if the notes say so ...

View file

@ -52,7 +52,7 @@ You are making your own device using a third party LoRaWAN stack so there will n
Choose the Frequency plan appropriate for your region. Consider that almost all countries have laws relating to what frequencies you use so don't get creative. For Europe please use the recommended option. For other regions use the entry marked 'used by TTN'. Choose the Frequency plan appropriate for your region. Consider that almost all countries have laws relating to what frequencies you use so don't get creative. For Europe please use the recommended option. For other regions use the entry marked 'used by TTN'.
Choose LoRaWAN 1.1.0 - the last one in the list - the latest specfication. RadioLib uses RP001 Regional Parameters 1.1 revision B. Choose LoRaWAN 1.1.0 - the last one in the list - the latest specfication. RadioLib uses RP001 Regional Parameters 1.1 revision A.
At this point you will be asked for your JoinEUI. As this is a DIY device and we are using RadioLib, you can use all zero's as recommended by The LoRa Alliance TR007 Technical Recommendations document. Once you've put in all zeros and clicked confirm you will be asked for a DevEUI, AppKey and NwkKey. It is preferable to have the console generate them so they are properly formatted. At this point you will be asked for your JoinEUI. As this is a DIY device and we are using RadioLib, you can use all zero's as recommended by The LoRa Alliance TR007 Technical Recommendations document. Once you've put in all zeros and clicked confirm you will be asked for a DevEUI, AppKey and NwkKey. It is preferable to have the console generate them so they are properly formatted.

View file

@ -6,17 +6,17 @@ RadioLib LoRaWAN examples.
* [LoRaWAN_ABP](https://github.com/jgromes/RadioLib/tree/master/examples/LoRaWAN/LoRaWAN_ABP): if you wish to use ABP instead of OTAA (but why?), this example shows how you can do this using RadioLib. * [LoRaWAN_ABP](https://github.com/jgromes/RadioLib/tree/master/examples/LoRaWAN/LoRaWAN_ABP): if you wish to use ABP instead of OTAA (but why?), this example shows how you can do this using RadioLib.
## LoRaWAN versions & regional parameters ## LoRaWAN versions & regional parameters
RadioLib implements both LoRaWAN Specification 1.1 and 1.0.4. Confusingly, 1.0.4 is newer than 1.1, but 1.1 includes more security checks and as such **LoRaWAN 1.1 is preferred**. RadioLib implements both LoRaWAN v1.1 and v1.0.4. Confusingly, v1.0.4 is newer than v1.1, but v1.1 includes more security checks and as such **LoRaWAN v1.1 is preferred**.
The catch is in the Regional Parameters: as RP002 1.0.4 is newer than RP001 1.1, it is more up to date regarding local laws & regulations. Therefore, RadioLib implements 1.0.4 as baseline and 1.1 (revision B) as fallback, and as such **RP002 Regional Parameters 1.0.4 is preferred**. The catch is in the Regional Parameters: as v1.0.4 is newer, it is more up to date regarding local laws & regulations. Therefore, RadioLib implements 1.0.4 as baseline and 1.1 as fallback, but **Regional Parameters v1.0.4 is preferred**.
_Note: the CN470 band is implemented as specified in RP001 1.1 revision B, as the RP002 1.0.4 version is much too complex._ _Note: the CN500 band is implemented as specified in RP v1.1, as the RP v1.0.4 version is much too complex._
To activate a LoRaWAN 1.1 session, supply all the required keys: To activate a LoRaWAN v1.1 session, supply all the required keys:
```cpp ```cpp
node.beginOTAA(joinEUI, devEUI, nwkKey, appKey); node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);
node.beginABP(devAddr, fNwkSIntKey, sNwkSIntKey, nwkSEncKey, appSKey); node.beginABP(devAddr, fNwkSIntKey, sNwkSIntKey, nwkSEncKey, appSKey);
``` ```
To activate a LoRaWAN 1.0.4 session, set the keys that are not available to `NULL`: To activate a LoRaWAN v1.0.4 session, set the keys that are not available to `NULL`:
```cpp ```cpp
node.beginOTAA(joinEUI, devEUI, NULL, appKey); node.beginOTAA(joinEUI, devEUI, NULL, appKey);
node.beginABP(devAddr, NULL, NULL, nwkSEncKey, appSKey); node.beginABP(devAddr, NULL, NULL, nwkSEncKey, appSKey);
@ -26,9 +26,9 @@ The device doesn't need to know the Regional Parameters version - that is of imp
## LoRaWAN persistence ## LoRaWAN persistence
> [!WARNING] > [!WARNING]
> These examples do not actually comply with LoRaWAN 1.0.4/1.1: for that, persistent storage is necessary. As the implementation of persistent storage differs between different platforms, these are not given here, but in a separate repository, see below: > These examples do not actually comply with LoRaWAN v1.0.4/v1.1: for that, persistent storage is necessary. As the implementation of persistent storage differs between different platforms, these are not given here, but in a separate repository, see below:
In [this repository](https://github.com/radiolib-org/radiolib-persistence), examples are provided that do comply with the required persistence of certain parameters for LoRaWAN 1.1. Examples are (or will become) available for some of the most popular platforms. **These examples assume you have successfully used the Starter sketch and understood (most of) the accompanying notes!** In [this repository](https://github.com/radiolib-org/radiolib-persistence), examples are provided that do comply with the required persistence of certain parameters for LoRaWAN v1.1. Examples are (or will become) available for some of the most popular platforms. **These examples assume you have successfully used the Starter sketch and understood (most of) the accompanying notes!**
Currently, examples are available for the following platforms: Currently, examples are available for the following platforms:
* [LoRaWAN for ESP32](https://github.com/radiolib-org/radiolib-persistence/tree/main/examples/LoRaWAN_ESP32) * [LoRaWAN for ESP32](https://github.com/radiolib-org/radiolib-persistence/tree/main/examples/LoRaWAN_ESP32)

View file

@ -30,13 +30,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create AFSK client instance using the FSK module // create AFSK client instance using the FSK module
// pin 5 is connected to SX1278 DIO2 // pin 5 is connected to SX1278 DIO2

View file

@ -30,13 +30,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create AFSK client instance using the FSK module // create AFSK client instance using the FSK module
// pin 5 is connected to SX1278 DIO2 // pin 5 is connected to SX1278 DIO2

View file

@ -31,13 +31,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create AFSK client instance using the FSK module // create AFSK client instance using the FSK module
// this requires connection to the module direct // this requires connection to the module direct

View file

@ -33,13 +33,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create Morse client instance using the FSK module // create Morse client instance using the FSK module
MorseClient morse(&radio); MorseClient morse(&radio);

View file

@ -7,7 +7,7 @@
// this example only works on ESP32 and is unlikely to work on ESP32S2/S3 etc. // this example only works on ESP32 and is unlikely to work on ESP32S2/S3 etc.
// if you need high portability, you should probably use Arduino anyway ... // if you need high portability, you should probably use Arduino anyway ...
#if CONFIG_IDF_TARGET_ESP32 == 0 #if CONFIG_IDF_TARGET_ESP32 == 0
#error This example HAL only supports ESP32 targets. Support for ESP32S2/S3 etc. can be added by adjusting this file to user needs. #error Target is not ESP32!
#endif #endif
// include all the dependencies // include all the dependencies

View file

@ -41,7 +41,7 @@
#include <RadioLib.h> #include <RadioLib.h>
// include the hardware abstraction layer // include the hardware abstraction layer
#include "hal/RPiPico/PicoHal.h" #include "PicoHal.h"
// create a new instance of the HAL class // create a new instance of the HAL class
PicoHal* hal = new PicoHal(SPI_PORT, SPI_MISO, SPI_MOSI, SPI_SCK); PicoHal* hal = new PicoHal(SPI_PORT, SPI_MISO, SPI_MOSI, SPI_SCK);

View file

@ -32,10 +32,6 @@ class PiHal : public RadioLibHal {
} }
void init() override { void init() override {
if(_gpioHandle != -1) {
return;
}
// first initialise lgpio library // first initialise lgpio library
if((_gpioHandle = lgGpiochipOpen(_gpioDevice)) < 0) { if((_gpioHandle = lgGpiochipOpen(_gpioDevice)) < 0) {
fprintf(stderr, "Could not open GPIO chip: %s\n", lguErrorText(_gpioHandle)); fprintf(stderr, "Could not open GPIO chip: %s\n", lguErrorText(_gpioHandle));
@ -52,7 +48,6 @@ class PiHal : public RadioLibHal {
// finally, stop the lgpio library // finally, stop the lgpio library
lgGpiochipClose(_gpioHandle); lgGpiochipClose(_gpioHandle);
_gpioHandle = -1;
} }
// GPIO-related methods (pinMode, digitalWrite etc.) should check // GPIO-related methods (pinMode, digitalWrite etc.) should check

View file

@ -18,7 +18,7 @@
#include <RadioLib.h> #include <RadioLib.h>
// include the hardware abstraction layer // include the hardware abstraction layer
#include "hal/RPi/PiHal.h" #include "PiHal.h"
// create a new instance of the HAL class // create a new instance of the HAL class
// use SPI channel 1, because on Waveshare LoRaWAN Hat, // use SPI channel 1, because on Waveshare LoRaWAN Hat,

View file

@ -50,21 +50,7 @@ add_executable(${PROJECT_NAME} main.cpp)
# The build system for libtock-c is a bit odd and the version of libraries # The build system for libtock-c is a bit odd and the version of libraries
# built changes based on compiler version. # built changes based on compiler version.
if (RISCV_BUILD) if (RISCV_BUILD)
if(EXISTS "$ENV{LIBTOCK_C_DIRECTORY}/lib/libtock-libc++-14.1.0") if(EXISTS "$ENV{LIBTOCK_C_DIRECTORY}/lib/libtock-libc++-13.2.0")
target_link_libraries(${PROJECT_NAME} PUBLIC
RadioLib
$ENV{LIBTOCK_C_DIRECTORY}/libtock/build/rv32imc/libtock.a
$ENV{LIBTOCK_C_DIRECTORY}/libtock-sync/build/rv32imc/libtocksync.a
$ENV{LIBTOCK_C_DIRECTORY}/lib/libtock-libc++-14.1.0/riscv/lib/gcc/riscv64-unknown-elf/14.1.0/rv32i/ilp32/libgcc.a
$ENV{LIBTOCK_C_DIRECTORY}/lib/libtock-libc++-14.1.0/riscv/riscv64-unknown-elf/lib/rv32i/ilp32/libstdc++.a
$ENV{LIBTOCK_C_DIRECTORY}/lib/libtock-newlib-4.4.0.20231231/riscv/riscv64-unknown-elf/lib/rv32i/ilp32/libc.a
$ENV{LIBTOCK_C_DIRECTORY}/lib/libtock-newlib-4.4.0.20231231/riscv/riscv64-unknown-elf/lib/rv32i/ilp32/libm.a
)
target_include_directories(RadioLib AFTER PUBLIC
$ENV{LIBTOCK_C_DIRECTORY}/lib/libtock-newlib-4.3.0.20230120/riscv/riscv64-unknown-elf/include/
)
elseif(EXISTS "$ENV{LIBTOCK_C_DIRECTORY}/lib/libtock-libc++-13.2.0")
target_link_libraries(${PROJECT_NAME} PUBLIC target_link_libraries(${PROJECT_NAME} PUBLIC
RadioLib RadioLib
$ENV{LIBTOCK_C_DIRECTORY}/libtock/build/rv32imc/libtock.a $ENV{LIBTOCK_C_DIRECTORY}/libtock/build/rv32imc/libtock.a
@ -94,17 +80,7 @@ if (RISCV_BUILD)
) )
endif() endif()
else() else()
if (EXISTS "$ENV{LIBTOCK_C_DIRECTORY}/lib/libtock-libc++-14.1.0") if(EXISTS "$ENV{LIBTOCK_C_DIRECTORY}/lib/libtock-libc++-13.2.0")
target_link_libraries(${PROJECT_NAME} PUBLIC
RadioLib
$ENV{LIBTOCK_C_DIRECTORY}/libtock/build/cortex-m4/libtock.a
$ENV{LIBTOCK_C_DIRECTORY}/libtock-sync/build/cortex-m4/libtocksync.a
$ENV{LIBTOCK_C_DIRECTORY}/lib/libtock-libc++-14.1.0/arm/lib/gcc/arm-none-eabi/14.1.0/libgcc.a
$ENV{LIBTOCK_C_DIRECTORY}/lib/libtock-libc++-14.1.0/arm/arm-none-eabi/lib/libstdc++.a
$ENV{LIBTOCK_C_DIRECTORY}/lib/libtock-newlib-4.4.0.20231231/arm/arm-none-eabi/lib/libc.a
$ENV{LIBTOCK_C_DIRECTORY}/lib/libtock-newlib-4.4.0.20231231/arm/arm-none-eabi/lib/libm.a
)
elseif(EXISTS "$ENV{LIBTOCK_C_DIRECTORY}/lib/libtock-libc++-13.2.0")
target_link_libraries(${PROJECT_NAME} PUBLIC target_link_libraries(${PROJECT_NAME} PUBLIC
RadioLib RadioLib
$ENV{LIBTOCK_C_DIRECTORY}/libtock/build/cortex-m4/libtock.a $ENV{LIBTOCK_C_DIRECTORY}/libtock/build/cortex-m4/libtock.a

View file

@ -23,7 +23,7 @@ The RadioLib example can be built with:
$ git clone https://github.com/jgromes/RadioLib.git $ git clone https://github.com/jgromes/RadioLib.git
$ cd RadioLib/examples/NonArduino/Tock/ $ cd RadioLib/examples/NonArduino/Tock/
$ git clone https://github.com/tock/libtock-c.git $ git clone https://github.com/tock/libtock-c.git
$ cd libtock-c; git checkout c0202f9ab78da4a6e95f136cf5250701e3778f63; cd ../ $ cd libtock-c; git checkout dbee65a56d74b4bad166317f199e80b959f7c82c; cd ../
$ LIBTOCK_C_DIRECTORY="$(pwd)/libtock-c" ./build.sh $ LIBTOCK_C_DIRECTORY="$(pwd)/libtock-c" ./build.sh
``` ```

View file

@ -3,9 +3,9 @@ set -e
rm -rf ./build-* rm -rf ./build-*
pushd ${LIBTOCK_C_DIRECTORY}/examples/cxx_hello cd libtock-c/examples/cxx_hello
make -j4 make -j4
popd cd ../../../
mkdir -p build-arm mkdir -p build-arm
cd build-arm cd build-arm

View file

@ -0,0 +1,225 @@
/*
RadioLib Non-Arduino Tock Library helper functions
Licensed under the MIT License
Copyright (c) 2023 Alistair Francis <alistair@alistair23.me>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef TOCK_HAL_H
#define TOCK_HAL_H
// include RadioLib
#include <RadioLib.h>
// include all the dependencies
#include "libtock/net/lora_phy.h"
#include "libtock/net/syscalls/lora_phy_syscalls.h"
#include "libtock-sync/net/lora_phy.h"
#include "libtock/peripherals/gpio.h"
#include "libtock-sync/services/alarm.h"
#include "libtock/kernel/read_only_state.h"
#define RADIO_BUSY 1
#define RADIO_DIO_1 2
#define RADIO_DIO_3 3
#define RADIO_RESET 4
// Skip the chips select as Tock handles this for us
#define RADIO_NSS RADIOLIB_NC
// define Arduino-style macros
#define PIN_LOW (0x0)
#define PIN_HIGH (0x1)
#define PIN_INPUT (0x01)
#define PIN_OUTPUT (0x03)
#define PIN_RISING (0x01)
#define PIN_FALLING (0x02)
typedef void (*gpioIrqFn)(void);
gpioIrqFn gpio_funcs[4] = { NULL, NULL, NULL, NULL};
uint32_t frequency = 0;
/*
* Get the the timer frequency in Hz.
*/
int alarm_internal_frequency(uint32_t* frequency) {
syscall_return_t rval = command(0x0, 1, 0, 0);
return tock_command_return_u32_to_returncode(rval, frequency);
}
int alarm_internal_read(uint32_t* time) {
syscall_return_t rval = command(0x0, 2, 0, 0);
return tock_command_return_u32_to_returncode(rval, time);
}
static void lora_phy_gpio_Callback (int gpioPin,
__attribute__ ((unused)) int arg2,
__attribute__ ((unused)) int arg3,
void* userdata)
{
gpioIrqFn fn = gpio_funcs[gpioPin - 1];
if (fn != NULL ) {
fn();
}
}
class TockHal : public RadioLibHal {
public:
// default constructor - initializes the base HAL and any needed private members
TockHal()
: RadioLibHal(PIN_INPUT, PIN_OUTPUT, PIN_LOW, PIN_HIGH, PIN_RISING, PIN_FALLING) {
}
void init() override {
}
void term() override {
}
// GPIO-related methods (pinMode, digitalWrite etc.) should check
// RADIOLIB_NC as an alias for non-connected pins
void pinMode(uint32_t pin, uint32_t mode) override {
if(pin == RADIOLIB_NC) {
return;
}
if (mode == PIN_OUTPUT) {
libtock_lora_phy_gpio_enable_output(pin);
} else if (mode == PIN_INPUT) {
libtock_lora_phy_gpio_enable_input(pin, libtock_pull_down);
}
}
void digitalWrite(uint32_t pin, uint32_t value) override {
if(pin == RADIOLIB_NC) {
return;
}
if (value) {
libtock_lora_phy_gpio_set(pin);
} else {
libtock_lora_phy_gpio_clear(pin);
}
}
uint32_t digitalRead(uint32_t pin) override {
int value;
if(pin == RADIOLIB_NC) {
return 0;
}
libtock_lora_phy_gpio_read(pin, &value);
return value;
}
void attachInterrupt(uint32_t interruptNum, gpioIrqFn interruptCb, uint32_t mode) override {
if(interruptNum == RADIOLIB_NC) {
return;
}
gpio_funcs[interruptNum - 1] = interruptCb;
libtock_lora_phy_gpio_command_interrupt_callback(lora_phy_gpio_Callback, NULL);
// set GPIO as input and enable interrupts on it
libtock_lora_phy_gpio_enable_input(interruptNum, libtock_pull_down);
libtock_lora_phy_gpio_enable_interrupt(interruptNum, libtock_change);
}
void detachInterrupt(uint32_t interruptNum) override {
if(interruptNum == RADIOLIB_NC) {
return;
}
gpio_funcs[interruptNum - 1] = NULL;
libtock_lora_phy_gpio_disable_interrupt(interruptNum);
}
void delay(unsigned long ms) override {
#if !defined(RADIOLIB_CLOCK_DRIFT_MS)
libtocksync_alarm_delay_ms(ms);
#else
libtocksync_alarm_delay_ms(ms * 1000 / (1000 + RADIOLIB_CLOCK_DRIFT_MS));
#endif
}
void delayMicroseconds(unsigned long us) override {
#if !defined(RADIOLIB_CLOCK_DRIFT_MS)
libtocksync_alarm_delay_ms(us / 1000);
#else
libtocksync_alarm_delay_ms((us * 1000 / (1000 + RADIOLIB_CLOCK_DRIFT_MS)) / 1000);
#endif
}
unsigned long millis() override {
uint32_t now;
unsigned long ms;
if (frequency == 0) {
alarm_internal_frequency(&frequency);
}
alarm_internal_read(&now);
ms = now / (frequency / 1000);
#if !defined(RADIOLIB_CLOCK_DRIFT_MS)
return ms;
#else
return ms * 1000 / (1000 + RADIOLIB_CLOCK_DRIFT_MS);
#endif
}
unsigned long micros() override {
return millis() / 1000;
}
long pulseIn(uint32_t pin, uint32_t state, unsigned long timeout) override {
return 0;
}
void spiBegin() {
}
void spiBeginTransaction() {
}
void spiTransfer(uint8_t* out, size_t len, uint8_t* in) {
libtocksync_lora_phy_read_write(out, in, len);
}
void spiEndTransaction() {
}
void spiEnd() {
}
void yield() {
::yield_no_wait();
}
private:
};
#endif

View file

@ -28,14 +28,14 @@
#include <RadioLib.h> #include <RadioLib.h>
// include the hardware abstraction layer // include the hardware abstraction layer
#include "RadioLib/libtockHal.h" #include "libtockHal.h"
// the entry point for the program // the entry point for the program
int main(void) { int main(void) {
printf("[SX1261] Initialising Radio ... \r\n"); printf("[SX1261] Initialising Radio ... \r\n");
// create a new instance of the HAL class // create a new instance of the HAL class
TockRadioLibHal* hal = new TockRadioLibHal(); TockHal* hal = new TockHal();
// now we can create the radio module // now we can create the radio module
// pinout corresponds to the SparkFun LoRa Thing Plus - expLoRaBLE // pinout corresponds to the SparkFun LoRa Thing Plus - expLoRaBLE
@ -43,7 +43,7 @@ int main(void) {
// DIO1 pin: 2 // DIO1 pin: 2
// NRST pin: 4 // NRST pin: 4
// BUSY pin: 1 // BUSY pin: 1
Module* tock_module = new Module(hal, RADIOLIB_RADIO_NSS, RADIOLIB_RADIO_DIO_1, RADIOLIB_RADIO_RESET, RADIOLIB_RADIO_BUSY); Module* tock_module = new Module(hal, RADIO_NSS, RADIO_DIO_1, RADIO_RESET, RADIO_BUSY);
SX1262* radio = new SX1262(tock_module); SX1262* radio = new SX1262(tock_module);
// Setup the radio // Setup the radio

View file

@ -45,13 +45,9 @@ const int pin = 5;
// create Pager client instance using the FSK module // create Pager client instance using the FSK module
PagerClient pager(&radio); PagerClient pager(&radio);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -31,13 +31,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create Pager client instance using the FSK module // create Pager client instance using the FSK module
PagerClient pager(&radio); PagerClient pager(&radio);

View file

@ -23,14 +23,6 @@
// extra GPIO/interrupt pin: 3 (unused on some modules) // extra GPIO/interrupt pin: 3 (unused on some modules)
RADIO_TYPE radio = new Module(10, 2, 9, 3); RADIO_TYPE radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// get pointer to the common layer // get pointer to the common layer
PhysicalLayer* phy = (PhysicalLayer*)&radio; PhysicalLayer* phy = (PhysicalLayer*)&radio;

View file

@ -21,13 +21,9 @@
// RESET pin: 3 // RESET pin: 3
RF69 radio = new Module(10, 2, 3); RF69 radio = new Module(10, 2, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //RF69 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -23,13 +23,9 @@
// RESET pin: 3 // RESET pin: 3
RF69 radio = new Module(10, 2, 3); RF69 radio = new Module(10, 2, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //RF69 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -30,13 +30,9 @@
// RESET pin: 3 // RESET pin: 3
RF69 radio = new Module(10, 2, 3); RF69 radio = new Module(10, 2, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //RF69 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -21,28 +21,9 @@
// RESET pin: 3 // RESET pin: 3
RF69 radio = new Module(10, 2, 3); RF69 radio = new Module(10, 2, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //RF69 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// flag to indicate that a packet was received
volatile bool receivedFlag = false;
// 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) {
// we got a packet, set the flag
receivedFlag = true;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -83,6 +64,21 @@ void setup() {
// radio.readData(); // radio.readData();
} }
// flag to indicate that a packet was received
volatile bool receivedFlag = false;
// 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) {
// we got a packet, set the flag
receivedFlag = true;
}
void loop() { void loop() {
// check if the flag is set // check if the flag is set
if(receivedFlag) { if(receivedFlag) {

View file

@ -33,13 +33,9 @@ RF69 radio1 = new Module(10, 2, 3);
// RESET pin: 5 // RESET pin: 5
RF69 radio2 = new Module(9, 4, 5); RF69 radio2 = new Module(9, 4, 5);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //RF69 radio3 = RadioShield.ModuleB;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio3 = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -21,13 +21,9 @@
// RESET pin: 3 // RESET pin: 3
RF69 radio = new Module(10, 2, 3); RF69 radio = new Module(10, 2, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //RF69 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -23,13 +23,9 @@
// RESET pin: 3 // RESET pin: 3
RF69 radio = new Module(10, 2, 3); RF69 radio = new Module(10, 2, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //RF69 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -27,13 +27,9 @@
// RESET pin: 3 // RESET pin: 3
RF69 radio = new Module(10, 2, 3); RF69 radio = new Module(10, 2, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //RF69 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -24,32 +24,13 @@
// RESET pin: 3 // RESET pin: 3
RF69 radio = new Module(10, 2, 3); RF69 radio = new Module(10, 2, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //RF69 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// save transmission state between loops // save transmission state between loops
int transmissionState = RADIOLIB_ERR_NONE; int transmissionState = RADIOLIB_ERR_NONE;
// flag to indicate that a packet was sent
volatile bool transmittedFlag = false;
// 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) {
// we sent a packet, set the flag
transmittedFlag = true;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -100,6 +81,21 @@ void setup() {
*/ */
} }
// flag to indicate that a packet was sent
volatile bool transmittedFlag = false;
// 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) {
// we sent a packet, set the flag
transmittedFlag = true;
}
// counter to keep track of transmitted packets // counter to keep track of transmitted packets
int count = 0; int count = 0;

View file

@ -32,13 +32,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create RTTY client instance using the FSK module // create RTTY client instance using the FSK module
RTTYClient rtty(&radio); RTTYClient rtty(&radio);

View file

@ -29,13 +29,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create AFSK client instance using the FSK module // create AFSK client instance using the FSK module
// this requires connection to the module direct // this requires connection to the module direct

View file

@ -42,13 +42,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create SSTV client instance using the FSK module // create SSTV client instance using the FSK module
SSTVClient sstv(&radio); SSTVClient sstv(&radio);

View file

@ -38,13 +38,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// create AFSK client instance using the FSK module // create AFSK client instance using the FSK module
// this requires connection to the module direct // this requires connection to the module direct

View file

@ -33,18 +33,6 @@ static const Module::RfSwitchMode_t rfswitch_table[] = {
END_OF_MODE_TABLE, END_OF_MODE_TABLE,
}; };
// flag to indicate that a packet was detected or CAD timed out
volatile bool scanFlag = false;
// 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!
void setFlag(void) {
// something happened, set the flag
scanFlag = true;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -78,6 +66,18 @@ void setup() {
} }
} }
// flag to indicate that a packet was detected or CAD timed out
volatile bool scanFlag = false;
// 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!
void setFlag(void) {
// something happened, set the flag
scanFlag = true;
}
void loop() { void loop() {
// check if the flag is set // check if the flag is set
if(scanFlag) { if(scanFlag) {

View file

@ -43,18 +43,6 @@ static const Module::RfSwitchMode_t rfswitch_table[] = {
END_OF_MODE_TABLE, END_OF_MODE_TABLE,
}; };
// flag to indicate that a packet was received
volatile bool receivedFlag = false;
// 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!
void setFlag(void) {
// we got a packet, set the flag
receivedFlag = true;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -109,6 +97,18 @@ void setup() {
// radio.scanChannel(); // radio.scanChannel();
} }
// flag to indicate that a packet was received
volatile bool receivedFlag = false;
// 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!
void setFlag(void) {
// we got a packet, set the flag
receivedFlag = true;
}
void loop() { void loop() {
// check if the flag is set // check if the flag is set
if(receivedFlag) { if(receivedFlag) {
@ -154,5 +154,8 @@ void loop() {
Serial.println(state); Serial.println(state);
} }
// put module back to listen mode
radio.startReceive();
} }
} }

View file

@ -38,18 +38,6 @@ static const Module::RfSwitchMode_t rfswitch_table[] = {
// save transmission state between loops // save transmission state between loops
int transmissionState = RADIOLIB_ERR_NONE; int transmissionState = RADIOLIB_ERR_NONE;
// flag to indicate that a packet was sent
volatile bool transmittedFlag = false;
// 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!
void setFlag(void) {
// we sent a packet, set the flag
transmittedFlag = true;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -97,6 +85,18 @@ void setup() {
*/ */
} }
// flag to indicate that a packet was sent
volatile bool transmittedFlag = false;
// 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!
void setFlag(void) {
// we sent a packet, set the flag
transmittedFlag = true;
}
// counter to keep track of transmitted packets // counter to keep track of transmitted packets
int count = 0; int count = 0;

View file

@ -29,13 +29,9 @@
// RESET pin: 3 // RESET pin: 3
SX1231 radio = new Module(10, 2, 3); SX1231 radio = new Module(10, 2, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1231 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -28,13 +28,9 @@
// RESET pin: 3 // RESET pin: 3
SX1231 radio = new Module(10, 2, 3); SX1231 radio = new Module(10, 2, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1231 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -30,13 +30,12 @@
// BUSY pin: 9 // BUSY pin: 9
SX1262 radio = new Module(10, 2, 3, 9); SX1262 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1262 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h> // or using CubeCell
Radio radio = new RadioModule(); //SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -25,28 +25,12 @@
// BUSY pin: 9 // BUSY pin: 9
SX1262 radio = new Module(10, 2, 3, 9); SX1262 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1262 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// flag to indicate that a packet was detected or CAD timed out // or using CubeCell
volatile bool scanFlag = false; //SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
// 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) {
// something happened, set the flag
scanFlag = true;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -77,6 +61,21 @@ void setup() {
} }
} }
// flag to indicate that a packet was detected or CAD timed out
volatile bool scanFlag = false;
// 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) {
// something happened, set the flag
scanFlag = true;
}
void loop() { void loop() {
// check if the flag is set // check if the flag is set
if(scanFlag) { if(scanFlag) {

View file

@ -27,31 +27,12 @@
// BUSY pin: 9 // BUSY pin: 9
SX1262 radio = new Module(10, 2, 3, 9); SX1262 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1262 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// whether we are receiving, or scanning // or using CubeCell
bool receiving = false; //SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
// flag to indicate that a packet was detected or CAD timed out
volatile bool scanFlag = false;
// 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) {
// something happened, set the flag
scanFlag = true;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -82,6 +63,23 @@ void setup() {
} }
} }
// flag to indicate that a packet was detected or CAD timed out
volatile bool scanFlag = false;
bool receiving = false;
// 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) {
// something happened, set the flag
scanFlag = true;
}
void loop() { void loop() {
// check if the flag is set // check if the flag is set
if(scanFlag) { if(scanFlag) {

View file

@ -26,13 +26,12 @@
// BUSY pin: 9 // BUSY pin: 9
SX1262 radio = new Module(10, 2, 3, 9); SX1262 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1262 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h> // or using CubeCell
Radio radio = new RadioModule(); //SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -126,4 +125,33 @@ void loop() {
Serial.println(F("[SX1262] Failed to receive packet, code ")); Serial.println(F("[SX1262] Failed to receive packet, code "));
Serial.println(state); Serial.println(state);
} }
// FSK modem has built-in address filtering system
// it can be enabled by setting node address, broadcast
// address, or both
//
// to transmit packet to a particular address,
// use the following methods:
//
// radio.transmit("Hello World!", address);
// radio.startTransmit("Hello World!", address);
// set node address to 0x02
state = radio.setNodeAddress(0x02);
// set broadcast address to 0xFF
state = radio.setBroadcastAddress(0xFF);
if (state != RADIOLIB_ERR_NONE) {
Serial.println(F("[SX1262] Unable to set address filter, code "));
Serial.println(state);
}
// address filtering can also be disabled
// NOTE: calling this method will also erase previously set
// node and broadcast address
/*
state = radio.disableAddressFiltering();
if (state != RADIOLIB_ERR_NONE) {
Serial.println(F("Unable to remove address filter, code "));
}
*/
} }

View file

@ -1,113 +0,0 @@
/*
RadioLib SX126x LR-FHSS Modem Example
This example shows how to use LR-FHSS modem in SX126x chips.
This modem can only transmit data, and is not able to receive.
This example transmits packets using SX1262 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 SX126x family can also be used.
Using blocking transmit is not recommended, as it will lead
to inefficient use of processor time!
Instead, interrupt transmit is recommended.
For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lr-fhss-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
// IRQ pin: 2
// NRST pin: 3
// BUSY pin: 9
SX1262 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() {
Serial.begin(9600);
// initialize SX1262 with default settings
Serial.print(F("[SX1262] Initializing ... "));
int state = radio.beginLRFHSS();
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true) { delay(10); }
}
// some modules have an external RF switch
// controlled via two pins (RX enable, TX enable)
// to enable automatic control of the switch,
// call the following method
// RX enable: 4
// TX enable: 5
/*
radio.setRfSwitchPins(4, 5);
*/
}
// counter to keep track of transmitted packets
int count = 0;
void loop() {
// LR-FHSS modem can only transmit!
Serial.print(F("[SX1262] Transmitting packet ... "));
// you can transmit C-string or Arduino string up to
// 256 characters long
String str = "Hello World! #" + String(count++);
int state = radio.transmit(str);
// you can also transmit byte array up to 256 bytes long
/*
byte byteArr[] = {0x01, 0x23, 0x45, 0x56, 0x78, 0xAB, 0xCD, 0xEF};
int state = radio.transmit(byteArr, 8);
*/
if (state == RADIOLIB_ERR_NONE) {
// the packet was successfully transmitted
Serial.println(F("success!"));
// print measured data rate
Serial.print(F("[SX1262] Datarate:\t"));
Serial.print(radio.getDataRate());
Serial.println(F(" bps"));
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
// the supplied packet was longer than 256 bytes
Serial.println(F("too long!"));
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
// timeout occurred while transmitting packet
Serial.println(F("timeout!"));
} else {
// some other error occurred
Serial.print(F("failed, code "));
Serial.println(state);
}
// wait for a second before transmitting again
delay(1000);
}

View file

@ -1,151 +0,0 @@
/*
RadioLib SX126x LR-FHSS Transmit with Interrupts Example
This example shows how to use LR-FHSS modem in SX126x chips.
This modem can only transmit data, and is not able to receive.
This example transmits packets using SX1262 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 SX126x family can also be used.
For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lr-fhss-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
// IRQ pin: 2
// NRST pin: 3
// BUSY pin: 9
SX1262 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// save transmission state between loops
int transmissionState = RADIOLIB_ERR_NONE;
// flag to indicate that a packet was sent
// or a frequency hop is needed
volatile bool flag = false;
// 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) {
// we sent a packet or need to hop, set the flag
flag = true;
}
void setup() {
Serial.begin(9600);
// initialize SX1262 with default settings
Serial.print(F("[SX1262] Initializing ... "));
int state = radio.beginLRFHSS();
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true) { delay(10); }
}
// set the function that will be called
// when packet transmission is finished
radio.setPacketSentAction(setFlag);
// start transmitting the first packet
Serial.print(F("[SX1262] 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);
*/
}
// counter to keep track of transmitted packets
int count = 0;
void loop() {
// LR-FHSS modem can only transmit!
// check if the previous transmission finished
if(flag) {
// reset flag
flag = false;
// check if this was caused by hopping or transmission finished
if(radio.getIrqFlags() & RADIOLIB_SX126X_IRQ_LR_FHSS_HOP) {
radio.hopLRFHSS();
} else {
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("[SX1262] Sending another packet ... "));
// you can transmit C-string or Arduino string up to
// 256 characters long
String str = "Hello World! #" + String(count++);
transmissionState = radio.startTransmit(str);
// you can also transmit byte array up to 256 bytes long
/*
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
0x89, 0xAB, 0xCD, 0xEF};
transmissionState = radio.startTransmit(byteArr, 8);
*/
}
}
}

View file

@ -1,9 +1,6 @@
/* /*
RadioLib SX126x Ping-Pong Example RadioLib SX126x Ping-Pong Example
This example is intended to run on two SX126x radios,
and send packets between the two.
For default module settings, see the wiki page For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
@ -25,13 +22,12 @@
// BUSY pin: 9 // BUSY pin: 9
SX1262 radio = new Module(10, 2, 3, 9); SX1262 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1262 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h> // or using CubeCell
Radio radio = new RadioModule(); //SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
*/
// save transmission states between loops // save transmission states between loops
int transmissionState = RADIOLIB_ERR_NONE; int transmissionState = RADIOLIB_ERR_NONE;

View file

@ -13,10 +13,10 @@
Other modules from SX126x family can also be used. Other modules from SX126x family can also be used.
Using blocking receive is not recommended, as it will lead Using blocking receive is not recommended, as it will lead
to significant amount of timeouts, inefficient use of processor to significant amount of timeouts, inefficient use of processor
time and can some miss packets! time and can some miss packets!
Instead, interrupt receive is recommended. Instead, interrupt receive is recommended.
For default module settings, see the wiki page For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
@ -35,13 +35,12 @@ Instead, interrupt receive is recommended.
// BUSY pin: 9 // BUSY pin: 9
SX1262 radio = new Module(10, 2, 3, 9); SX1262 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1262 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h> // or using CubeCell
Radio radio = new RadioModule(); //SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -31,28 +31,12 @@
// BUSY pin: 9 // BUSY pin: 9
SX1262 radio = new Module(10, 2, 3, 9); SX1262 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1262 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// flag to indicate that a packet was received // or using CubeCell
volatile bool receivedFlag = false; //SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
// 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) {
// we got a packet, set the flag
receivedFlag = true;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -93,6 +77,21 @@ void setup() {
// radio.scanChannel(); // radio.scanChannel();
} }
// flag to indicate that a packet was received
volatile bool receivedFlag = false;
// 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) {
// we got a packet, set the flag
receivedFlag = true;
}
void loop() { void loop() {
// check if the flag is set // check if the flag is set
if(receivedFlag) { if(receivedFlag) {

View file

@ -41,13 +41,12 @@ SX1262 radio1 = new Module(10, 2, 3, 9);
// BUSY pin: 6 // BUSY pin: 6
SX1268 radio2 = new Module(8, 4, 5, 6); SX1268 radio2 = new Module(8, 4, 5, 6);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1261 radio3 = RadioShield.ModuleB;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h> // or using CubeCell
Radio radio3 = new RadioModule(); //SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -34,14 +34,6 @@
// BUSY pin: 9 // BUSY pin: 9
SX1262 radio = new Module(10, 2, 3, 9); SX1262 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);

View file

@ -34,14 +34,6 @@
// BUSY pin: 9 // BUSY pin: 9
SX1262 radio = new Module(10, 2, 3, 9); SX1262 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// frequency range in MHz to scan // frequency range in MHz to scan
const float freqStart = 431; const float freqStart = 431;
const float freqEnd = 435; const float freqEnd = 435;

View file

@ -30,13 +30,12 @@
// BUSY pin: 9 // BUSY pin: 9
SX1262 radio = new Module(10, 2, 3, 9); SX1262 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1262 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h> // or using CubeCell
Radio radio = new RadioModule(); //SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -27,32 +27,16 @@
// BUSY pin: 9 // BUSY pin: 9
SX1262 radio = new Module(10, 2, 3, 9); SX1262 radio = new Module(10, 2, 3, 9);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1262 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h> // or using CubeCell
Radio radio = new RadioModule(); //SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
*/
// save transmission state between loops // save transmission state between loops
int transmissionState = RADIOLIB_ERR_NONE; int transmissionState = RADIOLIB_ERR_NONE;
// flag to indicate that a packet was sent
volatile bool transmittedFlag = false;
// 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) {
// we sent a packet, set the flag
transmittedFlag = true;
}
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -86,6 +70,21 @@ void setup() {
*/ */
} }
// flag to indicate that a packet was sent
volatile bool transmittedFlag = false;
// 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) {
// we sent a packet, set the flag
transmittedFlag = true;
}
// counter to keep track of transmitted packets // counter to keep track of transmitted packets
int count = 0; int count = 0;

View file

@ -31,13 +31,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -26,43 +26,9 @@
// DIO1 pin: 3 // DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3); SX1278 radio = new Module(10, 2, 9, 3);
// or detect the pinout automatically using RadioBoards // or using RadioShield
// https://github.com/radiolib-org/RadioBoards // https://github.com/jgromes/RadioShield
/* //SX1278 radio = RadioShield.ModuleA;
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// 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;
// 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) {
// 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) {
// we got a preamble, set the flag
detectedFlag = true;
}
void setup() { void setup() {
// Serial port speed must be high enough for this example // Serial port speed must be high enough for this example
@ -98,6 +64,36 @@ void setup() {
} }
} }
// 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;
// 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) {
// 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) {
// we got a preamble, set the flag
detectedFlag = true;
}
void loop() { void loop() {
// check if we need to restart channel activity detection // check if we need to restart channel activity detection
if(detectedFlag || timeoutFlag) { if(detectedFlag || timeoutFlag) {

Some files were not shown because too many files have changed in this diff Show more