Add RadioLib
parent
e7d5efc700
commit
290838bd1d
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**IMPORTANT: Check the wiki**
|
||||
Before submitting new issue, please check the [Wiki](https://github.com/jgromes/RadioLib/wiki) and the [API documentation](https://jgromes.github.io/RadioLib/). You might find a solution to your issue there.
|
||||
|
||||
**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).
|
||||
|
||||
**To Reproduce**
|
||||
Minimal Arduino sketch to reproduce the behavior. Please user Markdown to style the code to make it readable (see [Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code)).
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional info (please complete):**
|
||||
- MCU: [e.g. Arduino Uno, ESP8266 etc.]
|
||||
- Link to Arduino core: [e.g. https://github.com/stm32duino/Arduino_Core_STM32 when using official STM32 core. See readme for links to all supported cores]
|
||||
- Wireless module type [e.g. CC1101, SX1268, etc.]
|
||||
- Arduino IDE version [e.g. 1.8.5]
|
||||
- Library version [e.g. 3.0.0]
|
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**IMPORTANT: Check the wiki**
|
||||
Before submitting new issue, please check the [Wiki](https://github.com/jgromes/RadioLib/wiki) 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.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
name: Module not working
|
||||
about: Template to use when your module isn't working
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**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.
|
||||
2. RadioLib has a [Wiki](https://github.com/jgromes/RadioLib/wiki) 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).
|
||||
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).
|
||||
|
||||
**Sketch that is causing the module fail**
|
||||
|
||||
```c++
|
||||
paste the sketch here, even if it is an unmodified example code
|
||||
```
|
||||
|
||||
**Hardware setup**
|
||||
Wiring diagram, schematic, pictures etc.
|
||||
|
||||
**Debug mode output**
|
||||
Enable all [debug levels](https://github.com/jgromes/RadioLib/wiki/Debug-mode) and paste the Serial monitor output here.
|
||||
|
||||
**Additional info (please complete):**
|
||||
- MCU: [e.g. Arduino Uno, ESP8266 etc.]
|
||||
- Link to Arduino core: [e.g. https://github.com/stm32duino/Arduino_Core_STM32 when using official STM32 core. See readme for links to all supported cores]
|
||||
- Wireless module type [e.g. CC1101, SX1268, etc.]
|
||||
- Arduino IDE version [e.g. 1.8.5]
|
||||
- Library version [e.g. 3.0.0]
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
name: Regular issue
|
||||
about: Use this template for any other issue
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**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.
|
||||
2. RadioLib has a [Wiki](https://github.com/jgromes/RadioLib/wiki) 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).
|
||||
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).
|
|
@ -0,0 +1,66 @@
|
|||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: ['cpp']
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
fetch-depth: 2
|
||||
|
||||
# If this run was triggered by a pull request event, then checkout
|
||||
# the head of the pull request instead of the merge commit.
|
||||
- run: git checkout HEAD^2
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
|
||||
- name: Install arduino-cli
|
||||
run:
|
||||
|
|
||||
mkdir -p ~/.local/bin
|
||||
echo "~/.local/bin" >> $GITHUB_PATH
|
||||
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh
|
||||
|
||||
- name: Install platform
|
||||
run:
|
||||
|
|
||||
arduino-cli core update-index
|
||||
arduino-cli core install arduino:avr
|
||||
|
||||
- name: Static link
|
||||
run:
|
||||
|
|
||||
# static link fix from https://github.com/github/securitylab/discussions/171
|
||||
for i in ~/.arduino*/packages/arduino/tools/avr-gcc/*/bin/*; do
|
||||
mv "$i" "$i.real";
|
||||
printf '#!/bin/bash\nexec "'"$i"'.real" ${1+"$@"}\n' > "$i";
|
||||
chmod +x "$i";
|
||||
done
|
||||
|
||||
- name: Build example
|
||||
run:
|
||||
arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn arduino:avr:uno $PWD/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino --warnings=all
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
|
@ -0,0 +1,26 @@
|
|||
name: Doxygen
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
doxygen:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install Doxygen
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y doxygen
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Generate docs
|
||||
run: doxygen Doxyfile
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
uses: JamesIves/github-pages-deploy-action@releases/v3
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
BRANCH: gh-pages
|
||||
FOLDER: docs/html
|
|
@ -0,0 +1,178 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
board:
|
||||
- arduino:avr:uno
|
||||
- arduino:avr:mega
|
||||
- arduino:avr:leonardo
|
||||
- arduino:mbed:nano33ble
|
||||
- arduino:mbed:envie_m4
|
||||
- arduino:megaavr:uno2018
|
||||
- arduino:sam:arduino_due_x
|
||||
- arduino:samd:arduino_zero_native
|
||||
- adafruit:samd:adafruit_feather_m0
|
||||
- adafruit:nrf52:feather52832
|
||||
- esp32:esp32:esp32
|
||||
- esp8266:esp8266:generic
|
||||
- Intel:arc32:arduino_101
|
||||
- SparkFun:apollo3:sfe_artemis
|
||||
- STMicroelectronics:stm32:GenF3
|
||||
- stm32duino:STM32F1:mapleMini
|
||||
- MegaCoreX:megaavr:4809
|
||||
- arduino:mbed_rp2040:pico
|
||||
- CubeCell:CubeCell:CubeCell-Board
|
||||
- MegaCore:avr:1281
|
||||
- teensy:avr:teensy41
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
name: ${{ matrix.board }}
|
||||
env:
|
||||
run-build: ${{ (matrix.board == '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.board)) }}
|
||||
|
||||
steps:
|
||||
- name: Install arduino-cli
|
||||
if: ${{ env.run-build == 'true' }}
|
||||
run:
|
||||
|
|
||||
mkdir -p ~/.local/bin
|
||||
echo "~/.local/bin" >> $GITHUB_PATH
|
||||
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh
|
||||
|
||||
- name: Get platform name
|
||||
if: ${{ env.run-build == 'true' }}
|
||||
uses: jungwinter/split@v1
|
||||
id: split
|
||||
with:
|
||||
msg: ${{ matrix.board }}
|
||||
seperator: ':'
|
||||
|
||||
- name: Prepare platform-specific settings
|
||||
if: ${{ env.run-build == 'true' }}
|
||||
id: prep
|
||||
run:
|
||||
|
|
||||
# common settings - no extra options, skip nothing, all warnings
|
||||
echo "::set-output name=options::"
|
||||
echo "::set-output name=skip-pattern::''"
|
||||
echo "::set-output name=warnings::'all'"
|
||||
|
||||
# platform-dependent settings - extra board options, board index URLs, skip patterns etc.
|
||||
if [[ "${{ contains(matrix.board, 'arduino:avr:mega') }}" == "true" ]]; then
|
||||
# Arduino Mega
|
||||
echo "::set-output name=options:::cpu=atmega2560"
|
||||
|
||||
elif [[ "${{ contains(matrix.board, 'arduino:mbed') }}" == "true" ]]; then
|
||||
# Arduino Nano 33 BLE
|
||||
echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino"
|
||||
|
||||
elif [[ "${{ contains(matrix.board, 'arduino-beta:mbed') }}" == "true" ]]; then
|
||||
# Arduino Portenta H7
|
||||
echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino"
|
||||
|
||||
elif [[ "${{ contains(matrix.board, 'arduino:megaavr:uno2018') }}" == "true" ]]; then
|
||||
# Arduino Uno WiFi
|
||||
echo "::set-output name=options:::mode=on"
|
||||
|
||||
elif [[ "${{ contains(matrix.board, 'adafruit:samd') }}" == "true" ]]; then
|
||||
# Adafruit SAMD
|
||||
echo "::set-output name=options:::usbstack=arduino,debug=off"
|
||||
echo "::set-output name=index-url::--additional-urls https://adafruit.github.io/arduino-board-index/package_adafruit_index.json"
|
||||
|
||||
elif [[ "${{ contains(matrix.board, 'adafruit:nrf52') }}" == "true" ]]; then
|
||||
# Adafruit Feather nRF52
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3 python3-pip python3-setuptools
|
||||
pip3 install wheel
|
||||
pip3 install --user adafruit-nrfutil
|
||||
echo "/home/runner/.local/bin" >> $GITHUB_PATH
|
||||
echo "::set-output name=options:::softdevice=s132v6,debug=l0"
|
||||
echo "::set-output name=index-url::--additional-urls https://adafruit.github.io/arduino-board-index/package_adafruit_index.json"
|
||||
|
||||
elif [[ "${{ contains(matrix.board, 'esp32:esp32') }}" == "true" ]]; then
|
||||
# ESP32
|
||||
python -m pip install pyserial
|
||||
echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json"
|
||||
|
||||
elif [[ "${{ contains(matrix.board, 'esp8266:esp8266') }}" == "true" ]]; then
|
||||
# ESP8266
|
||||
echo "::set-output name=options:::xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K"
|
||||
echo "::set-output name=index-url::--additional-urls http://arduino.esp8266.com/stable/package_esp8266com_index.json"
|
||||
echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino"
|
||||
|
||||
elif [[ "${{ contains(matrix.board, 'SparkFun:apollo3') }}" == "true" ]]; then
|
||||
# SparkFun Apollo
|
||||
echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/sparkfun/Arduino_Apollo3/master/package_sparkfun_apollo3_index.json"
|
||||
echo "::set-output name=warnings::'none'"
|
||||
echo "::set-output name=skip-pattern::(HTTP|MQTT).*ino"
|
||||
|
||||
elif [[ "${{ contains(matrix.board, 'STMicroelectronics:stm32') }}" == "true" ]]; then
|
||||
# STM32 (official core)
|
||||
echo "::set-output name=options:::pnum=BLACKPILL_F303CC"
|
||||
echo "::set-output name=index-url::--additional-urls https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/main/package_stmicroelectronics_index.json"
|
||||
|
||||
elif [[ "${{ contains(matrix.board, 'stm32duino:STM32F1') }}" == "true" ]]; then
|
||||
# STM32 (unofficial core)
|
||||
echo "::set-output name=options:::bootloader_version=original,cpu_speed=speed_72mhz"
|
||||
echo "::set-output name=index-url::--additional-urls http://dan.drown.org/stm32duino/package_STM32duino_index.json"
|
||||
|
||||
elif [[ "${{ contains(matrix.board, 'MegaCoreX:megaavr') }}" == "true" ]]; then
|
||||
# MegaCoreX
|
||||
echo "::set-output name=index-url::--additional-urls https://mcudude.github.io/MegaCoreX/package_MCUdude_MegaCoreX_index.json"
|
||||
|
||||
elif [[ "${{ contains(matrix.board, 'CubeCell:CubeCell') }}" == "true" ]]; then
|
||||
# CubeCell
|
||||
echo "::set-output name=index-url::--additional-urls https://resource.heltec.cn/download/package_CubeCell_index.json"
|
||||
|
||||
elif [[ "${{ contains(matrix.board, 'MegaCore:avr') }}" == "true" ]]; then
|
||||
# MegaCore
|
||||
echo "::set-output name=index-url::--additional-urls https://mcudude.github.io/MegaCore/package_MCUdude_MegaCore_index.json"
|
||||
|
||||
elif [[ "${{ contains(matrix.board, 'teensy:avr') }}" == "true" ]]; then
|
||||
# Teensy
|
||||
echo "::set-output name=index-url::--additional-urls https://www.pjrc.com/teensy/td_156/package_teensy_index.json"
|
||||
|
||||
fi
|
||||
|
||||
- name: Install platform
|
||||
if: ${{ env.run-build == 'true' }}
|
||||
run:
|
||||
|
|
||||
arduino-cli core update-index ${{ format('{0}', steps.prep.outputs.index-url) }}
|
||||
arduino-cli core install ${{ format('{0}:{1} {2}', steps.split.outputs._0, steps.split.outputs._1, steps.prep.outputs.index-url) }}
|
||||
|
||||
- name: Checkout repository
|
||||
if: ${{ env.run-build == 'true' }}
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Build examples
|
||||
if: ${{ env.run-build == 'true' }}
|
||||
run:
|
||||
|
|
||||
for example in $(find $PWD/examples -name '*.ino' | sort); do
|
||||
# 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
|
||||
# build sketch
|
||||
echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m";
|
||||
arduino-cli compile --libraries /home/runner/work/RadioLib --fqbn ${{ matrix.board }}${{ steps.prep.outputs.options }} $example --warnings=${{ steps.prep.outputs.warnings }}
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n";
|
||||
exit 1;
|
||||
else
|
||||
echo -e "\033[1;32m${example##*/} build PASSED\033[0m\n";
|
||||
fi
|
||||
fi
|
||||
done
|
|
@ -0,0 +1,16 @@
|
|||
# Arduino Library Development file
|
||||
.development
|
||||
|
||||
# Atom
|
||||
*.tags
|
||||
*.tags1
|
||||
|
||||
# Jetbrain IDEs
|
||||
.idea
|
||||
|
||||
# Debug decoder
|
||||
extras/decoder/log.txt
|
||||
extras/decoder/out.txt
|
||||
|
||||
# PlatformIO
|
||||
.pio*
|
|
@ -0,0 +1,3 @@
|
|||
# Code of Conduct
|
||||
|
||||
Don't be an a*shole.
|
|
@ -0,0 +1,110 @@
|
|||
# Contributing to RadioLib
|
||||
|
||||
First of all, thank you very much for taking the time to contribute! All feedback and ideas are greatly appreciated.
|
||||
To keep this library organized, please follow these rules.
|
||||
|
||||
## Issues
|
||||
|
||||
The following rules guide submission of new issues. These rules are in place mainly so that the issue author can get help as quickly as possible.
|
||||
|
||||
1. **Questions are welcome, spam is not.**
|
||||
Any issues without description will be considered spam and as such will be **CLOSED** and **LOCKED** immediately!
|
||||
2. **This repository has issue templates.**
|
||||
To report bugs or suggest new features, use the provided issue templates. Use the default issue only if the templates do not fit your issue type.
|
||||
3. **Be as clear as possible when creating issues.**
|
||||
Issues with generic titles (e.g. "not working", "lora", etc.) will be **CLOSED** until the title is fixed, since the title is supposed to categorize the issue. The same applies for issues with very little information and extensive grammatical or formatting errors that make it difficult to find out what is the actual issue.
|
||||
4. **Issues deserve some attention too.**
|
||||
Issues that are left for 2 weeks without response by the original author when asked for further information will be closed due to inactivity. This is to keep track of important issues, the author is encouraged to reopen the issue at a later date.
|
||||
|
||||
## Code style guidelines
|
||||
|
||||
I like pretty code! Or at least, I like *consistent* code style. When creating pull requests, please follow these style guidelines, they're in place to keep high code readability.
|
||||
|
||||
1. **Bracket style**
|
||||
This library uses the following style of bracket indentation (1TBS, or "javascript" style):
|
||||
|
||||
```c++
|
||||
if (foo) {
|
||||
bar();
|
||||
} else {
|
||||
baz();
|
||||
}
|
||||
```
|
||||
|
||||
2. **Tabs**
|
||||
Use 2 space characters for tabs.
|
||||
|
||||
3. **Single-line comments**
|
||||
Comments can be very useful - and they can become the bane of readability. Every single-line comment should start at new line, have one space between comment delimiter `//` and the start of the comment itself. The comment should also start with a lower-case letter.
|
||||
|
||||
```c++
|
||||
// this function does something
|
||||
foo("bar");
|
||||
|
||||
// here it does something else
|
||||
foo(12345);
|
||||
```
|
||||
|
||||
4. **Split code into blocks**
|
||||
It is very easy to write code that machine can read. It is much harder to write one that humans can read. That's why it's a great idea to split code into blocks - even if the block is just a single line!
|
||||
|
||||
```c++
|
||||
// build a temporary buffer (first block)
|
||||
uint8_t* data = new uint8_t[len + 1];
|
||||
if(!data) {
|
||||
return(RADIOLIB_ERR_MEMORY_ALLOCATION_FAILED);
|
||||
}
|
||||
|
||||
// read the received data (second block)
|
||||
state = readData(data, len);
|
||||
|
||||
// add null terminator (third block)
|
||||
data[len] = 0;
|
||||
```
|
||||
|
||||
5. **Doxygen**
|
||||
If you're adding a new method, make sure to add appropriate Doxygen comments, so that the documentation is always complete.
|
||||
|
||||
6. **Keywords**
|
||||
This is an Arduino library, so it needs to comply with the Arduino library specification. To add a new keyword to the Arduino IDE syntax highlighting, add it to the keywords.txt file. **Use true tabs in keywords.txt! No spaces there!**
|
||||
|
||||
7. **Dynamic memory**
|
||||
Sometimes, RadioLib might be used in critical applications where dynamic memory allocation using `new` or `malloc` might cause issues. For such cases, RadioLib provides the option to compile using only static arrays. This means that every dynamically allocated array must have a sufficiently large static counterpart. Naturally, all dynamically allocated memory must be properly de-allocated using `delete` or `free`.
|
||||
|
||||
```c++
|
||||
// build a temporary buffer
|
||||
#if defined(RADIOLIB_STATIC_ONLY)
|
||||
uint8_t data[RADIOLIB_STATIC_ARRAY_SIZE + 1];
|
||||
#else
|
||||
uint8_t* data = new uint8_t[length + 1];
|
||||
if(!data) {
|
||||
return(RADIOLIB_ERR_MEMORY_ALLOCATION_FAILED);
|
||||
}
|
||||
#endif
|
||||
|
||||
// read the received data
|
||||
readData(data, length);
|
||||
|
||||
// deallocate temporary buffer
|
||||
#if !defined(RADIOLIB_STATIC_ONLY)
|
||||
delete[] data;
|
||||
#endif
|
||||
```
|
||||
|
||||
8. **God Mode**
|
||||
During development, it can be useful to have access to the low level drivers, such as the SPI commands. These are incredibly powerful, since they will basically let user do anything he wants with the module, outside of the normal level of sanity checks. As such, they are normally protected using C++ access modifiers `private` or `protected`. God mode disables this protection, and so any newly implemented `class` must contain the appropriate macro check:
|
||||
|
||||
```c++
|
||||
class Module {
|
||||
void publicMethod();
|
||||
|
||||
#if defined(RADIOLIB_GODMODE)
|
||||
private:
|
||||
#endif
|
||||
|
||||
void privateMethod();
|
||||
};
|
||||
```
|
||||
|
||||
9. **No Arduino Strings**
|
||||
Arduino `String` class should never be used internally in the library. The only allowed occurence of Arduino `String` is in public API methods, and only at the top-most layer.
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,99 @@
|
|||
# RadioLib ![Build Status](https://github.com/jgromes/RadioLib/workflows/CI/badge.svg)
|
||||
|
||||
### _One radio library to rule them all!_
|
||||
|
||||
## Universal wireless communication library for embedded devices
|
||||
|
||||
## See the [Wiki](https://github.com/jgromes/RadioLib/wiki) for further information. See the [GitHub Pages](https://jgromes.github.io/RadioLib) for detailed and up-to-date API reference.
|
||||
|
||||
RadioLib allows its users to integrate all sorts of different wireless communication modules, protocols and even digital modes into a single consistent system.
|
||||
Want to add a Bluetooth interface to your LoRa network? Sure thing! Do you just want to go really old-school and play around with radio teletype, slow-scan TV, or even Hellschreiber using nothing but a cheap radio module? Why not!
|
||||
|
||||
RadioLib was originally created as a driver for [__RadioShield__](https://github.com/jgromes/RadioShield), but it can be used to control as many different wireless modules as you like - or at least as many as your microcontroller can handle!
|
||||
|
||||
### Supported modules:
|
||||
* __CC1101__ FSK radio module
|
||||
* __LLCC68__ LoRa module
|
||||
* __nRF24L01__ 2.4 GHz module
|
||||
* __RF69__ FSK/OOK radio module
|
||||
* __RFM2x__ series FSK modules (RFM22, RM23)
|
||||
* __RFM9x__ series LoRa modules (RFM95, RM96, RFM97, RFM98)
|
||||
* __Si443x__ series FSK modules (Si4430, Si4431, Si4432)
|
||||
* __SX126x__ series LoRa modules (SX1261, SX1262, SX1268)
|
||||
* __SX127x__ series LoRa modules (SX1272, SX1273, SX1276, SX1277, SX1278, SX1279)
|
||||
* __SX128x__ series LoRa/GFSK/BLE/FLRC modules (SX1280, SX1281, SX1282)
|
||||
* __SX1231__ FSK/OOK radio module
|
||||
|
||||
### Supported protocols and digital modes:
|
||||
* [__AX.25__](https://www.sigidwiki.com/wiki/PACKET) using 2-FSK or AFSK for modules:
|
||||
SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, RFM2x and Si443x
|
||||
* [__RTTY__](https://www.sigidwiki.com/wiki/RTTY) using 2-FSK or AFSK for modules:
|
||||
SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x
|
||||
* [__Morse Code__](https://www.sigidwiki.com/wiki/Morse_Code_(CW)) using 2-FSK or AFSK for modules:
|
||||
SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x
|
||||
* [__SSTV__](https://www.sigidwiki.com/wiki/SSTV) using 2-FSK or AFSK for modules:
|
||||
SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, RFM2x and Si443x
|
||||
* [__Hellschreiber__](https://www.sigidwiki.com/wiki/Hellschreiber) using 2-FSK or AFSK for modules:
|
||||
SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x
|
||||
* [__APRS__](https://www.sigidwiki.com/wiki/APRS) using AFSK for modules:
|
||||
SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x
|
||||
* [__POCSAG__](https://www.sigidwiki.com/wiki/POCSAG) using 2-FSK for modules:
|
||||
SX127x, RFM9x, RF69, SX1231, CC1101, nRF24L01, RFM2x and Si443x
|
||||
|
||||
### Supported Arduino platforms:
|
||||
* __Arduino__
|
||||
* [__AVR__](https://github.com/arduino/ArduinoCore-avr) - Arduino Uno, Mega, Leonardo, Pro Mini, Nano etc.
|
||||
* [__mbed__](https://github.com/arduino/ArduinoCore-mbed) - Arduino Nano 33 BLE and Arduino Portenta H7
|
||||
* [__megaAVR__](https://github.com/arduino/ArduinoCore-megaavr) - Arduino Uno WiFi Rev.2 and Nano Every
|
||||
* [__SAM__](https://github.com/arduino/ArduinoCore-sam) - Arduino Due
|
||||
* [__SAMD__](https://github.com/arduino/ArduinoCore-samd) - Arduino Zero, MKR boards, M0 Pro etc.
|
||||
|
||||
* __Adafruit__
|
||||
* [__SAMD__](https://github.com/adafruit/ArduinoCore-samd) - Adafruit Feather M0 and M4 boards (Feather, Metro, Gemma, Trinket etc.)
|
||||
* [__nRF52__](https://github.com/adafruit/Adafruit_nRF52_Arduino) - Adafruit Feather nRF528x, Bluefruit and CLUE
|
||||
|
||||
* __Espressif__
|
||||
* [__ESP32__](https://github.com/espressif/arduino-esp32) - ESP32-based boards
|
||||
* [__ESP8266__](https://github.com/esp8266/Arduino) - ESP8266-based boards
|
||||
|
||||
* __Intel__
|
||||
* [__Curie__](https://github.com/arduino/ArduinoCore-arc32) - Arduino 101
|
||||
|
||||
* __SparkFun__
|
||||
* [__Apollo3__](https://github.com/sparkfun/Arduino_Apollo3) - Sparkfun Artemis Redboard
|
||||
|
||||
* __ST Microelectronics__
|
||||
* [__STM32__ (official core)](https://github.com/stm32duino/Arduino_Core_STM32) - STM32 Nucleo, Discovery, Maple, BluePill, BlackPill etc.
|
||||
* [__STM32__ (unofficial core)](https://github.com/rogerclarkmelbourne/Arduino_STM32) - STM32F1 and STM32F4-based boards
|
||||
|
||||
* __MCUdude__
|
||||
* [__MegaCoreX__](https://github.com/MCUdude/MegaCoreX) - megaAVR-0 series (ATmega4809, ATmega3209 etc.)
|
||||
* [__MegaCore__](https://github.com/MCUdude/MegaCore) - AVR (ATmega1281, ATmega640 etc.)
|
||||
|
||||
* __Raspberry Pi__
|
||||
* [__RP2040__](https://github.com/arduino/ArduinoCore-mbed) - Raspberry Pi Pico and Arduino Nano RP2040 Connect
|
||||
* [__Raspberry Pi__](https://github.com/me-no-dev/RasPiArduino) - Arduino framework for RaspberryPI
|
||||
|
||||
* __Heltec__
|
||||
* [__CubeCell__](https://github.com/HelTecAutomation/CubeCell-Arduino) - ASR650X series (CubeCell-Board, CubeCell-Capsule, CubeCell-Module etc.)
|
||||
|
||||
* __PJRC__
|
||||
* [__Teensy__](https://github.com/PaulStoffregen/cores) - Teensy 2.x, 3.x and 4.x boards
|
||||
|
||||
The list above is by no means exhaustive - RadioLib code is independent of the used platform! Compilation of all examples is tested for all platforms officially supported prior to releasing new version.
|
||||
|
||||
### In development:
|
||||
* __AX5243__ FSK module
|
||||
* __LoRaWAN__ protocol for SX127x, RFM9x and SX126x modules
|
||||
* ___and more!___
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
### Where should I start?
|
||||
First of all, take a look at the [examples](https://github.com/jgromes/RadioLib/tree/master/examples) and the [Wiki](https://github.com/jgromes/RadioLib/wiki) - especially the [Basics](https://github.com/jgromes/RadioLib/wiki/Basics) page. There's a lot of useful information over there. If something isn't working as expected, try searching the [issues](https://github.com/jgromes/RadioLib/issues/).
|
||||
|
||||
### Help, my module isn't working!
|
||||
The fastest way to get help is by creating an [issue](https://github.com/jgromes/RadioLib/issues/new/choose) using the appropriate template. It is also highly recommended to try running the examples first - their functionality is tested from time to time and they should work. Finally, RadioLib is still under development, which means that sometimes, backwards-incompatible changes might be introduced. Though these are kept at minimum, sometimes it is unavoidable. You can check the [release changelog](https://github.com/jgromes/RadioLib/releases) to find out if there's been such a major change recently.
|
||||
|
||||
### RadioLib doesn't support my module! What should I do?
|
||||
Start by creating new issue (if it doesn't exist yet). If you have some experience with microcontrollers and C/C++ in general, you can try to add the support yourself! Use the template files in `/extras/` folder to get started. This is by far the fastest way to implement new modules into RadioLib, since I can't be working on everything all the time. If you don't trust your programming skills enough to have a go at it yourself, don't worry. I will try to implement all requested modules, but it will take me a while.
|
|
@ -0,0 +1,5 @@
|
|||
# Security Policy
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
RadioLib is provided as-is without any warranty, and is not intended to be used in security-critical applications. However, if you discover a vulnerability within the library code, please report it to gromes.jan@gmail.com.
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
RadioLib AFSK Imperial March Example
|
||||
|
||||
This example shows how to EXECUTE ORDER 66
|
||||
|
||||
Other modules that can be used for AFSK:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// include the melody
|
||||
#include "melody.h"
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// this requires connection to the module direct
|
||||
// input pin, here connected to Arduino pin 5
|
||||
// SX127x/RFM9x: DIO2
|
||||
// RF69: DIO2
|
||||
// SX1231: DIO2
|
||||
// CC1101: GDO2
|
||||
// Si443x/RFM2x: GPIO
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for AFSK
|
||||
// (RF69, CC1101,, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize AFSK client
|
||||
Serial.print(F("[AFSK] Initializing ... "));
|
||||
state = audio.begin();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[AFSK] Executing Order 66 ... "));
|
||||
|
||||
// calculate whole note duration
|
||||
int wholenote = (60000 * 4) / 120;
|
||||
|
||||
// iterate over the melody
|
||||
for(unsigned int note = 0; note < sizeof(melody) / sizeof(melody[0]); note += 2) {
|
||||
// calculate the duration of each note
|
||||
int noteDuration = 0;
|
||||
int divider = melody[note + 1];
|
||||
if(divider > 0) {
|
||||
// regular note, just proceed
|
||||
noteDuration = wholenote / divider;
|
||||
} else if(divider < 0) {
|
||||
// dotted notes are represented with negative durations!!
|
||||
noteDuration = wholenote / abs(divider);
|
||||
noteDuration *= 1.5; // increases the duration in half for dotted notes
|
||||
}
|
||||
|
||||
// we only play the note for 90% of the duration, leaving 10% as a pause
|
||||
audio.tone(melody[note]);
|
||||
delay(noteDuration*0.9);
|
||||
audio.noTone();
|
||||
delay(noteDuration*0.1);
|
||||
}
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
Note definitions, melody and melody-related functions
|
||||
adapted from https://github.com/robsoncouto/arduino-songs
|
||||
by Robson Couto, 2019
|
||||
*/
|
||||
|
||||
#define NOTE_B0 31
|
||||
#define NOTE_C1 33
|
||||
#define NOTE_CS1 35
|
||||
#define NOTE_D1 37
|
||||
#define NOTE_DS1 39
|
||||
#define NOTE_E1 41
|
||||
#define NOTE_F1 44
|
||||
#define NOTE_FS1 46
|
||||
#define NOTE_G1 49
|
||||
#define NOTE_GS1 52
|
||||
#define NOTE_A1 55
|
||||
#define NOTE_AS1 58
|
||||
#define NOTE_B1 62
|
||||
#define NOTE_C2 65
|
||||
#define NOTE_CS2 69
|
||||
#define NOTE_D2 73
|
||||
#define NOTE_DS2 78
|
||||
#define NOTE_E2 82
|
||||
#define NOTE_F2 87
|
||||
#define NOTE_FS2 93
|
||||
#define NOTE_G2 98
|
||||
#define NOTE_GS2 104
|
||||
#define NOTE_A2 110
|
||||
#define NOTE_AS2 117
|
||||
#define NOTE_B2 123
|
||||
#define NOTE_C3 131
|
||||
#define NOTE_CS3 139
|
||||
#define NOTE_D3 147
|
||||
#define NOTE_DS3 156
|
||||
#define NOTE_E3 165
|
||||
#define NOTE_F3 175
|
||||
#define NOTE_FS3 185
|
||||
#define NOTE_G3 196
|
||||
#define NOTE_GS3 208
|
||||
#define NOTE_A3 220
|
||||
#define NOTE_AS3 233
|
||||
#define NOTE_B3 247
|
||||
#define NOTE_C4 262
|
||||
#define NOTE_CS4 277
|
||||
#define NOTE_D4 294
|
||||
#define NOTE_DS4 311
|
||||
#define NOTE_E4 330
|
||||
#define NOTE_F4 349
|
||||
#define NOTE_FS4 370
|
||||
#define NOTE_G4 392
|
||||
#define NOTE_GS4 415
|
||||
#define NOTE_A4 440
|
||||
#define NOTE_AS4 466
|
||||
#define NOTE_B4 494
|
||||
#define NOTE_C5 523
|
||||
#define NOTE_CS5 554
|
||||
#define NOTE_D5 587
|
||||
#define NOTE_DS5 622
|
||||
#define NOTE_E5 659
|
||||
#define NOTE_F5 698
|
||||
#define NOTE_FS5 740
|
||||
#define NOTE_G5 784
|
||||
#define NOTE_GS5 831
|
||||
#define NOTE_A5 880
|
||||
#define NOTE_AS5 932
|
||||
#define NOTE_B5 988
|
||||
#define NOTE_C6 1047
|
||||
#define NOTE_CS6 1109
|
||||
#define NOTE_D6 1175
|
||||
#define NOTE_DS6 1245
|
||||
#define NOTE_E6 1319
|
||||
#define NOTE_F6 1397
|
||||
#define NOTE_FS6 1480
|
||||
#define NOTE_G6 1568
|
||||
#define NOTE_GS6 1661
|
||||
#define NOTE_A6 1760
|
||||
#define NOTE_AS6 1865
|
||||
#define NOTE_B6 1976
|
||||
#define NOTE_C7 2093
|
||||
#define NOTE_CS7 2217
|
||||
#define NOTE_D7 2349
|
||||
#define NOTE_DS7 2489
|
||||
#define NOTE_E7 2637
|
||||
#define NOTE_F7 2794
|
||||
#define NOTE_FS7 2960
|
||||
#define NOTE_G7 3136
|
||||
#define NOTE_GS7 3322
|
||||
#define NOTE_A7 3520
|
||||
#define NOTE_AS7 3729
|
||||
#define NOTE_B7 3951
|
||||
#define NOTE_C8 4186
|
||||
#define NOTE_CS8 4435
|
||||
#define NOTE_D8 4699
|
||||
#define NOTE_DS8 4978
|
||||
#define REST 0
|
||||
|
||||
// notes of the moledy followed by the duration.
|
||||
// a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on
|
||||
// !!negative numbers are used to represent dotted notes,
|
||||
// so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!!
|
||||
int melody[] = {
|
||||
|
||||
// Darth Vader theme (Imperial March) - Star wars
|
||||
// Score available at https://musescore.com/user/202909/scores/1141521
|
||||
// The tenor saxophone part was used
|
||||
|
||||
NOTE_A4,-4, NOTE_A4,-4, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_F4,8, REST,8,
|
||||
NOTE_A4,-4, NOTE_A4,-4, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_A4,16, NOTE_F4,8, REST,8,
|
||||
NOTE_A4,4, NOTE_A4,4, NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16,
|
||||
|
||||
NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16, NOTE_A4,2,//4
|
||||
NOTE_E5,4, NOTE_E5,4, NOTE_E5,4, NOTE_F5,-8, NOTE_C5,16,
|
||||
NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16, NOTE_A4,2,
|
||||
|
||||
NOTE_A5,4, NOTE_A4,-8, NOTE_A4,16, NOTE_A5,4, NOTE_GS5,-8, NOTE_G5,16, //7
|
||||
NOTE_DS5,16, NOTE_D5,16, NOTE_DS5,8, REST,8, NOTE_A4,8, NOTE_DS5,4, NOTE_D5,-8, NOTE_CS5,16,
|
||||
|
||||
NOTE_C5,16, NOTE_B4,16, NOTE_C5,16, REST,8, NOTE_F4,8, NOTE_GS4,4, NOTE_F4,-8, NOTE_A4,-16,//9
|
||||
NOTE_C5,4, NOTE_A4,-8, NOTE_C5,16, NOTE_E5,2,
|
||||
|
||||
NOTE_A5,4, NOTE_A4,-8, NOTE_A4,16, NOTE_A5,4, NOTE_GS5,-8, NOTE_G5,16, //7
|
||||
NOTE_DS5,16, NOTE_D5,16, NOTE_DS5,8, REST,8, NOTE_A4,8, NOTE_DS5,4, NOTE_D5,-8, NOTE_CS5,16,
|
||||
|
||||
NOTE_C5,16, NOTE_B4,16, NOTE_C5,16, REST,8, NOTE_F4,8, NOTE_GS4,4, NOTE_F4,-8, NOTE_A4,-16,//9
|
||||
NOTE_A4,4, NOTE_F4,-8, NOTE_C5,16, NOTE_A4,2,
|
||||
|
||||
};
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
RadioLib AFSK Example
|
||||
|
||||
This example shows hot to send audio FSK tones
|
||||
using SX1278's FSK modem.
|
||||
|
||||
Other modules that can be used for AFSK:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// this requires connection to the module direct
|
||||
// input pin, here connected to Arduino pin 5
|
||||
// SX127x/RFM9x: DIO2
|
||||
// RF69: DIO2
|
||||
// SX1231: DIO2
|
||||
// CC1101: GDO2
|
||||
// Si443x/RFM2x: GPIO
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for AFSK
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize AFSK client
|
||||
Serial.print(F("[AFSK] Initializing ... "));
|
||||
state = audio.begin();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// AFSKClient can be used to transmit tones,
|
||||
// same as Arduino tone() function
|
||||
|
||||
// 400 Hz tone
|
||||
Serial.print(F("[AFSK] 400 Hz tone ... "));
|
||||
audio.tone(400);
|
||||
delay(1000);
|
||||
|
||||
// silence
|
||||
Serial.println(F("done!"));
|
||||
audio.noTone();
|
||||
delay(1000);
|
||||
|
||||
// AFSKClient can also be used to transmit HAM-friendly
|
||||
// RTTY, Morse code, Hellschreiber, SSTV and AX.25.
|
||||
// Details on how to use AFSK are in the example
|
||||
// folders for each of the above modes.
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
RadioLib AM-modulated AFSK Example
|
||||
|
||||
This example shows hot to send AM-modulated
|
||||
audio FSK tones using SX1278's OOK modem.
|
||||
|
||||
Other modules that can be used for AFSK:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
SX1278 radio = new Module(10, 2, 9);
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// this requires connection to the module direct
|
||||
// input pin, here connected to Arduino pin 5
|
||||
// SX127x/RFM9x: DIO2
|
||||
// RF69: DIO2
|
||||
// SX1231: DIO2
|
||||
// CC1101: GDO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for AFSK
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize AFSK client
|
||||
Serial.print(F("[AFSK] Initializing ... "));
|
||||
state = audio.begin();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// after that, set mode to OOK
|
||||
Serial.print(F("[SX1278] Switching to OOK ... "));
|
||||
state = radio.setOOK(true);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// AFSKClient can be used to transmit tones,
|
||||
// same as Arduino tone() function
|
||||
|
||||
// 400 Hz tone
|
||||
Serial.print(F("[AFSK] 400 Hz tone ... "));
|
||||
audio.tone(400);
|
||||
delay(1000);
|
||||
|
||||
// silence
|
||||
Serial.println(F("done!"));
|
||||
audio.noTone();
|
||||
delay(1000);
|
||||
|
||||
// AFSKClient can also be used to transmit HAM-friendly
|
||||
// RTTY, Morse code, Hellschreiber, SSTV and AX.25.
|
||||
// Details on how to use AFSK are in the example
|
||||
// folders for each of the above modes.
|
||||
|
||||
// CAUTION: Unlike standard AFSK, the result when using OOK
|
||||
// must be demodulated as AM!
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
RadioLib APRS Mic-E Example
|
||||
|
||||
This example sends APRS position reports
|
||||
encoded in the Mic-E format using SX1278's
|
||||
FSK modem. The data is modulated as AFSK
|
||||
at 1200 baud using Bell 202 tones.
|
||||
|
||||
DO NOT transmit in APRS bands unless
|
||||
you have a ham radio license!
|
||||
|
||||
Other modules that can be used for APRS:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- nRF24
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
// create AX.25 client instance using the AFSK instance
|
||||
AX25Client ax25(&audio);
|
||||
|
||||
// create APRS client isntance using the AX.25 client
|
||||
APRSClient aprs(&ax25);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278
|
||||
// NOTE: moved to ISM band on purpose
|
||||
// DO NOT transmit in APRS bands without ham radio license!
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for AX.25
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize AX.25 client
|
||||
Serial.print(F("[AX.25] Initializing ... "));
|
||||
// source station callsign: "N7LEM"
|
||||
// source station SSID: 0
|
||||
// preamble length: 8 bytes
|
||||
state = ax25.begin("N7LEM");
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize APRS client
|
||||
Serial.print(F("[APRS] Initializing ... "));
|
||||
// symbol: '>' (car)
|
||||
state = aprs.begin('>');
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[APRS] Sending Mic-E position ... "));
|
||||
int state = aprs.sendMicE(49.1945, 16.6000, 120, 10, RADIOLIB_APRS_MIC_E_TYPE_EN_ROUTE);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// wait one minute before transmitting again
|
||||
delay(60000);
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
RadioLib APRS Position Example
|
||||
|
||||
This example sends APRS position reports
|
||||
using SX1278's FSK modem. The data is
|
||||
modulated as AFSK at 1200 baud using Bell
|
||||
202 tones.
|
||||
|
||||
DO NOT transmit in APRS bands unless
|
||||
you have a ham radio license!
|
||||
|
||||
Other modules that can be used for APRS:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- nRF24
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
// create AX.25 client instance using the AFSK instance
|
||||
AX25Client ax25(&audio);
|
||||
|
||||
// create APRS client isntance using the AX.25 client
|
||||
APRSClient aprs(&ax25);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278
|
||||
// NOTE: moved to ISM band on purpose
|
||||
// DO NOT transmit in APRS bands without ham radio license!
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK(434.0);
|
||||
|
||||
// when using one of the non-LoRa modules for AX.25
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize AX.25 client
|
||||
Serial.print(F("[AX.25] Initializing ... "));
|
||||
// source station callsign: "N7LEM"
|
||||
// source station SSID: 0
|
||||
// preamble length: 8 bytes
|
||||
state = ax25.begin("N7LEM");
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize APRS client
|
||||
Serial.print(F("[APRS] Initializing ... "));
|
||||
// symbol: '>' (car)
|
||||
state = aprs.begin('>');
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[APRS] Sending position ... "));
|
||||
|
||||
// send a location without message or timestamp
|
||||
int state = aprs.sendPosition("N0CALL", 0, "4911.67N", "01635.96E");
|
||||
delay(500);
|
||||
|
||||
// send a location with message and without timestamp
|
||||
state |= aprs.sendPosition("N0CALL", 0, "4911.67N", "01635.96E", "I'm here!");
|
||||
delay(500);
|
||||
|
||||
// send a location with message and timestamp
|
||||
state |= aprs.sendPosition("N0CALL", 0, "4911.67N", "01635.96E", "I'm here!", "093045z");
|
||||
delay(500);
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// wait one minute before transmitting again
|
||||
delay(60000);
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
RadioLib AX.25 Frame Example
|
||||
|
||||
This example shows how to send various
|
||||
AX.25 frames using SX1278's FSK modem.
|
||||
|
||||
Other modules that can be used for AX.25:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- SX126x
|
||||
- nRF24
|
||||
- Si443x/RFM2x
|
||||
|
||||
Using raw AX.25 frames requires some
|
||||
knowledge of the protocol, refer to
|
||||
AX25_Transmit for basic operation.
|
||||
Frames shown in this example are not
|
||||
exhaustive; all possible AX.25 frames
|
||||
should be supported.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AX.25 client instance using the FSK module
|
||||
AX25Client ax25(&radio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 1.2 kbps (1200 baud 2-FSK AX.25)
|
||||
// frequency deviation: 0.5 kHz (1200 baud 2-FSK AX.25)
|
||||
int state = radio.beginFSK(434.0, 1.2, 0.5);
|
||||
|
||||
// when using one of the non-LoRa modules for AX.25
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize AX.25 client
|
||||
Serial.print(F("[AX.25] Initializing ... "));
|
||||
// source station callsign: "N7LEM"
|
||||
// source station SSID: 0
|
||||
// preamble length: 8 bytes
|
||||
state = ax25.begin("N7LEM");
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// create AX.25 Unnumbered Information frame
|
||||
// destination station callsign: "NJ7P"
|
||||
// destination station SSID: 0
|
||||
// source station callsign: "N7LEM"
|
||||
// source station SSID: 0
|
||||
// control field: UI, P/F not used, unnumbered frame
|
||||
// protocol identifier: no layer 3 protocol implemented
|
||||
// information field: "Hello World!"
|
||||
AX25Frame frameUI("NJ7P", 0, "N7LEM", 0, RADIOLIB_AX25_CONTROL_U_UNNUMBERED_INFORMATION |
|
||||
RADIOLIB_AX25_CONTROL_POLL_FINAL_DISABLED | RADIOLIB_AX25_CONTROL_UNNUMBERED_FRAME,
|
||||
RADIOLIB_AX25_PID_NO_LAYER_3, "Hello World (unnumbered)!");
|
||||
|
||||
// send the frame
|
||||
Serial.print(F("[AX.25] Sending UI frame ... "));
|
||||
int state = ax25.sendFrame(&frameUI);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else {
|
||||
// some error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
|
||||
// create AX.25 Receive Ready frame
|
||||
// destination station callsign: "NJ7P"
|
||||
// destination station SSID: 0
|
||||
// source station callsign: "N7LEM"
|
||||
// source station SSID: 0
|
||||
// control field: RR, P/F not used, supervisory frame
|
||||
AX25Frame frameRR("NJ7P", 0, "N7LEM", 0, RADIOLIB_AX25_CONTROL_S_RECEIVE_READY |
|
||||
RADIOLIB_AX25_CONTROL_POLL_FINAL_DISABLED | RADIOLIB_AX25_CONTROL_SUPERVISORY_FRAME);
|
||||
|
||||
// set receive sequence number (0 - 7)
|
||||
frameRR.setRecvSequence(0);
|
||||
|
||||
// send the frame
|
||||
Serial.print(F("[AX.25] Sending RR frame ... "));
|
||||
state = ax25.sendFrame(&frameRR);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else {
|
||||
// some error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
|
||||
// create AX.25 Information frame
|
||||
// destination station callsign: "NJ7P"
|
||||
// destination station SSID: 0
|
||||
// source station callsign: "N7LEM"
|
||||
// source station SSID: 0
|
||||
// control field: P/F not used, information frame
|
||||
// protocol identifier: no layer 3 protocol implemented
|
||||
// information field: "Hello World (numbered)!"
|
||||
AX25Frame frameI("NJ7P", 0, "N7LEM", 0, RADIOLIB_AX25_CONTROL_POLL_FINAL_DISABLED |
|
||||
RADIOLIB_AX25_CONTROL_INFORMATION_FRAME, RADIOLIB_AX25_PID_NO_LAYER_3,
|
||||
"Hello World (numbered)!");
|
||||
|
||||
// set receive sequence number (0 - 7)
|
||||
frameI.setRecvSequence(0);
|
||||
|
||||
// set send sequence number (0 - 7)
|
||||
frameI.setSendSequence(0);
|
||||
|
||||
// send the frame
|
||||
Serial.print(F("[AX.25] Sending I frame ... "));
|
||||
state = ax25.sendFrame(&frameI);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else {
|
||||
// some error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
RadioLib AX.25 Transmit Example
|
||||
|
||||
This example sends AX.25 messages using
|
||||
SX1278's FSK modem.
|
||||
|
||||
Other modules that can be used for AX.25:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- SX126x
|
||||
- nRF24
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AX.25 client instance using the FSK module
|
||||
AX25Client ax25(&radio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 1.2 kbps (1200 baud 2-FSK AX.25)
|
||||
int state = radio.beginFSK(434.0, 1.2);
|
||||
|
||||
// when using one of the non-LoRa modules for AX.25
|
||||
// (RF69, CC1101,, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize AX.25 client
|
||||
Serial.print(F("[AX.25] Initializing ... "));
|
||||
// source station callsign: "N7LEM"
|
||||
// source station SSID: 0
|
||||
// preamble length: 8 bytes
|
||||
state = ax25.begin("N7LEM");
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// send AX.25 unnumbered information frame
|
||||
Serial.print(F("[AX.25] Sending UI frame ... "));
|
||||
// destination station callsign: "NJ7P"
|
||||
// destination station SSID: 0
|
||||
int state = ax25.transmit("Hello World!", "NJ7P");
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else {
|
||||
// some error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
RadioLib AX.25 Transmit AFSK Example
|
||||
|
||||
This example sends AX.25 messages using
|
||||
SX1278's FSK modem. The data is modulated
|
||||
as AFSK at 1200 baud using Bell 202 tones.
|
||||
|
||||
Other modules that can be used for AX.25
|
||||
with AFSK modulation:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- nRF24
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
// create AX.25 client instance using the AFSK instance
|
||||
AX25Client ax25(&audio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for AX.25
|
||||
// (RF69, CC1101,, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize AX.25 client
|
||||
Serial.print(F("[AX.25] Initializing ... "));
|
||||
// source station callsign: "N7LEM"
|
||||
// source station SSID: 0
|
||||
// preamble length: 8 bytes
|
||||
state = ax25.begin("N7LEM");
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// Sometimes, it may be required to adjust audio
|
||||
// frequencies to match the expected 1200/2200 Hz tones.
|
||||
// The following method will offset mark frequency by
|
||||
// 100 Hz up and space frequency by 100 Hz down
|
||||
/*
|
||||
Serial.print(F("[AX.25] Setting correction ... "));
|
||||
state = ax25.setCorrection(100, -100);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// send AX.25 unnumbered information frame
|
||||
Serial.print(F("[AX.25] Sending UI frame ... "));
|
||||
// destination station callsign: "NJ7P"
|
||||
// destination station SSID: 0
|
||||
int state = ax25.transmit("Hello World!", "NJ7P");
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else {
|
||||
// some error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
RadioLib CC1101 Receive Example
|
||||
|
||||
This example receives packets using CC1101 FSK radio module.
|
||||
To successfully receive data, the following settings have to be the same
|
||||
on both transmitter and receiver:
|
||||
- carrier frequency
|
||||
- bit rate
|
||||
- frequency deviation
|
||||
- sync word
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// CC1101 has the following connections:
|
||||
// CS pin: 10
|
||||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//CC1101 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[CC1101] Waiting for incoming transmission ... "));
|
||||
|
||||
// you can receive data as an Arduino String
|
||||
String str;
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
// print the data of the packet
|
||||
Serial.print(F("[CC1101] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
// of the last received packet
|
||||
Serial.print(F("[CC1101] RSSI:\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print LQI (Link Quality Indicator)
|
||||
// of the last received packet, lower is better
|
||||
Serial.print(F("[CC1101] LQI:\t\t"));
|
||||
Serial.println(radio.getLQI());
|
||||
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
RadioLib CC1101 Receive with Address Example
|
||||
|
||||
This example receives packets using CC1101 FSK radio
|
||||
module. Packets can have 1-byte address of the
|
||||
destination node. After setting node address, this node
|
||||
will automatically filter out any packets that do not
|
||||
contain either node address or broadcast addresses.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// CC1101 has the following connections:
|
||||
// CS pin: 10
|
||||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//CC1101 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set node address
|
||||
// NOTE: Calling this method will automatically enable
|
||||
// address filtering. CC1101 also allows to set
|
||||
// number of broadcast address (0/1/2).
|
||||
// The following sets one broadcast address 0x00.
|
||||
// When setting two broadcast addresses, 0x00 and
|
||||
// 0xFF will be used.
|
||||
Serial.print(F("[CC1101] Setting node address ... "));
|
||||
state = radio.setNodeAddress(0x01, 1);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// address filtering can also be disabled
|
||||
// NOTE: Calling this method will also erase previously
|
||||
// set node address
|
||||
/*
|
||||
Serial.print(F("[CC1101] Disabling address filtering ... "));
|
||||
state == radio.disableAddressFiltering();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[CC1101] Waiting for incoming transmission ... "));
|
||||
|
||||
// you can receive data as an Arduino String
|
||||
String str;
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
// print the data of the packet
|
||||
Serial.print(F("[CC1101] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
// of the last received packet
|
||||
Serial.print(F("[CC1101] RSSI:\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print LQI (Link Quality Indicator)
|
||||
// of the last received packet, lower is better
|
||||
Serial.print(F("[CC1101] LQI:\t\t"));
|
||||
Serial.println(radio.getLQI());
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
RadioLib CC1101 Receive with Interrupts Example
|
||||
|
||||
This example listens for FSK transmissions and tries to
|
||||
receive them. Once a packet is received, an interrupt is
|
||||
triggered.
|
||||
|
||||
To successfully receive data, the following settings have to be the same
|
||||
on both transmitter and receiver:
|
||||
- carrier frequency
|
||||
- bit rate
|
||||
- frequency deviation
|
||||
- sync word
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// CC1101 has the following connections:
|
||||
// CS pin: 10
|
||||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//CC1101 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
radio.setGdo0Action(setFlag);
|
||||
|
||||
// start listening for packets
|
||||
Serial.print(F("[CC1101] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
volatile bool receivedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we got a packet, set the flag
|
||||
receivedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the flag is set
|
||||
if(receivedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
receivedFlag = false;
|
||||
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[CC1101] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[CC1101] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
// of the last received packet
|
||||
Serial.print(F("[CC1101] RSSI:\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print LQI (Link Quality Indicator)
|
||||
// of the last received packet, lower is better
|
||||
Serial.print(F("[CC1101] LQI:\t\t"));
|
||||
Serial.println(radio.getLQI());
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// put module back to listen mode
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
RadioLib CC1101 Settings Example
|
||||
|
||||
This example shows how to change all the properties of RF69 radio.
|
||||
RadioLib currently supports the following settings:
|
||||
- pins (SPI slave select, digital IO 0, digital IO 1)
|
||||
- carrier frequency
|
||||
- bit rate
|
||||
- receiver bandwidth
|
||||
- allowed frequency deviation
|
||||
- output power during transmission
|
||||
- sync word
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// CC1101 has the following connections:
|
||||
// CS pin: 10
|
||||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
CC1101 radio1 = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
|
||||
// second CC1101 has different connections:
|
||||
// CS pin: 9
|
||||
// GDO0 pin: 4
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 5 (optional)
|
||||
CC1101 radio2 = new Module(9, 4, RADIOLIB_NC, 53);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//CC1101 radio3 = RadioShield.ModuleB;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
int state = radio1.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// initialize CC1101 with non-default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 32.0 kbps
|
||||
// frequency deviation: 60.0 kHz
|
||||
// Rx bandwidth: 250.0 kHz
|
||||
// output power: 7 dBm
|
||||
// preamble length: 32 bits
|
||||
state = radio2.begin(434.0, 32.0, 60.0, 250.0, 7, 32);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// you can also change the settings at runtime
|
||||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 433.5 MHz
|
||||
if (radio1.setFrequency(433.5) == RADIOLIB_ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("[CC1101] Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bit rate to 100.0 kbps
|
||||
state = radio1.setBitRate(100.0);
|
||||
if (state == RADIOLIB_ERR_INVALID_BIT_RATE) {
|
||||
Serial.println(F("[CC1101] Selected bit rate is invalid for this module!"));
|
||||
while (true);
|
||||
} else if (state == RADIOLIB_ERR_INVALID_BIT_RATE_BW_RATIO) {
|
||||
Serial.println(F("[CC1101] Selected bit rate to bandwidth ratio is invalid!"));
|
||||
Serial.println(F("[CC1101] Increase receiver bandwidth to set this bit rate."));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set receiver bandwidth to 250.0 kHz
|
||||
if (radio1.setRxBandwidth(250.0) == RADIOLIB_ERR_INVALID_RX_BANDWIDTH) {
|
||||
Serial.println(F("[CC1101] Selected receiver bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set allowed frequency deviation to 10.0 kHz
|
||||
if (radio1.setFrequencyDeviation(10.0) == RADIOLIB_ERR_INVALID_FREQUENCY_DEVIATION) {
|
||||
Serial.println(F("[CC1101] Selected frequency deviation is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set output power to 5 dBm
|
||||
if (radio1.setOutputPower(5) == RADIOLIB_ERR_INVALID_OUTPUT_POWER) {
|
||||
Serial.println(F("[CC1101] Selected output power is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// 2 bytes can be set as sync word
|
||||
if (radio1.setSyncWord(0x01, 0x23) == RADIOLIB_ERR_INVALID_SYNC_WORD) {
|
||||
Serial.println(F("[CC1101] Selected sync word is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// nothing here
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
RadioLib CC1101 Transmit Example
|
||||
|
||||
This example transmits packets using CC1101 FSK radio module.
|
||||
Each packet contains up to 64 bytes of data, in the form of:
|
||||
- Arduino String
|
||||
- null-terminated char array (C-string)
|
||||
- arbitrary binary data (byte array)
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// CC1101 has the following connections:
|
||||
// CS pin: 10
|
||||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//CC1101 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[CC1101] Transmitting packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to 63 characters long
|
||||
int state = radio.transmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 63 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 64 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
RadioLib CC1101 Transmit to Address Example
|
||||
|
||||
This example transmits packets using CC1101 FSK radio
|
||||
module. Packets can have 1-byte address of the
|
||||
destination node. After setting node address, this node
|
||||
will automatically filter out any packets that do not
|
||||
contain either node address or broadcast addresses.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// CC1101 has the following connections:
|
||||
// CS pin: 10
|
||||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//CC1101 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set node address
|
||||
// NOTE: Calling this method will automatically enable
|
||||
// address filtering. CC1101 also allows to set
|
||||
// number of broadcast address (0/1/2).
|
||||
// The following sets one broadcast address 0x00.
|
||||
// When setting two broadcast addresses, 0x00 and
|
||||
// 0xFF will be used.
|
||||
Serial.print(F("[CC1101] Setting node address ... "));
|
||||
state = radio.setNodeAddress(0x01, 1);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// address filtering can also be disabled
|
||||
// NOTE: Calling this method will also erase previously
|
||||
// set node address
|
||||
/*
|
||||
Serial.print(F("[CC1101] Disabling address filtering ... "));
|
||||
state == radio.disableAddressFiltering();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[CC1101] Transmitting packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to 63 characters long
|
||||
int state = radio.transmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 63 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 255 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
RadioLib CC1101 Transmit with Interrupts Example
|
||||
|
||||
This example transmits packets using CC1101 FSK radio module.
|
||||
Once a packet is transmitted, an interrupt is triggered.
|
||||
Each packet contains up to 64 bytes of data, in the form of:
|
||||
- Arduino String
|
||||
- null-terminated char array (C-string)
|
||||
- arbitrary binary data (byte array)
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// CC1101 has the following connections:
|
||||
// CS pin: 10
|
||||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//CC1101 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
radio.setGdo0Action(setFlag);
|
||||
|
||||
// start transmitting the first packet
|
||||
Serial.print(F("[CC1101] Sending first packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 64 characters long
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 64 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x56,
|
||||
0x78, 0xAB, 0xCD, 0xEF};
|
||||
state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was sent
|
||||
volatile bool transmittedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we sent a packet, set the flag
|
||||
transmittedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the previous transmission finished
|
||||
if(transmittedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
// NOTE: when using interrupt-driven transmit method,
|
||||
// it is not possible to automatically measure
|
||||
// transmission data rate using getDataRate()
|
||||
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(transmissionState);
|
||||
|
||||
}
|
||||
|
||||
// clean up after transmission is finished
|
||||
// this will ensure transmitter is disabled,
|
||||
// RF switch is powered down etc.
|
||||
radio.finishTransmit();
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
// send another one
|
||||
Serial.print(F("[CC1101] Sending another packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 256 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
// we're ready to send more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
RadioLib FSK4 Transmit Example
|
||||
|
||||
This example sends an example FSK-4 'Horus Binary' message
|
||||
using SX1278's FSK modem.
|
||||
|
||||
This signal can be demodulated using a SSB demodulator (SDR or otherwise),
|
||||
and horusdemodlib: https://github.com/projecthorus/horusdemodlib/wiki
|
||||
|
||||
Other modules that can be used for FSK4:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- SX126x
|
||||
- nRF24
|
||||
- Si443x/RFM2x
|
||||
- SX128x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create FSK4 client instance using the FSK module
|
||||
FSK4Client fsk4(&radio);
|
||||
|
||||
// An encoded Horus Binary telemetry packet.
|
||||
// Refer here for packet format information:
|
||||
// https://github.com/projecthorus/horusdemodlib/wiki/2---Modem-Details#horus-binary-v1-mode-4-fsk
|
||||
// After demodulation, deinterleaving, and descrambling, this results in a packet:
|
||||
// 00000001172D0000000000000000D20463010AFF2780
|
||||
// This decodes to the Habitat-compatible telemetry string:
|
||||
// $$4FSKTEST,0,01:23:45,0.00000,0.00000,1234,99,1,10,5.00*ABCD
|
||||
int horusPacketLen = 45;
|
||||
byte horusPacket[] = {
|
||||
0x45, 0x24, 0x24, 0x48, 0x2F, 0x12, 0x16, 0x08, 0x15, 0xC1,
|
||||
0x49, 0xB2, 0x06, 0xFC, 0x92, 0xEB, 0x93, 0xD7, 0xEE, 0x5D,
|
||||
0x35, 0xA0, 0x91, 0xDA, 0x8D, 0x5F, 0x85, 0x6B, 0x63, 0x03,
|
||||
0x6B, 0x60, 0xEA, 0xFE, 0x55, 0x9D, 0xF1, 0xAB, 0xE5, 0x5E,
|
||||
0xDB, 0x7C, 0xDB, 0x21, 0x5A, 0x19
|
||||
};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for FSK4
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize FSK4 client
|
||||
// NOTE: FSK4 frequency shift will be rounded
|
||||
// to the nearest multiple of frequency step size.
|
||||
// The exact value depends on the module:
|
||||
// SX127x/RFM9x - 61 Hz
|
||||
// RF69 - 61 Hz
|
||||
// CC1101 - 397 Hz
|
||||
// SX126x - 1 Hz
|
||||
// nRF24 - 1000000 Hz
|
||||
// Si443x/RFM2x - 156 Hz
|
||||
// SX128x - 198 Hz
|
||||
Serial.print(F("[FSK4] Initializing ... "));
|
||||
// low ("space") frequency: 434.0 MHz
|
||||
// frequency shift: 270 Hz
|
||||
// baud rate: 100 baud
|
||||
state = fsk4.begin(434.0, 270, 100);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[FSK4] Sending FSK4 data packet ... "));
|
||||
|
||||
// send out idle condition for 1000 ms
|
||||
fsk4.idle();
|
||||
delay(1000);
|
||||
|
||||
// FSK4Client supports binary write methods
|
||||
|
||||
// send some bytes as a preamble
|
||||
for(int i = 0; i < 8; i++) {
|
||||
fsk4.write(0x1B);
|
||||
}
|
||||
|
||||
// now send the encoded packet
|
||||
fsk4.write(horusPacket, horusPacketLen);
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
RadioLib FSK4 Transmit AFSK Example
|
||||
|
||||
This example sends an example FSK-4 'Horus Binary' message
|
||||
using SX1278's FSK modem. The data is modulated as AFSK.
|
||||
|
||||
This signal can be demodulated using an FM demodulator (SDR or otherwise),
|
||||
and horusdemodlib: https://github.com/projecthorus/horusdemodlib/wiki
|
||||
|
||||
Other modules that can be used for FSK4:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
// create FSK4 client instance using the AFSK instance
|
||||
FSK4Client fsk4(&audio);
|
||||
|
||||
// An encoded Horus Binary telemetry packet.
|
||||
// Refer here for packet format information:
|
||||
// https://github.com/projecthorus/horusdemodlib/wiki/2---Modem-Details#horus-binary-v1-mode-4-fsk
|
||||
// After demodulation, deinterleaving, and descrambling, this results in a packet:
|
||||
// 00000001172D0000000000000000D20463010AFF2780
|
||||
// This decodes to the Habitat-compatible telemetry string:
|
||||
// $$4FSKTEST,0,01:23:45,0.00000,0.00000,1234,99,1,10,5.00*ABCD
|
||||
int horusPacketLen = 45;
|
||||
byte horusPacket[] = {
|
||||
0x45, 0x24, 0x24, 0x48, 0x2F, 0x12, 0x16, 0x08, 0x15, 0xC1,
|
||||
0x49, 0xB2, 0x06, 0xFC, 0x92, 0xEB, 0x93, 0xD7, 0xEE, 0x5D,
|
||||
0x35, 0xA0, 0x91, 0xDA, 0x8D, 0x5F, 0x85, 0x6B, 0x63, 0x03,
|
||||
0x6B, 0x60, 0xEA, 0xFE, 0x55, 0x9D, 0xF1, 0xAB, 0xE5, 0x5E,
|
||||
0xDB, 0x7C, 0xDB, 0x21, 0x5A, 0x19
|
||||
};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for RTTY
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize FSK4 client
|
||||
// NOTE: Unlike FSK FSK4, AFSK requires no rounding of
|
||||
// the frequency shift.
|
||||
Serial.print(F("[FSK4] Initializing ... "));
|
||||
// low ("space") frequency: 434.0 MHz
|
||||
// frequency shift: 270 Hz
|
||||
// baud rate: 100 baud
|
||||
state = fsk4.begin(400, 270, 100);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[FSK4] Sending FSK4 data packet ... "));
|
||||
|
||||
// send out idle condition for 500 ms
|
||||
fsk4.idle();
|
||||
delay(1000);
|
||||
|
||||
// FSK4Client supports binary write methods
|
||||
|
||||
// send some bytes as a preamble
|
||||
for(int i = 0; i < 8; i++) {
|
||||
fsk4.write(0x1B);
|
||||
}
|
||||
|
||||
// now send the encoded packet
|
||||
fsk4.write(horusPacket, horusPacketLen);
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
RadioLib Hellschreiber Transmit Example
|
||||
|
||||
This example sends Hellschreiber message using
|
||||
SX1278's FSK modem.
|
||||
|
||||
Other modules that can be used for Hellschreiber:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- SX126x
|
||||
- nRF24
|
||||
- Si443x/RFM2x
|
||||
- SX128x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create Hellschreiber client instance using the FSK module
|
||||
HellClient hell(&radio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for Morse code
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize Hellschreiber client
|
||||
Serial.print(F("[Hell] Initializing ... "));
|
||||
// base frequency: 434.0 MHz
|
||||
// speed: 122.5 Baud ("Feld Hell")
|
||||
state = hell.begin(434.0);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[Hell] Sending Hellschreiber data ... "));
|
||||
|
||||
// HellClient supports all methods of the Serial class
|
||||
// NOTE: Lower case letter will be capitalized.
|
||||
|
||||
// Arduino String class
|
||||
String aStr = "Arduino String";
|
||||
hell.print(aStr);
|
||||
|
||||
// character array (C-String)
|
||||
hell.print("C-String");
|
||||
|
||||
// string saved in flash
|
||||
hell.print(F("Flash String"));
|
||||
|
||||
// character
|
||||
hell.print('c');
|
||||
|
||||
// byte
|
||||
// formatting DEC/HEX/OCT/BIN is supported for
|
||||
// any integer type (byte/int/long)
|
||||
hell.print(255, HEX);
|
||||
|
||||
// integer number
|
||||
int i = 1000;
|
||||
hell.print(i);
|
||||
|
||||
// floating point number
|
||||
// NOTE: println() has no effect on the transmission,
|
||||
// and is only kept for compatibility reasons.
|
||||
float f = -3.1415;
|
||||
hell.println(f, 3);
|
||||
|
||||
// custom glyph - must be a 7 byte array of rows 7 pixels long
|
||||
uint8_t customGlyph[] = { 0b0000000, 0b0010100, 0b0010100, 0b0000000, 0b0100010, 0b0011100, 0b0000000 };
|
||||
hell.printGlyph(customGlyph);
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
RadioLib Hellschreiber Transmit AFSK Example
|
||||
|
||||
This example sends Hellschreiber message using
|
||||
SX1278's FSK modem. The data is modulated
|
||||
as AFSK.
|
||||
|
||||
Other modules that can be used for Hellschreiber
|
||||
with AFSK modulation:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
// create Hellschreiber client instance using the AFSK instance
|
||||
HellClient hell(&audio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for Morse code
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize Hellschreiber client
|
||||
Serial.print(F("[Hell] Initializing ... "));
|
||||
// AFSK tone frequency: 400 Hz
|
||||
// speed: 122.5 Baud ("Feld Hell")
|
||||
state = hell.begin(400);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[Hell] Sending Hellschreiber data ... "));
|
||||
|
||||
// HellClient supports all methods of the Serial class
|
||||
// NOTE: Lower case letter will be capitalized.
|
||||
|
||||
// Arduino String class
|
||||
String aStr = "Arduino String";
|
||||
hell.print(aStr);
|
||||
|
||||
// character array (C-String)
|
||||
hell.print("C-String");
|
||||
|
||||
// string saved in flash
|
||||
hell.print(F("Flash String"));
|
||||
|
||||
// in AFSK mode, it is possible to invert the text colors
|
||||
// use white text on black background
|
||||
hell.setInversion(true);
|
||||
hell.print("Inverted String");
|
||||
hell.setInversion(false);
|
||||
|
||||
// character
|
||||
hell.print('c');
|
||||
|
||||
// byte
|
||||
// formatting DEC/HEX/OCT/BIN is supported for
|
||||
// any integer type (byte/int/long)
|
||||
hell.print(255, HEX);
|
||||
|
||||
// integer number
|
||||
int i = 1000;
|
||||
hell.print(i);
|
||||
|
||||
// floating point number
|
||||
// NOTE: println() has no effect on the transmission,
|
||||
// and is only kept for compatibility reasons.
|
||||
float f = -3.1415;
|
||||
hell.println(f, 3);
|
||||
|
||||
// custom glyph - must be a 7 byte array of rows 7 pixels long
|
||||
uint8_t customGlyph[] = { 0b0000000, 0b0010100, 0b0010100, 0b0000000, 0b0100010, 0b0011100, 0b0000000 };
|
||||
hell.printGlyph(customGlyph);
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
RadioLib SX127x Morse Receive AM Example
|
||||
|
||||
This example receives Morse code message using
|
||||
SX1278's FSK modem. The signal is expected to be
|
||||
modulated as OOK, to be demodulated in AM mode.
|
||||
|
||||
Other modules that can be used for Morse Code
|
||||
with AFSK modulation:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
// create Morse client instance using the AFSK instance
|
||||
MorseClient morse(&audio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// when using one of the non-LoRa modules for Morse code
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
// initialize Morse client
|
||||
Serial.print(F("[Morse] Initializing ... "));
|
||||
// AFSK tone frequency: 400 Hz
|
||||
// speed: 20 words per minute
|
||||
state = morse.begin(400);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// after that, set mode to OOK to emulate AM modulation
|
||||
Serial.print(F("[SX1278] Switching to OOK ... "));
|
||||
state = radio.setOOK(true);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// start direct mode reception
|
||||
radio.receiveDirect();
|
||||
}
|
||||
|
||||
// save symbol and length between loops
|
||||
byte symbol = 0;
|
||||
byte len = 0;
|
||||
|
||||
void loop() {
|
||||
// try to read a new symbol
|
||||
int state = morse.read(&symbol, &len);
|
||||
|
||||
// check if we have something to decode
|
||||
if(state != RADIOLIB_MORSE_INTER_SYMBOL) {
|
||||
// decode and print
|
||||
Serial.print(MorseClient::decode(symbol, len));
|
||||
|
||||
// reset the symbol buffer
|
||||
symbol = 0;
|
||||
len = 0;
|
||||
|
||||
// check if we have a complete word
|
||||
if(state == RADIOLIB_MORSE_WORD_COMPLETE) {
|
||||
// inter-word space, interpret that as a new line
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
RadioLib Morse Transmit AM Example
|
||||
|
||||
This example sends Morse code message using
|
||||
SX1278's FSK modem. The signal is modulated
|
||||
as OOK, and may be demodulated in AM mode.
|
||||
|
||||
Other modules that can be used for Morse Code
|
||||
with AM modulation:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
// create Morse client instance using the AFSK instance
|
||||
MorseClient morse(&audio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for Morse code
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize Morse client
|
||||
Serial.print(F("[Morse] Initializing ... "));
|
||||
// tone frequency: 400 Hz
|
||||
// speed: 20 words per minute
|
||||
state = morse.begin(400);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// after that, set mode to OOK to emulate AM modulation
|
||||
Serial.print(F("[SX1278] Switching to OOK ... "));
|
||||
state = radio.setOOK(true);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[Morse] Sending Morse data ... "));
|
||||
|
||||
// MorseClient supports all methods of the Serial class
|
||||
// NOTE: Characters that do not have ITU-R M.1677-1
|
||||
// representation will not be sent! Lower case
|
||||
// letters will be capitalized.
|
||||
|
||||
// send start signal first
|
||||
morse.startSignal();
|
||||
|
||||
// Arduino String class
|
||||
String aStr = "Arduino String";
|
||||
morse.print(aStr);
|
||||
|
||||
// character array (C-String)
|
||||
morse.print("C-String");
|
||||
|
||||
// string saved in flash
|
||||
morse.print(F("Flash String"));
|
||||
|
||||
// character
|
||||
morse.print('c');
|
||||
|
||||
// byte
|
||||
// formatting DEC/HEX/OCT/BIN is supported for
|
||||
// any integer type (byte/int/long)
|
||||
morse.print(255, HEX);
|
||||
|
||||
// integer number
|
||||
int i = 1000;
|
||||
morse.print(i);
|
||||
|
||||
// floating point number
|
||||
// NOTE: When using println(), the transmission will be
|
||||
// terminated with end-of-work signal (...-.-).
|
||||
float f = -3.1415;
|
||||
morse.println(f, 3);
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
RadioLib Morse Transmit AFSK Example
|
||||
|
||||
This example sends Morse code message using
|
||||
SX1278's FSK modem. The signal is modulated
|
||||
as AFSK, and may be demodulated in FM mode.
|
||||
|
||||
Other modules that can be used for Morse Code
|
||||
with AFSK modulation:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(5, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 10);
|
||||
|
||||
// create Morse client instance using the AFSK instance
|
||||
MorseClient morse(&audio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for Morse code
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize Morse client
|
||||
Serial.print(F("[Morse] Initializing ... "));
|
||||
// tone frequency: 400 Hz
|
||||
// speed: 20 words per minute
|
||||
state = morse.begin(400);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// after that, set mode to OOK
|
||||
Serial.print(F("[SX1278] Switching to OOK ... "));
|
||||
state = radio.setOOK(true);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[Morse] Sending Morse data ... "));
|
||||
|
||||
// MorseClient supports all methods of the Serial class
|
||||
// NOTE: Characters that do not have ITU-R M.1677-1
|
||||
// representation will not be sent! Lower case
|
||||
// letters will be capitalized.
|
||||
|
||||
// send start signal first
|
||||
morse.startSignal();
|
||||
|
||||
// Arduino String class
|
||||
String aStr = "Arduino String";
|
||||
morse.print(aStr);
|
||||
|
||||
// character array (C-String)
|
||||
morse.print("C-String");
|
||||
|
||||
// string saved in flash
|
||||
morse.print(F("Flash String"));
|
||||
|
||||
// character
|
||||
morse.print('c');
|
||||
|
||||
// byte
|
||||
// formatting DEC/HEX/OCT/BIN is supported for
|
||||
// any integer type (byte/int/long)
|
||||
morse.print(255, HEX);
|
||||
|
||||
// integer number
|
||||
int i = 1000;
|
||||
morse.print(i);
|
||||
|
||||
// floating point number
|
||||
// NOTE: When using println(), the transmission will be
|
||||
// terminated with end-of-work signal (...-.-).
|
||||
float f = -3.1415;
|
||||
morse.println(f, 3);
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
RadioLib Morse Transmit SSB Example
|
||||
|
||||
This example sends Morse code message using
|
||||
SX1278's FSK modem. The signal is an unmodulated
|
||||
carrier wave, and may be demodulated in SSB mode.
|
||||
|
||||
Other modules that can be used for Morse Code:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- SX126x
|
||||
- nRF24
|
||||
- Si443x/RFM2x
|
||||
- SX128x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create Morse client instance using the FSK module
|
||||
MorseClient morse(&radio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for Morse code
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize Morse client
|
||||
Serial.print(F("[Morse] Initializing ... "));
|
||||
// carrier wave frequency: 434.0 MHz
|
||||
// speed: 20 words per minute
|
||||
state = morse.begin(434.0);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[Morse] Sending Morse data ... "));
|
||||
|
||||
// MorseClient supports all methods of the Serial class
|
||||
// NOTE: Characters that do not have ITU-R M.1677-1
|
||||
// representation will not be sent! Lower case
|
||||
// letters will be capitalized.
|
||||
|
||||
// send start signal first
|
||||
morse.startSignal();
|
||||
|
||||
// Arduino String class
|
||||
String aStr = "Arduino String";
|
||||
morse.print(aStr);
|
||||
|
||||
// character array (C-String)
|
||||
morse.print("C-String");
|
||||
|
||||
// string saved in flash
|
||||
morse.print(F("Flash String"));
|
||||
|
||||
// character
|
||||
morse.print('c');
|
||||
|
||||
// byte
|
||||
// formatting DEC/HEX/OCT/BIN is supported for
|
||||
// any integer type (byte/int/long)
|
||||
morse.print(255, HEX);
|
||||
|
||||
// integer number
|
||||
int i = 1000;
|
||||
morse.print(i);
|
||||
|
||||
// floating point number
|
||||
// NOTE: When using println(), the transmission will be
|
||||
// terminated with end-of-work signal (...-.-).
|
||||
float f = -3.1415;
|
||||
morse.println(f, 3);
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
RadioLib Pager (POCSAG) Receive Example
|
||||
|
||||
This example shows how to receive FSK packets without using
|
||||
SX127x packet engine.
|
||||
|
||||
This example receives POCSAG messages using SX1278's
|
||||
FSK modem in direct mode.
|
||||
|
||||
Other modules that can be used to receive POCSAG:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(5, 2, 9, 3);
|
||||
|
||||
// DIO2 pin: 5
|
||||
const int pin = 4;
|
||||
|
||||
// create Pager client instance using the FSK module
|
||||
PagerClient pager(&radio);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// initalize Pager client
|
||||
Serial.print(F("[Pager] Initializing ... "));
|
||||
// base (center) frequency: 434.0 MHz
|
||||
// speed: 1200 bps
|
||||
state = pager.begin(434.0, 1200);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// start receiving POCSAG messages
|
||||
Serial.print(F("[Pager] Starting to listen ... "));
|
||||
// address of this "pager": 1234567
|
||||
state = pager.startReceive(pin, 1234567);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// the number of batches to wait for
|
||||
// 2 batches will usually be enough to fit short and medium messages
|
||||
if (pager.available() >= 2) {
|
||||
Serial.print(F("[Pager] Received pager data, decoding ... "));
|
||||
|
||||
// you can read the data as an Arduino String
|
||||
String str;
|
||||
int state = pager.readData(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
size_t numBytes = 0;
|
||||
int state = radio.receive(byteArr, &numBytes);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
|
||||
// print the received data
|
||||
Serial.print(F("[Pager] Data:\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else {
|
||||
// some error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
RadioLib Pager (POCSAG) Transmit Example
|
||||
|
||||
This example sends POCSAG messages using SX1278's
|
||||
FSK modem.
|
||||
|
||||
Other modules that can be used to send POCSAG:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- SX126x
|
||||
- nRF24
|
||||
- Si443x/RFM2x
|
||||
- SX128x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(5, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create Pager client instance using the FSK module
|
||||
PagerClient pager(&radio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initalize Pager client
|
||||
Serial.print(F("[Pager] Initializing ... "));
|
||||
// base (center) frequency: 434.0 MHz
|
||||
// speed: 1200 bps
|
||||
state = pager.begin(434.0, 1200);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[Pager] Transmitting messages ... "));
|
||||
|
||||
// the simples form of "message" is just a tone on the destination pager
|
||||
int state = pager.sendTone(1234567);
|
||||
delay(500);
|
||||
|
||||
// next, transmit numeric (BCD) message to the destination pager
|
||||
// NOTE: Only characters 0123456789*U-() and space
|
||||
// can be sent in a BCD message!
|
||||
state |= pager.transmit("0123456789*U -()", 1234567);
|
||||
delay(500);
|
||||
|
||||
// finally, let's transmit an ASCII message now
|
||||
state |= pager.transmit("Hello World!", 1234567, RADIOLIB_PAGER_ASCII);
|
||||
delay(500);
|
||||
|
||||
// we can also send only a tone
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(3000);
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
RadioLib RF69 Receive Example
|
||||
|
||||
This example receives packets using RF69 FSK radio module.
|
||||
To successfully receive data, the following settings have to be the same
|
||||
on both transmitter and receiver:
|
||||
- carrier frequency
|
||||
- bit rate
|
||||
- frequency deviation
|
||||
- sync word
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// RF69 has the following connections:
|
||||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[RF69] Waiting for incoming transmission ... "));
|
||||
|
||||
// you can receive data as an Arduino String
|
||||
String str;
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
// print the data of the packet
|
||||
Serial.print(F("[RF69] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
// of the last received packet
|
||||
Serial.print(F("[RF69] RSSI:\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
RadioLib RF69 Receive with AES Example
|
||||
|
||||
This example receives packets using RF69 FSK radio module.
|
||||
Packets are decrypted using hardware AES.
|
||||
NOTE: When using address filtering, the address byte is NOT encrypted!
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// RF69 has the following connections:
|
||||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set AES key that will be used to decrypt the packet
|
||||
// NOTE: the key must be exactly 16 bytes long!
|
||||
uint8_t key[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
|
||||
radio.setAESKey(key);
|
||||
|
||||
// enable AES encryption
|
||||
radio.enableAES();
|
||||
|
||||
// AES encryption can also be disabled
|
||||
/*
|
||||
radio.disableAES();
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[RF69] Waiting for incoming transmission ... "));
|
||||
|
||||
// you can receive data as an Arduino String
|
||||
String str;
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
// print the data of the packet
|
||||
Serial.print(F("[RF69] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
RadioLib RF69 Receive with Address Example
|
||||
|
||||
This example receives packets using RF69 FSK radio module.
|
||||
Packets can have 1-byte address of the destination node.
|
||||
After setting node (or broadcast) address, this node will
|
||||
automatically filter out any packets that do not contain
|
||||
either node address or broadcast address.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// RF69 has the following connections:
|
||||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set node address
|
||||
// NOTE: calling this method will automatically enable
|
||||
// address filtering (node address only)
|
||||
Serial.print(F("[RF69] Setting node address ... "));
|
||||
state = radio.setNodeAddress(0x02);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set broadcast address
|
||||
// NOTE: calling this method will automatically enable
|
||||
// address filtering (node or broadcast address)
|
||||
Serial.print(F("[RF69] Setting broadcast address ... "));
|
||||
state = radio.setBroadcastAddress(0xFF);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// address filtering can also be disabled
|
||||
// NOTE: calling this method will also erase previously set
|
||||
// node and broadcast address
|
||||
/*
|
||||
Serial.print(F("[RF69] Disabling address filtering ... "));
|
||||
state == radio.disableAddressFiltering();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[RF69] Waiting for incoming transmission ... "));
|
||||
|
||||
// you can receive data as an Arduino String
|
||||
String str;
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
// print the data of the packet
|
||||
Serial.print(F("[RF69] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
RadioLib RF69 Receive with Interrupts Example
|
||||
|
||||
This example listens for FSK transmissions and tries to
|
||||
receive them. Once a packet is received, an interrupt is
|
||||
triggered.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// RF69 has the following connections:
|
||||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
radio.setDio0Action(setFlag);
|
||||
|
||||
// start listening for packets
|
||||
Serial.print(F("[RF69] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
volatile bool receivedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we got a packet, set the flag
|
||||
receivedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the flag is set
|
||||
if(receivedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
receivedFlag = false;
|
||||
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[RF69] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[RF69] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
// of the last received packet
|
||||
Serial.print(F("[RF69] RSSI:\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// put module back to listen mode
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
RadioLib RF69 Settings Example
|
||||
|
||||
This example shows how to change all the properties of RF69 radio.
|
||||
RadioLib currently supports the following settings:
|
||||
- pins (SPI slave select, digital IO 0, digital IO 1)
|
||||
- carrier frequency
|
||||
- bit rate
|
||||
- receiver bandwidth
|
||||
- allowed frequency deviation
|
||||
- output power during transmission
|
||||
- sync word
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// RF69 has the following connections:
|
||||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 radio1 = new Module(10, 2, 3);
|
||||
|
||||
// second CC1101 has different connections:
|
||||
// CS pin: 9
|
||||
// DIO0 pin: 4
|
||||
// RESET pin: 5
|
||||
RF69 radio2 = new Module(9, 4, 5);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 radio3 = RadioShield.ModuleB;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio1.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// initialize RF69 with non-default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
// carrier frequency: 868.0 MHz
|
||||
// bit rate: 300.0 kbps
|
||||
// frequency deviation: 60.0 kHz
|
||||
// Rx bandwidth: 250.0 kHz
|
||||
// output power: 17 dBm
|
||||
// preamble length: 32 bits
|
||||
state = radio2.begin(868.0, 300.0, 60.0, 250.0, 17, 32);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// you can also change the settings at runtime
|
||||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 433.5 MHz
|
||||
if (radio1.setFrequency(433.5) == RADIOLIB_ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("[RF69] Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bit rate to 100.0 kbps
|
||||
state = radio1.setBitRate(100.0);
|
||||
if (state == RADIOLIB_ERR_INVALID_BIT_RATE) {
|
||||
Serial.println(F("[RF69] Selected bit rate is invalid for this module!"));
|
||||
while (true);
|
||||
} else if (state == RADIOLIB_ERR_INVALID_BIT_RATE_BW_RATIO) {
|
||||
Serial.println(F("[RF69] Selected bit rate to bandwidth ratio is invalid!"));
|
||||
Serial.println(F("[RF69] Increase receiver bandwidth to set this bit rate."));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set receiver bandwidth to 250.0 kHz
|
||||
state = radio1.setRxBandwidth(250.0);
|
||||
if (state == RADIOLIB_ERR_INVALID_RX_BANDWIDTH) {
|
||||
Serial.println(F("[RF69] Selected receiver bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
} else if (state == RADIOLIB_ERR_INVALID_BIT_RATE_BW_RATIO) {
|
||||
Serial.println(F("[RF69] Selected bit rate to bandwidth ratio is invalid!"));
|
||||
Serial.println(F("[RF69] Decrease bit rate to set this receiver bandwidth."));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set allowed frequency deviation to 10.0 kHz
|
||||
if (radio1.setFrequencyDeviation(10.0) == RADIOLIB_ERR_INVALID_FREQUENCY_DEVIATION) {
|
||||
Serial.println(F("[RF69] Selected frequency deviation is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set output power to 2 dBm
|
||||
if (radio1.setOutputPower(2) == RADIOLIB_ERR_INVALID_OUTPUT_POWER) {
|
||||
Serial.println(F("[RF69] Selected output power is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// up to 8 bytes can be set as sync word
|
||||
// NOTE: sync word must not contain any zero bytes
|
||||
// set sync word to 0x0123456789ABCDEF
|
||||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
||||
if (radio1.setSyncWord(syncWord, 8) == RADIOLIB_ERR_INVALID_SYNC_WORD) {
|
||||
Serial.println(F("[RF69] Selected sync word is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
Serial.println(F("[RF69] All settings changed successfully!"));
|
||||
|
||||
// RF69 can also measure temperature (roughly)
|
||||
// to get correct temperature measurements, the sensor must be calibrated
|
||||
// at ambient temperature
|
||||
radio1.setAmbientTemperature(25); // replace 25 with your ambient temperature
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// measure temperature
|
||||
Serial.print(F("[RF69] Measured temperature: "));
|
||||
Serial.print(radio1.getTemperature());
|
||||
Serial.println(F(" deg C"));
|
||||
|
||||
// wait 100 ms before the next measurement
|
||||
delay(100);
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
RadioLib RF69 Transmit Example
|
||||
|
||||
This example transmits packets using RF69 FSK radio module.
|
||||
Each packet contains up to 64 bytes of data, in the form of:
|
||||
- Arduino String
|
||||
- null-terminated char array (C-string)
|
||||
- arbitrary binary data (byte array)
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// RF69 has the following connections:
|
||||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// NOTE: some RF69 modules use high power output,
|
||||
// those are usually marked RF69H(C/CW).
|
||||
// To configure RadioLib for these modules,
|
||||
// you must call setOutputPower() with
|
||||
// second argument set to true.
|
||||
/*
|
||||
Serial.print(F("[RF69] Setting high power module ... "));
|
||||
state = radio.setOutputPower(20, true);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[RF69] Transmitting packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to 64 characters long
|
||||
int state = radio.transmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 64 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 64 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
RadioLib RF69 Transmit with AES Example
|
||||
|
||||
This example transmits packets using RF69 FSK radio module.
|
||||
Packets are encrypted using hardware AES.
|
||||
NOTE: When using address filtering, the address byte is NOT encrypted!
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// RF69 has the following connections:
|
||||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set AES key to encrypt the packet
|
||||
// NOTE: the key must be exactly 16 bytes long!
|
||||
uint8_t key[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
|
||||
radio.setAESKey(key);
|
||||
|
||||
// enable AES encryption
|
||||
radio.enableAES();
|
||||
|
||||
// AES encryption can also be disabled
|
||||
/*
|
||||
radio.disableAES();
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[RF69] Transmitting packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to 64 characters long
|
||||
int state = radio.transmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 64 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 64 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
RadioLib RF69 Transmit to Address Example
|
||||
|
||||
This example transmits packets using RF69 FSK radio module.
|
||||
Packets can have 1-byte address of the destination node.
|
||||
After setting node (or broadcast) address, this node will
|
||||
automatically filter out any packets that do not contain
|
||||
either node address or broadcast address.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// RF69 has the following connections:
|
||||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set node address
|
||||
// NOTE: calling this method will automatically enable
|
||||
// address filtering (node address only)
|
||||
Serial.print(F("[RF69] Setting node address ... "));
|
||||
state = radio.setNodeAddress(0x01);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set broadcast address
|
||||
// NOTE: calling this method will automatically enable
|
||||
// address filtering (node or broadcast address)
|
||||
Serial.print(F("[RF69] Setting broadcast address ... "));
|
||||
state = radio.setBroadcastAddress(0xFF);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// address filtering can also be disabled
|
||||
// NOTE: calling this method will also erase previously set
|
||||
// node and broadcast address
|
||||
/*
|
||||
Serial.print(F("[RF69] Disabling address filtering ... "));
|
||||
state = radio.disableAddressFiltering();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[RF69] Transmitting packet ... "));
|
||||
|
||||
// transmit C-string or Arduino string to node with address 0x02
|
||||
int state = radio.transmit("Hello World!", 0x02);
|
||||
|
||||
// transmit byte array to node with address 0x02
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8, 0x02);
|
||||
*/
|
||||
|
||||
// transmit C-string or Arduino string in broadcast mode
|
||||
/*
|
||||
int state = radio.transmit("Hello World!", 0xFF);
|
||||
*/
|
||||
|
||||
// transmit byte array in broadcast mode
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8, 0xFF);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 64 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
RadioLib RF69 Transmit with Interrupts Example
|
||||
|
||||
This example transmits FSK packets with one second delays
|
||||
between them. Each packet contains up to 64 bytes
|
||||
of data, in the form of:
|
||||
- Arduino String
|
||||
- null-terminated char array (C-string)
|
||||
- arbitrary binary data (byte array)
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// RF69 has the following connections:
|
||||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
radio.setDio0Action(setFlag);
|
||||
|
||||
// NOTE: some RF69 modules use high power output,
|
||||
// those are usually marked RF69H(C/CW).
|
||||
// To configure RadioLib for these modules,
|
||||
// you must call setOutputPower() with
|
||||
// second argument set to true.
|
||||
/*
|
||||
Serial.print(F("[RF69] Setting high power module ... "));
|
||||
state = radio.setOutputPower(20, true);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
*/
|
||||
|
||||
// start transmitting the first packet
|
||||
Serial.print(F("[RF69] Sending first packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 64 characters long
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 64 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was sent
|
||||
volatile bool transmittedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we sent a packet, set the flag
|
||||
transmittedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the previous transmission finished
|
||||
if(transmittedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
// NOTE: when using interrupt-driven transmit method,
|
||||
// it is not possible to automatically measure
|
||||
// transmission data rate using getDataRate()
|
||||
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(transmissionState);
|
||||
|
||||
}
|
||||
|
||||
// clean up after transmission is finished
|
||||
// this will ensure transmitter is disabled,
|
||||
// RF switch is powered down etc.
|
||||
radio.finishTransmit();
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
// send another one
|
||||
Serial.print(F("[RF69] Sending another packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 64 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
// we're ready to send more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
RadioLib RTTY Transmit Example
|
||||
|
||||
This example sends RTTY message using SX1278's
|
||||
FSK modem.
|
||||
|
||||
Other modules that can be used for RTTY:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- SX126x
|
||||
- nRF24
|
||||
- Si443x/RFM2x
|
||||
- SX128x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create RTTY client instance using the FSK module
|
||||
RTTYClient rtty(&radio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for RTTY
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize RTTY client
|
||||
// NOTE: RTTY frequency shift will be rounded
|
||||
// to the nearest multiple of frequency step size.
|
||||
// The exact value depends on the module:
|
||||
// SX127x/RFM9x - 61 Hz
|
||||
// RF69 - 61 Hz
|
||||
// CC1101 - 397 Hz
|
||||
// SX126x - 1 Hz
|
||||
// nRF24 - 1000000 Hz
|
||||
// Si443x/RFM2x - 156 Hz
|
||||
// SX128x - 198 Hz
|
||||
Serial.print(F("[RTTY] Initializing ... "));
|
||||
// low ("space") frequency: 434.0 MHz
|
||||
// frequency shift: 183 Hz
|
||||
// baud rate: 45 baud
|
||||
// encoding: ASCII (7-bit)
|
||||
// stop bits: 1
|
||||
state = rtty.begin(434.0, 183, 45);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
/*
|
||||
// RadioLib also provides ITA2 ("Baudot") support
|
||||
rtty.begin(434, 183, 45, ITA2);
|
||||
|
||||
// All transmissions in loop() (strings and numbers)
|
||||
// will now be encoded using ITA2 code
|
||||
|
||||
// ASCII characters that do not have ITA2 equivalent
|
||||
// will be sent as NUL (including lower case letters!)
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[RTTY] Sending RTTY data ... "));
|
||||
|
||||
// send out idle condition for 500 ms
|
||||
rtty.idle();
|
||||
delay(500);
|
||||
|
||||
// RTTYClient supports all methods of the Serial class
|
||||
|
||||
// Arduino String class
|
||||
String aStr = "Arduino String";
|
||||
rtty.println(aStr);
|
||||
|
||||
// character array (C-String)
|
||||
rtty.println("C-String");
|
||||
|
||||
// string saved in flash
|
||||
rtty.println(F("Flash String"));
|
||||
|
||||
// character
|
||||
rtty.println('c');
|
||||
|
||||
// byte
|
||||
// formatting DEC/HEX/OCT/BIN is supported for
|
||||
// any integer type (byte/int/long)
|
||||
rtty.println(255, HEX);
|
||||
|
||||
// integer number
|
||||
int i = 1000;
|
||||
rtty.println(i);
|
||||
|
||||
// floating point number
|
||||
float f = -3.1415;
|
||||
rtty.println(f, 3);
|
||||
|
||||
// turn the transmitter off
|
||||
rtty.standby();
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
RadioLib RTTY Transmit AFSK Example
|
||||
|
||||
This example sends RTTY message using SX1278's
|
||||
FSK modem. The data is modulated as AFSK.
|
||||
|
||||
Other modules that can be used for RTTY:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- Si443x/RFM2x
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
// create RTTY client instance using the AFSK instance
|
||||
RTTYClient rtty(&audio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for RTTY
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// initialize RTTY client
|
||||
// NOTE: Unlike FSK RTTY, AFSK requires no rounding of
|
||||
// the frequency shift.
|
||||
Serial.print(F("[RTTY] Initializing ... "));
|
||||
// space frequency: 400 Hz
|
||||
// frequency shift: 170 Hz
|
||||
// baud rate: 45 baud
|
||||
// encoding: ASCII (7-bit)
|
||||
// stop bits: 1
|
||||
state = rtty.begin(400, 170, 45);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
/*
|
||||
// RadioLib also provides ITA2 ("Baudot") support
|
||||
rtty.begin(400, 170, 45, ITA2);
|
||||
|
||||
// All transmissions in loop() (strings and numbers)
|
||||
// will now be encoded using ITA2 code
|
||||
|
||||
// ASCII characters that do not have ITA2 equivalent
|
||||
// will be sent as NUL (including lower case letters!)
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[RTTY] Sending RTTY data ... "));
|
||||
|
||||
// send out idle condition for 500 ms
|
||||
rtty.idle();
|
||||
delay(500);
|
||||
|
||||
// RTTYClient supports all methods of the Serial class
|
||||
|
||||
// Arduino String class
|
||||
String aStr = "Arduino String";
|
||||
rtty.println(aStr);
|
||||
|
||||
// character array (C-String)
|
||||
rtty.println("C-String");
|
||||
|
||||
// string saved in flash
|
||||
rtty.println(F("Flash String"));
|
||||
|
||||
// character
|
||||
rtty.println('c');
|
||||
|
||||
// byte
|
||||
// formatting DEC/HEX/OCT/BIN is supported for
|
||||
// any integer type (byte/int/long)
|
||||
rtty.println(255, HEX);
|
||||
|
||||
// integer number
|
||||
int i = 1000;
|
||||
rtty.println(i);
|
||||
|
||||
// floating point number
|
||||
float f = -3.1415;
|
||||
rtty.println(f, 3);
|
||||
|
||||
// turn the transmitter off
|
||||
rtty.standby();
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
RadioLib SSTV Transmit Example
|
||||
|
||||
The following example sends SSTV picture using
|
||||
SX1278's FSK modem.
|
||||
|
||||
Other modules that can be used for SSTV:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- SX126x
|
||||
|
||||
NOTE: SSTV is an analog modulation, and
|
||||
requires precise frequency control.
|
||||
Some of the above modules can only
|
||||
set their frequency in rough steps,
|
||||
so the result can be distorted.
|
||||
Using high-precision radio with TCXO
|
||||
(like SX126x) is recommended.
|
||||
|
||||
NOTE: Some platforms (such as Arduino Uno)
|
||||
might not be fast enough to correctly
|
||||
send pictures via high-speed modes
|
||||
like Scottie2 or Martin2. For those,
|
||||
lower speed modes such as Wrasse,
|
||||
Scottie1 or Martin1 are recommended.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create SSTV client instance using the FSK module
|
||||
SSTVClient sstv(&radio);
|
||||
|
||||
// test "image" - actually just a single 320px line
|
||||
// will be sent over and over again, to create vertical color stripes at the receiver
|
||||
uint32_t line[320] = {
|
||||
// black
|
||||
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
|
||||
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
|
||||
|
||||
// blue
|
||||
0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF,
|
||||
0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF,
|
||||
|
||||
// green
|
||||
0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00,
|
||||
0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00,
|
||||
|
||||
// cyan
|
||||
0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
|
||||
// red
|
||||
0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000,
|
||||
0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000,
|
||||
|
||||
// magenta
|
||||
0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF,
|
||||
0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF,
|
||||
|
||||
// yellow
|
||||
0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00,
|
||||
0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00,
|
||||
|
||||
// white
|
||||
0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF,
|
||||
0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF
|
||||
};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// when using one of the non-LoRa modules for SSTV
|
||||
// (RF69, SX1231 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
// initialize SSTV client
|
||||
Serial.print(F("[SSTV] Initializing ... "));
|
||||
// 0 Hz tone frequency: 434.0 MHz
|
||||
// SSTV mode: Wrasse (SC2-180)
|
||||
// correction factor: 0.95
|
||||
// NOTE: Due to different speeds of various platforms
|
||||
// supported by RadioLib (Arduino Uno, ESP32 etc),
|
||||
// and because SSTV is analog protocol, incorrect
|
||||
// timing of pulses can lead to distortions.
|
||||
// To compensate, correction factor can be used
|
||||
// to adjust the length of timing pulses
|
||||
// (lower number = shorter pulses).
|
||||
// The value is usually around 0.95 (95%).
|
||||
state = sstv.begin(434.0, Wrasse, 0.95);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// to help tune the receiver, SSTVClient can send
|
||||
// continuous beep at the frequency corresponding to
|
||||
// 1900 Hz in upper sideband (aka USB) modulation
|
||||
// (SSTV header "leader tone")
|
||||
/*
|
||||
sstv.idle();
|
||||
while(true);
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// send picture with 8 color stripes
|
||||
Serial.print(F("[SSTV] Sending test picture ... "));
|
||||
|
||||
// send synchronization header first
|
||||
sstv.sendHeader();
|
||||
|
||||
// send all picture lines
|
||||
for(uint16_t i = 0; i < sstv.getPictureHeight(); i++) {
|
||||
sstv.sendLine(line);
|
||||
}
|
||||
|
||||
// turn off transmitter
|
||||
radio.standby();
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
delay(30000);
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
RadioLib SSTV Transmit AFSK Example
|
||||
|
||||
The following example sends SSTV picture using
|
||||
SX1278's FSK modem. The data is modulated
|
||||
as AFSK.
|
||||
|
||||
Other modules that can be used for SSTV:
|
||||
with AFSK modulation:
|
||||
- SX127x/RFM9x
|
||||
- RF69
|
||||
- SX1231
|
||||
- CC1101
|
||||
- Si443x/RFM2x
|
||||
|
||||
NOTE: Some platforms (such as Arduino Uno)
|
||||
might not be fast enough to correctly
|
||||
send pictures via high-speed modes
|
||||
like Scottie2 or Martin2. For those,
|
||||
lower speed modes such as Wrasse,
|
||||
Scottie1 or Martin1 are recommended.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AFSK client instance using the FSK module
|
||||
// pin 5 is connected to SX1278 DIO2
|
||||
AFSKClient audio(&radio, 5);
|
||||
|
||||
// create SSTV client instance using the AFSK instance
|
||||
SSTVClient sstv(&audio);
|
||||
|
||||
// test "image" - actually just a single 320px line
|
||||
// will be sent over and over again, to create vertical color stripes at the receiver
|
||||
uint32_t line[320] = {
|
||||
// black
|
||||
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
|
||||
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
|
||||
|
||||
// blue
|
||||
0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF,
|
||||
0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF,
|
||||
|
||||
// green
|
||||
0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00,
|
||||
0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00,
|
||||
|
||||
// cyan
|
||||
0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
|
||||
// red
|
||||
0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000,
|
||||
0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000,
|
||||
|
||||
// magenta
|
||||
0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF,
|
||||
0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF,
|
||||
|
||||
// yellow
|
||||
0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00,
|
||||
0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00,
|
||||
|
||||
// white
|
||||
0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF,
|
||||
0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF
|
||||
};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// when using one of the non-LoRa modules for SSTV
|
||||
// (RF69, SX1231 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
// initialize SSTV client
|
||||
Serial.print(F("[SSTV] Initializing ... "));
|
||||
// SSTV mode: Wrasse (SC2-180)
|
||||
// correction factor: 0.95
|
||||
// NOTE: Due to different speeds of various platforms
|
||||
// supported by RadioLib (Arduino Uno, ESP32 etc),
|
||||
// and because SSTV is analog protocol, incorrect
|
||||
// timing of pulses can lead to distortions.
|
||||
// To compensate, correction factor can be used
|
||||
// to adjust the length of timing pulses
|
||||
// (lower number = shorter pulses).
|
||||
// The value is usually around 0.95 (95%).
|
||||
state = sstv.begin(Wrasse, 0.95);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// to help tune the receiver, SSTVClient can send
|
||||
// continuous 1900 Hz beep
|
||||
/*
|
||||
sstv.idle();
|
||||
while(true);
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// send picture with 8 color stripes
|
||||
Serial.print(F("[SSTV] Sending test picture ... "));
|
||||
|
||||
// send synchronization header first
|
||||
sstv.sendHeader();
|
||||
|
||||
// send all picture lines
|
||||
for(uint16_t i = 0; i < sstv.getPictureHeight(); i++) {
|
||||
sstv.sendLine(line);
|
||||
}
|
||||
|
||||
// turn off transmitter
|
||||
radio.standby();
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
delay(30000);
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
RadioLib SX1231 Receive Example
|
||||
|
||||
This example receives packets using SX1231 FSK radio module.
|
||||
|
||||
NOTE: SX1231 offers the same features as RF69 and has the same
|
||||
interface. Please see RF69 examples for examples on AES,
|
||||
address filtering, interrupts and settings.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1231 has the following connections:
|
||||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
SX1231 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1231 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1231 with default settings
|
||||
Serial.print(F("[SX1231] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[SX1231] Waiting for incoming transmission ... "));
|
||||
|
||||
// you can receive data as an Arduino String
|
||||
String str;
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
// print the data of the packet
|
||||
Serial.print(F("[SX1231] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
RadioLib SX1231 Transmit Example
|
||||
|
||||
This example transmits packets using SX1231 FSK radio module.
|
||||
|
||||
NOTE: SX1231 offers the same features as RF69 and has the same
|
||||
interface. Please see RF69 examples for examples on AES,
|
||||
address filtering, interrupts and settings.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1231 has the following connections:
|
||||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
SX1231 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1231 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1231 with default settings
|
||||
Serial.print(F("[SX1231] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[SX1231] Transmitting packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to 256 characters long
|
||||
int state = radio.transmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 256 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 256 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
}
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
RadioLib SX126x Channel Activity Detection Example
|
||||
|
||||
This example uses SX1262 to scan the current LoRa
|
||||
channel and detect ongoing LoRa transmissions.
|
||||
Unlike SX127x CAD, SX126x can detect any part
|
||||
of LoRa transmission, not just the preamble.
|
||||
|
||||
Other modules from SX126x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1262 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[SX1262] Scanning channel for LoRa transmission ... "));
|
||||
|
||||
// start scanning current channel
|
||||
int state = radio.scanChannel();
|
||||
|
||||
if (state == RADIOLIB_LORA_DETECTED) {
|
||||
// LoRa preamble was detected
|
||||
Serial.println(F("detected!"));
|
||||
|
||||
} else if (state == RADIOLIB_CHANNEL_FREE) {
|
||||
// no preamble was detected, channel is free
|
||||
Serial.println(F("channel is free!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// wait 100 ms before new scan
|
||||
delay(100);
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
RadioLib SX126x Channel Activity Detection Example
|
||||
|
||||
This example uses SX1262 to scan the current LoRa
|
||||
channel and detect ongoing LoRa transmissions.
|
||||
Unlike SX127x CAD, SX126x can detect any part
|
||||
of LoRa transmission, not just the preamble.
|
||||
|
||||
Other modules from SX126x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1262 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when LoRa packet or timeout is detected
|
||||
radio.setDio1Action(setFlag);
|
||||
|
||||
// start scanning the channel
|
||||
Serial.print(F("[SX1262] Starting scan for LoRa preamble ... "));
|
||||
state = radio.startChannelScan();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was detected or CAD timed out
|
||||
volatile bool scanFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// something happened, set the flag
|
||||
scanFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the flag is set
|
||||
if(scanFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
scanFlag = false;
|
||||
|
||||
// check CAD result
|
||||
int state = radio.getChannelScanResult();
|
||||
|
||||
if (state == RADIOLIB_LORA_DETECTED) {
|
||||
// LoRa packet was detected
|
||||
Serial.println(F("[SX1262] Packet detected!"));
|
||||
|
||||
} else if (state == RADIOLIB_CHANNEL_FREE) {
|
||||
// channel is free
|
||||
Serial.println(F("[SX1262] Channel is free!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("[SX1262] Failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// start scanning the channel again
|
||||
Serial.print(F("[SX1262] Starting scan for LoRa preamble ... "));
|
||||
state = radio.startChannelScan();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
RadioLib SX126x FSK Modem Example
|
||||
|
||||
This example shows how to use FSK modem in SX126x chips.
|
||||
|
||||
NOTE: The sketch below is just a guide on how to use
|
||||
FSK modem, so this code should not be run directly!
|
||||
Instead, modify the other examples to use FSK
|
||||
modem and use the appropriate configuration
|
||||
methods.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---fsk-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1262 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 FSK modem with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// if needed, you can switch between LoRa and FSK modes
|
||||
//
|
||||
// radio.begin() start LoRa mode (and disable FSK)
|
||||
// radio.beginFSK() start FSK mode (and disable LoRa)
|
||||
|
||||
// the following settings can also
|
||||
// be modified at run-time
|
||||
state = radio.setFrequency(433.5);
|
||||
state = radio.setBitRate(100.0);
|
||||
state = radio.setFrequencyDeviation(10.0);
|
||||
state = radio.setRxBandwidth(250.0);
|
||||
state = radio.setOutputPower(10.0);
|
||||
state = radio.setCurrentLimit(100.0);
|
||||
state = radio.setDataShaping(RADIOLIB_SHAPING_1_0);
|
||||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
state = radio.setSyncWord(syncWord, 8);
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("Unable to set configuration, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// FSK modem on SX126x can handle the sync word setting in bits, not just
|
||||
// whole bytes. The value used is left-justified.
|
||||
// This makes same result as radio.setSyncWord(syncWord, 8):
|
||||
state = radio.setSyncBits(syncWord, 64);
|
||||
// This will use 0x012 as sync word (12 bits only):
|
||||
state = radio.setSyncBits(syncWord, 12);
|
||||
|
||||
// FSK modem allows advanced CRC configuration
|
||||
// Default is CCIT CRC16 (2 bytes, initial 0x1D0F, polynomial 0x1021, inverted)
|
||||
// Set CRC to IBM CRC (2 bytes, initial 0xFFFF, polynomial 0x8005, non-inverted)
|
||||
state = radio.setCRC(2, 0xFFFF, 0x8005, false);
|
||||
// set CRC length to 0 to disable CRC
|
||||
|
||||
#warning "This sketch is just an API guide! Read the note at line 6."
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// FSK modem can use the same transmit/receive methods
|
||||
// as the LoRa modem, even their interrupt-driven versions
|
||||
|
||||
// transmit FSK packet
|
||||
int state = radio.transmit("Hello World!");
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1262] Packet transmitted successfully!"));
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
Serial.println(F("[SX1262] Packet too long!"));
|
||||
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
|
||||
Serial.println(F("[SX1262] Timed out while transmitting!"));
|
||||
} else {
|
||||
Serial.println(F("[SX1262] Failed to transmit packet, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// receive FSK packet
|
||||
String str;
|
||||
state = radio.receive(str);
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1262] Received packet!"));
|
||||
Serial.print(F("[SX1262] Data:\t"));
|
||||
Serial.println(str);
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
Serial.println(F("[SX1262] Timed out while waiting for packet!"));
|
||||
} else {
|
||||
Serial.println(F("[SX1262] Failed to receive packet, code "));
|
||||
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 "));
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
RadioLib SX126x Ping-Pong Example
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// uncomment the following only on one
|
||||
// of the nodes to initiate the pings
|
||||
//#define INITIATING_NODE
|
||||
|
||||
// SX1262 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
// save transmission states between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
// flag to indicate transmission or reception state
|
||||
bool transmitFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// flag to indicate that a packet was sent or received
|
||||
volatile bool operationDone = false;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is transmitted or received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we sent aor received packet, set the flag
|
||||
operationDone = true;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
radio.setDio1Action(setFlag);
|
||||
|
||||
#if defined(INITIATING_NODE)
|
||||
// send the first packet on this node
|
||||
Serial.print(F("[SX1262] Sending first packet ... "));
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
transmitFlag = true;
|
||||
#else
|
||||
// start listening for LoRa packets on this node
|
||||
Serial.print(F("[SX1262] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the previous operation finished
|
||||
if(operationDone) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
operationDone = false;
|
||||
|
||||
if(transmitFlag) {
|
||||
// the previous operation was transmission, listen for response
|
||||
// print the result
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(transmissionState);
|
||||
|
||||
}
|
||||
|
||||
// listen for response
|
||||
radio.startReceive();
|
||||
transmitFlag = false;
|
||||
|
||||
} else {
|
||||
// the previous operation was reception
|
||||
// print data and send another packet
|
||||
String str;
|
||||
int state = radio.readData(str);
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[SX1262] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[SX1262] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
Serial.print(F("[SX1262] RSSI:\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print SNR (Signal-to-Noise Ratio)
|
||||
Serial.print(F("[SX1262] SNR:\t\t"));
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
}
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
// send another one
|
||||
Serial.print(F("[SX1262] Sending another packet ... "));
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
transmitFlag = true;
|
||||
}
|
||||
|
||||
// we're ready to process more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
RadioLib SX126x Receive Example
|
||||
|
||||
This example listens for LoRa transmissions using SX126x Lora modules.
|
||||
To successfully receive data, the following settings have to be the same
|
||||
on both transmitter and receiver:
|
||||
- carrier frequency
|
||||
- bandwidth
|
||||
- spreading factor
|
||||
- coding rate
|
||||
- sync word
|
||||
- preamble length
|
||||
|
||||
Other modules from SX126x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1262 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[SX1262] Waiting for incoming transmission ... "));
|
||||
|
||||
// you can receive data as an Arduino String
|
||||
// NOTE: receive() is a blocking method!
|
||||
// See example ReceiveInterrupt for details
|
||||
// on non-blocking reception method.
|
||||
String str;
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
// print the data of the packet
|
||||
Serial.print(F("[SX1262] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print the RSSI (Received Signal Strength Indicator)
|
||||
// of the last received packet
|
||||
Serial.print(F("[SX1262] RSSI:\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print the SNR (Signal-to-Noise Ratio)
|
||||
// of the last received packet
|
||||
Serial.print(F("[SX1262] SNR:\t\t"));
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
RadioLib SX126x Receive with Interrupts Example
|
||||
|
||||
This example listens for LoRa transmissions and tries to
|
||||
receive them. Once a packet is received, an interrupt is
|
||||
triggered. To successfully receive data, the following
|
||||
settings have to be the same on both transmitter
|
||||
and receiver:
|
||||
- carrier frequency
|
||||
- bandwidth
|
||||
- spreading factor
|
||||
- coding rate
|
||||
- sync word
|
||||
|
||||
Other modules from SX126x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1262 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
radio.setDio1Action(setFlag);
|
||||
|
||||
// start listening for LoRa packets
|
||||
Serial.print(F("[SX1262] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
// radio.scanChannel();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
volatile bool receivedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we got a packet, set the flag
|
||||
receivedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the flag is set
|
||||
if(receivedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
receivedFlag = false;
|
||||
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[SX1262] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[SX1262] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
Serial.print(F("[SX1262] RSSI:\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print SNR (Signal-to-Noise Ratio)
|
||||
Serial.print(F("[SX1262] SNR:\t\t"));
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// put module back to listen mode
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
/*
|
||||
RadioLib SX126x Settings Example
|
||||
|
||||
This example shows how to change all the properties of LoRa transmission.
|
||||
RadioLib currently supports the following settings:
|
||||
- pins (SPI slave select, DIO1, DIO2, BUSY pin)
|
||||
- carrier frequency
|
||||
- bandwidth
|
||||
- spreading factor
|
||||
- coding rate
|
||||
- sync word
|
||||
- output power during transmission
|
||||
- CRC
|
||||
- preamble length
|
||||
- TCXO voltage
|
||||
- DIO2 RF switch control
|
||||
|
||||
Other modules from SX126x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1262 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 radio1 = new Module(10, 2, 3, 9);
|
||||
|
||||
// SX12628 has different connections:
|
||||
// NSS pin: 8
|
||||
// DIO1 pin: 4
|
||||
// NRST pin: 5
|
||||
// BUSY pin: 6
|
||||
SX1268 radio2 = new Module(8, 4, 5, 6);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1261 radio3 = RadioShield.ModuleB;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1268 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio1.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// initialize the second LoRa instance with
|
||||
// non-default settings
|
||||
// this LoRa link will have high data rate,
|
||||
// but lower range
|
||||
Serial.print(F("[SX1268] Initializing ... "));
|
||||
// carrier frequency: 915.0 MHz
|
||||
// bandwidth: 500.0 kHz
|
||||
// spreading factor: 6
|
||||
// coding rate: 5
|
||||
// sync word: 0x34 (public network/LoRaWAN)
|
||||
// output power: 2 dBm
|
||||
// preamble length: 20 symbols
|
||||
state = radio2.begin(915.0, 500.0, 6, 5, 0x34, 20);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// you can also change the settings at runtime
|
||||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 433.5 MHz
|
||||
if (radio1.setFrequency(433.5) == RADIOLIB_ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bandwidth to 250 kHz
|
||||
if (radio1.setBandwidth(250.0) == RADIOLIB_ERR_INVALID_BANDWIDTH) {
|
||||
Serial.println(F("Selected bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set spreading factor to 10
|
||||
if (radio1.setSpreadingFactor(10) == RADIOLIB_ERR_INVALID_SPREADING_FACTOR) {
|
||||
Serial.println(F("Selected spreading factor is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set coding rate to 6
|
||||
if (radio1.setCodingRate(6) == RADIOLIB_ERR_INVALID_CODING_RATE) {
|
||||
Serial.println(F("Selected coding rate is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set LoRa sync word to 0xAB
|
||||
if (radio1.setSyncWord(0xAB) != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("Unable to set sync word!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set output power to 10 dBm (accepted range is -17 - 22 dBm)
|
||||
if (radio1.setOutputPower(10) == RADIOLIB_ERR_INVALID_OUTPUT_POWER) {
|
||||
Serial.println(F("Selected output power is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set over current protection limit to 80 mA (accepted range is 45 - 240 mA)
|
||||
// NOTE: set value to 0 to disable overcurrent protection
|
||||
if (radio1.setCurrentLimit(80) == RADIOLIB_ERR_INVALID_CURRENT_LIMIT) {
|
||||
Serial.println(F("Selected current limit is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set LoRa preamble length to 15 symbols (accepted range is 0 - 65535)
|
||||
if (radio1.setPreambleLength(15) == RADIOLIB_ERR_INVALID_PREAMBLE_LENGTH) {
|
||||
Serial.println(F("Selected preamble length is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// disable CRC
|
||||
if (radio1.setCRC(false) == RADIOLIB_ERR_INVALID_CRC_CONFIGURATION) {
|
||||
Serial.println(F("Selected CRC is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// Some SX126x modules have TCXO (temperature compensated crystal
|
||||
// oscillator). To configure TCXO reference voltage,
|
||||
// the following method can be used.
|
||||
if (radio1.setTCXO(2.4) == RADIOLIB_ERR_INVALID_TCXO_VOLTAGE) {
|
||||
Serial.println(F("Selected TCXO voltage is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// Some SX126x modules use DIO2 as RF switch. To enable
|
||||
// this feature, the following method can be used.
|
||||
// NOTE: As long as DIO2 is configured to control RF switch,
|
||||
// it can't be used as interrupt pin!
|
||||
if (radio1.setDio2AsRfSwitch() != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("Failed to set DIO2 as RF switch!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
Serial.println(F("All settings succesfully changed!"));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// nothing here
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
RadioLib SX126x Transmit Example
|
||||
|
||||
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---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1262 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// 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);
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[SX1262] Transmitting packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
// NOTE: transmit() is a blocking method!
|
||||
// See example SX126x_Transmit_Interrupt for details
|
||||
// on non-blocking transmission method.
|
||||
int state = radio.transmit("Hello World!");
|
||||
|
||||
// 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 occured 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);
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
RadioLib SX126x Transmit with Interrupts Example
|
||||
|
||||
This example transmits LoRa packets with one second delays
|
||||
between them. 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---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1262 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// or using CubeCell
|
||||
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
radio.setDio1Action(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);
|
||||
*/
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was sent
|
||||
volatile bool transmittedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we sent a packet, set the flag
|
||||
transmittedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the previous transmission finished
|
||||
if(transmittedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
// NOTE: when using interrupt-driven transmit method,
|
||||
// it is not possible to automatically measure
|
||||
// transmission data rate using getDataRate()
|
||||
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(transmissionState);
|
||||
|
||||
}
|
||||
|
||||
// clean up after transmission is finished
|
||||
// this will ensure transmitter is disabled,
|
||||
// RF switch is powered down etc.
|
||||
radio.finishTransmit();
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
// send another one
|
||||
Serial.print(F("[SX1262] Sending another packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 256 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
// we're ready to send more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
RadioLib SX127x Channel Activity Detection Example
|
||||
|
||||
This example scans the current LoRa channel and detects
|
||||
valid LoRa preambles. Preamble is the first part of
|
||||
LoRa transmission, so this can be used to check
|
||||
if the LoRa channel is free, or if you should start
|
||||
receiving a message.
|
||||
|
||||
Other modules from SX127x/RFM9x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[SX1278] Scanning channel for LoRa preamble ... "));
|
||||
|
||||
// start scanning current channel
|
||||
int state = radio.scanChannel();
|
||||
|
||||
if (state == RADIOLIB_PREAMBLE_DETECTED) {
|
||||
// LoRa preamble was detected
|
||||
Serial.println(F("detected preamble!"));
|
||||
|
||||
} else if (state == RADIOLIB_CHANNEL_FREE) {
|
||||
// no preamble was detected, channel is free
|
||||
Serial.println(F("channel is free!"));
|
||||
|
||||
}
|
||||
|
||||
// wait 100 ms before new scan
|
||||
delay(100);
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
RadioLib SX127x Channel Activity Detection with Interrupts Example
|
||||
|
||||
This example scans the current LoRa channel and detects
|
||||
valid LoRa preambles. Preamble is the first part of
|
||||
LoRa transmission, so this can be used to check
|
||||
if the LoRa channel is free, or if you should start
|
||||
receiving a message.
|
||||
|
||||
Other modules from SX127x/RFM9x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// save state between loops
|
||||
int scanState = RADIOLIB_ERR_NONE;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when LoRa preamble is not detected within CAD timeout period
|
||||
radio.setDio0Action(setFlagTimeout);
|
||||
|
||||
// set the function that will be called
|
||||
// when LoRa preamble is detected
|
||||
radio.setDio1Action(setFlagDetected);
|
||||
|
||||
// start scanning the channel
|
||||
Serial.print(F("[SX1278] Starting scan for LoRa preamble ... "));
|
||||
state = radio.startChannelScan();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
}
|
||||
|
||||
// flag to indicate that a preamble was not detected
|
||||
volatile bool timeoutFlag = false;
|
||||
|
||||
// flag to indicate that a preamble was detected
|
||||
volatile bool detectedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when no preamble
|
||||
// is detected within timeout period
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlagTimeout(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we timed out, set the flag
|
||||
timeoutFlag = true;
|
||||
}
|
||||
|
||||
// this function is called when LoRa preamble
|
||||
// is detected within timeout period
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlagDetected(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we got a preamble, set the flag
|
||||
detectedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if we got a preamble
|
||||
if(detectedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
detectedFlag = false;
|
||||
|
||||
// LoRa preamble was detected
|
||||
Serial.print(F("[SX1278] Preamble detected!"));
|
||||
|
||||
}
|
||||
|
||||
// check if we need to restart channel activity detection
|
||||
if(detectedFlag || timeoutFlag) {
|
||||
// start scanning the channel
|
||||
Serial.print(F("[SX1278] Starting scan for LoRa preamble ... "));
|
||||
|
||||
// start scanning current channel
|
||||
int state = radio.startChannelScan();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,206 @@
|
|||
/*
|
||||
RadioLib SX127x FSK Modem Example
|
||||
|
||||
This example shows how to use FSK modem in SX127x chips.
|
||||
|
||||
NOTE: The sketch below is just a guide on how to use
|
||||
FSK modem, so this code should not be run directly!
|
||||
Instead, modify the other examples to use FSK
|
||||
modem and use the appropriate configuration
|
||||
methods.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---fsk-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 fsk = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 FSK modem with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// if needed, you can switch between LoRa and FSK modes
|
||||
//
|
||||
// radio.begin() start LoRa mode (and disable FSK)
|
||||
// radio.beginFSK() start FSK mode (and disable LoRa)
|
||||
|
||||
// the following settings can also
|
||||
// be modified at run-time
|
||||
state = radio.setFrequency(433.5);
|
||||
state = radio.setBitRate(100.0);
|
||||
state = radio.setFrequencyDeviation(10.0);
|
||||
state = radio.setRxBandwidth(250.0);
|
||||
state = radio.setOutputPower(10.0);
|
||||
state = radio.setCurrentLimit(100);
|
||||
state = radio.setDataShaping(RADIOLIB_SHAPING_0_5);
|
||||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
state = radio.setSyncWord(syncWord, 8);
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("Unable to set configuration, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// FSK modulation can be changed to OOK
|
||||
// NOTE: When using OOK, the maximum bit rate is only 32.768 kbps!
|
||||
// Also, data shaping changes from Gaussian filter to
|
||||
// simple filter with cutoff frequency. Make sure to call
|
||||
// setDataShapingOOK() to set the correct shaping!
|
||||
state = radio.setOOK(true);
|
||||
state = radio.setDataShapingOOK(1);
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("Unable to change modulation, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
#warning "This sketch is just an API guide! Read the note at line 6."
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// FSK modem can use the same transmit/receive methods
|
||||
// as the LoRa modem, even their interrupt-driven versions
|
||||
// NOTE: FSK modem maximum packet length is 63 bytes!
|
||||
|
||||
// transmit FSK packet
|
||||
int state = radio.transmit("Hello World!");
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Packet transmitted successfully!"));
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
Serial.println(F("[SX1278] Packet too long!"));
|
||||
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
|
||||
Serial.println(F("[SX1278] Timed out while transmitting!"));
|
||||
} else {
|
||||
Serial.println(F("[SX1278] Failed to transmit packet, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// receive FSK packet
|
||||
String str;
|
||||
state = radio.receive(str);
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Received packet!"));
|
||||
Serial.print(F("[SX1278] Data:\t"));
|
||||
Serial.println(str);
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
Serial.println(F("[SX1278] Timed out while waiting for packet!"));
|
||||
} else {
|
||||
Serial.println(F("[SX1278] Failed to receive packet, code "));
|
||||
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("[SX1278] 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 "));
|
||||
}
|
||||
*/
|
||||
|
||||
// FSK modem supports direct data transmission
|
||||
// in this mode, SX127x directly transmits any data
|
||||
// sent to DIO1 (data) and DIO2 (clock)
|
||||
|
||||
// activate direct mode transmitter
|
||||
state = radio.transmitDirect();
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Unable to start direct transmission mode, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// using the direct mode, it is possible to transmit
|
||||
// FM notes with Arduino tone() function
|
||||
|
||||
// it is recommended to set data shaping to 0
|
||||
// (no shaping) when transmitting audio
|
||||
state = radio.setDataShaping(0.0);
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Unable to set data shaping, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// transmit FM tone at 1000 Hz for 1 second, then 500 Hz for 1 second
|
||||
// (DIO2 is connected to Arduino pin 4)
|
||||
// Note: tone() function is not available on ESP32, Arduino Due and CubeCell
|
||||
// on these platforms, the following will do nothing
|
||||
#if !defined(RADIOLIB_TONE_UNSUPPORTED)
|
||||
tone(4, 1000);
|
||||
delay(1000);
|
||||
tone(4, 500);
|
||||
delay(1000);
|
||||
noTone(4);
|
||||
#endif
|
||||
|
||||
// NOTE: after calling transmitDirect(), SX127x will start
|
||||
// transmitting immediately! This signal can jam other
|
||||
// devices at the same frequency, it is up to the user
|
||||
// to disable it with standby() method!
|
||||
|
||||
// direct mode transmissions can also be received
|
||||
// as bit stream on DIO1 (data) and DIO2 (clock)
|
||||
state = radio.receiveDirect();
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Unable to start direct reception mode, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// NOTE: you will not be able to send or receive packets
|
||||
// while direct mode is active! to deactivate it, call method
|
||||
// radio.packetMode()
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
RadioLib SX127x Ping-Pong Example
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// uncomment the following only on one
|
||||
// of the nodes to initiate the pings
|
||||
//#define INITIATING_NODE
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// NRST pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission states between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
// flag to indicate transmission or reception state
|
||||
bool transmitFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// flag to indicate that a packet was sent or received
|
||||
volatile bool operationDone = false;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is transmitted or received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we sent or received packet, set the flag
|
||||
operationDone = true;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
radio.setDio0Action(setFlag);
|
||||
|
||||
#if defined(INITIATING_NODE)
|
||||
// send the first packet on this node
|
||||
Serial.print(F("[SX1278] Sending first packet ... "));
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
transmitFlag = true;
|
||||
#else
|
||||
// start listening for LoRa packets on this node
|
||||
Serial.print(F("[SX1278] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the previous operation finished
|
||||
if(operationDone) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
operationDone = false;
|
||||
|
||||
if(transmitFlag) {
|
||||
// the previous operation was transmission, listen for response
|
||||
// print the result
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(transmissionState);
|
||||
|
||||
}
|
||||
|
||||
// listen for response
|
||||
radio.startReceive();
|
||||
transmitFlag = false;
|
||||
|
||||
} else {
|
||||
// the previous operation was reception
|
||||
// print data and send another packet
|
||||
String str;
|
||||
int state = radio.readData(str);
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[SX1278] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[SX1278] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
Serial.print(F("[SX1278] RSSI:\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print SNR (Signal-to-Noise Ratio)
|
||||
Serial.print(F("[SX1278] SNR:\t\t"));
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
}
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
// send another one
|
||||
Serial.print(F("[SX1278] Sending another packet ... "));
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
transmitFlag = true;
|
||||
}
|
||||
|
||||
// we're ready to process more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
RadioLib SX127x Receive Example
|
||||
|
||||
This example listens for LoRa transmissions using SX127x Lora modules.
|
||||
To successfully receive data, the following settings have to be the same
|
||||
on both transmitter and receiver:
|
||||
- carrier frequency
|
||||
- bandwidth
|
||||
- spreading factor
|
||||
- coding rate
|
||||
- sync word
|
||||
- preamble length
|
||||
|
||||
Other modules from SX127x/RFM9x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[SX1278] Waiting for incoming transmission ... "));
|
||||
|
||||
// you can receive data as an Arduino String
|
||||
// NOTE: receive() is a blocking method!
|
||||
// See example ReceiveInterrupt for details
|
||||
// on non-blocking reception method.
|
||||
String str;
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
// print the data of the packet
|
||||
Serial.print(F("[SX1278] Data:\t\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print the RSSI (Received Signal Strength Indicator)
|
||||
// of the last received packet
|
||||
Serial.print(F("[SX1278] RSSI:\t\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print the SNR (Signal-to-Noise Ratio)
|
||||
// of the last received packet
|
||||
Serial.print(F("[SX1278] SNR:\t\t\t"));
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
// print frequency error
|
||||
// of the last received packet
|
||||
Serial.print(F("[SX1278] Frequency error:\t"));
|
||||
Serial.print(radio.getFrequencyError());
|
||||
Serial.println(F(" Hz"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
RadioLib SX127x Direct Receive Example
|
||||
|
||||
This example shows how to receive FSK packets without using
|
||||
SX127x packet engine.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// DIO2 pin: 5
|
||||
const int pin = 5;
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with FSK modem at 9600 bps
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK(434.0, 9.6, 20.0);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the direct mode sync word
|
||||
// the default RadioLib FSK sync word is 0x12AD
|
||||
// we can add in some preamble bits, to lower the chance
|
||||
// of false detection
|
||||
radio.setDirectSyncWord(0x555512AD, 32);
|
||||
|
||||
// set function that will be called each time a bit is received
|
||||
radio.setDirectAction(readBit);
|
||||
|
||||
// start direct mode reception
|
||||
radio.receiveDirect();
|
||||
}
|
||||
|
||||
// this function is called when a new bit is received
|
||||
void readBit(void) {
|
||||
// read the data bit
|
||||
radio.readBit(pin);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// we expect the packet to contain the string "Hello World!",
|
||||
// a length byte and 2 CRC bytes, that's 15 bytes in total
|
||||
if(radio.available() >= 15) {
|
||||
Serial.println("[SX1278] Received packet in direct mode!");
|
||||
while(radio.available()) {
|
||||
// read a byte
|
||||
byte b = radio.read();
|
||||
|
||||
// print it
|
||||
Serial.print(b, HEX);
|
||||
Serial.print('\t');
|
||||
Serial.write(b);
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
RadioLib SX127x Transmit with Frequency Hopping Example
|
||||
|
||||
This example transmits packets using SX1278 LoRa radio module.
|
||||
Each packet contains up to 256 bytes of data, in the form of:
|
||||
- Arduino String
|
||||
- null-terminated char array (C-string)
|
||||
- arbitrary binary data (byte array)
|
||||
|
||||
Other modules from SX127x/RFM9x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
|
||||
SX127x supports FHSS or Frequency Hopping Spread Spectrum.
|
||||
Once a hopping period is set and a transmission is started, the radio
|
||||
will begin triggering interrupts every hop period where the radio frequency
|
||||
is changed to the next channel.
|
||||
*/
|
||||
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
volatile bool receivedFlag = false;
|
||||
|
||||
// flag to indicate frequency must be changed
|
||||
volatile bool fhssChangeFlag = false;
|
||||
|
||||
// the channel frequencies can be generated randomly or hard coded
|
||||
// NOTE: The frequency list MUST be the same on both sides!
|
||||
float channels[] = { 433.0, 433.4, 433.2, 433.6, 434.0, 433.8 };
|
||||
int numberOfChannels = sizeof(channels) / sizeof(float);
|
||||
|
||||
// counter to keep track of how many frequency hops were performed
|
||||
int hopsCompleted = 0;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setRxFlag(void) {
|
||||
receivedFlag = true;
|
||||
}
|
||||
|
||||
// this function is called when FhssChangeChannel interrupt occurs
|
||||
// (at the beginning of each transmission)
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFHSSFlag(void) {
|
||||
fhssChangeFlag = true;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// begin radio on home channel
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin(channels[0]);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set hop period in symbols
|
||||
// this will also enable FHSS
|
||||
state = radio.setFHSSHoppingPeriod(9);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function to call when reception is finished
|
||||
radio.setDio0Action(setRxFlag);
|
||||
|
||||
// set the function to call when we need to hcange frequency
|
||||
radio.setDio1Action(setFHSSFlag);
|
||||
|
||||
// start listening for LoRa packets
|
||||
Serial.print(F("[SX1278] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the reception flag is set
|
||||
if (receivedFlag == true) {
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[SX1278] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[SX1278] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("[SX1278] CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("[SX1278] Failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// print the number of hops it took
|
||||
Serial.print(F("[SX1278] Hops completed: "));
|
||||
Serial.println(hopsCompleted);
|
||||
|
||||
// reset the counter
|
||||
hopsCompleted = 0;
|
||||
|
||||
// put the module back to listen mode
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets, clear the flag
|
||||
receivedFlag = false;
|
||||
}
|
||||
|
||||
// check if we need to do another frequency hop
|
||||
if (fhssChangeFlag == true) {
|
||||
// we do, change it now
|
||||
int state = radio.setFrequency(channels[radio.getFHSSChannel() % numberOfChannels]);
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("[SX1278] Failed to change frequency, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// increment the counter
|
||||
hopsCompleted++;
|
||||
|
||||
// clear the FHSS interrupt
|
||||
radio.clearFHSSInt();
|
||||
|
||||
// we're ready to do another hop, clear the flag
|
||||
fhssChangeFlag = false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
RadioLib SX127x Receive with Interrupts Example
|
||||
|
||||
This example listens for LoRa transmissions and tries to
|
||||
receive them. Once a packet is received, an interrupt is
|
||||
triggered. To successfully receive data, the following
|
||||
settings have to be the same on both transmitter
|
||||
and receiver:
|
||||
- carrier frequency
|
||||
- bandwidth
|
||||
- spreading factor
|
||||
- coding rate
|
||||
- sync word
|
||||
|
||||
Other modules from SX127x/RFM9x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
radio.setDio0Action(setFlag);
|
||||
|
||||
// start listening for LoRa packets
|
||||
Serial.print(F("[SX1278] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
// radio.scanChannel();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
volatile bool receivedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we got a packet, set the flag
|
||||
receivedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the flag is set
|
||||
if(receivedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
receivedFlag = false;
|
||||
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[SX1278] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[SX1278] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
Serial.print(F("[SX1278] RSSI:\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print SNR (Signal-to-Noise Ratio)
|
||||
Serial.print(F("[SX1278] SNR:\t\t"));
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
// print frequency error
|
||||
Serial.print(F("[SX1278] Frequency error:\t"));
|
||||
Serial.print(radio.getFrequencyError());
|
||||
Serial.println(F(" Hz"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("[SX1278] CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("[SX1278] Failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// put module back to listen mode
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
RadioLib SX127x Settings Example
|
||||
|
||||
This example shows how to change all the properties of LoRa transmission.
|
||||
RadioLib currently supports the following settings:
|
||||
- pins (SPI slave select, digital IO 0, digital IO 1)
|
||||
- carrier frequency
|
||||
- bandwidth
|
||||
- spreading factor
|
||||
- coding rate
|
||||
- sync word
|
||||
- output power during transmission
|
||||
|
||||
Other modules from SX127x/RFM9x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio1 = new Module(10, 2, 9, 3);
|
||||
|
||||
// SX1272 has different connections:
|
||||
// NSS pin: 9
|
||||
// DIO0 pin: 4
|
||||
// RESET pin: 5
|
||||
// DIO1 pin: 6
|
||||
SX1272 radio2 = new Module(9, 4, 5, 6);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1276 radio3 = RadioShield.ModuleB;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio1.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// initialize the second LoRa instance with
|
||||
// non-default settings
|
||||
// this LoRa link will have high data rate,
|
||||
// but lower range
|
||||
// NOTE: when using spreading factor 6, the total packet
|
||||
// length has to be known in advance!
|
||||
// you have to pass the number of expected bytes
|
||||
// to the receive() method
|
||||
Serial.print(F("[SX1272] Initializing ... "));
|
||||
// carrier frequency: 915.0 MHz
|
||||
// bandwidth: 500.0 kHz
|
||||
// spreading factor: 6
|
||||
// coding rate: 5
|
||||
// sync word: 0x14
|
||||
// output power: 2 dBm
|
||||
// preamble length: 20 symbols
|
||||
// amplifier gain: 1 (maximum gain)
|
||||
state = radio2.begin(915.0, 500.0, 6, 5, 0x14, 2, 20, 1);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// you can also change the settings at runtime
|
||||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 433.5 MHz
|
||||
if (radio1.setFrequency(433.5) == RADIOLIB_ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bandwidth to 250 kHz
|
||||
if (radio1.setBandwidth(250.0) == RADIOLIB_ERR_INVALID_BANDWIDTH) {
|
||||
Serial.println(F("Selected bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set spreading factor to 10
|
||||
if (radio1.setSpreadingFactor(10) == RADIOLIB_ERR_INVALID_SPREADING_FACTOR) {
|
||||
Serial.println(F("Selected spreading factor is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set coding rate to 6
|
||||
if (radio1.setCodingRate(6) == RADIOLIB_ERR_INVALID_CODING_RATE) {
|
||||
Serial.println(F("Selected coding rate is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set LoRa sync word to 0x14
|
||||
// NOTE: value 0x34 is reserved for LoRaWAN networks and should not be used
|
||||
if (radio1.setSyncWord(0x14) != RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("Unable to set sync word!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set output power to 10 dBm (accepted range is -3 - 17 dBm)
|
||||
// NOTE: 20 dBm value allows high power operation, but transmission
|
||||
// duty cycle MUST NOT exceed 1%
|
||||
if (radio1.setOutputPower(10) == RADIOLIB_ERR_INVALID_OUTPUT_POWER) {
|
||||
Serial.println(F("Selected output power is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set over current protection limit to 80 mA (accepted range is 45 - 240 mA)
|
||||
// NOTE: set value to 0 to disable overcurrent protection
|
||||
if (radio1.setCurrentLimit(80) == RADIOLIB_ERR_INVALID_CURRENT_LIMIT) {
|
||||
Serial.println(F("Selected current limit is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set LoRa preamble length to 15 symbols (accepted range is 6 - 65535)
|
||||
if (radio1.setPreambleLength(15) == RADIOLIB_ERR_INVALID_PREAMBLE_LENGTH) {
|
||||
Serial.println(F("Selected preamble length is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set amplifier gain to 1 (accepted range is 1 - 6, where 1 is maximum gain)
|
||||
// NOTE: set value to 0 to enable automatic gain control
|
||||
// leave at 0 unless you know what you're doing
|
||||
if (radio1.setGain(1) == RADIOLIB_ERR_INVALID_GAIN) {
|
||||
Serial.println(F("Selected gain is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
Serial.println(F("All settings successfully changed!"));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// nothing here
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
RadioLib SX127x Transmit Example
|
||||
|
||||
This example transmits packets using SX1278 LoRa radio module.
|
||||
Each packet contains up to 256 bytes of data, in the form of:
|
||||
- Arduino String
|
||||
- null-terminated char array (C-string)
|
||||
- arbitrary binary data (byte array)
|
||||
|
||||
Other modules from SX127x/RFM9x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// 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);
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[SX1278] Transmitting packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
// NOTE: transmit() is a blocking method!
|
||||
// See example SX127x_Transmit_Interrupt for details
|
||||
// on non-blocking transmission method.
|
||||
int state = radio.transmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 256 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F(" success!"));
|
||||
|
||||
// print measured data rate
|
||||
Serial.print(F("[SX1278] 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);
|
||||
}
|
|
@ -0,0 +1,182 @@
|
|||
/*
|
||||
RadioLib SX127x Transmit with Frequency Hopping Example
|
||||
|
||||
This example transmits packets using SX1278 LoRa radio module.
|
||||
Each packet contains up to 256 bytes of data, in the form of:
|
||||
- Arduino String
|
||||
- null-terminated char array (C-string)
|
||||
- arbitrary binary data (byte array)
|
||||
|
||||
Other modules from SX127x/RFM9x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
|
||||
SX127x supports FHSS or Frequency Hopping Spread Spectrum.
|
||||
Once a hopping period is set and a transmission is started, the radio
|
||||
will begin triggering interrupts every hop period where the radio frequency
|
||||
is changed to the next channel.
|
||||
*/
|
||||
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
volatile bool transmittedFlag = false;
|
||||
|
||||
// flag to indicate frequency must be changed
|
||||
volatile bool fhssChangeFlag = false;
|
||||
|
||||
// the channel frequencies can be generated randomly or hard coded
|
||||
// NOTE: The frequency list MUST be the same on both sides!
|
||||
float channels[] = { 433.0, 433.4, 433.2, 433.6, 434.0, 433.8 };
|
||||
int numberOfChannels = sizeof(channels) / sizeof(float);
|
||||
|
||||
// counter to keep track of how many frequency hops were performed
|
||||
int hopsCompleted = 0;
|
||||
|
||||
// counter that increments with each sent packet
|
||||
int packetCounter = 0;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
// this is the packet that will be sent
|
||||
String longPacket = "Let's create a really long packet to trigger \
|
||||
lots of hop interrupts. A packet can be up to 256 bytes long. \
|
||||
This packet is 222 bytes so using sf = 9, bw = 125, timeOnAir is \
|
||||
1488ms. 1488ms / (9*4.10ms) = 40 hops. Counter: ";
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setTxFlag(void) {
|
||||
transmittedFlag = true;
|
||||
}
|
||||
|
||||
// this function is called when FhssChangeChannel interrupt occurs
|
||||
// (at the beginning of each transmission)
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFHSSFlag(void) {
|
||||
fhssChangeFlag = true;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// begin radio on home channel
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin(channels[0]);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set hop period in symbols
|
||||
// this will also enable FHSS
|
||||
state = radio.setFHSSHoppingPeriod(9);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function to call when transmission is finished
|
||||
radio.setDio0Action(setTxFlag);
|
||||
|
||||
// set the function to call when we need to hcange frequency
|
||||
radio.setDio1Action(setFHSSFlag);
|
||||
|
||||
// start transmitting the first packet
|
||||
Serial.print(F("[SX1278] Sending first packet ... "));
|
||||
String packet = longPacket + packetCounter;
|
||||
transmissionState = radio.startTransmit(packet);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the transmission flag is set
|
||||
if (transmittedFlag == true) {
|
||||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(transmissionState);
|
||||
|
||||
}
|
||||
|
||||
// The channel is automatically reset to 0 upon completion
|
||||
Serial.print(F("[SX1278] Radio is on channel: "));
|
||||
Serial.println(radio.getFHSSChannel());
|
||||
|
||||
// print the number of hops it took
|
||||
Serial.print(F("[SX1278] Hops completed: "));
|
||||
Serial.println(hopsCompleted);
|
||||
|
||||
// reset the counter
|
||||
hopsCompleted = 0;
|
||||
|
||||
// return to home channel before the next transaction
|
||||
radio.setFrequency(channels[radio.getFHSSChannel() % numberOfChannels]);
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
// increment the packet counter
|
||||
packetCounter++;
|
||||
|
||||
// send another packet
|
||||
Serial.print(F("[SX1278] Sending another packet ... "));
|
||||
String packet = longPacket + packetCounter;
|
||||
transmissionState = radio.startTransmit(packet);
|
||||
}
|
||||
|
||||
// check if we need to do another frequency hop
|
||||
if (fhssChangeFlag == true) {
|
||||
// we do, change it now
|
||||
int state = radio.setFrequency(channels[radio.getFHSSChannel() % numberOfChannels]);
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("[SX1278] Failed to change frequency, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// increment the counter
|
||||
hopsCompleted++;
|
||||
|
||||
// clear the FHSS interrupt
|
||||
radio.clearFHSSInt();
|
||||
|
||||
// we're ready to do another hop, clear the flag
|
||||
fhssChangeFlag = false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
RadioLib SX127x Transmit with Interrupts Example
|
||||
|
||||
This example transmits LoRa packets with one second delays
|
||||
between them. Each packet contains up to 256 bytes
|
||||
of data, in the form of:
|
||||
- Arduino String
|
||||
- null-terminated char array (C-string)
|
||||
- arbitrary binary data (byte array)
|
||||
|
||||
Other modules from SX127x/RFM9x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
radio.setDio0Action(setFlag);
|
||||
|
||||
// start transmitting the first packet
|
||||
Serial.print(F("[SX1278] Sending first packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 256 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was sent
|
||||
volatile bool transmittedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we sent a packet, set the flag
|
||||
transmittedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the previous transmission finished
|
||||
if(transmittedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
// NOTE: when using interrupt-driven transmit method,
|
||||
// it is not possible to automatically measure
|
||||
// transmission data rate using getDataRate()
|
||||
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(transmissionState);
|
||||
|
||||
}
|
||||
|
||||
// clean up after transmission is finished
|
||||
// this will ensure transmitter is disabled,
|
||||
// RF switch is powered down etc.
|
||||
radio.finishTransmit();
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
// send another one
|
||||
Serial.print(F("[SX1278] Sending another packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 256 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
// we're ready to send more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
RadioLib SX128x BLE Modem Example
|
||||
|
||||
This example shows how to use BLE modem in SX128x chips.
|
||||
RadioLib does not provide BLE protocol support (yet),
|
||||
only compatibility with the physical layer.
|
||||
|
||||
NOTE: The sketch below is just a guide on how to use
|
||||
BLE modem, so this code should not be run directly!
|
||||
Instead, modify the other examples to use BLE
|
||||
modem and use the appropriate configuration
|
||||
methods.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---ble-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1280 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.beginBLE();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// if needed, you can switch between any of the modems
|
||||
//
|
||||
// radio.begin() start LoRa modem (and disable BLE)
|
||||
// radio.beginBLE() start BLE modem (and disable LoRa)
|
||||
|
||||
// the following settings can also
|
||||
// be modified at run-time
|
||||
state = radio.setFrequency(2410.5);
|
||||
state = radio.setBitRate(250);
|
||||
state = radio.setFrequencyDeviation(100.0);
|
||||
state = radio.setOutputPower(5);
|
||||
state = radio.setDataShaping(1.0);
|
||||
state = radio.setAccessAddress(0x12345678);
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("Unable to set configuration, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
#warning "This sketch is just an API guide! Read the note at line 6."
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// BLE modem can use the same transmit/receive methods
|
||||
// as the LoRa modem, even their interrupt-driven versions
|
||||
|
||||
// transmit BLE packet
|
||||
int state = radio.transmit("Hello World!");
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Packet transmitted successfully!"));
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
Serial.println(F("[SX1280] Packet too long!"));
|
||||
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
|
||||
Serial.println(F("[SX1280] Timed out while transmitting!"));
|
||||
} else {
|
||||
Serial.print(F("[SX1280] Failed to transmit packet, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// receive BLE packet
|
||||
String str;
|
||||
state = radio.receive(str);
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Received packet!"));
|
||||
Serial.print(F("[SX1280] Data:\t"));
|
||||
Serial.println(str);
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
Serial.println(F("[SX1280] Timed out while waiting for packet!"));
|
||||
} else {
|
||||
Serial.print(F("[SX1280] Failed to receive packet, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
RadioLib SX128x Channel Activity Detection Example
|
||||
|
||||
This example uses SX1280 to scan the current LoRa
|
||||
channel and detect ongoing LoRa transmissions.
|
||||
|
||||
Other modules from SX128x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1280 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[SX1280] Scanning channel for LoRa transmission ... "));
|
||||
|
||||
// start scanning current channel
|
||||
int state = radio.scanChannel();
|
||||
|
||||
if (state == RADIOLIB_LORA_DETECTED) {
|
||||
// LoRa preamble was detected
|
||||
Serial.println(F("detected!"));
|
||||
|
||||
} else if (state == RADIOLIB_CHANNEL_FREE) {
|
||||
// no preamble was detected, channel is free
|
||||
Serial.println(F("channel is free!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// wait 100 ms before new scan
|
||||
delay(100);
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
RadioLib SX128x FLRC Modem Example
|
||||
|
||||
This example shows how to use FLRC modem in SX128x chips.
|
||||
|
||||
NOTE: The sketch below is just a guide on how to use
|
||||
FLRC modem, so this code should not be run directly!
|
||||
Instead, modify the other examples to use FLRC
|
||||
modem and use the appropriate configuration
|
||||
methods.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---flrc-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1280 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.beginFLRC();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// if needed, you can switch between any of the modems
|
||||
//
|
||||
// radio.begin() start LoRa modem (and disable FLRC)
|
||||
// radio.beginFLRC() start FLRC modem (and disable LoRa)
|
||||
|
||||
// the following settings can also
|
||||
// be modified at run-time
|
||||
state = radio.setFrequency(2410.5);
|
||||
state = radio.setBitRate(520);
|
||||
state = radio.setCodingRate(2);
|
||||
state = radio.setOutputPower(5);
|
||||
state = radio.setDataShaping(1.0);
|
||||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67};
|
||||
state = radio.setSyncWord(syncWord, 4);
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("Unable to set configuration, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
#warning "This sketch is just an API guide! Read the note at line 6."
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// FLRC modem can use the same transmit/receive methods
|
||||
// as the LoRa modem, even their interrupt-driven versions
|
||||
|
||||
// transmit FLRC packet
|
||||
int state = radio.transmit("Hello World!");
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Packet transmitted successfully!"));
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
Serial.println(F("[SX1280] Packet too long!"));
|
||||
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
|
||||
Serial.println(F("[SX1280] Timed out while transmitting!"));
|
||||
} else {
|
||||
Serial.println(F("[SX1280] Failed to transmit packet, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// receive FLRC packet
|
||||
String str;
|
||||
state = radio.receive(str);
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Received packet!"));
|
||||
Serial.print(F("[SX1280] Data:\t"));
|
||||
Serial.println(str);
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
Serial.println(F("[SX1280] Timed out while waiting for packet!"));
|
||||
} else {
|
||||
Serial.print(F("[SX1280] Failed to receive packet, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
RadioLib SX128x GFSK Modem Example
|
||||
|
||||
This example shows how to use GFSK modem in SX128x chips.
|
||||
|
||||
NOTE: The sketch below is just a guide on how to use
|
||||
GFSK modem, so this code should not be run directly!
|
||||
Instead, modify the other examples to use GFSK
|
||||
modem and use the appropriate configuration
|
||||
methods.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---gfsk-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1280 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.beginGFSK();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// if needed, you can switch between any of the modems
|
||||
//
|
||||
// radio.begin() start LoRa modem (and disable GFSK)
|
||||
// radio.beginGFSK() start GFSK modem (and disable LoRa)
|
||||
|
||||
// the following settings can also
|
||||
// be modified at run-time
|
||||
state = radio.setFrequency(2410.5);
|
||||
state = radio.setBitRate(200);
|
||||
state = radio.setFrequencyDeviation(100.0);
|
||||
state = radio.setOutputPower(5);
|
||||
state = radio.setDataShaping(RADIOLIB_SHAPING_1_0);
|
||||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89};
|
||||
state = radio.setSyncWord(syncWord, 5);
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Serial.print(F("Unable to set configuration, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
#warning "This sketch is just an API guide! Read the note at line 6."
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// GFSK modem can use the same transmit/receive methods
|
||||
// as the LoRa modem, even their interrupt-driven versions
|
||||
|
||||
// transmit GFSK packet
|
||||
int state = radio.transmit("Hello World!");
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Packet transmitted successfully!"));
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
Serial.println(F("[SX1280] Packet too long!"));
|
||||
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
|
||||
Serial.println(F("[SX1280] Timed out while transmitting!"));
|
||||
} else {
|
||||
Serial.println(F("[SX1280] Failed to transmit packet, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// receive GFSK packet
|
||||
String str;
|
||||
state = radio.receive(str);
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Received packet!"));
|
||||
Serial.print(F("[SX1280] Data:\t"));
|
||||
Serial.println(str);
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
Serial.println(F("[SX1280] Timed out while waiting for packet!"));
|
||||
} else {
|
||||
Serial.print(F("[SX1280] Failed to receive packet, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
RadioLib SX128x Ranging Example
|
||||
|
||||
This example performs ranging exchange between two
|
||||
SX1280 LoRa radio modules. Ranging allows to measure
|
||||
distance between the modules using time-of-flight
|
||||
measurement.
|
||||
|
||||
Only SX1280 and SX1282 support ranging!
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1280 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[SX1280] Ranging ... "));
|
||||
|
||||
// start ranging exchange
|
||||
// range as master: true
|
||||
// slave address: 0x12345678
|
||||
int state = radio.range(true, 0x12345678);
|
||||
|
||||
// the other module must be configured as slave with the same address
|
||||
/*
|
||||
int state = radio.range(false, 0x12345678);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// ranging finished successfully
|
||||
Serial.println(F("success!"));
|
||||
Serial.print(F("[SX1280] Distance:\t\t\t"));
|
||||
Serial.print(radio.getRangingResult());
|
||||
Serial.println(F(" meters"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_RANGING_TIMEOUT) {
|
||||
// timed out waiting for ranging packet
|
||||
Serial.println(F("timed out!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// wait for a second before ranging again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
RadioLib SX128x Receive Example
|
||||
|
||||
This example listens for LoRa transmissions using SX126x Lora modules.
|
||||
To successfully receive data, the following settings have to be the same
|
||||
on both transmitter and receiver:
|
||||
- carrier frequency
|
||||
- bandwidth
|
||||
- spreading factor
|
||||
- coding rate
|
||||
- sync word
|
||||
- preamble length
|
||||
|
||||
Other modules from SX128x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1280 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[SX1280] Waiting for incoming transmission ... "));
|
||||
|
||||
// you can receive data as an Arduino String
|
||||
// NOTE: receive() is a blocking method!
|
||||
// See example ReceiveInterrupt for details
|
||||
// on non-blocking reception method.
|
||||
String str;
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
// print the data of the packet
|
||||
Serial.print(F("[SX1280] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print the RSSI (Received Signal Strength Indicator)
|
||||
// of the last received packet
|
||||
Serial.print(F("[SX1280] RSSI:\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print the SNR (Signal-to-Noise Ratio)
|
||||
// of the last received packet
|
||||
Serial.print(F("[SX1280] SNR:\t\t"));
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
// print the Frequency Error
|
||||
// of the last received packet
|
||||
Serial.print(F("[SX1280] Frequency Error:\t"));
|
||||
Serial.print(radio.getFrequencyError());
|
||||
Serial.println(F(" Hz"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
RadioLib SX128x Receive with Interrupts Example
|
||||
|
||||
This example listens for LoRa transmissions and tries to
|
||||
receive them. Once a packet is received, an interrupt is
|
||||
triggered. To successfully receive data, the following
|
||||
settings have to be the same on both transmitter
|
||||
and receiver:
|
||||
- carrier frequency
|
||||
- bandwidth
|
||||
- spreading factor
|
||||
- coding rate
|
||||
- sync word
|
||||
|
||||
Other modules from SX128x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1280 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
radio.setDio1Action(setFlag);
|
||||
|
||||
// start listening for LoRa packets
|
||||
Serial.print(F("[SX1280] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
// radio.scanChannel();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
volatile bool receivedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we got a packet, set the flag
|
||||
receivedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the flag is set
|
||||
if(receivedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
receivedFlag = false;
|
||||
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[SX1280] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[SX1280] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
Serial.print(F("[SX1280] RSSI:\t\t"));
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print SNR (Signal-to-Noise Ratio)
|
||||
Serial.print(F("[SX1280] SNR:\t\t"));
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
// print the Frequency Error
|
||||
// of the last received packet
|
||||
Serial.print(F("[SX1280] Frequency Error:\t"));
|
||||
Serial.print(radio.getFrequencyError());
|
||||
Serial.println(F(" Hz"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// put module back to listen mode
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
RadioLib SX128x Settings Example
|
||||
|
||||
This example shows how to change all the properties of LoRa transmission.
|
||||
RadioLib currently supports the following settings:
|
||||
- pins (SPI slave select, DIO1, DIO2, BUSY pin)
|
||||
- carrier frequency
|
||||
- bandwidth
|
||||
- spreading factor
|
||||
- coding rate
|
||||
- output power during transmission
|
||||
- CRC
|
||||
- preamble length
|
||||
|
||||
Other modules from SX128x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1280 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 radio1 = new Module(10, 2, 3, 9);
|
||||
|
||||
// SX1280 has the following connections:
|
||||
// NSS pin: 8
|
||||
// DIO1 pin: 4
|
||||
// NRST pin: 5
|
||||
// BUSY pin: 6
|
||||
SX1281 radio2 = new Module(8, 4, 5, 6);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1282 radio3 = RadioShield.ModuleB;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio1.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// initialize the second LoRa instance with
|
||||
// non-default settings
|
||||
// this LoRa link will have high data rate,
|
||||
// but lower range
|
||||
Serial.print(F("[SX1281] Initializing ... "));
|
||||
// carrier frequency: 2450.0 MHz
|
||||
// bandwidth: 1625.0 kHz
|
||||
// spreading factor: 7
|
||||
// coding rate: 5
|
||||
// output power: 2 dBm
|
||||
// preamble length: 20 symbols
|
||||
state = radio2.begin(2450.0, 1625.0, 7, 5, 2, 20);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// you can also change the settings at runtime
|
||||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 2410.5 MHz
|
||||
if (radio1.setFrequency(2410.5) == RADIOLIB_ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bandwidth to 203.125 kHz
|
||||
if (radio1.setBandwidth(203.125) == RADIOLIB_ERR_INVALID_BANDWIDTH) {
|
||||
Serial.println(F("Selected bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set spreading factor to 10
|
||||
if (radio1.setSpreadingFactor(10) == RADIOLIB_ERR_INVALID_SPREADING_FACTOR) {
|
||||
Serial.println(F("Selected spreading factor is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set coding rate to 6
|
||||
if (radio1.setCodingRate(6) == RADIOLIB_ERR_INVALID_CODING_RATE) {
|
||||
Serial.println(F("Selected coding rate is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set output power to -2 dBm
|
||||
if (radio1.setOutputPower(-2) == RADIOLIB_ERR_INVALID_OUTPUT_POWER) {
|
||||
Serial.println(F("Selected output power is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set LoRa preamble length to 16 symbols (accepted range is 2 - 65535)
|
||||
if (radio1.setPreambleLength(16) == RADIOLIB_ERR_INVALID_PREAMBLE_LENGTH) {
|
||||
Serial.println(F("Selected preamble length is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// disable CRC
|
||||
if (radio1.setCRC(false) == RADIOLIB_ERR_INVALID_CRC_CONFIGURATION) {
|
||||
Serial.println(F("Selected CRC is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
Serial.println(F("All settings succesfully changed!"));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// nothing here
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
RadioLib SX128x Transmit Example
|
||||
|
||||
This example transmits packets using SX1280 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 SX128x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1280 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
// carrier frequency: 2400.0 MHz
|
||||
// bandwidth: 812.5 kHz
|
||||
// spreading factor: 9
|
||||
// coding rate: 7
|
||||
// output power: 10 dBm
|
||||
// preamble length: 12 symbols
|
||||
// CRC: enabled
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// 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);
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[SX1280] Transmitting packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
// NOTE: transmit() is a blocking method!
|
||||
// See example SX128x_Transmit_Interrupt for details
|
||||
// on non-blocking transmission method.
|
||||
int state = radio.transmit("Hello World!");
|
||||
|
||||
// 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!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 256 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
RadioLib SX128x Transmit with Interrupts Example
|
||||
|
||||
This example transmits LoRa packets with one second delays
|
||||
between them. 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 SX128x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1280 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
radio.setDio1Action(setFlag);
|
||||
|
||||
// start transmitting the first packet
|
||||
Serial.print(F("[SX1280] Sending first packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 256 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was sent
|
||||
volatile bool transmittedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we sent a packet, set the flag
|
||||
transmittedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the previous transmission finished
|
||||
if(transmittedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
} 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("[SX1280] Sending another packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 256 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
// we're ready to send more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
RadioLib Si443x Receive Example
|
||||
|
||||
This example receives packets using Si443x FSK radio module.
|
||||
To successfully receive data, the following settings have to be the same
|
||||
on both transmitter and receiver:
|
||||
- carrier frequency
|
||||
- bit rate
|
||||
- frequency deviation
|
||||
- sync word
|
||||
|
||||
Other modules from Si443x/RFM2x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#si443xrfm2x
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// Si4432 has the following connections:
|
||||
// nSEL pin: 10
|
||||
// nIRQ pin: 2
|
||||
// SDN pin: 9
|
||||
Si4432 radio = new Module(10, 2, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//Si4432 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize Si4432 with default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[Si4432] Waiting for incoming transmission ... "));
|
||||
|
||||
// you can receive data as an Arduino String
|
||||
String str;
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
// print the data of the packet
|
||||
Serial.print(F("[Si4432] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
RadioLib Si443x Receive with Interrupts Example
|
||||
|
||||
This example listens for FSK transmissions and tries to
|
||||
receive them. Once a packet is received, an interrupt is
|
||||
triggered.
|
||||
|
||||
Other modules from Si443x/RFM2x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#si443xrfm2x
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// Si4432 has the following connections:
|
||||
// nSEL pin: 10
|
||||
// nIRQ pin: 2
|
||||
// SDN pin: 9
|
||||
Si4432 radio = new Module(10, 2, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//Si4432 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize Si4432 with default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
radio.setIrqAction(setFlag);
|
||||
|
||||
// start listening for packets
|
||||
Serial.print(F("[Si4432] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
volatile bool receivedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we got a packet, set the flag
|
||||
receivedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the flag is set
|
||||
if(receivedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
receivedFlag = false;
|
||||
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[Si4432] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[Si4432] Data:\t\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// put module back to listen mode
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
RadioLib Si443x Settings Example
|
||||
|
||||
This example shows how to change all the properties of RF69 radio.
|
||||
RadioLib currently supports the following settings:
|
||||
- pins (SPI slave select, nIRQ, shutdown)
|
||||
- carrier frequency
|
||||
- bit rate
|
||||
- receiver bandwidth
|
||||
- frequency deviation
|
||||
- output power during transmission
|
||||
- sync word
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#si443xrfm2x
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// Si4432 has the following connections:
|
||||
// nSEL pin: 10
|
||||
// nIRQ pin: 2
|
||||
// SDN pin: 9
|
||||
Si4432 radio1 = new Module(10, 2, 9);
|
||||
|
||||
// Si4432 has the following connections:
|
||||
// nSEL pin: 8
|
||||
// nIRQ pin: 3
|
||||
// SDN pin: 7
|
||||
Si4432 radio2 = new Module(8, 3, 7);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//Si4432 radio3 = RadioShield.ModuleB;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize Si4432 with default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
int state = radio1.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// initialize Si4432 with non-default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
// carrier frequency: 868.0 MHz
|
||||
// bit rate: 200.0 kbps
|
||||
// frequency deviation: 60.0 kHz
|
||||
// Rx bandwidth: 335.5 kHz
|
||||
// output power: 17 dBm
|
||||
// preamble length: 32 bits
|
||||
state = radio2.begin(868.0, 200.0, 60.0, 335.5, 17, 32);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// you can also change the settings at runtime
|
||||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 433.5 MHz
|
||||
if (radio1.setFrequency(433.5) == RADIOLIB_ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("[Si4432] Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bit rate to 100.0 kbps
|
||||
state = radio1.setBitRate(100.0);
|
||||
if (state == RADIOLIB_ERR_INVALID_BIT_RATE) {
|
||||
Serial.println(F("[Si4432] Selected bit rate is invalid for this module!"));
|
||||
while (true);
|
||||
} else if (state == RADIOLIB_ERR_INVALID_BIT_RATE_BW_RATIO) {
|
||||
Serial.println(F("[Si4432] Selected bit rate to bandwidth ratio is invalid!"));
|
||||
Serial.println(F("[Si4432] Increase receiver bandwidth to set this bit rate."));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set receiver bandwidth to 284.8 kHz
|
||||
state = radio1.setRxBandwidth(284.8);
|
||||
if (state == RADIOLIB_ERR_INVALID_RX_BANDWIDTH) {
|
||||
Serial.println(F("[Si4432] Selected receiver bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set frequency deviation to 10.0 kHz
|
||||
if (radio1.setFrequencyDeviation(10.0) == RADIOLIB_ERR_INVALID_FREQUENCY_DEVIATION) {
|
||||
Serial.println(F("[Si4432] Selected frequency deviation is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set output power to 2 dBm
|
||||
if (radio1.setOutputPower(2) == RADIOLIB_ERR_INVALID_OUTPUT_POWER) {
|
||||
Serial.println(F("[Si4432] Selected output power is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// up to 4 bytes can be set as sync word
|
||||
// set sync word to 0x01234567
|
||||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67};
|
||||
if (radio1.setSyncWord(syncWord, 4) == RADIOLIB_ERR_INVALID_SYNC_WORD) {
|
||||
Serial.println(F("[Si4432] Selected sync word is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
Serial.println(F("[Si4432] All settings changed successfully!"));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// nothing here
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
RadioLib Si443x Transmit Example
|
||||
|
||||
This example transmits packets using Si4432 FSK radio module.
|
||||
Each packet contains up to 64 bytes of data, in the form of:
|
||||
- Arduino String
|
||||
- null-terminated char array (C-string)
|
||||
- arbitrary binary data (byte array)
|
||||
|
||||
Other modules from Si443x/RFM2x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#si443xrfm2x
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// Si4432 has the following connections:
|
||||
// nSEL pin: 10
|
||||
// nIRQ pin: 2
|
||||
// SDN pin: 9
|
||||
Si4432 radio = new Module(10, 2, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//Si4432 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize Si4432 with default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[Si4432] Transmitting packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 64 characters long
|
||||
// NOTE: transmit() is a blocking method!
|
||||
// See example Si443x_Transmit_Interrupt for details
|
||||
// on non-blocking transmission method.
|
||||
int state = radio.transmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 64 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!"));
|
||||
|
||||
} 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 occured 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);
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
RadioLib Si443x Transmit with Interrupts Example
|
||||
|
||||
This example transmits packets using Si4432 FSK radio module.
|
||||
Each packet contains up to 64 bytes of data, in the form of:
|
||||
- Arduino String
|
||||
- null-terminated char array (C-string)
|
||||
- arbitrary binary data (byte array)
|
||||
|
||||
Other modules from Si443x/RFM2x family can also be used.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#si443xrfm2x
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// Si4432 has the following connections:
|
||||
// nSEL pin: 10
|
||||
// nIRQ pin: 2
|
||||
// SDN pin: 9
|
||||
Si4432 radio = new Module(10, 2, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//Si4432 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize Si4432 with default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
radio.setIrqAction(setFlag);
|
||||
|
||||
// start transmitting the first packet
|
||||
Serial.print(F("[Si4432] Sending first packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 64 characters long
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 64 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was sent
|
||||
volatile bool transmittedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we sent a packet, set the flag
|
||||
transmittedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the previous transmission finished
|
||||
if(transmittedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
} 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("[Si4432] Sending another packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 64 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
// we're ready to send more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
RadioLib Stream Receive Example
|
||||
|
||||
This example shows how to receive data in "Stream" mode.
|
||||
In this mode, arbitrary length of data may be sent, up to
|
||||
"infinite" continuous transmission between two devices.
|
||||
|
||||
Caveats:
|
||||
- CRC of the payload is not supported
|
||||
- the length of the payload must be known in advance
|
||||
|
||||
Modules that can be used for Stream are:
|
||||
- SX127x/RFM9x (FSK mode only)
|
||||
- RF69
|
||||
- SX1231
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for Stream transmit
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when receive buffer is full
|
||||
radio.setFifoFullAction(fifoGet);
|
||||
|
||||
// fixed packet length mode is required
|
||||
radio.fixedPacketLengthMode(0);
|
||||
|
||||
// start listening for packets
|
||||
Serial.print(F("[SX1278] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
// radio.scanChannel();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
volatile bool receivedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// how many bytes are there in total
|
||||
const int totalLength = 512;
|
||||
|
||||
// counter to keep track of how many bytes have been received so far
|
||||
volatile int receivedLength = 0;
|
||||
|
||||
// buffer to save the received data into
|
||||
volatile uint8_t rxBuffer[totalLength + 1];
|
||||
|
||||
// this function is called when the radio receive buffer
|
||||
// is full and ready to be read
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void fifoGet(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// set the flag when we receive the full packet
|
||||
receivedFlag = radio.fifoGet(rxBuffer, totalLength, &receivedLength);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the flag is set
|
||||
if(receivedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// packet was successfully received
|
||||
Serial.println(F("[SX1278] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[SX1278] Data:\t\t"));
|
||||
Serial.println((char*)rxBuffer);
|
||||
|
||||
// reset flag
|
||||
receivedFlag = false;
|
||||
receivedLength = 0;
|
||||
|
||||
// put module back to listen mode
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
RadioLib Stream Transmit Example
|
||||
|
||||
This example shows how to transmit data in "Stream" mode.
|
||||
In this mode, arbitrary length of data may be sent, up to
|
||||
"infinite" continuous transmission between two devices.
|
||||
|
||||
Caveats:
|
||||
- CRC of the payload is not supported
|
||||
- the length of the payload must be known in advance
|
||||
|
||||
Modules that can be used for Stream are:
|
||||
- SX127x/RFM9x (FSK mode only)
|
||||
- RF69
|
||||
- SX1231
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// SX1278 has the following connections:
|
||||
// NSS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
// this packet is much longer than would normally fit
|
||||
// into SX1278's internal buffer
|
||||
String longPacket = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\
|
||||
Maecenas at urna ut nunc imperdiet laoreet. Aliquam erat volutpat.\
|
||||
Etiam mattis mauris vitae posuere tincidunt. In sit amet bibendum nisl,\
|
||||
a ultrices lorem. Duis hendrerit ultricies condimentum. Phasellus eget nisi\
|
||||
eget massa aliquam bibendum. Pellentesque ante neque, aliquam non diam non,\
|
||||
fringilla facilisis ipsum. Morbi in molestie orci. Vestibulum luctus\
|
||||
venenatis arcu sit amet pellentesque. Nulla posuere sit amet turpis\
|
||||
id pharetra. Curabitur nec.";
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
int state = radio.beginFSK();
|
||||
|
||||
// when using one of the non-LoRa modules for Stream transmit
|
||||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when transmit buffer is empty
|
||||
radio.setFifoEmptyAction(fifoAdd);
|
||||
|
||||
// fixed packet length mode is required
|
||||
radio.fixedPacketLengthMode(0);
|
||||
|
||||
// start transmitting the long packet
|
||||
Serial.print(F("[SX1278] Sending a very long packet ... "));
|
||||
transmissionState = radio.startTransmit(longPacket);
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was sent
|
||||
volatile bool transmittedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// how many bytes are there in total
|
||||
volatile int totalLength = longPacket.length();
|
||||
|
||||
// counter to keep track of how many bytes still need to be sent
|
||||
volatile int remLength = totalLength;
|
||||
|
||||
// this function is called when the radio transmit buffer
|
||||
// is empty and ready to be refilled
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void fifoAdd(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add more bytes to the transmit buffer
|
||||
uint8_t* txBuffPtr = (uint8_t*)longPacket.c_str();
|
||||
transmittedFlag = radio.fifoAdd(txBuffPtr, totalLength, &remLength);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the previous transmission finished
|
||||
if(transmittedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
// reset the counter
|
||||
remLength = totalLength;
|
||||
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
// NOTE: when using interrupt-driven transmit method,
|
||||
// it is not possible to automatically measure
|
||||
// transmission data rate using getDataRate()
|
||||
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(transmissionState);
|
||||
|
||||
}
|
||||
|
||||
// NOTE: in FSK mode, SX127x will not automatically
|
||||
// turn transmitter off after sending a packet
|
||||
// set mode to standby to ensure we don't jam others
|
||||
radio.standby();
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
// send another one
|
||||
Serial.print(F("[SX1278] Sending another long packet ... "));
|
||||
transmissionState = radio.startTransmit(longPacket);
|
||||
|
||||
// we're ready to send more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
RadioLib nRF24 Receive Example
|
||||
|
||||
This example listens for FSK transmissions using nRF24 2.4 GHz radio module.
|
||||
To successfully receive data, the following settings have to be the same
|
||||
on both transmitter and receiver:
|
||||
- carrier frequency
|
||||
- data rate
|
||||
- transmit pipe on transmitter must match receive pipe
|
||||
on receiver
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#nrf24
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// nRF24 has the following connections:
|
||||
// CS pin: 10
|
||||
// IRQ pin: 2
|
||||
// CE pin: 3
|
||||
nRF24 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//nRF24 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize nRF24 with default settings
|
||||
Serial.print(F("[nRF24] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// set receive pipe 0 address
|
||||
// NOTE: address width in bytes MUST be equal to the
|
||||
// width set in begin() or setAddressWidth()
|
||||
// methods (5 by default)
|
||||
Serial.print(F("[nRF24] Setting address for receive pipe 0 ... "));
|
||||
byte addr[] = {0x01, 0x23, 0x45, 0x67, 0x89};
|
||||
state = radio.setReceivePipe(0, addr);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[nRF24] Waiting for incoming transmission ... "));
|
||||
|
||||
// you can receive data as an Arduino String
|
||||
// NOTE: receive() is a blocking method!
|
||||
// See example ReceiveInterrupt for details
|
||||
// on non-blocking reception method.
|
||||
String str;
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
// print the data of the packet
|
||||
Serial.print(F("[nRF24] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
RadioLib nRF24 Receive Example
|
||||
|
||||
This example listens for FSK transmissions using nRF24 2.4 GHz radio module.
|
||||
Once a packet is received, an interrupt is triggered.
|
||||
To successfully receive data, the following settings have to be the same
|
||||
on both transmitter and receiver:
|
||||
- carrier frequency
|
||||
- data rate
|
||||
- transmit pipe on transmitter must match receive pipe
|
||||
on receiver
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#nrf24
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// nRF24 has the following connections:
|
||||
// CS pin: 10
|
||||
// IRQ pin: 2
|
||||
// CE pin: 3
|
||||
nRF24 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//nRF24 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize nRF24 with default settings
|
||||
Serial.print(F("[nRF24] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// set receive pipe 0 address
|
||||
// NOTE: address width in bytes MUST be equal to the
|
||||
// width set in begin() or setAddressWidth()
|
||||
// methods (5 by default)
|
||||
Serial.print(F("[nRF24] Setting address for receive pipe 0 ... "));
|
||||
byte addr[] = {0x01, 0x23, 0x45, 0x67, 0x89};
|
||||
state = radio.setReceivePipe(0, addr);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
radio.setIrqAction(setFlag);
|
||||
|
||||
// start listening
|
||||
Serial.print(F("[nRF24] Starting to listen ... "));
|
||||
state = radio.startReceive();
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while (true);
|
||||
}
|
||||
|
||||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
volatile bool receivedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is received by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we got a packet, set the flag
|
||||
receivedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the flag is set
|
||||
if(receivedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
receivedFlag = false;
|
||||
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[nRF24] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[nRF24] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else {
|
||||
// some other error occurred
|
||||
Serial.print(F("[nRF24] Failed, code "));
|
||||
Serial.println(state);
|
||||
|
||||
}
|
||||
|
||||
// put module back to listen mode
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
RadioLib nRF24 Transmit Example
|
||||
|
||||
This example transmits packets using nRF24 2.4 GHz radio module.
|
||||
Each packet contains up to 32 bytes of data, in the form of:
|
||||
- Arduino String
|
||||
- null-terminated char array (C-string)
|
||||
- arbitrary binary data (byte array)
|
||||
|
||||
Packet delivery is automatically acknowledged by the receiver.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#nrf24
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// nRF24 has the following connections:
|
||||
// CS pin: 10
|
||||
// IRQ pin: 2
|
||||
// CE pin: 3
|
||||
nRF24 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//nRF24 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize nRF24 with default settings
|
||||
Serial.print(F("[nRF24] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// set transmit address
|
||||
// NOTE: address width in bytes MUST be equal to the
|
||||
// width set in begin() or setAddressWidth()
|
||||
// methods (5 by default)
|
||||
byte addr[] = {0x01, 0x23, 0x45, 0x67, 0x89};
|
||||
Serial.print(F("[nRF24] Setting transmit pipe ... "));
|
||||
state = radio.setTransmitPipe(addr);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("[nRF24] Transmitting packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 32 characters long
|
||||
int state = radio.transmit("Hello World!");
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 32 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_ACK_NOT_RECEIVED) {
|
||||
// acknowledge from destination module
|
||||
// was not received within 15 retries
|
||||
Serial.println(F("ACK not received!"));
|
||||
|
||||
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
|
||||
// timed out while transmitting
|
||||
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);
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
RadioLib nRF24 Transmit with Interrupts Example
|
||||
|
||||
This example transmits packets using nRF24 2.4 GHz radio module.
|
||||
Each packet contains up to 32 bytes of data, in the form of:
|
||||
- Arduino String
|
||||
- null-terminated char array (C-string)
|
||||
- arbitrary binary data (byte array)
|
||||
|
||||
Packet delivery is automatically acknowledged by the receiver.
|
||||
|
||||
For default module settings, see the wiki page
|
||||
https://github.com/jgromes/RadioLib/wiki/Default-configuration#nrf24
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
*/
|
||||
|
||||
// include the library
|
||||
#include <RadioLib.h>
|
||||
|
||||
// nRF24 has the following connections:
|
||||
// CS pin: 10
|
||||
// IRQ pin: 2
|
||||
// CE pin: 3
|
||||
nRF24 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//nRF24 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = RADIOLIB_ERR_NONE;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize nRF24 with default settings
|
||||
Serial.print(F("[nRF24] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// set transmit address
|
||||
// NOTE: address width in bytes MUST be equal to the
|
||||
// width set in begin() or setAddressWidth()
|
||||
// methods (5 by default)
|
||||
byte addr[] = {0x01, 0x23, 0x45, 0x67, 0x89};
|
||||
Serial.print(F("[nRF24] Setting transmit pipe ... "));
|
||||
state = radio.setTransmitPipe(addr);
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
while(true);
|
||||
}
|
||||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
radio.setIrqAction(setFlag);
|
||||
|
||||
// start transmitting the first packet
|
||||
Serial.print(F("[nRF24] Sending first packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 256 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was sent
|
||||
volatile bool transmittedFlag = false;
|
||||
|
||||
// disable interrupt when it's not needed
|
||||
volatile bool enableInterrupt = true;
|
||||
|
||||
// this function is called when a complete packet
|
||||
// is transmitted by the module
|
||||
// IMPORTANT: this function MUST be 'void' type
|
||||
// and MUST NOT have any arguments!
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ICACHE_RAM_ATTR
|
||||
#endif
|
||||
void setFlag(void) {
|
||||
// check if the interrupt is enabled
|
||||
if(!enableInterrupt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we sent a packet, set the flag
|
||||
transmittedFlag = true;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// check if the previous transmission finished
|
||||
if(transmittedFlag) {
|
||||
// disable the interrupt service routine while
|
||||
// processing the data
|
||||
enableInterrupt = false;
|
||||
|
||||
// reset flag
|
||||
transmittedFlag = false;
|
||||
|
||||
if (transmissionState == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully sent
|
||||
Serial.println(F("transmission finished!"));
|
||||
|
||||
// NOTE: when using interrupt-driven transmit method,
|
||||
// it is not possible to automatically measure
|
||||
// transmission data rate using getDataRate()
|
||||
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(transmissionState);
|
||||
|
||||
}
|
||||
|
||||
// clean up after transmission is finished
|
||||
// this will ensure transmitter is disabled,
|
||||
// RF switch is powered down etc.
|
||||
radio.finishTransmit();
|
||||
|
||||
// wait a second before transmitting again
|
||||
delay(1000);
|
||||
|
||||
// send another one
|
||||
Serial.print(F("[nRF24] Sending another packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = radio.startTransmit("Hello World!");
|
||||
|
||||
// you can also transmit byte array up to 256 bytes long
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
// we're ready to send more packets,
|
||||
// enable interrupt service routine
|
||||
enableInterrupt = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
import re, sys, argparse
|
||||
from pathlib import Path
|
||||
from argparse import RawTextHelpFormatter
|
||||
|
||||
|
||||
'''
|
||||
TODO list:
|
||||
1. Parse macro values (the names of bits in all registers in header file)
|
||||
2. Failed SPI write handling
|
||||
3. SX126x/SX128x handling
|
||||
'''
|
||||
|
||||
|
||||
def get_macro_name(value, macros):
|
||||
for macro in macros:
|
||||
if macro[1] == value:
|
||||
return macro[0]
|
||||
return 'UNKNOWN_VALUE'
|
||||
|
||||
|
||||
def get_macro_value(value):
|
||||
return ' 0x{0:02X}\n'.format(int(value, 16))
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(formatter_class=RawTextHelpFormatter, description='''
|
||||
RadioLib debug output decoder script. Turns RadioLib Serial dumps into readable text.
|
||||
|
||||
Step-by-step guid on how to use the decoder:
|
||||
1. Uncomment lines 312 (#define RADIOLIB_DEBUG) and 313 (#define RADIOLIB_VERBOSE) in RadioLib/src/BuildOpt.h
|
||||
2. Recompile and upload the failing Arduino sketch
|
||||
3. Open Arduino IDE Serial Monitor and enable timestamps
|
||||
4. Copy the Serial output and save it into a .txt file
|
||||
5. Run this script
|
||||
|
||||
Output will be saved in the file specified by --out and printed to the terminal
|
||||
''')
|
||||
parser.add_argument('file', metavar='file', type=str, help='Text file of the debug output')
|
||||
parser.add_argument('--out', metavar='out', default='./out.txt', type=str, help='Where to save the decoded file (defaults to ./out.txt)')
|
||||
args = parser.parse_args()
|
||||
|
||||
# open the log file
|
||||
log = open(args.file, 'r').readlines()
|
||||
|
||||
# find modules that are in use
|
||||
used_modules = []
|
||||
pattern_module = re.compile('(([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?.[0-9]{3} -> )?M\t')
|
||||
for entry in log:
|
||||
m = pattern_module.search(entry)
|
||||
if m != None:
|
||||
used_modules.append(entry[m.end():].rstrip())
|
||||
|
||||
# get paths to all relevant header files
|
||||
header_files = []
|
||||
for path in Path('../../src').rglob('*.h'):
|
||||
for module in used_modules:
|
||||
if module in path.name:
|
||||
header_files.append(path)
|
||||
|
||||
# extract names of address macros from the header files
|
||||
macro_addresses = []
|
||||
pattern_define = re.compile('#define \w* +\w*(\n| +\/\/){1}')
|
||||
for path in header_files:
|
||||
file = open(path, 'r').readlines()
|
||||
for line in file:
|
||||
m = pattern_define.search(line)
|
||||
if m != None:
|
||||
s = re.split(' +', m.group().rstrip())
|
||||
if (s.__len__() > 1) and ('_REG' in s[1]):
|
||||
macro_addresses.append([s[1], int(s[2], 0)])
|
||||
|
||||
'''
|
||||
# extract names of value macros for each adddress macro
|
||||
macro_values = []
|
||||
for path in header_files:
|
||||
file = open(path, 'r').readlines()
|
||||
for line in file:
|
||||
for module in used_modules:
|
||||
pattern_addr_macro = re.compile('\/\/ SI443X_REG_\w+'.format(module.capitalize()))
|
||||
'''
|
||||
|
||||
# parse every line in the log file
|
||||
out = []
|
||||
pattern_debug = re.compile('(([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?.[0-9]{3} -> )?[RWM]\t.+')
|
||||
for entry in log:
|
||||
m = pattern_debug.search(entry)
|
||||
if m != None:
|
||||
s = re.split('( |\t)+', entry.rstrip())
|
||||
cmd_len = int((s.__len__() - 7)/2)
|
||||
new_entry = s[0] + s[1] + s[2] + s[3]
|
||||
if s[4] == 'W':
|
||||
macro_address = int(s[6], 16)
|
||||
new_entry += 'write {0:>2} 0x{1:02X} {2}\n'.format(cmd_len, macro_address, get_macro_name(macro_address, macro_addresses))
|
||||
for i in range(cmd_len):
|
||||
new_entry += get_macro_value(s[8 + 2*i]);
|
||||
elif s[4] == 'R':
|
||||
macro_address = int(s[6], 16)
|
||||
new_entry += 'read {0:>2} 0x{1:02X} {2}\n'.format(cmd_len, macro_address, get_macro_name(macro_address, macro_addresses))
|
||||
for i in range(cmd_len):
|
||||
new_entry += get_macro_value(s[8 + 2*i]);
|
||||
elif s[4] == 'M':
|
||||
new_entry += 'module {}\n'.format(s[6])
|
||||
out.append(new_entry)
|
||||
else:
|
||||
out.append(entry)
|
||||
|
||||
# write the output file
|
||||
out_file = open(args.out, 'w')
|
||||
for line in out:
|
||||
print(line, end='')
|
||||
out_file.write(line)
|
||||
out_file.close()
|
|
@ -0,0 +1,22 @@
|
|||
#include "<module_name>.h"
|
||||
#if !defined(RADIOLIB_EXCLUDE_<module_name>)
|
||||
|
||||
<module_name>::<module_name>(Module* mod) {
|
||||
/*
|
||||
Constructor implementation MUST assign the provided "mod" pointer to the private "_mod" pointer.
|
||||
*/
|
||||
_mod = mod;
|
||||
}
|
||||
|
||||
int16_t <module_name>::begin() {
|
||||
/*
|
||||
"begin" method implementation MUST call the "init" method with appropriate settings.
|
||||
*/
|
||||
_mod->init();
|
||||
|
||||
/*
|
||||
"begin" method SHOULD implement some sort of mechanism to verify the connection between Arduino and the module.
|
||||
|
||||
For example, reading a version register
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
RadioLib Module Template header file
|
||||
|
||||
Before opening pull request, please make sure that:
|
||||
1. All files MUST be compiled without errors using default Arduino IDE settings.
|
||||
2. All files SHOULD be compiled without warnings with compiler warnings set to "All".
|
||||
3. Example sketches MUST be working correctly and MUST be stable enough to run for prolonged periods of time.
|
||||
4. Writing style SHOULD be consistent.
|
||||
5. Comments SHOULD be in place for the most important chunks of code and SHOULD be free of typos.
|
||||
6. To indent, 2 spaces MUST be used.
|
||||
|
||||
If at any point you are unsure about the required style, please refer to the rest of the modules.
|
||||
*/
|
||||
|
||||
#if !defined(_RADIOLIB_<module_name>_H) && !defined(RADIOLIB_EXCLUDE_<module_name>)
|
||||
#if !defined(_RADIOLIB_<module_name>_H)
|
||||
#define _RADIOLIB_<module_name>_H
|
||||
|
||||
/*
|
||||
Header file for each module MUST include Module.h and TypeDef.h in the src folder.
|
||||
The header file MAY include additional header files.
|
||||
*/
|
||||
#include "../../Module.h"
|
||||
#include "../../TypeDef.h"
|
||||
|
||||
/*
|
||||
Only use the following include if the module implements methods for OSI physical layer control.
|
||||
This concerns only modules similar to SX127x/RF69/CC1101 etc.
|
||||
|
||||
In this case, your class MUST implement all virtual methods of PhysicalLayer class.
|
||||
*/
|
||||
//#include "../../protocols/PhysicalLayer/PhysicalLayer.h"
|
||||
|
||||
/*
|
||||
Register map
|
||||
Definition of SPI register map SHOULD be placed here. The register map SHOULD have two parts:
|
||||
|
||||
1 - Address map: only defines register names and addresses. Register names MUST match names in
|
||||
official documentation (datasheets etc.).
|
||||
2 - Variable map: defines variables inside register. This functions as a bit range map for a specific register.
|
||||
Bit range (MSB and LSB) as well as short description for each variable MUST be provided in a comment.
|
||||
|
||||
See RF69 and SX127x header files for examples of register maps.
|
||||
*/
|
||||
// <module_name> register map | spaces up to this point
|
||||
#define RADIOLIB_<module_name>_REG_<register_name> 0x00
|
||||
|
||||
// <module_name>_REG_<register_name> MSB LSB DESCRIPTION
|
||||
#define RADIOLIB_<module_name>_<register_variable> 0b00000000 // 7 0 <description>
|
||||
|
||||
|
||||
/*
|
||||
Module class definition
|
||||
|
||||
The module class MAY inherit from the following classes:
|
||||
|
||||
1 - PhysicalLayer: In case the module implements methods for OSI physical layer control (e.g. SX127x).
|
||||
2 - Common class: In case the module further specifies some more generic class (e.g. SX127x/SX1278)
|
||||
*/
|
||||
class <module_name> {
|
||||
public:
|
||||
/*
|
||||
Constructor MUST have only one parameter "Module* mod".
|
||||
The class MAY implement additional overloaded constructors.
|
||||
*/
|
||||
// constructor
|
||||
<module_name>(Module* mod);
|
||||
|
||||
/*
|
||||
The class MUST implement at least one basic method called "begin".
|
||||
The "begin" method MUST initialize the module and return the status as int16_t type.
|
||||
*/
|
||||
// basic methods
|
||||
int16_t begin();
|
||||
|
||||
/*
|
||||
The class MAY implement additional methods.
|
||||
All implemented methods SHOULD return the status as int16_t type.
|
||||
*/
|
||||
|
||||
#if !defined(RADIOLIB_GODMODE)
|
||||
private:
|
||||
#endif
|
||||
/*
|
||||
The class MUST contain private member "Module* _mod"
|
||||
*/
|
||||
Module* _mod;
|
||||
|
||||
/*
|
||||
The class MAY contain additional private variables and/or methods.
|
||||
Private member variables MUST have a name prefixed with "_" (underscore, ASCII 0x5F)
|
||||
|
||||
Usually, these are variables for saving module configuration, or methods that do not have to be exposed to the end user.
|
||||
*/
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,340 @@
|
|||
#######################################
|
||||
# Syntax Coloring Map For RadioLib
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
RadioLib KEYWORD1
|
||||
RadioShield KEYWORD1
|
||||
Module KEYWORD1
|
||||
|
||||
# modules
|
||||
CC1101 KEYWORD1
|
||||
LLCC68 KEYWORD1
|
||||
nRF24 KEYWORD1
|
||||
RF69 KEYWORD1
|
||||
RFM22 KEYWORD1
|
||||
RFM23 KEYWORD1
|
||||
RFM95 KEYWORD1
|
||||
RFM96 KEYWORD1
|
||||
RFM97 KEYWORD1
|
||||
RFM98 KEYWORD1
|
||||
Si4430 KEYWORD1
|
||||
Si4431 KEYWORD1
|
||||
Si4432 KEYWORD1
|
||||
SIM800 KEYWORD1
|
||||
SX1231 KEYWORD1
|
||||
SX1261 KEYWORD1
|
||||
SX1262 KEYWORD1
|
||||
SX1268 KEYWORD1
|
||||
SX1272 KEYWORD1
|
||||
SX1273 KEYWORD1
|
||||
SX1276 KEYWORD1
|
||||
SX1277 KEYWORD1
|
||||
SX1278 KEYWORD1
|
||||
SX1279 KEYWORD1
|
||||
SX1280 KEYWORD1
|
||||
SX1281 KEYWORD1
|
||||
SX1282 KEYWORD1
|
||||
|
||||
# protocols
|
||||
RTTYClient KEYWORD1
|
||||
MorseClient KEYWORD1
|
||||
AX25Client KEYWORD1
|
||||
AX25Frame KEYWORD1
|
||||
SSTVClient KEYWORD1
|
||||
HellClient KEYWORD1
|
||||
AFSKClient KEYWORD1
|
||||
FSK4Client KEYWORD1
|
||||
APRSClient KEYWORD1
|
||||
PagerClient KEYWORD1
|
||||
|
||||
# SSTV modes
|
||||
Scottie1 KEYWORD1
|
||||
Scottie2 KEYWORD1
|
||||
ScottieDX KEYWORD1
|
||||
Martin1 KEYWORD1
|
||||
Martin2 KEYWORD1
|
||||
Wrasse KEYWORD1
|
||||
PasokonP3 KEYWORD1
|
||||
PasokonP5 KEYWORD1
|
||||
PasokonP7 KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
# RadioLib
|
||||
ModuleA KEYWORD2
|
||||
ModuleB KEYWORD2
|
||||
Module KEYWORD2
|
||||
|
||||
# SX127x/RFM9x + RF69 + CC1101
|
||||
begin KEYWORD2
|
||||
beginFSK KEYWORD2
|
||||
transmit KEYWORD2
|
||||
receive KEYWORD2
|
||||
scanChannel KEYWORD2
|
||||
sleep KEYWORD2
|
||||
standby KEYWORD2
|
||||
transmitDirect KEYWORD2
|
||||
receiveDirect KEYWORD2
|
||||
packetMode KEYWORD2
|
||||
setDio0Action KEYWORD2
|
||||
setDio1Action KEYWORD2
|
||||
clearDio0Action KEYWORD2
|
||||
clearDio1Action KEYWORD2
|
||||
startTransmit KEYWORD2
|
||||
finishTransmit KEYWORD2
|
||||
startReceive KEYWORD2
|
||||
readData KEYWORD2
|
||||
startChannelScan KEYWORD2
|
||||
getChannelScanResult KEYWORD2
|
||||
setBandwidth KEYWORD2
|
||||
setSpreadingFactor KEYWORD2
|
||||
setCodingRate KEYWORD2
|
||||
setFrequency KEYWORD2
|
||||
setSyncWord KEYWORD2
|
||||
setOutputPower KEYWORD2
|
||||
setCurrentLimit KEYWORD2
|
||||
setPreambleLength KEYWORD2
|
||||
setGain KEYWORD2
|
||||
getFrequencyError KEYWORD2
|
||||
getRSSI KEYWORD2
|
||||
getAFCError KEYWORD2
|
||||
getSNR KEYWORD2
|
||||
getDataRate KEYWORD2
|
||||
setBitRate KEYWORD2
|
||||
setRxBandwidth KEYWORD2
|
||||
setAFCBandwidth KEYWORD2
|
||||
setAFC KEYWORD2
|
||||
setAFCAGCTrigger KEYWORD2
|
||||
setFrequencyDeviation KEYWORD2
|
||||
setNodeAddress KEYWORD2
|
||||
setBroadcastAddress KEYWORD2
|
||||
disableAddressFiltering KEYWORD2
|
||||
setDataShaping KEYWORD2
|
||||
setOOK KEYWORD2
|
||||
setDataShapingOOK KEYWORD2
|
||||
setCRC KEYWORD2
|
||||
variablePacketLengthMode KEYWORD2
|
||||
fixedPacketLengthMode KEYWORD2
|
||||
setCrcFiltering KEYWORD2
|
||||
enableSyncWordFiltering KEYWORD2
|
||||
disableSyncWordFiltering KEYWORD2
|
||||
setPromiscuous KEYWORD2
|
||||
setRSSIConfig KEYWORD2
|
||||
setEncoding KEYWORD2
|
||||
getIRQFlags KEYWORD2
|
||||
getModemStatus KEYWORD2
|
||||
getTempRaw KEYWORD2
|
||||
setRfSwitchPins KEYWORD2
|
||||
forceLDRO KEYWORD2
|
||||
autoLDRO KEYWORD2
|
||||
getChipVersion KEYWORD2
|
||||
invertIQ KEYWORD2
|
||||
setOokThresholdType KEYWORD2
|
||||
setOokPeakThresholdDecrement KEYWORD2
|
||||
setOokFixedOrFloorThreshold KEYWORD2
|
||||
setOokPeakThresholdStep KEYWORD2
|
||||
setDirectSyncWord KEYWORD2
|
||||
setDirectAction KEYWORD2
|
||||
readBit KEYWORD2
|
||||
enableBitSync KEYWORD2
|
||||
disableBitSync KEYWORD2
|
||||
setFHSSHoppingPeriod KEYWORD2
|
||||
getFHSSHoppingPeriod KEYWORD2
|
||||
getFHSSChannel KEYWORD2
|
||||
clearFHSSInt KEYWORD2
|
||||
randomByte KEYWORD2
|
||||
getPacketLength KEYWORD2
|
||||
setFifoEmptyAction KEYWORD2
|
||||
clearFifoEmptyAction KEYWORD2
|
||||
setFifoFullAction KEYWORD2
|
||||
clearFifoFullAction KEYWORD2
|
||||
fifoAdd KEYWORD2
|
||||
fifoGet KEYWORD2
|
||||
|
||||
# RF69-specific
|
||||
setAESKey KEYWORD2
|
||||
enableAES KEYWORD2
|
||||
disableAES KEYWORD2
|
||||
getTemperature KEYWORD2
|
||||
setAmbientTemperature KEYWORD2
|
||||
setLnaTestBoost KEYWORD2
|
||||
setOokFixedThreshold KEYWORD2
|
||||
enableContinuousModeBitSync KEYWORD2
|
||||
disableContinuousModeBitSync KEYWORD2
|
||||
|
||||
# CC1101-specific
|
||||
getLQI KEYWORD2
|
||||
setGdo0Action KEYWORD2
|
||||
setGdo2Action KEYWORD2
|
||||
clearGdo0Action KEYWORD2
|
||||
clearGdo2Action KEYWORD2
|
||||
setCrcFiltering KEYWORD2
|
||||
|
||||
# SX126x-specific
|
||||
setTCXO KEYWORD2
|
||||
setDio2AsRfSwitch KEYWORD2
|
||||
getTimeOnAir KEYWORD2
|
||||
implicitHeader KEYWORD2
|
||||
explicitHeader KEYWORD2
|
||||
setSyncBits KEYWORD2
|
||||
setWhitening KEYWORD2
|
||||
startReceiveDutyCycle KEYWORD2
|
||||
startReceiveDutyCycleAuto KEYWORD2
|
||||
setRegulatorLDO KEYWORD2
|
||||
setRegulatorDCDC KEYWORD2
|
||||
getCurrentLimit KEYWORD2
|
||||
getIrqStatus KEYWORD2
|
||||
getLastError KEYWORD2
|
||||
|
||||
# nRF24
|
||||
setIrqAction KEYWORD2
|
||||
setAddressWidth KEYWORD2
|
||||
setTransmitPipe KEYWORD2
|
||||
setReceivePipe KEYWORD2
|
||||
disablePipe KEYWORD2
|
||||
getStatus KEYWORD2
|
||||
setAutoAck KEYWORD2
|
||||
|
||||
# RTTY
|
||||
idle KEYWORD2
|
||||
byteArr KEYWORD2
|
||||
|
||||
# Morse
|
||||
startSignal KEYWORD2
|
||||
|
||||
# AX.25
|
||||
setRepeaters KEYWORD2
|
||||
setRecvSequence KEYWORD2
|
||||
setSendSequence KEYWORD2
|
||||
sendFrame KEYWORD2
|
||||
setCorrection KEYWORD2
|
||||
|
||||
# SSTV
|
||||
sendHeader KEYWORD2
|
||||
sendLine KEYWORD2
|
||||
getPictureHeight KEYWORD2
|
||||
|
||||
# SX128x
|
||||
beginGFSK KEYWORD2
|
||||
beginFLRC KEYWORD2
|
||||
beginBLE KEYWORD2
|
||||
setAccessAddress KEYWORD2
|
||||
range KEYWORD2
|
||||
startRanging KEYWORD2
|
||||
getRangingResult KEYWORD2
|
||||
|
||||
# Hellschreiber
|
||||
printGlyph KEYWORD2
|
||||
setInversion KEYWORD2
|
||||
|
||||
# AFSK
|
||||
tone KEYWORD2
|
||||
noTone KEYWORD2
|
||||
|
||||
# APRS
|
||||
sendPosition KEYWORD2
|
||||
sendMicE KEYWORD2
|
||||
|
||||
# Pager
|
||||
sendTone KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
||||
RADIOLIB_NC LITERAL1
|
||||
RADIOLIB_VERSION LITERAL1
|
||||
|
||||
RADIOLIB_SHAPING_NONE LITERAL1
|
||||
RADIOLIB_SHAPING_0_3 LITERAL1
|
||||
RADIOLIB_SHAPING_0_5 LITERAL1
|
||||
RADIOLIB_SHAPING_0_7 LITERAL1
|
||||
RADIOLIB_SHAPING_1_0 LITERAL1
|
||||
|
||||
RADIOLIB_ENCODING_NRZ LITERAL1
|
||||
RADIOLIB_ENCODING_MANCHESTER LITERAL1
|
||||
RADIOLIB_ENCODING_WHITENING LITERAL1
|
||||
|
||||
RADIOLIB_BUILTIN_MODULE LITERAL1
|
||||
|
||||
RADIOLIB_MORSE_INTER_SYMBOL LITERAL1
|
||||
RADIOLIB_MORSE_CHAR_COMPLETE LITERAL1
|
||||
RADIOLIB_MORSE_WORD_COMPLETE LITERAL1
|
||||
|
||||
RADIOLIB_ERR_NONE LITERAL1
|
||||
RADIOLIB_ERR_UNKNOWN LITERAL1
|
||||
|
||||
RADIOLIB_ERR_CHIP_NOT_FOUND LITERAL1
|
||||
RADIOLIB_ERR_MEMORY_ALLOCATION_FAILED LITERAL1
|
||||
RADIOLIB_ERR_PACKET_TOO_LONG LITERAL1
|
||||
RADIOLIB_ERR_TX_TIMEOUT LITERAL1
|
||||
RADIOLIB_ERR_RX_TIMEOUT LITERAL1
|
||||
RADIOLIB_ERR_CRC_MISMATCH LITERAL1
|
||||
RADIOLIB_ERR_INVALID_BANDWIDTH LITERAL1
|
||||
RADIOLIB_ERR_INVALID_SPREADING_FACTOR LITERAL1
|
||||
RADIOLIB_ERR_INVALID_CODING_RATE LITERAL1
|
||||
RADIOLIB_ERR_INVALID_BIT_RANGE LITERAL1
|
||||
RADIOLIB_ERR_INVALID_FREQUENCY LITERAL1
|
||||
RADIOLIB_ERR_INVALID_OUTPUT_POWER LITERAL1
|
||||
RADIOLIB_PREAMBLE_DETECTED LITERAL1
|
||||
RADIOLIB_CHANNEL_FREE LITERAL1
|
||||
RADIOLIB_ERR_SPI_WRITE_FAILED LITERAL1
|
||||
RADIOLIB_ERR_INVALID_CURRENT_LIMIT LITERAL1
|
||||
RADIOLIB_ERR_INVALID_PREAMBLE_LENGTH LITERAL1
|
||||
RADIOLIB_ERR_INVALID_GAIN LITERAL1
|
||||
RADIOLIB_ERR_WRONG_MODEM LITERAL1
|
||||
RADIOLIB_ERR_INVALID_NUM_SAMPLES LITERAL1
|
||||
RADIOLIB_ERR_INVALID_RSSI_OFFSET LITERAL1
|
||||
RADIOLIB_ERR_INVALID_ENCODING LITERAL1
|
||||
|
||||
RADIOLIB_ERR_INVALID_BIT_RATE LITERAL1
|
||||
RADIOLIB_ERR_INVALID_FREQUENCY_DEVIATION LITERAL1
|
||||
RADIOLIB_ERR_INVALID_BIT_RATE_BW_RATIO LITERAL1
|
||||
RADIOLIB_ERR_INVALID_RX_BANDWIDTH LITERAL1
|
||||
RADIOLIB_ERR_INVALID_SYNC_WORD LITERAL1
|
||||
RADIOLIB_ERR_INVALID_DATA_SHAPING LITERAL1
|
||||
RADIOLIB_ERR_INVALID_MODULATION LITERAL1
|
||||
RADIOLIB_ERR_INVALID_OOK_RSSI_PEAK_TYPE LITERAL1
|
||||
|
||||
RADIOLIB_ERR_INVALID_SYMBOL LITERAL1
|
||||
RADIOLIB_ERR_INVALID_MIC_E_TELEMETRY LITERAL1
|
||||
RADIOLIB_ERR_INVALID_MIC_E_TELEMETRY_LENGTH LITERAL1
|
||||
RADIOLIB_ERR_MIC_E_TELEMETRY_STATUS LITERAL1
|
||||
|
||||
RADIOLIB_ASCII LITERAL1
|
||||
RADIOLIB_ASCII_EXTENDED LITERAL1
|
||||
RADIOLIB_ITA2 LITERAL1
|
||||
RADIOLIB_ERR_INVALID_RTTY_SHIFT LITERAL1
|
||||
RADIOLIB_ERR_UNSUPPORTED_ENCODING LITERAL1
|
||||
|
||||
RADIOLIB_ERR_INVALID_DATA_RATE LITERAL1
|
||||
RADIOLIB_ERR_INVALID_ADDRESS_WIDTH LITERAL1
|
||||
RADIOLIB_ERR_INVALID_PIPE_NUMBER LITERAL1
|
||||
RADIOLIB_ERR_ACK_NOT_RECEIVED LITERAL1
|
||||
|
||||
RADIOLIB_ERR_INVALID_NUM_BROAD_ADDRS LITERAL1
|
||||
|
||||
RADIOLIB_ERR_INVALID_CRC_CONFIGURATION LITERAL1
|
||||
RADIOLIB_LORA_DETECTED LITERAL1
|
||||
RADIOLIB_ERR_INVALID_TCXO_VOLTAGE LITERAL1
|
||||
RADIOLIB_ERR_INVALID_MODULATION_PARAMETERS LITERAL1
|
||||
RADIOLIB_ERR_SPI_CMD_TIMEOUT LITERAL1
|
||||
RADIOLIB_ERR_SPI_CMD_INVALID LITERAL1
|
||||
RADIOLIB_ERR_SPI_CMD_FAILED LITERAL1
|
||||
RADIOLIB_ERR_INVALID_SLEEP_PERIOD LITERAL1
|
||||
RADIOLIB_ERR_INVALID_RX_PERIOD LITERAL1
|
||||
|
||||
RADIOLIB_ERR_INVALID_CALLSIGN LITERAL1
|
||||
RADIOLIB_ERR_INVALID_NUM_REPEATERS LITERAL1
|
||||
RADIOLIB_ERR_INVALID_REPEATER_CALLSIGN LITERAL1
|
||||
|
||||
RADIOLIB_ERR_RANGING_TIMEOUT LITERAL1
|
||||
|
||||
RADIOLIB_ERR_INVALID_PAYLOAD LITERAL1
|
||||
RADIOLIB_ERR_ADDRESS_NOT_FOUND LITERAL1
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue