Merge branch 'master' into development
This commit is contained in:
commit
a84d38a93d
168 changed files with 5754 additions and 2520 deletions
3
.github/ISSUE_TEMPLATE/bug_report.md
vendored
3
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
@ -11,7 +11,7 @@ assignees: ''
|
|||
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: uncomment [debug macro definitions in BuildOpt.h](https://github.com/jgromes/RadioLib/blob/master/src/BuildOpt.h#L135) and post the output.
|
||||
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)).
|
||||
|
@ -24,6 +24,7 @@ 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]
|
||||
|
|
34
.github/ISSUE_TEMPLATE/module-not-working.md
vendored
Normal file
34
.github/ISSUE_TEMPLATE/module-not-working.md
vendored
Normal file
|
@ -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]
|
66
.github/workflows/codeql-analysis.yml
vendored
Normal file
66
.github/workflows/codeql-analysis.yml
vendored
Normal file
|
@ -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
|
26
.github/workflows/doxygen.yml
vendored
Normal file
26
.github/workflows/doxygen.yml
vendored
Normal file
|
@ -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
|
162
.github/workflows/main.yml
vendored
Normal file
162
.github/workflows/main.yml
vendored
Normal file
|
@ -0,0 +1,162 @@
|
|||
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
|
||||
- STM32:stm32:GenF3
|
||||
- stm32duino:STM32F1:mapleMini
|
||||
- MegaCoreX:megaavr:4809
|
||||
|
||||
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://www.adafruit.com/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://www.adafruit.com/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, 'STM32:stm32') }}" == "true" ]]; then
|
||||
# STM32 (official core)
|
||||
echo "::set-output name=options:::pnum=BLACKPILL_F303CC"
|
||||
echo "::set-output name=index-url::--additional-urls https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_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"
|
||||
|
||||
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
|
40
.gitignore
vendored
40
.gitignore
vendored
|
@ -1,42 +1,10 @@
|
|||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
# Arduino Library Development file
|
||||
.development
|
||||
|
||||
# Arduino testing sketches
|
||||
examples/test/
|
||||
|
||||
# Atom
|
||||
*.tags
|
||||
*.tags1
|
||||
|
||||
# Debug decoder
|
||||
extras/decoder/log.txt
|
||||
extras/decoder/out.txt
|
||||
|
|
95
.travis.yml
95
.travis.yml
|
@ -1,95 +0,0 @@
|
|||
env:
|
||||
global:
|
||||
- ARDUINO_IDE_VERSION="1.8.9"
|
||||
matrix:
|
||||
# see https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#options
|
||||
# and https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt
|
||||
- BOARD="esp32:esp32:esp32"
|
||||
- BOARD="STM32:stm32:GenF3:pnum=BLACKPILL_F303CC"
|
||||
- BOARD="esp8266:esp8266:generic:xtal=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,eesz=512K"
|
||||
# - BOARD="SparkFun:apollo3:amap3redboard"
|
||||
- BOARD="arduino:samd:arduino_zero_native"
|
||||
- BOARD="arduino:sam:arduino_due_x"
|
||||
- BOARD="arduino:avr:uno"
|
||||
- BOARD="arduino:avr:leonardo"
|
||||
- BOARD="arduino:avr:mega:cpu=atmega2560"
|
||||
|
||||
before_install:
|
||||
# install Arduino IDE
|
||||
- wget https://downloads.arduino.cc/arduino-$ARDUINO_IDE_VERSION-linux64.tar.xz
|
||||
- tar xf arduino-$ARDUINO_IDE_VERSION-linux64.tar.xz
|
||||
- mv arduino-$ARDUINO_IDE_VERSION $HOME/arduino-ide
|
||||
- export PATH=$PATH:$HOME/arduino-ide
|
||||
|
||||
# firewall Arduino IDE noise (https://github.com/per1234/arduino-ci-script/issues/1#issuecomment-504158113)
|
||||
- sudo iptables -P INPUT DROP
|
||||
- sudo iptables -P FORWARD DROP
|
||||
- sudo iptables -P OUTPUT ACCEPT
|
||||
- sudo iptables -A INPUT -i lo -j ACCEPT
|
||||
- sudo iptables -A OUTPUT -o lo -j ACCEPT
|
||||
- sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
|
||||
|
||||
# install 3rd party boards
|
||||
- arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json,https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json,https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json" --save-prefs 2>&1
|
||||
- if [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then
|
||||
arduino --install-boards esp8266:esp8266;
|
||||
export SKIP_PAT='(HTTP|MQTT).*ino';
|
||||
elif [[ "$BOARD" =~ "esp32:esp32:" ]]; then
|
||||
arduino --install-boards esp32:esp32;
|
||||
elif [[ "$BOARD" =~ "STM32:stm32:" ]]; then
|
||||
arduino --install-boards STM32:stm32;
|
||||
elif [[ "$BOARD" =~ "arduino:samd:" ]]; then
|
||||
arduino --install-boards arduino:samd;
|
||||
elif [[ "$BOARD" =~ "arduino:sam:" ]]; then
|
||||
arduino --install-boards arduino:sam;
|
||||
elif [[ "$BOARD" =~ "SparkFun:apollo3:" ]]; then
|
||||
arduino --install-boards SparkFun:apollo3;
|
||||
fi
|
||||
|
||||
# create directory to save the library and create symbolic link
|
||||
install:
|
||||
- mkdir -p $HOME/Arduino/libraries
|
||||
- ln -s $PWD $HOME/Arduino/libraries/RadioLib
|
||||
|
||||
# only build the master branch
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
script:
|
||||
# build all example sketches
|
||||
- |
|
||||
for example in $(find $PWD/examples -name '*.ino' | sort); do
|
||||
# check whether to skip this sketch
|
||||
if [ ! -z "$SKIP_PAT" ] && [[ ${example} =~ $SKIP_PAT ]]; then
|
||||
# skip sketch
|
||||
echo -e "\n\033[1;33mSkipped ${example##*/} (matched with $SKIP_PAT)\033[0m";
|
||||
else
|
||||
# build sketch
|
||||
echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m";
|
||||
arduino --verify --board $BOARD $example;
|
||||
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
|
||||
|
||||
# generate Doxygen documentation (only for Arduino UNO)
|
||||
- if [ $BOARD = "arduino:avr:uno" ]; then
|
||||
sudo apt-get update;
|
||||
sudo apt-get install -y doxygen;
|
||||
doxygen Doxyfile;
|
||||
fi
|
||||
|
||||
# deploy Doxygen docs on master branch and only when building for Arduino UNO
|
||||
deploy:
|
||||
provider: pages
|
||||
skip_cleanup: true
|
||||
local_dir: docs/html
|
||||
github_token: $GH_REPO_TOKEN
|
||||
on:
|
||||
branch: master
|
||||
condition: $BOARD = "arduino:avr:uno"
|
3
CODE_OF_CONDUCT.md
Normal file
3
CODE_OF_CONDUCT.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Code of Conduct
|
||||
|
||||
Don't be an a*shole.
|
68
README.md
68
README.md
|
@ -1,3 +1,5 @@
|
|||
# RadioLib 
|
||||
|
||||
### _One radio library to rule them all!_
|
||||
|
||||
## Universal wireless communication library for Arduino
|
||||
|
@ -26,41 +28,65 @@ RadioLib was originally created as a driver for [__RadioShield__](https://github
|
|||
* __XBee__ modules (S2B)
|
||||
|
||||
### Supported protocols and digital modes:
|
||||
* __MQTT__ for modules: ESP8266
|
||||
* __HTTP__ for modules: ESP8266
|
||||
* __AX.25__ for modules: SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, RFM2x and Si443x
|
||||
* [__RTTY__](https://www.sigidwiki.com/wiki/RTTY) for modules: SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x
|
||||
* [__Morse Code__](https://www.sigidwiki.com/wiki/Morse_Code_(CW)) for modules: SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x
|
||||
* [__SSTV__](https://www.sigidwiki.com/wiki/SSTV) for modules: SX127x, RFM9x, SX126x, RF69 and SX1231
|
||||
* [__Hellschreiber__](https://www.sigidwiki.com/wiki/Hellschreiber) for modules: SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x
|
||||
* __MQTT__ for modules:
|
||||
ESP8266
|
||||
* __HTTP__ for modules:
|
||||
ESP8266
|
||||
* __AX.25__ 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
|
||||
|
||||
### Supported platforms:
|
||||
* __Arduino AVR__ - tested with hardware on Uno, Mega and Leonardo
|
||||
* __ESP8266__ - tested with hardware on NodeMCU and Wemos D1
|
||||
* __ESP32__ - tested with hardware on ESP-WROOM-32
|
||||
* __STM32__ - tested with hardware on Nucleo L452RE-P
|
||||
* __Arduino SAMD__ - Arduino Zero, Arduino MKR boards, M0 Pro etc.
|
||||
* __Arduino SAM__ - Arduino Due
|
||||
* __Adafruit nRF52__ - Adafruit Bluefruit Feather etc.
|
||||
* _Intel Curie_ - Arduino 101
|
||||
* _Arduino megaAVR_ - Arduino Uno WiFi Rev.2 etc.
|
||||
* _Apollo3_ - SparkFun Artemis Redboard etc.
|
||||
* _Arduino nRF52_ - Arduino Nano 33 BLE
|
||||
* __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.
|
||||
|
||||
The list above is by no means exhaustive. Most of RadioLib code is independent of the used platform, so as long as your board is running some Arduino-compatible core, RadioLib should work. Compilation of all examples is tested for all platforms in __bold__ on each git push. Platforms in _italic_ are not tested on each push, but do compile and should be working.
|
||||
* __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.)
|
||||
|
||||
The list above is by no means exhaustive. Most of RadioLib code is independent of the used platform, so as long as your board is running some Arduino-compatible core, RadioLib should work. Compilation of all examples is tested for all platforms prior to releasing new version.
|
||||
|
||||
### In development:
|
||||
* __SIM800C__ GSM module
|
||||
* __LoRaWAN__ protocol for SX127x, RFM9x and SX126x modules
|
||||
* __APRS__ protocol for all the modules that can transmit AX.25
|
||||
* ___and more!___
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
### 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. Also, you should check out [RadioShield](https://github.com/jgromes/RadioShield) - open source Arduino shield that will allow you to easily connect any two wireless modules supported by RadioLib!
|
||||
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?assignees=&labels=&template=bug_report.md&title=) 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.
|
||||
The fastest way to get help is by creating an [issue](https://github.com/jgromes/RadioLib/issues/new/choose) using the appropriate template. It is also highly recommended to try running the examples first - their functionality is tested from time to time and they should work. Finally, RadioLib is still under development, which means that sometimes, backwards-incompatible changes might be introduced. Though these are kept at minimum, sometimes it is unavoidable. You can check the [release changelog](https://github.com/jgromes/RadioLib/releases) to find out if there's been such a major change recently.
|
||||
|
||||
### RadioLib doesn't support my module! What should I do?
|
||||
Start by creating new issue (if it doesn't exist yet). If you have some experience with Arduino and C/C++ in general, you can try to add the support yourself! Use the template files in `/extras/` folder to get started. This is by far the fastest way to implement new modules into RadioLib, since I can't be working on everything all the time. If you don't trust your programming skills enough to have a go at it yourself, don't worry. I will try to implement all requested modules, but it will take me a while.
|
||||
|
|
5
SECURITY.md
Normal file
5
SECURITY.md
Normal file
|
@ -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.
|
94
examples/AFSK/AFSK_Imperial_March/AFSK_Imperial_March.ino
Normal file
94
examples/AFSK/AFSK_Imperial_March/AFSK_Imperial_March.ino
Normal file
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
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 == 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);
|
||||
}
|
128
examples/AFSK/AFSK_Imperial_March/melody.h
Normal file
128
examples/AFSK/AFSK_Imperial_March/melody.h
Normal file
|
@ -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,
|
||||
|
||||
};
|
77
examples/AFSK/AFSK_Tone/AFSK_Tone.ino
Normal file
77
examples/AFSK/AFSK_Tone/AFSK_Tone.ino
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
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 == 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
|
||||
audio.tone(400);
|
||||
delay(1000);
|
||||
|
||||
// silence
|
||||
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.
|
||||
}
|
|
@ -19,6 +19,12 @@
|
|||
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
|
||||
|
@ -29,14 +35,14 @@
|
|||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 fsk = new Module(10, 2, 9, 3);
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 fsk = RadioShield.ModuleA;
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AX.25 client instance using the FSK module
|
||||
AX25Client ax25(&fsk);
|
||||
AX25Client ax25(&radio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
@ -44,13 +50,13 @@ void setup() {
|
|||
// initialize SX1278
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 1.2 kbps (1200 baud AFSK AX.25)
|
||||
// frequency deviation: 0.5 kHz (1200 baud AFSK AX.25)
|
||||
int state = fsk.beginFSK(434.0, 1.2, 0.5);
|
||||
// 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 = fsk.begin();
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
|
|
|
@ -12,6 +12,12 @@
|
|||
- 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
|
||||
|
@ -22,14 +28,14 @@
|
|||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 fsk = new Module(10, 2, 9, 3);
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 fsk = RadioShield.ModuleA;
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create AX.25 client instance using the FSK module
|
||||
AX25Client ax25(&fsk);
|
||||
AX25Client ax25(&radio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
@ -37,13 +43,13 @@ void setup() {
|
|||
// initialize SX1278
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 1.2 kbps (1200 baud AFSK AX.25)
|
||||
// frequency deviation: 0.5 kHz (1200 baud AFSK AX.25)
|
||||
int state = fsk.beginFSK(434.0, 1.2, 0.5);
|
||||
// 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 = fsk.begin();
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
|
|
97
examples/AX25/AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino
Normal file
97
examples/AX25/AX25_Transmit_AFSK/AX25_Transmit_AFSK.ino
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
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 == 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 == 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 == 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);
|
||||
}
|
|
@ -9,6 +9,9 @@
|
|||
- 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/
|
||||
*/
|
||||
|
@ -21,23 +24,18 @@
|
|||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//CC1101 cc = RadioShield.ModuleA;
|
||||
//CC1101 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
// carrier frequency: 868.0 MHz
|
||||
// bit rate: 4.8 kbps
|
||||
// frequency deviation: 48.0 kHz
|
||||
// Rx bandwidth: 325.0 kHz
|
||||
// sync word: 0xD391
|
||||
int state = cc.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -52,12 +50,12 @@ void loop() {
|
|||
|
||||
// you can receive data as an Arduino String
|
||||
String str;
|
||||
int state = cc.receive(str);
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = cc.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
@ -71,13 +69,13 @@ void loop() {
|
|||
// print RSSI (Received Signal Strength Indicator)
|
||||
// of the last received packet
|
||||
Serial.print(F("[CC1101] RSSI:\t\t"));
|
||||
Serial.print(cc.getRSSI());
|
||||
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(cc.getLQI());
|
||||
Serial.println(radio.getLQI());
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
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/
|
||||
*/
|
||||
|
@ -19,23 +22,18 @@
|
|||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//CC1101 cc = RadioShield.ModuleA;
|
||||
//CC1101 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
// carrier frequency: 868.0 MHz
|
||||
// bit rate: 4.8 kbps
|
||||
// frequency deviation: 48.0 kHz
|
||||
// Rx bandwidth: 325.0 kHz
|
||||
// sync word: 0xD391
|
||||
int state = cc.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -52,7 +50,7 @@ void setup() {
|
|||
// When setting two broadcast addresses, 0x00 and
|
||||
// 0xFF will be used.
|
||||
Serial.print(F("[CC1101] Setting node address ... "));
|
||||
state = cc.setNodeAddress(0x01, 1);
|
||||
state = radio.setNodeAddress(0x01, 1);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -66,7 +64,7 @@ void setup() {
|
|||
// set node address
|
||||
/*
|
||||
Serial.print(F("[CC1101] Disabling address filtering ... "));
|
||||
state == cc.disableAddressFiltering();
|
||||
state == radio.disableAddressFiltering();
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -82,12 +80,12 @@ void loop() {
|
|||
|
||||
// you can receive data as an Arduino String
|
||||
String str;
|
||||
int state = cc.receive(str);
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = cc.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
@ -101,13 +99,13 @@ void loop() {
|
|||
// print RSSI (Received Signal Strength Indicator)
|
||||
// of the last received packet
|
||||
Serial.print(F("[CC1101] RSSI:\t\t"));
|
||||
Serial.print(cc.getRSSI());
|
||||
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(cc.getLQI());
|
||||
Serial.println(radio.getLQI());
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
|
|
|
@ -12,8 +12,11 @@
|
|||
- frequency deviation
|
||||
- sync word
|
||||
|
||||
For full API reference, see the GitHub Pages
|
||||
https://jgromes.github.io/RadioLib/
|
||||
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
|
||||
|
@ -24,23 +27,18 @@
|
|||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
CC1101 cc = new Module(5, 2, RADIOLIB_NC, 3);
|
||||
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//CC1101 cc = RadioShield.ModuleA;
|
||||
//CC1101 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
// carrier frequency: 868.0 MHz
|
||||
// bit rate: 4.8 kbps
|
||||
// frequency deviation: 48.0 kHz
|
||||
// Rx bandwidth: 325.0 kHz
|
||||
// sync word: 0xD391
|
||||
int state = cc.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -51,11 +49,11 @@ void setup() {
|
|||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
cc.setGdo0Action(setFlag);
|
||||
radio.setGdo0Action(setFlag);
|
||||
|
||||
// start listening for packets
|
||||
Serial.print(F("[CC1101] Starting to listen ... "));
|
||||
state = cc.startReceive();
|
||||
state = radio.startReceive();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -67,11 +65,11 @@ void setup() {
|
|||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// cc.standby()
|
||||
// cc.sleep()
|
||||
// cc.transmit();
|
||||
// cc.receive();
|
||||
// cc.readData();
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
|
@ -105,36 +103,33 @@ void loop() {
|
|||
receivedFlag = false;
|
||||
|
||||
// you can read received data as an Arduino String
|
||||
//String str;
|
||||
//int state = cc.readData(str);
|
||||
String str;
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = cc.readData(byteArr, 8);
|
||||
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("[CC1101] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.println(F("[CC1101] Data:\t\t"));
|
||||
//Serial.println(str);
|
||||
for(uint8_t i = 0; i < 8; i++) {
|
||||
Serial.println(byteArr[i], HEX);
|
||||
}
|
||||
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(cc.getRSSI());
|
||||
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(cc.getLQI());
|
||||
Serial.println(radio.getLQI());
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
|
@ -148,7 +143,7 @@ void loop() {
|
|||
}
|
||||
|
||||
// put module back to listen mode
|
||||
cc.startReceive();
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
- 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/
|
||||
*/
|
||||
|
@ -23,30 +26,25 @@
|
|||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
CC1101 cc1 = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
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 cc2 = new Module(9, 4, RADIOLIB_NC, 53);
|
||||
CC1101 radio2 = new Module(9, 4, RADIOLIB_NC, 53);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//CC1101 cc3 = RadioShield.ModuleB;
|
||||
//CC1101 radio3 = RadioShield.ModuleB;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
// carrier frequency: 868.0 MHz
|
||||
// bit rate: 4.8 kbps
|
||||
// frequency deviation: 48.0 kHz
|
||||
// Rx bandwidth: 325.0 kHz
|
||||
// sync word: 0xD391
|
||||
int state = cc1.begin();
|
||||
int state = radio1.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -61,8 +59,9 @@ void setup() {
|
|||
// bit rate: 32.0 kbps
|
||||
// frequency deviation: 60.0 kHz
|
||||
// Rx bandwidth: 250.0 kHz
|
||||
// sync word: 0xD391
|
||||
state = cc2.begin(434.0, 32.0, 60.0, 250.0);
|
||||
// output power: 7 dBm
|
||||
// preamble length: 32 bits
|
||||
state = radio2.begin(434.0, 32.0, 60.0, 250.0, 7, 32);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -75,13 +74,13 @@ void setup() {
|
|||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 433.5 MHz
|
||||
if (cc1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||
if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("[CC1101] Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bit rate to 100.0 kbps
|
||||
state = cc1.setBitRate(100.0);
|
||||
state = radio1.setBitRate(100.0);
|
||||
if (state == ERR_INVALID_BIT_RATE) {
|
||||
Serial.println(F("[CC1101] Selected bit rate is invalid for this module!"));
|
||||
while (true);
|
||||
|
@ -92,25 +91,25 @@ void setup() {
|
|||
}
|
||||
|
||||
// set receiver bandwidth to 250.0 kHz
|
||||
if (cc1.setRxBandwidth(250.0) == ERR_INVALID_RX_BANDWIDTH) {
|
||||
if (radio1.setRxBandwidth(250.0) == 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 (cc1.setFrequencyDeviation(10.0) == ERR_INVALID_FREQUENCY_DEVIATION) {
|
||||
if (radio1.setFrequencyDeviation(10.0) == 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 (cc1.setOutputPower(5) == ERR_INVALID_OUTPUT_POWER) {
|
||||
if (radio1.setOutputPower(5) == 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 (cc1.setSyncWord(0x01, 0x23) == ERR_INVALID_SYNC_WORD) {
|
||||
if (radio1.setSyncWord(0x01, 0x23) == ERR_INVALID_SYNC_WORD) {
|
||||
Serial.println(F("[CC1101] Selected sync word is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
- 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/
|
||||
*/
|
||||
|
@ -19,23 +22,18 @@
|
|||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//CC1101 cc = RadioShield.ModuleA;
|
||||
//CC1101 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize CC1101
|
||||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
// carrier frequency: 868.0 MHz
|
||||
// bit rate: 4.8 kbps
|
||||
// frequency deviation: 48.0 kHz
|
||||
// Rx bandwidth: 325.0 kHz
|
||||
// sync word: 0xD391
|
||||
int state = cc.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -49,12 +47,12 @@ void loop() {
|
|||
Serial.print(F("[CC1101] Transmitting packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to 63 characters long
|
||||
int state = cc.transmit("Hello World!");
|
||||
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 = cc.transmit(byteArr, 8);
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
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/
|
||||
*/
|
||||
|
@ -19,23 +22,18 @@
|
|||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//CC1101 cc = RadioShield.ModuleA;
|
||||
//CC1101 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
// carrier frequency: 868.0 MHz
|
||||
// bit rate: 4.8 kbps
|
||||
// frequency deviation: 48.0 kHz
|
||||
// Rx bandwidth: 325.0 kHz
|
||||
// sync word: 0xD391
|
||||
int state = cc.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -52,7 +50,7 @@ void setup() {
|
|||
// When setting two broadcast addresses, 0x00 and
|
||||
// 0xFF will be used.
|
||||
Serial.print(F("[CC1101] Setting node address ... "));
|
||||
state = cc.setNodeAddress(0x01, 1);
|
||||
state = radio.setNodeAddress(0x01, 1);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -66,7 +64,7 @@ void setup() {
|
|||
// set node address
|
||||
/*
|
||||
Serial.print(F("[CC1101] Disabling address filtering ... "));
|
||||
state == cc.disableAddressFiltering();
|
||||
state == radio.disableAddressFiltering();
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -81,12 +79,12 @@ void loop() {
|
|||
Serial.print(F("[CC1101] Transmitting packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to 63 characters long
|
||||
int state = cc.transmit("Hello World!");
|
||||
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 = cc.transmit(byteArr, 8);
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
- 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/
|
||||
*/
|
||||
|
@ -20,11 +23,11 @@
|
|||
// GDO0 pin: 2
|
||||
// RST pin: unused
|
||||
// GDO2 pin: 3 (optional)
|
||||
CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//CC1101 cc = RadioShield.ModuleA;
|
||||
//CC1101 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = ERR_NONE;
|
||||
|
@ -34,12 +37,7 @@ void setup() {
|
|||
|
||||
// initialize CC1101 with default settings
|
||||
Serial.print(F("[CC1101] Initializing ... "));
|
||||
// carrier frequency: 868.0 MHz
|
||||
// bit rate: 4.8 kbps
|
||||
// frequency deviation: 48.0 kHz
|
||||
// Rx bandwidth: 325.0 kHz
|
||||
// sync word: 0xD391
|
||||
int state = cc.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -50,20 +48,20 @@ void setup() {
|
|||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
cc.setGdo0Action(setFlag);
|
||||
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 = cc.startTransmit("Hello World!");
|
||||
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 = cc.startTransmit(byteArr, 8);
|
||||
state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -119,13 +117,13 @@ void loop() {
|
|||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = cc.startTransmit("Hello World!");
|
||||
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 = cc.startTransmit(byteArr, 8);
|
||||
int state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
// we're ready to send more packets,
|
||||
|
|
|
@ -13,6 +13,12 @@
|
|||
- 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
|
||||
|
@ -23,32 +29,25 @@
|
|||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 fsk = new Module(10, 2, 9, 3);
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 fsk = RadioShield.ModuleA;
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create Hellschreiber client instance using the FSK module
|
||||
HellClient hell(&fsk);
|
||||
HellClient hell(&radio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// output power: 13 dBm
|
||||
// current limit: 100 mA
|
||||
// sync word: 0x2D 0x01
|
||||
int state = fsk.beginFSK();
|
||||
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 = fsk.begin();
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
|
@ -106,7 +105,7 @@ void loop() {
|
|||
float f = -3.1415;
|
||||
hell.println(f, 3);
|
||||
|
||||
// custom glyph - must be a 7 byte array of rows 7 pixels long
|
||||
// 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);
|
||||
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
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 == 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 == 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);
|
||||
}
|
|
@ -13,6 +13,12 @@
|
|||
- 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
|
||||
|
@ -23,32 +29,25 @@
|
|||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 fsk = new Module(10, 2, 9, 3);
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 fsk = RadioShield.ModuleA;
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create Morse client instance using the FSK module
|
||||
MorseClient morse(&fsk);
|
||||
MorseClient morse(&radio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// output power: 13 dBm
|
||||
// current limit: 100 mA
|
||||
// sync word: 0x2D 0x01
|
||||
int state = fsk.beginFSK();
|
||||
|
||||
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 = fsk.begin();
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
|
|
120
examples/Morse/Morse_Transmit_AFSK/Morse_Transmit_AFSK.ino
Normal file
120
examples/Morse/Morse_Transmit_AFSK/Morse_Transmit_AFSK.ino
Normal file
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
RadioLib Morse Transmit AFSK Example
|
||||
|
||||
This example sends Morse code message using
|
||||
SX1278's FSK modem. The data is modulated
|
||||
as AFSK.
|
||||
|
||||
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();
|
||||
|
||||
// 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 == 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 ... "));
|
||||
// AFSK tone frequency: 400 MHz
|
||||
// speed: 20 words per minute
|
||||
state = morse.begin(400);
|
||||
if(state == 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);
|
||||
}
|
|
@ -9,6 +9,9 @@
|
|||
- 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/
|
||||
*/
|
||||
|
@ -20,24 +23,18 @@
|
|||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 rf = new Module(10, 2, 3);
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 rf = RadioShield.ModuleA;
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// output power: 13 dBm
|
||||
// sync word: 0x2D01
|
||||
int state = rf.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -52,12 +49,12 @@ void loop() {
|
|||
|
||||
// you can receive data as an Arduino String
|
||||
String str;
|
||||
int state = rf.receive(str);
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = rf.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
@ -68,6 +65,12 @@ void loop() {
|
|||
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 == ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
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/
|
||||
*/
|
||||
|
@ -16,24 +19,18 @@
|
|||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 rf = new Module(10, 2, 3);
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 rf = RadioShield.ModuleA;
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// output power: 13 dBm
|
||||
// sync word: 0x2D01
|
||||
int state = rf.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -46,14 +43,14 @@ void setup() {
|
|||
// 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};
|
||||
rf.setAESKey(key);
|
||||
radio.setAESKey(key);
|
||||
|
||||
// enable AES encryption
|
||||
rf.enableAES();
|
||||
radio.enableAES();
|
||||
|
||||
// AES encryption can also be disabled
|
||||
/*
|
||||
rf.disableAES();
|
||||
radio.disableAES();
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -62,12 +59,12 @@ void loop() {
|
|||
|
||||
// you can receive data as an Arduino String
|
||||
String str;
|
||||
int state = rf.receive(str);
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = rf.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
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/
|
||||
*/
|
||||
|
@ -18,24 +21,18 @@
|
|||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 rf = new Module(10, 2, 3);
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 rf = RadioShield.ModuleA;
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// output power: 13 dBm
|
||||
// sync word: 0x2D01
|
||||
int state = rf.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -48,7 +45,7 @@ void setup() {
|
|||
// NOTE: calling this method will automatically enable
|
||||
// address filtering (node address only)
|
||||
Serial.print(F("[RF69] Setting node address ... "));
|
||||
state = rf.setNodeAddress(0x02);
|
||||
state = radio.setNodeAddress(0x02);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -61,7 +58,7 @@ void setup() {
|
|||
// NOTE: calling this method will automatically enable
|
||||
// address filtering (node or broadcast address)
|
||||
Serial.print(F("[RF69] Setting broadcast address ... "));
|
||||
state = rf.setBroadcastAddress(0xFF);
|
||||
state = radio.setBroadcastAddress(0xFF);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -75,7 +72,7 @@ void setup() {
|
|||
// node and broadcast address
|
||||
/*
|
||||
Serial.print(F("[RF69] Disabling address filtering ... "));
|
||||
state == rf.disableAddressFiltering();
|
||||
state == radio.disableAddressFiltering();
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -91,12 +88,12 @@ void loop() {
|
|||
|
||||
// you can receive data as an Arduino String
|
||||
String str;
|
||||
int state = rf.receive(str);
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = rf.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
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/
|
||||
*/
|
||||
|
@ -16,24 +19,18 @@
|
|||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 rf = new Module(10, 2, 3);
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 rf = RadioShield.ModuleA;
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// output power: 13 dBm
|
||||
// sync word: 0x2D01
|
||||
int state = rf.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -44,11 +41,11 @@ void setup() {
|
|||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
rf.setDio0Action(setFlag);
|
||||
radio.setDio0Action(setFlag);
|
||||
|
||||
// start listening for packets
|
||||
Serial.print(F("[RF69] Starting to listen ... "));
|
||||
state = rf.startReceive();
|
||||
state = radio.startReceive();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -60,11 +57,11 @@ void setup() {
|
|||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// rf.standby()
|
||||
// rf.sleep()
|
||||
// rf.transmit();
|
||||
// rf.receive();
|
||||
// rf.readData();
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
|
@ -99,12 +96,12 @@ void loop() {
|
|||
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
int state = rf.readData(str);
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = rf.readData(byteArr, 8);
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
@ -112,9 +109,15 @@ void loop() {
|
|||
Serial.println(F("[RF69] Received packet!"));
|
||||
|
||||
// print data of the packet
|
||||
Serial.print(F("[RF69] Data:\t\t\t"));
|
||||
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 == ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
@ -127,7 +130,7 @@ void loop() {
|
|||
}
|
||||
|
||||
// put module back to listen mode
|
||||
rf.startReceive();
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
- 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/
|
||||
*/
|
||||
|
@ -22,30 +25,24 @@
|
|||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 rf1 = new Module(10, 2, 3);
|
||||
RF69 radio1 = new Module(10, 2, 3);
|
||||
|
||||
// second CC1101 has different connections:
|
||||
// CS pin: 9
|
||||
// DIO0 pin: 4
|
||||
// RESET pin: 5
|
||||
RF69 rf2 = new Module(9, 4, 5);
|
||||
RF69 radio2 = new Module(9, 4, 5);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 rf3 = RadioShield.ModuleB;
|
||||
//RF69 radio3 = RadioShield.ModuleB;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// output power: 13 dBm
|
||||
// sync word: 0x2D01
|
||||
int state = rf1.begin();
|
||||
int state = radio1.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -61,8 +58,8 @@ void setup() {
|
|||
// frequency deviation: 60.0 kHz
|
||||
// Rx bandwidth: 250.0 kHz
|
||||
// output power: 17 dBm
|
||||
// sync word: 0x2D01
|
||||
state = rf2.begin(868.0, 300.0, 60.0, 250.0, 17);
|
||||
// preamble length: 32 bits
|
||||
state = radio2.begin(868.0, 300.0, 60.0, 250.0, 17, 32);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -75,13 +72,13 @@ void setup() {
|
|||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 433.5 MHz
|
||||
if (rf1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||
if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("[RF69] Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bit rate to 100.0 kbps
|
||||
state = rf1.setBitRate(100.0);
|
||||
state = radio1.setBitRate(100.0);
|
||||
if (state == ERR_INVALID_BIT_RATE) {
|
||||
Serial.println(F("[RF69] Selected bit rate is invalid for this module!"));
|
||||
while (true);
|
||||
|
@ -92,7 +89,7 @@ void setup() {
|
|||
}
|
||||
|
||||
// set receiver bandwidth to 250.0 kHz
|
||||
state = rf1.setRxBandwidth(250.0);
|
||||
state = radio1.setRxBandwidth(250.0);
|
||||
if (state == ERR_INVALID_RX_BANDWIDTH) {
|
||||
Serial.println(F("[RF69] Selected receiver bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
|
@ -103,13 +100,13 @@ void setup() {
|
|||
}
|
||||
|
||||
// set allowed frequency deviation to 10.0 kHz
|
||||
if (rf1.setFrequencyDeviation(10.0) == ERR_INVALID_FREQUENCY_DEVIATION) {
|
||||
if (radio1.setFrequencyDeviation(10.0) == 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 (rf1.setOutputPower(2) == ERR_INVALID_OUTPUT_POWER) {
|
||||
if (radio1.setOutputPower(2) == ERR_INVALID_OUTPUT_POWER) {
|
||||
Serial.println(F("[RF69] Selected output power is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
@ -118,7 +115,7 @@ void setup() {
|
|||
// NOTE: sync word must not contain any zero bytes
|
||||
// set sync word to 0x0123456789ABCDEF
|
||||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
||||
if (rf1.setSyncWord(syncWord, 8) == ERR_INVALID_SYNC_WORD) {
|
||||
if (radio1.setSyncWord(syncWord, 8) == ERR_INVALID_SYNC_WORD) {
|
||||
Serial.println(F("[RF69] Selected sync word is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
@ -128,13 +125,13 @@ void setup() {
|
|||
// RF69 can also measure temperature (roughly)
|
||||
// to get correct temperature measurements, the sensor must be calibrated
|
||||
// at ambient temperature
|
||||
rf1.setAmbientTemperature(25); // replace 25 with your ambient temperature
|
||||
radio1.setAmbientTemperature(25); // replace 25 with your ambient temperature
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// measure temperature
|
||||
Serial.print(F("[RF69] Measured temperature: "));
|
||||
Serial.print(rf1.getTemperature());
|
||||
Serial.print(radio1.getTemperature());
|
||||
Serial.println(F(" deg C"));
|
||||
|
||||
// wait 100 ms before the next measurement
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
- 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/
|
||||
*/
|
||||
|
@ -18,24 +21,18 @@
|
|||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 rf = new Module(10, 2, 3);
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 rf = RadioShield.ModuleA;
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// output power: 13 dBm
|
||||
// sync word: 0x2D01
|
||||
int state = rf.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -43,18 +40,35 @@ void setup() {
|
|||
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 == 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 = rf.transmit("Hello World!");
|
||||
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 = rf.transmit(byteArr, 8);
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
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/
|
||||
*/
|
||||
|
@ -16,24 +19,18 @@
|
|||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 rf = new Module(10, 2, 3);
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 rf = RadioShield.ModuleA;
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// output power: 13 dBm
|
||||
// sync word: 0x2D01
|
||||
int state = rf.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -46,14 +43,14 @@ void setup() {
|
|||
// 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};
|
||||
rf.setAESKey(key);
|
||||
radio.setAESKey(key);
|
||||
|
||||
// enable AES encryption
|
||||
rf.enableAES();
|
||||
radio.enableAES();
|
||||
|
||||
// AES encryption can also be disabled
|
||||
/*
|
||||
rf.disableAES();
|
||||
radio.disableAES();
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -61,12 +58,12 @@ void loop() {
|
|||
Serial.print(F("[RF69] Transmitting packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to 64 characters long
|
||||
int state = rf.transmit("Hello World!");
|
||||
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 = rf.transmit(byteArr, 8);
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
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/
|
||||
*/
|
||||
|
@ -18,24 +21,18 @@
|
|||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 rf = new Module(10, 2, 3);
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 rf = RadioShield.ModuleA;
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// output power: 13 dBm
|
||||
// sync word: 0x2D01
|
||||
int state = rf.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -48,7 +45,7 @@ void setup() {
|
|||
// NOTE: calling this method will automatically enable
|
||||
// address filtering (node address only)
|
||||
Serial.print(F("[RF69] Setting node address ... "));
|
||||
state = rf.setNodeAddress(0x01);
|
||||
state = radio.setNodeAddress(0x01);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -61,7 +58,7 @@ void setup() {
|
|||
// NOTE: calling this method will automatically enable
|
||||
// address filtering (node or broadcast address)
|
||||
Serial.print(F("[RF69] Setting broadcast address ... "));
|
||||
state = rf.setBroadcastAddress(0xFF);
|
||||
state = radio.setBroadcastAddress(0xFF);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -75,7 +72,7 @@ void setup() {
|
|||
// node and broadcast address
|
||||
/*
|
||||
Serial.print(F("[RF69] Disabling address filtering ... "));
|
||||
state = rf.disableAddressFiltering();
|
||||
state = radio.disableAddressFiltering();
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -90,23 +87,23 @@ void loop() {
|
|||
Serial.print(F("[RF69] Transmitting packet ... "));
|
||||
|
||||
// transmit C-string or Arduino string to node with address 0x02
|
||||
int state = rf.transmit("Hello World!", 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 = rf.transmit(byteArr, 8, 0x02);
|
||||
int state = radio.transmit(byteArr, 8, 0x02);
|
||||
*/
|
||||
|
||||
// transmit C-string or Arduino string in broadcast mode
|
||||
/*
|
||||
int state = rf.transmit("Hello World!", 0xFF);
|
||||
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 = rf.transmit(byteArr, 8, 0xFF);
|
||||
int state = radio.transmit(byteArr, 8, 0xFF);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
- 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/
|
||||
*/
|
||||
|
@ -19,11 +22,11 @@
|
|||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
RF69 rf = new Module(10, 2, 3);
|
||||
RF69 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//RF69 rf = RadioShield.ModuleA;
|
||||
//RF69 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = ERR_NONE;
|
||||
|
@ -33,13 +36,7 @@ void setup() {
|
|||
|
||||
// initialize RF69 with default settings
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// output power: 13 dBm
|
||||
// sync word: 0x2D01
|
||||
int state = rf.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -50,20 +47,37 @@ void setup() {
|
|||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
rf.setDio0Action(setFlag);
|
||||
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 == 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 = rf.startTransmit("Hello World!");
|
||||
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 = rf.startTransmit(byteArr, 8);
|
||||
state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -119,13 +133,13 @@ void loop() {
|
|||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = rf.startTransmit("Hello World!");
|
||||
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 = rf.startTransmit(byteArr, 8);
|
||||
int state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
// we're ready to send more packets,
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
- 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/
|
||||
*/
|
||||
|
@ -26,32 +29,25 @@
|
|||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 fsk = new Module(10, 2, 9, 3);
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 fsk = RadioShield.ModuleA;
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create RTTY client instance using the FSK module
|
||||
RTTYClient rtty(&fsk);
|
||||
RTTYClient rtty(&radio);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// output power: 13 dBm
|
||||
// current limit: 100 mA
|
||||
// sync word: 0x2D 0x01
|
||||
int state = fsk.beginFSK();
|
||||
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 = fsk.begin();
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
|
|
130
examples/RTTY/RTTY_Transmit_AFSK/RTTY_Transmit_AFSK.ino
Normal file
130
examples/RTTY/RTTY_Transmit_AFSK/RTTY_Transmit_AFSK.ino
Normal file
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
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 == 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 == 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);
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
// wait for a second before transmitting again
|
||||
delay(1000);
|
||||
}
|
|
@ -25,6 +25,9 @@
|
|||
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/
|
||||
*/
|
||||
|
@ -37,14 +40,14 @@
|
|||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 fsk = new Module(10, 2, 9, 3);
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 fsk = RadioShield.ModuleA;
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// create SSTV client instance using the FSK module
|
||||
SSTVClient sstv(&fsk);
|
||||
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
|
||||
|
@ -85,16 +88,9 @@ uint32_t line[320] = {
|
|||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// output power: 13 dBm
|
||||
// current limit: 100 mA
|
||||
// sync word: 0x2D 0x01
|
||||
int state = fsk.beginFSK();
|
||||
int state = radio.beginFSK();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -105,7 +101,7 @@ void setup() {
|
|||
|
||||
// when using one of the non-LoRa modules for SSTV
|
||||
// (RF69, SX1231 etc.), use the basic begin() method
|
||||
// int state = fsk.begin();
|
||||
// int state = radio.begin();
|
||||
|
||||
// initialize SSTV client
|
||||
Serial.print(F("[SSTV] Initializing ... "));
|
||||
|
@ -152,7 +148,7 @@ void loop() {
|
|||
}
|
||||
|
||||
// turn off transmitter
|
||||
fsk.standby();
|
||||
radio.standby();
|
||||
|
||||
Serial.println(F("done!"));
|
||||
|
||||
|
|
152
examples/SSTV/SSTV_Transmit_AFSK/SSTV_Transmit_AFSK.ino
Normal file
152
examples/SSTV/SSTV_Transmit_AFSK/SSTV_Transmit_AFSK.ino
Normal file
|
@ -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 == 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 == 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);
|
||||
}
|
|
@ -7,6 +7,9 @@
|
|||
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/
|
||||
*/
|
||||
|
@ -18,24 +21,18 @@
|
|||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
SX1231 rf = new Module(10, 2, 3);
|
||||
SX1231 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1231 rf = RadioShield.ModuleA;
|
||||
//SX1231 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1231 with default settings
|
||||
Serial.print(F("[SX1231] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// frequency deviation: 50.0 kHz
|
||||
// output power: 13 dBm
|
||||
// sync word: 0x2D01
|
||||
int state = rf.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -50,12 +47,12 @@ void loop() {
|
|||
|
||||
// you can receive data as an Arduino String
|
||||
String str;
|
||||
int state = rf.receive(str);
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = rf.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
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/
|
||||
*/
|
||||
|
@ -18,24 +21,18 @@
|
|||
// CS pin: 10
|
||||
// DIO0 pin: 2
|
||||
// RESET pin: 3
|
||||
SX1231 rf = new Module(10, 2, 3);
|
||||
SX1231 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1231 rf = RadioShield.ModuleA;
|
||||
//SX1231 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1231 with default settings
|
||||
Serial.print(F("[SX1231] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// frequency deviation: 50.0 kHz
|
||||
// output power: 13 dBm
|
||||
// sync word: 0x2D01
|
||||
int state = rf.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -49,12 +46,12 @@ void loop() {
|
|||
Serial.print(F("[SX1231] Transmitting packet ... "));
|
||||
|
||||
// you can transmit C-string or Arduino string up to 256 characters long
|
||||
int state = rf.transmit("Hello World!");
|
||||
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 = rf.transmit(byteArr, 8);
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -20,29 +23,18 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 lora = new Module(10, 2, 3, 9);
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 lora = RadioShield.ModuleA;
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bandwidth: 125.0 kHz
|
||||
// spreading factor: 9
|
||||
// coding rate: 7
|
||||
// sync word: 0x12 (private network)
|
||||
// output power: 14 dBm
|
||||
// current limit: 60 mA
|
||||
// preamble length: 8 symbols
|
||||
// TCXO voltage: 1.6 V (set to 0 to not use TCXO)
|
||||
// regulator: DC-DC (set to true to use LDO)
|
||||
// CRC: enabled
|
||||
int state = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -56,7 +48,7 @@ void loop() {
|
|||
Serial.print(F("[SX1262] Scanning channel for LoRa transmission ... "));
|
||||
|
||||
// start scanning current channel
|
||||
int state = lora.scanChannel();
|
||||
int state = radio.scanChannel();
|
||||
|
||||
if (state == LORA_DETECTED) {
|
||||
// LoRa preamble was detected
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
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/
|
||||
*/
|
||||
|
@ -21,30 +24,18 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 fsk = new Module(10, 2, 3, 9);
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 fsk = RadioShield.ModuleA;
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 FSK modem with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 156.2 kHz
|
||||
// output power: 14 dBm
|
||||
// current limit: 60.0 mA
|
||||
// preamble length: 16 bits
|
||||
// data shaping: Gaussian, BT = 0.5
|
||||
// TCXO voltage: 1.6 V (set to 0 to not use TCXO)
|
||||
// regulator: DC-DC (set to true to use LDO)
|
||||
// sync word: 0x2D 0x01
|
||||
// CRC: enabled, CRC16 (CCIT)
|
||||
int state = fsk.beginFSK();
|
||||
int state = radio.beginFSK();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -55,21 +46,21 @@ void setup() {
|
|||
|
||||
// if needed, you can switch between LoRa and FSK modes
|
||||
//
|
||||
// lora.begin() start LoRa mode (and disable FSK)
|
||||
// lora.beginFSK() start FSK mode (and disable LoRa)
|
||||
// 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 = fsk.setFrequency(433.5);
|
||||
state = fsk.setBitRate(100.0);
|
||||
state = fsk.setFrequencyDeviation(10.0);
|
||||
state = fsk.setRxBandwidth(250.0);
|
||||
state = fsk.setOutputPower(10.0);
|
||||
state = fsk.setCurrentLimit(100.0);
|
||||
state = fsk.setDataShaping(1.0);
|
||||
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 = fsk.setSyncWord(syncWord, 8);
|
||||
state = radio.setSyncWord(syncWord, 8);
|
||||
if (state != ERR_NONE) {
|
||||
Serial.print(F("Unable to set configuration, code "));
|
||||
Serial.println(state);
|
||||
|
@ -78,15 +69,15 @@ void setup() {
|
|||
|
||||
// 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 fsk.setSyncWord(syncWord, 8):
|
||||
state = fsk.setSyncBits(syncWord, 64);
|
||||
// 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 = fsk.setSyncBits(syncWord, 12);
|
||||
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 = fsk.setCRC(2, 0xFFFF, 0x8005, false);
|
||||
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."
|
||||
|
@ -97,11 +88,11 @@ void loop() {
|
|||
// as the LoRa modem, even their interrupt-driven versions
|
||||
|
||||
// transmit FSK packet
|
||||
int state = fsk.transmit("Hello World!");
|
||||
int state = radio.transmit("Hello World!");
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = lora.transmit(byteArr, 8);
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("[SX1262] Packet transmitted successfully!"));
|
||||
|
@ -116,10 +107,10 @@ void loop() {
|
|||
|
||||
// receive FSK packet
|
||||
String str;
|
||||
state = fsk.receive(str);
|
||||
state = radio.receive(str);
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = lora.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("[SX1262] Received packet!"));
|
||||
|
@ -139,13 +130,13 @@ void loop() {
|
|||
// to transmit packet to a particular address,
|
||||
// use the following methods:
|
||||
//
|
||||
// fsk.transmit("Hello World!", address);
|
||||
// fsk.startTransmit("Hello World!", address);
|
||||
// radio.transmit("Hello World!", address);
|
||||
// radio.startTransmit("Hello World!", address);
|
||||
|
||||
// set node address to 0x02
|
||||
state = fsk.setNodeAddress(0x02);
|
||||
state = radio.setNodeAddress(0x02);
|
||||
// set broadcast address to 0xFF
|
||||
state = fsk.setBroadcastAddress(0xFF);
|
||||
state = radio.setBroadcastAddress(0xFF);
|
||||
if (state != ERR_NONE) {
|
||||
Serial.println(F("[SX1262] Unable to set address filter, code "));
|
||||
Serial.println(state);
|
||||
|
@ -155,7 +146,7 @@ void loop() {
|
|||
// NOTE: calling this method will also erase previously set
|
||||
// node and broadcast address
|
||||
/*
|
||||
state = fsk.disableAddressFiltering();
|
||||
state = radio.disableAddressFiltering();
|
||||
if (state != ERR_NONE) {
|
||||
Serial.println(F("Unable to remove address filter, code "));
|
||||
}
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -25,29 +28,18 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 lora = new Module(10, 2, 3, 9);
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 lora = RadioShield.ModuleA;
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bandwidth: 125.0 kHz
|
||||
// spreading factor: 9
|
||||
// coding rate: 7
|
||||
// sync word: 0x12 (private network)
|
||||
// output power: 14 dBm
|
||||
// current limit: 60 mA
|
||||
// preamble length: 8 symbols
|
||||
// TCXO voltage: 1.6 V (set to 0 to not use TCXO)
|
||||
// regulator: DC-DC (set to true to use LDO)
|
||||
// CRC: enabled
|
||||
int state = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -65,12 +57,12 @@ void loop() {
|
|||
// See example ReceiveInterrupt for details
|
||||
// on non-blocking reception method.
|
||||
String str;
|
||||
int state = lora.receive(str);
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = lora.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
@ -84,13 +76,13 @@ void loop() {
|
|||
// print the RSSI (Received Signal Strength Indicator)
|
||||
// of the last received packet
|
||||
Serial.print(F("[SX1262] RSSI:\t\t"));
|
||||
Serial.print(lora.getRSSI());
|
||||
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(lora.getSNR());
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
|
|
|
@ -12,7 +12,10 @@
|
|||
- coding rate
|
||||
- sync word
|
||||
|
||||
Other modules from SX126x/RFM9x family can also be used.
|
||||
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/
|
||||
|
@ -26,29 +29,18 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 lora = new Module(10, 2, 3, 9);
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 lora = RadioShield.ModuleA;
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bandwidth: 125.0 kHz
|
||||
// spreading factor: 9
|
||||
// coding rate: 7
|
||||
// sync word: 0x12 (private network)
|
||||
// output power: 14 dBm
|
||||
// current limit: 60 mA
|
||||
// preamble length: 8 symbols
|
||||
// TCXO voltage: 1.6 V (set to 0 to not use TCXO)
|
||||
// regulator: DC-DC (set to true to use LDO)
|
||||
// CRC: enabled
|
||||
int state = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -59,11 +51,11 @@ void setup() {
|
|||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
lora.setDio1Action(setFlag);
|
||||
radio.setDio1Action(setFlag);
|
||||
|
||||
// start listening for LoRa packets
|
||||
Serial.print(F("[SX1262] Starting to listen ... "));
|
||||
state = lora.startReceive();
|
||||
state = radio.startReceive();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -75,12 +67,12 @@ void setup() {
|
|||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// lora.standby()
|
||||
// lora.sleep()
|
||||
// lora.transmit();
|
||||
// lora.receive();
|
||||
// lora.readData();
|
||||
// lora.scanChannel();
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
// radio.scanChannel();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
|
@ -115,12 +107,12 @@ void loop() {
|
|||
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
int state = lora.readData(str);
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = lora.readData(byteArr, 8);
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
@ -133,12 +125,12 @@ void loop() {
|
|||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
Serial.print(F("[SX1262] RSSI:\t\t"));
|
||||
Serial.print(lora.getRSSI());
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print SNR (Signal-to-Noise Ratio)
|
||||
Serial.print(F("[SX1262] SNR:\t\t"));
|
||||
Serial.print(lora.getSNR());
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
|
@ -153,7 +145,7 @@ void loop() {
|
|||
}
|
||||
|
||||
// put module back to listen mode
|
||||
lora.startReceive();
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -29,36 +32,25 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 loraSX1262 = new Module(10, 2, 3, 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 loraSX1268 = new Module(8, 4, 5, 6);
|
||||
SX1268 radio2 = new Module(8, 4, 5, 6);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1261 loraSX1261 = RadioShield.ModuleB;
|
||||
//SX1261 radio3 = RadioShield.ModuleB;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1268 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bandwidth: 125.0 kHz
|
||||
// spreading factor: 9
|
||||
// coding rate: 7
|
||||
// sync word: 0x12 (private network)
|
||||
// output power: 14 dBm
|
||||
// current limit: 60 mA
|
||||
// preamble length: 8 symbols
|
||||
// TCXO voltage: 1.6 V (set to 0 to not use TCXO)
|
||||
// regulator: DC-DC (set to true to use LDO)
|
||||
// CRC: enabled
|
||||
int state = loraSX1262.begin();
|
||||
int state = radio1.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -78,10 +70,8 @@ void setup() {
|
|||
// coding rate: 5
|
||||
// sync word: 0x34 (public network/LoRaWAN)
|
||||
// output power: 2 dBm
|
||||
// current limit: 50 mA
|
||||
// preamble length: 20 symbols
|
||||
// CRC: enabled
|
||||
state = loraSX1268.begin(915.0, 500.0, 6, 5, 0x34, 50, 20);
|
||||
state = radio2.begin(915.0, 500.0, 6, 5, 0x34, 20);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -94,56 +84,56 @@ void setup() {
|
|||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 433.5 MHz
|
||||
if (loraSX1262.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||
if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bandwidth to 250 kHz
|
||||
if (loraSX1262.setBandwidth(250.0) == ERR_INVALID_BANDWIDTH) {
|
||||
if (radio1.setBandwidth(250.0) == ERR_INVALID_BANDWIDTH) {
|
||||
Serial.println(F("Selected bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set spreading factor to 10
|
||||
if (loraSX1262.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) {
|
||||
if (radio1.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) {
|
||||
Serial.println(F("Selected spreading factor is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set coding rate to 6
|
||||
if (loraSX1262.setCodingRate(6) == ERR_INVALID_CODING_RATE) {
|
||||
if (radio1.setCodingRate(6) == ERR_INVALID_CODING_RATE) {
|
||||
Serial.println(F("Selected coding rate is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set LoRa sync word to 0xAB
|
||||
if (loraSX1262.setSyncWord(0xAB) != ERR_NONE) {
|
||||
if (radio1.setSyncWord(0xAB) != 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 (loraSX1262.setOutputPower(10) == ERR_INVALID_OUTPUT_POWER) {
|
||||
if (radio1.setOutputPower(10) == 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 (loraSX1262.setCurrentLimit(80) == ERR_INVALID_CURRENT_LIMIT) {
|
||||
if (radio1.setCurrentLimit(80) == 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 (loraSX1262.setPreambleLength(15) == ERR_INVALID_PREAMBLE_LENGTH) {
|
||||
if (radio1.setPreambleLength(15) == ERR_INVALID_PREAMBLE_LENGTH) {
|
||||
Serial.println(F("Selected preamble length is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// disable CRC
|
||||
if (loraSX1262.setCRC(false) == ERR_INVALID_CRC_CONFIGURATION) {
|
||||
if (radio1.setCRC(false) == ERR_INVALID_CRC_CONFIGURATION) {
|
||||
Serial.println(F("Selected CRC is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
@ -151,7 +141,7 @@ void setup() {
|
|||
// Some SX126x modules have TCXO (temperature compensated crystal
|
||||
// oscillator). To configure TCXO reference voltage,
|
||||
// the following method can be used.
|
||||
if (loraSX1262.setTCXO(2.4) == ERR_INVALID_TCXO_VOLTAGE) {
|
||||
if (radio1.setTCXO(2.4) == ERR_INVALID_TCXO_VOLTAGE) {
|
||||
Serial.println(F("Selected TCXO voltage is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
@ -160,7 +150,7 @@ void setup() {
|
|||
// this feature, the following method can be used.
|
||||
// NOTE: As long as DIO2 is configured to control RF switch,
|
||||
// it can't be used as interrupt pin!
|
||||
if (loraSX1262.setDio2AsRfSwitch() != ERR_NONE) {
|
||||
if (radio1.setDio2AsRfSwitch() != ERR_NONE) {
|
||||
Serial.println(F("Failed to set DIO2 as RF switch!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -21,29 +24,18 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 lora = new Module(10, 2, 3, 9);
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 lora = RadioShield.ModuleA;
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bandwidth: 125.0 kHz
|
||||
// spreading factor: 9
|
||||
// coding rate: 7
|
||||
// sync word: 0x12 (private network)
|
||||
// output power: 14 dBm
|
||||
// current limit: 60 mA
|
||||
// preamble length: 8 symbols
|
||||
// TCXO voltage: 1.6 V (set to 0 to not use TCXO)
|
||||
// regulator: DC-DC (set to true to use LDO)
|
||||
// CRC: enabled
|
||||
int state = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -51,6 +43,16 @@ void setup() {
|
|||
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() {
|
||||
|
@ -61,12 +63,12 @@ void loop() {
|
|||
// NOTE: transmit() is a blocking method!
|
||||
// See example SX126x_Transmit_Interrupt for details
|
||||
// on non-blocking transmission method.
|
||||
int state = lora.transmit("Hello World!");
|
||||
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 = lora.transmit(byteArr, 8);
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
@ -75,7 +77,7 @@ void loop() {
|
|||
|
||||
// print measured data rate
|
||||
Serial.print(F("[SX1262] Datarate:\t"));
|
||||
Serial.print(lora.getDataRate());
|
||||
Serial.print(radio.getDataRate());
|
||||
Serial.println(F(" bps"));
|
||||
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -22,7 +25,11 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1262 lora = new Module(10, 2, 3, 9);
|
||||
SX1262 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1262 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = ERR_NONE;
|
||||
|
@ -32,18 +39,7 @@ void setup() {
|
|||
|
||||
// initialize SX1262 with default settings
|
||||
Serial.print(F("[SX1262] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bandwidth: 125.0 kHz
|
||||
// spreading factor: 9
|
||||
// coding rate: 7
|
||||
// sync word: 0x12 (private network)
|
||||
// output power: 14 dBm
|
||||
// current limit: 60 mA
|
||||
// preamble length: 8 symbols
|
||||
// TCXO voltage: 1.6 V (set to 0 to not use TCXO)
|
||||
// regulator: DC-DC (set to true to use LDO)
|
||||
// CRC: enabled
|
||||
int state = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -54,20 +50,20 @@ void setup() {
|
|||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
lora.setDio1Action(setFlag);
|
||||
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 = lora.startTransmit("Hello World!");
|
||||
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 = lora.startTransmit(byteArr, 8);
|
||||
state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -123,13 +119,13 @@ void loop() {
|
|||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = lora.startTransmit("Hello World!");
|
||||
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 = lora.startTransmit(byteArr, 8);
|
||||
int state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
// we're ready to send more packets,
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -21,27 +24,18 @@
|
|||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 lora = new Module(10, 2, 9, 3);
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 lora = RadioShield.ModuleA;
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bandwidth: 125.0 kHz
|
||||
// spreading factor: 9
|
||||
// coding rate: 7
|
||||
// sync word: 0x12
|
||||
// output power: 17 dBm
|
||||
// current limit: 100 mA
|
||||
// preamble length: 8 symbols
|
||||
// amplifier gain: 0 (automatic gain control)
|
||||
int state = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -55,7 +49,7 @@ void loop() {
|
|||
Serial.print(F("[SX1278] Scanning channel for LoRa preamble ... "));
|
||||
|
||||
// start scanning current channel
|
||||
int state = lora.scanChannel();
|
||||
int state = radio.scanChannel();
|
||||
|
||||
if (state == PREAMBLE_DETECTED) {
|
||||
// LoRa preamble was detected
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
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/
|
||||
*/
|
||||
|
@ -21,7 +24,7 @@
|
|||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 fsk = new Module(10, 2, 9, 3);
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
|
@ -32,16 +35,7 @@ void setup() {
|
|||
|
||||
// initialize SX1278 FSK modem with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 125.0 kHz
|
||||
// output power: 13 dBm
|
||||
// current limit: 100 mA
|
||||
// data shaping: Gaussian, BT = 0.5
|
||||
// sync word: 0x2D 0x01
|
||||
// OOK modulation: disabled
|
||||
int state = fsk.beginFSK();
|
||||
int state = radio.beginFSK();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -52,21 +46,21 @@ void setup() {
|
|||
|
||||
// if needed, you can switch between LoRa and FSK modes
|
||||
//
|
||||
// lora.begin() start LoRa mode (and disable FSK)
|
||||
// lora.beginFSK() start FSK mode (and disable LoRa)
|
||||
// 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 = fsk.setFrequency(433.5);
|
||||
state = fsk.setBitRate(100.0);
|
||||
state = fsk.setFrequencyDeviation(10.0);
|
||||
state = fsk.setRxBandwidth(250.0);
|
||||
state = fsk.setOutputPower(10.0);
|
||||
state = fsk.setCurrentLimit(100);
|
||||
state = fsk.setDataShaping(0.5);
|
||||
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 = fsk.setSyncWord(syncWord, 8);
|
||||
state = radio.setSyncWord(syncWord, 8);
|
||||
if (state != ERR_NONE) {
|
||||
Serial.print(F("Unable to set configuration, code "));
|
||||
Serial.println(state);
|
||||
|
@ -78,8 +72,8 @@ void setup() {
|
|||
// Also, data shaping changes from Gaussian filter to
|
||||
// simple filter with cutoff frequency. Make sure to call
|
||||
// setDataShapingOOK() to set the correct shaping!
|
||||
state = fsk.setOOK(true);
|
||||
state = fsk.setDataShapingOOK(1);
|
||||
state = radio.setOOK(true);
|
||||
state = radio.setDataShapingOOK(1);
|
||||
if (state != ERR_NONE) {
|
||||
Serial.print(F("Unable to change modulation, code "));
|
||||
Serial.println(state);
|
||||
|
@ -95,11 +89,11 @@ void loop() {
|
|||
// NOTE: FSK modem maximum packet length is 63 bytes!
|
||||
|
||||
// transmit FSK packet
|
||||
int state = fsk.transmit("Hello World!");
|
||||
int state = radio.transmit("Hello World!");
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = lora.transmit(byteArr, 8);
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Packet transmitted successfully!"));
|
||||
|
@ -114,10 +108,10 @@ void loop() {
|
|||
|
||||
// receive FSK packet
|
||||
String str;
|
||||
state = fsk.receive(str);
|
||||
state = radio.receive(str);
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = lora.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Received packet!"));
|
||||
|
@ -137,13 +131,13 @@ void loop() {
|
|||
// to transmit packet to a particular address,
|
||||
// use the following methods:
|
||||
//
|
||||
// fsk.transmit("Hello World!", address);
|
||||
// fsk.startTransmit("Hello World!", address);
|
||||
// radio.transmit("Hello World!", address);
|
||||
// radio.startTransmit("Hello World!", address);
|
||||
|
||||
// set node address to 0x02
|
||||
state = fsk.setNodeAddress(0x02);
|
||||
state = radio.setNodeAddress(0x02);
|
||||
// set broadcast address to 0xFF
|
||||
state = fsk.setBroadcastAddress(0xFF);
|
||||
state = radio.setBroadcastAddress(0xFF);
|
||||
if (state != ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Unable to set address filter, code "));
|
||||
Serial.println(state);
|
||||
|
@ -153,7 +147,7 @@ void loop() {
|
|||
// NOTE: calling this method will also erase previously set
|
||||
// node and broadcast address
|
||||
/*
|
||||
state = fsk.disableAddressFiltering();
|
||||
state = radio.disableAddressFiltering();
|
||||
if (state != ERR_NONE) {
|
||||
Serial.println(F("Unable to remove address filter, code "));
|
||||
}
|
||||
|
@ -164,7 +158,7 @@ void loop() {
|
|||
// sent to DIO1 (data) and DIO2 (clock)
|
||||
|
||||
// activate direct mode transmitter
|
||||
state = fsk.transmitDirect();
|
||||
state = radio.transmitDirect();
|
||||
if (state != ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Unable to start direct transmission mode, code "));
|
||||
Serial.println(state);
|
||||
|
@ -175,7 +169,7 @@ void loop() {
|
|||
|
||||
// it is recommended to set data shaping to 0
|
||||
// (no shaping) when transmitting audio
|
||||
state = fsk.setDataShaping(0.0);
|
||||
state = radio.setDataShaping(0.0);
|
||||
if (state != ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Unable to set data shaping, code "));
|
||||
Serial.println(state);
|
||||
|
@ -199,7 +193,7 @@ void loop() {
|
|||
|
||||
// direct mode transmissions can also be received
|
||||
// as bit stream on DIO1 (data) and DIO2 (clock)
|
||||
state = fsk.receiveDirect();
|
||||
state = radio.receiveDirect();
|
||||
if (state != ERR_NONE) {
|
||||
Serial.println(F("[SX1278] Unable to start direct reception mode, code "));
|
||||
Serial.println(state);
|
||||
|
@ -207,5 +201,5 @@ void loop() {
|
|||
|
||||
// NOTE: you will not be able to send or receive packets
|
||||
// while direct mode is active! to deactivate it, call method
|
||||
// fsk.packetMode()
|
||||
// radio.packetMode()
|
||||
}
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -25,27 +28,18 @@
|
|||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 lora = new Module(10, 2, 9, 3);
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 lora = RadioShield.ModuleA;
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bandwidth: 125.0 kHz
|
||||
// spreading factor: 9
|
||||
// coding rate: 7
|
||||
// sync word: 0x12
|
||||
// output power: 17 dBm
|
||||
// current limit: 100 mA
|
||||
// preamble length: 8 symbols
|
||||
// amplifier gain: 0 (automatic gain control)
|
||||
int state = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -63,12 +57,12 @@ void loop() {
|
|||
// See example ReceiveInterrupt for details
|
||||
// on non-blocking reception method.
|
||||
String str;
|
||||
int state = lora.receive(str);
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = lora.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
@ -82,19 +76,19 @@ void loop() {
|
|||
// print the RSSI (Received Signal Strength Indicator)
|
||||
// of the last received packet
|
||||
Serial.print(F("[SX1278] RSSI:\t\t\t"));
|
||||
Serial.print(lora.getRSSI());
|
||||
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(lora.getSNR());
|
||||
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(lora.getFrequencyError());
|
||||
Serial.print(radio.getFrequencyError());
|
||||
Serial.println(F(" Hz"));
|
||||
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -26,27 +29,18 @@
|
|||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 lora = new Module(10, 2, 9, 3);
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 lora = RadioShield.ModuleA;
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bandwidth: 125.0 kHz
|
||||
// spreading factor: 9
|
||||
// coding rate: 7
|
||||
// sync word: 0x12
|
||||
// output power: 17 dBm
|
||||
// current limit: 100 mA
|
||||
// preamble length: 8 symbols
|
||||
// amplifier gain: 0 (automatic gain control)
|
||||
int state = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -57,11 +51,11 @@ void setup() {
|
|||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
lora.setDio0Action(setFlag);
|
||||
radio.setDio0Action(setFlag);
|
||||
|
||||
// start listening for LoRa packets
|
||||
Serial.print(F("[SX1278] Starting to listen ... "));
|
||||
state = lora.startReceive();
|
||||
state = radio.startReceive();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -73,12 +67,12 @@ void setup() {
|
|||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// lora.standby()
|
||||
// lora.sleep()
|
||||
// lora.transmit();
|
||||
// lora.receive();
|
||||
// lora.readData();
|
||||
// lora.scanChannel();
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
// radio.scanChannel();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
|
@ -113,12 +107,12 @@ void loop() {
|
|||
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
int state = lora.readData(str);
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = lora.readData(byteArr, 8);
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
@ -131,17 +125,17 @@ void loop() {
|
|||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
Serial.print(F("[SX1278] RSSI:\t\t"));
|
||||
Serial.print(lora.getRSSI());
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print SNR (Signal-to-Noise Ratio)
|
||||
Serial.print(F("[SX1278] SNR:\t\t"));
|
||||
Serial.print(lora.getSNR());
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
// print frequency error
|
||||
Serial.print(F("[SX1278] Frequency error:\t"));
|
||||
Serial.print(lora.getFrequencyError());
|
||||
Serial.print(radio.getFrequencyError());
|
||||
Serial.println(F(" Hz"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
|
@ -156,7 +150,7 @@ void loop() {
|
|||
}
|
||||
|
||||
// put module back to listen mode
|
||||
lora.startReceive();
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -25,34 +28,25 @@
|
|||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 loraSX1278 = new Module(10, 2, 9, 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 loraSX1272 = new Module(9, 4, 5, 6);
|
||||
SX1272 radio2 = new Module(9, 4, 5, 6);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1276 loraSX1276 = RadioShield.ModuleB;
|
||||
//SX1276 radio3 = RadioShield.ModuleB;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bandwidth: 125.0 kHz
|
||||
// spreading factor: 9
|
||||
// coding rate: 7
|
||||
// sync word: 0x12
|
||||
// output power: 17 dBm
|
||||
// current limit: 100 mA
|
||||
// preamble length: 8 symbols
|
||||
// amplifier gain: 0 (automatic gain control)
|
||||
int state = loraSX1278.begin();
|
||||
int state = radio1.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -76,10 +70,9 @@ void setup() {
|
|||
// coding rate: 5
|
||||
// sync word: 0x14
|
||||
// output power: 2 dBm
|
||||
// current limit: 50 mA
|
||||
// preamble length: 20 symbols
|
||||
// amplifier gain: 1 (maximum gain)
|
||||
state = loraSX1272.begin(915.0, 500.0, 6, 5, 0x14, 2);
|
||||
state = radio2.begin(915.0, 500.0, 6, 5, 0x14, 2, 20, 1);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -92,32 +85,32 @@ void setup() {
|
|||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 433.5 MHz
|
||||
if (loraSX1278.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||
if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bandwidth to 250 kHz
|
||||
if (loraSX1278.setBandwidth(250.0) == ERR_INVALID_BANDWIDTH) {
|
||||
if (radio1.setBandwidth(250.0) == ERR_INVALID_BANDWIDTH) {
|
||||
Serial.println(F("Selected bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set spreading factor to 10
|
||||
if (loraSX1278.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) {
|
||||
if (radio1.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) {
|
||||
Serial.println(F("Selected spreading factor is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set coding rate to 6
|
||||
if (loraSX1278.setCodingRate(6) == ERR_INVALID_CODING_RATE) {
|
||||
if (radio1.setCodingRate(6) == 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 (loraSX1278.setSyncWord(0x14) != ERR_NONE) {
|
||||
if (radio1.setSyncWord(0x14) != ERR_NONE) {
|
||||
Serial.println(F("Unable to set sync word!"));
|
||||
while (true);
|
||||
}
|
||||
|
@ -125,20 +118,20 @@ void setup() {
|
|||
// set output power to 10 dBm (accepted range is -3 - 17 dBm)
|
||||
// NOTE: 20 dBm value allows high power operation, but transmission
|
||||
// duty cycle MUST NOT exceed 1%
|
||||
if (loraSX1278.setOutputPower(10) == ERR_INVALID_OUTPUT_POWER) {
|
||||
if (radio1.setOutputPower(10) == 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 (loraSX1278.setCurrentLimit(80) == ERR_INVALID_CURRENT_LIMIT) {
|
||||
if (radio1.setCurrentLimit(80) == 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 (loraSX1278.setPreambleLength(15) == ERR_INVALID_PREAMBLE_LENGTH) {
|
||||
if (radio1.setPreambleLength(15) == ERR_INVALID_PREAMBLE_LENGTH) {
|
||||
Serial.println(F("Selected preamble length is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
@ -146,7 +139,7 @@ void setup() {
|
|||
// set amplifier gain to 1 (accepted range is 1 - 6, where 1 is maximum gain)
|
||||
// NOTE: set value to 0 to enable automatic gain control
|
||||
// leave at 0 unless you know what you're doing
|
||||
if (loraSX1278.setGain(1) == ERR_INVALID_GAIN) {
|
||||
if (radio1.setGain(1) == ERR_INVALID_GAIN) {
|
||||
Serial.println(F("Selected gain is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -21,27 +24,18 @@
|
|||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 lora = new Module(10, 2, 9, 3);
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 lora = RadioShield.ModuleA;
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bandwidth: 125.0 kHz
|
||||
// spreading factor: 9
|
||||
// coding rate: 7
|
||||
// sync word: 0x12
|
||||
// output power: 17 dBm
|
||||
// current limit: 100 mA
|
||||
// preamble length: 8 symbols
|
||||
// amplifier gain: 0 (automatic gain control)
|
||||
int state = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -49,6 +43,16 @@ void setup() {
|
|||
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() {
|
||||
|
@ -59,12 +63,12 @@ void loop() {
|
|||
// NOTE: transmit() is a blocking method!
|
||||
// See example SX127x_Transmit_Interrupt for details
|
||||
// on non-blocking transmission method.
|
||||
int state = lora.transmit("Hello World!");
|
||||
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 = lora.transmit(byteArr, 8);
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
@ -73,7 +77,7 @@ void loop() {
|
|||
|
||||
// print measured data rate
|
||||
Serial.print(F("[SX1278] Datarate:\t"));
|
||||
Serial.print(lora.getDataRate());
|
||||
Serial.print(radio.getDataRate());
|
||||
Serial.println(F(" bps"));
|
||||
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -22,11 +25,11 @@
|
|||
// DIO0 pin: 2
|
||||
// RESET pin: 9
|
||||
// DIO1 pin: 3
|
||||
SX1278 lora = new Module(10, 2, 9, 3);
|
||||
SX1278 radio = new Module(10, 2, 9, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1278 lora = RadioShield.ModuleA;
|
||||
//SX1278 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = ERR_NONE;
|
||||
|
@ -36,16 +39,7 @@ void setup() {
|
|||
|
||||
// initialize SX1278 with default settings
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bandwidth: 125.0 kHz
|
||||
// spreading factor: 9
|
||||
// coding rate: 7
|
||||
// sync word: 0x12
|
||||
// output power: 17 dBm
|
||||
// current limit: 100 mA
|
||||
// preamble length: 8 symbols
|
||||
// amplifier gain: 0 (automatic gain control)
|
||||
int state = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -56,20 +50,20 @@ void setup() {
|
|||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
lora.setDio0Action(setFlag);
|
||||
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 = lora.startTransmit("Hello World!");
|
||||
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 = lora.startTransmit(byteArr, 8);
|
||||
state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -125,13 +119,13 @@ void loop() {
|
|||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = lora.startTransmit("Hello World!");
|
||||
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 = lora.startTransmit(byteArr, 8);
|
||||
int state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
// we're ready to send more packets,
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
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/
|
||||
*/
|
||||
|
@ -23,25 +26,18 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 ble = new Module(10, 2, 3, 9);
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 ble = RadioShield.ModuleA;
|
||||
//SX1280 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
// carrier frequency: 2400.0 MHz
|
||||
// bit rate: 800 kbps
|
||||
// frequency deviation: 400.0 kHz
|
||||
// output power: 10 dBm
|
||||
// preamble length: 16 bits
|
||||
// data shaping: Gaussian, BT = 0.5
|
||||
// CRC: enabled, CRC16 (CCIT)
|
||||
int state = ble.beginBLE();
|
||||
int state = radio.beginBLE();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -50,19 +46,19 @@ void setup() {
|
|||
while (true);
|
||||
}
|
||||
|
||||
// if needed, you can switch between LoRa and FSK modes
|
||||
// if needed, you can switch between any of the modems
|
||||
//
|
||||
// ble.begin() start LoRa mode (and disable BLE)
|
||||
// lora.beginBLE() start BLE mode (and disable LoRa)
|
||||
// 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 = ble.setFrequency(2410.5);
|
||||
state = ble.setBitRate(200);
|
||||
state = ble.setFrequencyDeviation(100.0);
|
||||
state = ble.setOutputPower(5);
|
||||
state = ble.setDataShaping(1.0);
|
||||
state = ble.setAccessAddress(0x12345678);
|
||||
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 != ERR_NONE) {
|
||||
Serial.print(F("Unable to set configuration, code "));
|
||||
Serial.println(state);
|
||||
|
@ -77,11 +73,11 @@ void loop() {
|
|||
// as the LoRa modem, even their interrupt-driven versions
|
||||
|
||||
// transmit BLE packet
|
||||
int state = ble.transmit("Hello World!");
|
||||
int state = radio.transmit("Hello World!");
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = ble.transmit(byteArr, 8);
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Packet transmitted successfully!"));
|
||||
|
@ -90,16 +86,16 @@ void loop() {
|
|||
} else if (state == ERR_TX_TIMEOUT) {
|
||||
Serial.println(F("[SX1280] Timed out while transmitting!"));
|
||||
} else {
|
||||
Serial.println(F("[SX1280] Failed to transmit packet, code "));
|
||||
Serial.print(F("[SX1280] Failed to transmit packet, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
// receive BLE packet
|
||||
String str;
|
||||
state = ble.receive(str);
|
||||
state = radio.receive(str);
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = ble.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Received packet!"));
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -18,25 +21,18 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 lora = new Module(10, 2, 3, 9);
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 lora = RadioShield.ModuleA;
|
||||
//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 = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -50,7 +46,7 @@ void loop() {
|
|||
Serial.print(F("[SX1280] Scanning channel for LoRa transmission ... "));
|
||||
|
||||
// start scanning current channel
|
||||
int state = lora.scanChannel();
|
||||
int state = radio.scanChannel();
|
||||
|
||||
if (state == LORA_DETECTED) {
|
||||
// LoRa preamble was detected
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
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/
|
||||
*/
|
||||
|
@ -21,26 +24,18 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 flrc = new Module(10, 2, 3, 9);
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 flrc = RadioShield.ModuleA;
|
||||
//SX1280 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
// carrier frequency: 2400.0 MHz
|
||||
// bit rate: 650 kbps
|
||||
// coding rate: 3
|
||||
// output power: 10 dBm
|
||||
// preamble length: 16 bits
|
||||
// data shaping: Gaussian, BT = 0.5
|
||||
// sync word: 0x2D 0x01 0x4B 0x1D
|
||||
// CRC: enabled
|
||||
int state = flrc.beginFLRC();
|
||||
int state = radio.beginFLRC();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -49,20 +44,20 @@ void setup() {
|
|||
while (true);
|
||||
}
|
||||
|
||||
// if needed, you can switch between LoRa and FLRC modes
|
||||
// if needed, you can switch between any of the modems
|
||||
//
|
||||
// flrc.begin() start LoRa mode (and disable FLRC)
|
||||
// lora.beginFLRC() start FLRC mode (and disable LoRa)
|
||||
// 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 = flrc.setFrequency(2410.5);
|
||||
state = flrc.setBitRate(200);
|
||||
state = flrc.setCodingRate(2);
|
||||
state = flrc.setOutputPower(5);
|
||||
state = flrc.setDataShaping(1.0);
|
||||
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 = flrc.setSyncWord(syncWord, 4);
|
||||
state = radio.setSyncWord(syncWord, 4);
|
||||
if (state != ERR_NONE) {
|
||||
Serial.print(F("Unable to set configuration, code "));
|
||||
Serial.println(state);
|
||||
|
@ -77,11 +72,11 @@ void loop() {
|
|||
// as the LoRa modem, even their interrupt-driven versions
|
||||
|
||||
// transmit FLRC packet
|
||||
int state = flrc.transmit("Hello World!");
|
||||
int state = radio.transmit("Hello World!");
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = flrc.transmit(byteArr, 8);
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Packet transmitted successfully!"));
|
||||
|
@ -94,12 +89,12 @@ void loop() {
|
|||
Serial.println(state);
|
||||
}
|
||||
|
||||
// receive GFSK packet
|
||||
// receive FLRC packet
|
||||
String str;
|
||||
state = flrc.receive(str);
|
||||
state = radio.receive(str);
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = flrc.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Received packet!"));
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
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/
|
||||
*/
|
||||
|
@ -21,26 +24,18 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 gfsk = new Module(10, 2, 3, 9);
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 lora = RadioShield.ModuleA;
|
||||
//SX1280 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize SX1280 with default settings
|
||||
Serial.print(F("[SX1280] Initializing ... "));
|
||||
// carrier frequency: 2400.0 MHz
|
||||
// bit rate: 800 kbps
|
||||
// frequency deviation: 400.0 kHz
|
||||
// output power: 10 dBm
|
||||
// preamble length: 16 bits
|
||||
// data shaping: Gaussian, BT = 0.5
|
||||
// sync word: 0x2D 0x01
|
||||
// CRC: enabled, CRC16 (CCIT)
|
||||
int state = gfsk.beginGFSK();
|
||||
int state = radio.beginGFSK();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -49,20 +44,20 @@ void setup() {
|
|||
while (true);
|
||||
}
|
||||
|
||||
// if needed, you can switch between LoRa and FSK modes
|
||||
// if needed, you can switch between any of the modems
|
||||
//
|
||||
// gfsk.begin() start LoRa mode (and disable GFSK)
|
||||
// lora.beginGFSK() start GFSK mode (and disable LoRa)
|
||||
// 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 = gfsk.setFrequency(2410.5);
|
||||
state = gfsk.setBitRate(200);
|
||||
state = gfsk.setFrequencyDeviation(100.0);
|
||||
state = gfsk.setOutputPower(5);
|
||||
state = gfsk.setDataShaping(1.0);
|
||||
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 = gfsk.setSyncWord(syncWord, 5);
|
||||
state = radio.setSyncWord(syncWord, 5);
|
||||
if (state != ERR_NONE) {
|
||||
Serial.print(F("Unable to set configuration, code "));
|
||||
Serial.println(state);
|
||||
|
@ -77,11 +72,11 @@ void loop() {
|
|||
// as the LoRa modem, even their interrupt-driven versions
|
||||
|
||||
// transmit GFSK packet
|
||||
int state = gfsk.transmit("Hello World!");
|
||||
int state = radio.transmit("Hello World!");
|
||||
/*
|
||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||
0x89, 0xAB, 0xCD, 0xEF};
|
||||
int state = gfsk.transmit(byteArr, 8);
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Packet transmitted successfully!"));
|
||||
|
@ -96,10 +91,10 @@ void loop() {
|
|||
|
||||
// receive GFSK packet
|
||||
String str;
|
||||
state = gfsk.receive(str);
|
||||
state = radio.receive(str);
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = gfsk.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("[SX1280] Received packet!"));
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -20,25 +23,18 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 lora = new Module(10, 2, 3, 9);
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 lora = RadioShield.ModuleA;
|
||||
//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 = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -54,18 +50,18 @@ void loop() {
|
|||
// start ranging exchange
|
||||
// range as master: true
|
||||
// slave address: 0x12345678
|
||||
int state = lora.range(true, 0x12345678);
|
||||
int state = radio.range(true, 0x12345678);
|
||||
|
||||
// the other module must be configured as slave with the same address
|
||||
/*
|
||||
int state = lora.range(false, 0x12345678);
|
||||
int state = radio.range(false, 0x12345678);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
// ranging finished successfully
|
||||
Serial.println(F("success!"));
|
||||
Serial.print(F("[SX1280] Distance:\t\t\t"));
|
||||
Serial.print(lora.getRangingResult());
|
||||
Serial.print(radio.getRangingResult());
|
||||
Serial.println(F(" meters"));
|
||||
|
||||
} else if (state == ERR_RANGING_TIMEOUT) {
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -25,25 +28,18 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 lora = new Module(10, 2, 3, 9);
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 lora = RadioShield.ModuleA;
|
||||
//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 = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -61,12 +57,12 @@ void loop() {
|
|||
// See example ReceiveInterrupt for details
|
||||
// on non-blocking reception method.
|
||||
String str;
|
||||
int state = lora.receive(str);
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = lora.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
@ -80,13 +76,13 @@ void loop() {
|
|||
// print the RSSI (Received Signal Strength Indicator)
|
||||
// of the last received packet
|
||||
Serial.print(F("[SX1280] RSSI:\t\t"));
|
||||
Serial.print(lora.getRSSI());
|
||||
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(lora.getSNR());
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -26,25 +29,18 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 lora = new Module(10, 2, 3, 9);
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 lora = RadioShield.ModuleA;
|
||||
//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 = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -55,11 +51,11 @@ void setup() {
|
|||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
lora.setDio1Action(setFlag);
|
||||
radio.setDio1Action(setFlag);
|
||||
|
||||
// start listening for LoRa packets
|
||||
Serial.print(F("[SX1280] Starting to listen ... "));
|
||||
state = lora.startReceive();
|
||||
state = radio.startReceive();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -71,12 +67,12 @@ void setup() {
|
|||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// lora.standby()
|
||||
// lora.sleep()
|
||||
// lora.transmit();
|
||||
// lora.receive();
|
||||
// lora.readData();
|
||||
// lora.scanChannel();
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
// radio.scanChannel();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
|
@ -111,12 +107,12 @@ void loop() {
|
|||
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
int state = lora.readData(str);
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = lora.readData(byteArr, 8);
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
@ -129,12 +125,12 @@ void loop() {
|
|||
|
||||
// print RSSI (Received Signal Strength Indicator)
|
||||
Serial.print(F("[SX1280] RSSI:\t\t"));
|
||||
Serial.print(lora.getRSSI());
|
||||
Serial.print(radio.getRSSI());
|
||||
Serial.println(F(" dBm"));
|
||||
|
||||
// print SNR (Signal-to-Noise Ratio)
|
||||
Serial.print(F("[SX1280] SNR:\t\t"));
|
||||
Serial.print(lora.getSNR());
|
||||
Serial.print(radio.getSNR());
|
||||
Serial.println(F(" dB"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
|
@ -149,7 +145,7 @@ void loop() {
|
|||
}
|
||||
|
||||
// put module back to listen mode
|
||||
lora.startReceive();
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -26,32 +29,25 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 loraSX1280 = new Module(10, 2, 3, 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 loraSX1281 = new Module(8, 4, 5, 6);
|
||||
SX1281 radio2 = new Module(8, 4, 5, 6);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1282 loraSX1282 = RadioShield.ModuleB;
|
||||
//SX1282 radio3 = RadioShield.ModuleB;
|
||||
|
||||
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 = loraSX1280.begin();
|
||||
int state = radio1.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -71,8 +67,7 @@ void setup() {
|
|||
// coding rate: 5
|
||||
// output power: 2 dBm
|
||||
// preamble length: 20 symbols
|
||||
// CRC: enabled
|
||||
state = loraSX1281.begin(2450.0, 1625.0, 7, 5, 2, 20);
|
||||
state = radio2.begin(2450.0, 1625.0, 7, 5, 2, 20);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -85,43 +80,43 @@ void setup() {
|
|||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 2410.5 MHz
|
||||
if (loraSX1280.setFrequency(2410.5) == ERR_INVALID_FREQUENCY) {
|
||||
if (radio1.setFrequency(2410.5) == ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bandwidth to 203.125 kHz
|
||||
if (loraSX1280.setBandwidth(203.125) == ERR_INVALID_BANDWIDTH) {
|
||||
if (radio1.setBandwidth(203.125) == ERR_INVALID_BANDWIDTH) {
|
||||
Serial.println(F("Selected bandwidth is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set spreading factor to 10
|
||||
if (loraSX1280.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) {
|
||||
if (radio1.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) {
|
||||
Serial.println(F("Selected spreading factor is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set coding rate to 6
|
||||
if (loraSX1280.setCodingRate(6) == ERR_INVALID_CODING_RATE) {
|
||||
if (radio1.setCodingRate(6) == ERR_INVALID_CODING_RATE) {
|
||||
Serial.println(F("Selected coding rate is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set output power to -2 dBm
|
||||
if (loraSX1280.setOutputPower(-2) == ERR_INVALID_OUTPUT_POWER) {
|
||||
if (radio1.setOutputPower(-2) == 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 (loraSX1280.setPreambleLength(16) == ERR_INVALID_PREAMBLE_LENGTH) {
|
||||
if (radio1.setPreambleLength(16) == ERR_INVALID_PREAMBLE_LENGTH) {
|
||||
Serial.println(F("Selected preamble length is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// disable CRC
|
||||
if (loraSX1280.setCRC(false) == ERR_INVALID_CRC_CONFIGURATION) {
|
||||
if (radio1.setCRC(false) == ERR_INVALID_CRC_CONFIGURATION) {
|
||||
Serial.println(F("Selected CRC is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -21,11 +24,11 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 lora = new Module(10, 2, 3, 9);
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 lora = RadioShield.ModuleA;
|
||||
//SX1280 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
@ -39,7 +42,7 @@ void setup() {
|
|||
// output power: 10 dBm
|
||||
// preamble length: 12 symbols
|
||||
// CRC: enabled
|
||||
int state = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -47,6 +50,16 @@ void setup() {
|
|||
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() {
|
||||
|
@ -57,12 +70,12 @@ void loop() {
|
|||
// NOTE: transmit() is a blocking method!
|
||||
// See example SX128x_Transmit_Interrupt for details
|
||||
// on non-blocking transmission method.
|
||||
int state = lora.transmit("Hello World!");
|
||||
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 = lora.transmit(byteArr, 8);
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -22,11 +25,11 @@
|
|||
// DIO1 pin: 2
|
||||
// NRST pin: 3
|
||||
// BUSY pin: 9
|
||||
SX1280 lora = new Module(10, 2, 3, 9);
|
||||
SX1280 radio = new Module(10, 2, 3, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//SX1280 lora = RadioShield.ModuleA;
|
||||
//SX1280 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = ERR_NONE;
|
||||
|
@ -36,14 +39,7 @@ void setup() {
|
|||
|
||||
// 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 = lora.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -54,20 +50,20 @@ void setup() {
|
|||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
lora.setDio1Action(setFlag);
|
||||
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 = lora.startTransmit("Hello World!");
|
||||
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 = lora.startTransmit(byteArr, 8);
|
||||
state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -119,13 +115,13 @@ void loop() {
|
|||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = lora.startTransmit("Hello World!");
|
||||
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 = lora.startTransmit(byteArr, 8);
|
||||
int state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
// we're ready to send more packets,
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -22,24 +25,18 @@
|
|||
// nSEL pin: 10
|
||||
// nIRQ pin: 2
|
||||
// SDN pin: 9
|
||||
Si4432 fsk = new Module(10, 2, 9);
|
||||
Si4432 radio = new Module(10, 2, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//Si4432 fsk = RadioShield.ModuleA;
|
||||
//Si4432 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize Si4432 with default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 225.1 kHz
|
||||
// output power: 11 dBm
|
||||
// sync word: 0x2D 0x01
|
||||
int state = fsk.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -54,12 +51,12 @@ void loop() {
|
|||
|
||||
// you can receive data as an Arduino String
|
||||
String str;
|
||||
int state = fsk.receive(str);
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = rf.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -18,24 +21,18 @@
|
|||
// nSEL pin: 10
|
||||
// nIRQ pin: 2
|
||||
// SDN pin: 9
|
||||
Si4432 fsk = new Module(10, 2, 9);
|
||||
Si4432 radio = new Module(10, 2, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//Si4432 fsk = RadioShield.ModuleA;
|
||||
//Si4432 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize Si4432 with default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 225.1 kHz
|
||||
// output power: 11 dBm
|
||||
// sync word: 0x2D 0x01
|
||||
int state = fsk.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -46,11 +43,11 @@ void setup() {
|
|||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
fsk.setIrqAction(setFlag);
|
||||
radio.setIrqAction(setFlag);
|
||||
|
||||
// start listening for packets
|
||||
Serial.print(F("[Si4432] Starting to listen ... "));
|
||||
state = fsk.startReceive();
|
||||
state = radio.startReceive();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -62,11 +59,11 @@ void setup() {
|
|||
// if needed, 'listen' mode can be disabled by calling
|
||||
// any of the following methods:
|
||||
//
|
||||
// fsk.standby()
|
||||
// fsk.sleep()
|
||||
// fsk.transmit();
|
||||
// fsk.receive();
|
||||
// fsk.readData();
|
||||
// radio.standby()
|
||||
// radio.sleep()
|
||||
// radio.transmit();
|
||||
// radio.receive();
|
||||
// radio.readData();
|
||||
}
|
||||
|
||||
// flag to indicate that a packet was received
|
||||
|
@ -101,12 +98,12 @@ void loop() {
|
|||
|
||||
// you can read received data as an Arduino String
|
||||
String str;
|
||||
int state = fsk.readData(str);
|
||||
int state = radio.readData(str);
|
||||
|
||||
// you can also read received data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = fsk.readData(byteArr, 8);
|
||||
int state = radio.readData(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
@ -129,7 +126,7 @@ void loop() {
|
|||
}
|
||||
|
||||
// put module back to listen mode
|
||||
fsk.startReceive();
|
||||
radio.startReceive();
|
||||
|
||||
// we're ready to receive more packets,
|
||||
// enable interrupt service routine
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
- 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/
|
||||
*/
|
||||
|
@ -22,30 +25,24 @@
|
|||
// nSEL pin: 10
|
||||
// nIRQ pin: 2
|
||||
// SDN pin: 9
|
||||
Si4432 fsk1 = new Module(10, 2, 9);
|
||||
Si4432 radio1 = new Module(10, 2, 9);
|
||||
|
||||
// Si4432 has the following connections:
|
||||
// nSEL pin: 8
|
||||
// nIRQ pin: 3
|
||||
// SDN pin: 7
|
||||
Si4432 fsk2 = new Module(8, 3, 7);
|
||||
Si4432 radio2 = new Module(8, 3, 7);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//Si4432 fsk3 = RadioShield.ModuleB;
|
||||
//Si4432 radio3 = RadioShield.ModuleB;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize Si4432 with default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 225.1 kHz
|
||||
// output power: 11 dBm
|
||||
// sync word: 0x2D 0x01
|
||||
int state = fsk1.begin();
|
||||
int state = radio1.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -61,8 +58,8 @@ void setup() {
|
|||
// frequency deviation: 60.0 kHz
|
||||
// Rx bandwidth: 335.5 kHz
|
||||
// output power: 17 dBm
|
||||
// sync word: 0x2D 0x01
|
||||
state = fsk2.begin(868.0, 200.0, 60.0, 335.5, 17);
|
||||
// preamble length: 32 bits
|
||||
state = radio2.begin(868.0, 200.0, 60.0, 335.5, 17, 32);
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -75,13 +72,13 @@ void setup() {
|
|||
// and check if the configuration was changed successfully
|
||||
|
||||
// set carrier frequency to 433.5 MHz
|
||||
if (fsk1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||
if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||
Serial.println(F("[Si4432] Selected frequency is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
||||
// set bit rate to 100.0 kbps
|
||||
state = fsk1.setBitRate(100.0);
|
||||
state = radio1.setBitRate(100.0);
|
||||
if (state == ERR_INVALID_BIT_RATE) {
|
||||
Serial.println(F("[Si4432] Selected bit rate is invalid for this module!"));
|
||||
while (true);
|
||||
|
@ -92,20 +89,20 @@ void setup() {
|
|||
}
|
||||
|
||||
// set receiver bandwidth to 284.8 kHz
|
||||
state = fsk1.setRxBandwidth(284.8);
|
||||
state = radio1.setRxBandwidth(284.8);
|
||||
if (state == 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 (fsk1.setFrequencyDeviation(10.0) == ERR_INVALID_FREQUENCY_DEVIATION) {
|
||||
if (radio1.setFrequencyDeviation(10.0) == 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 (fsk1.setOutputPower(2) == ERR_INVALID_OUTPUT_POWER) {
|
||||
if (radio1.setOutputPower(2) == ERR_INVALID_OUTPUT_POWER) {
|
||||
Serial.println(F("[Si4432] Selected output power is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
@ -113,7 +110,7 @@ void setup() {
|
|||
// up to 4 bytes can be set as sync word
|
||||
// set sync word to 0x01234567
|
||||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67};
|
||||
if (fsk1.setSyncWord(syncWord, 4) == ERR_INVALID_SYNC_WORD) {
|
||||
if (radio1.setSyncWord(syncWord, 4) == ERR_INVALID_SYNC_WORD) {
|
||||
Serial.println(F("[Si4432] Selected sync word is invalid for this module!"));
|
||||
while (true);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -20,24 +23,18 @@
|
|||
// nSEL pin: 10
|
||||
// nIRQ pin: 2
|
||||
// SDN pin: 9
|
||||
Si4432 fsk = new Module(10, 2, 9);
|
||||
Si4432 radio = new Module(10, 2, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//Si4432 fsk = RadioShield.ModuleA;
|
||||
//Si4432 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize Si4432 with default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 225.1 kHz
|
||||
// output power: 11 dBm
|
||||
// sync word: 0x2D 0x01
|
||||
int state = fsk.begin();
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -55,12 +52,12 @@ void loop() {
|
|||
// NOTE: transmit() is a blocking method!
|
||||
// See example Si443x_Transmit_Interrupt for details
|
||||
// on non-blocking transmission method.
|
||||
int state = fsk.transmit("Hello World!");
|
||||
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 = fsk.transmit(byteArr, 8);
|
||||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -20,11 +23,11 @@
|
|||
// nSEL pin: 10
|
||||
// nIRQ pin: 2
|
||||
// SDN pin: 9
|
||||
Si4432 fsk = new Module(10, 2, 9);
|
||||
Si4432 radio = new Module(10, 2, 9);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//Si4432 fsk = RadioShield.ModuleA;
|
||||
//Si4432 radio = RadioShield.ModuleA;
|
||||
|
||||
// save transmission state between loops
|
||||
int transmissionState = ERR_NONE;
|
||||
|
@ -34,14 +37,7 @@ void setup() {
|
|||
|
||||
// initialize Si4432 with default settings
|
||||
Serial.print(F("[Si4432] Initializing ... "));
|
||||
// carrier frequency: 434.0 MHz
|
||||
// bit rate: 48.0 kbps
|
||||
// frequency deviation: 50.0 kHz
|
||||
// Rx bandwidth: 225.1 kHz
|
||||
// output power: 11 dBm
|
||||
// sync word: 0x2D 0x01
|
||||
int state = fsk.begin();
|
||||
fsk.setOutputPower(13);
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -52,20 +48,20 @@ void setup() {
|
|||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
fsk.setIrqAction(setFlag);
|
||||
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 = fsk.startTransmit("Hello World!");
|
||||
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 = fsk.startTransmit(byteArr, 8);
|
||||
state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -117,13 +113,13 @@ void loop() {
|
|||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 256 characters long
|
||||
transmissionState = fsk.startTransmit("Hello World!");
|
||||
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 = fsk.startTransmit(byteArr, 8);
|
||||
int state = radio.startTransmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
// we're ready to send more packets,
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
- 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/
|
||||
*/
|
||||
|
@ -20,22 +23,18 @@
|
|||
// CS pin: 10
|
||||
// IRQ pin: 2
|
||||
// CE pin: 3
|
||||
nRF24 nrf = new Module(10, 2, 3);
|
||||
nRF24 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//nRF24 nrf = RadioShield.ModuleA;
|
||||
//nRF24 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize nRF24
|
||||
// initialize nRF24 with default settings
|
||||
Serial.print(F("[nRF24] Initializing ... "));
|
||||
// carrier frequency: 2400 MHz
|
||||
// data rate: 1000 kbps
|
||||
// output power: -12 dBm
|
||||
// address width: 5 bytes
|
||||
int state = nrf.begin();
|
||||
int state = radio.begin();
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -50,7 +49,7 @@ void setup() {
|
|||
// methods (5 by default)
|
||||
Serial.print(F("[nRF24] Setting address for receive pipe 0 ... "));
|
||||
byte addr[] = {0x01, 0x23, 0x45, 0x67, 0x89};
|
||||
state = nrf.setReceivePipe(0, addr);
|
||||
state = radio.setReceivePipe(0, addr);
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -68,12 +67,12 @@ void loop() {
|
|||
// See example ReceiveInterrupt for details
|
||||
// on non-blocking reception method.
|
||||
String str;
|
||||
int state = nrf.receive(str);
|
||||
int state = radio.receive(str);
|
||||
|
||||
// you can also receive data as byte array
|
||||
/*
|
||||
byte byteArr[8];
|
||||
int state = nrf.receive(byteArr, 8);
|
||||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
|
||||
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/
|
||||
*/
|
||||
|
@ -20,22 +23,18 @@
|
|||
// CS pin: 10
|
||||
// IRQ pin: 2
|
||||
// CE pin: 3
|
||||
nRF24 nrf = new Module(10, 2, 3);
|
||||
nRF24 radio = new Module(10, 2, 3);
|
||||
|
||||
// or using RadioShield
|
||||
// https://github.com/jgromes/RadioShield
|
||||
//nRF24 nrf = RadioShield.ModuleA;
|
||||
//nRF24 radio = RadioShield.ModuleA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// initialize nRF24
|
||||
// initialize nRF24 with default settings
|
||||
Serial.print(F("[nRF24] Initializing ... "));
|
||||
// carrier frequency: 2400 MHz
|
||||
// data rate: 1000 kbps
|
||||
// output power: -12 dBm
|
||||
// address width: 5 bytes
|
||||
int state = nrf.begin();
|
||||
int state = radio.begin();
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -50,7 +49,7 @@ void setup() {
|
|||
// methods (5 by default)
|
||||
byte addr[] = {0x01, 0x23, 0x45, 0x67, 0x89};
|
||||
Serial.print(F("[nRF24] Setting transmit pipe ... "));
|
||||
state = nrf.setTransmitPipe(addr);
|
||||
state = radio.setTransmitPipe(addr);
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -65,7 +64,7 @@ void loop() {
|
|||
|
||||
// you can transmit C-string or Arduino string up to
|
||||
// 32 characters long
|
||||
int state = nrf.transmit("Hello World!");
|
||||
int state = radio.transmit("Hello World!");
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
|
|
112
extras/decoder/DebugDecoder.py
Normal file
112
extras/decoder/DebugDecoder.py
Normal file
|
@ -0,0 +1,112 @@
|
|||
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
|
||||
4. AT 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()
|
|
@ -1,4 +1,5 @@
|
|||
#include "<module_name>.h"
|
||||
#if !defined(RADIOLIB_EXCLUDE_<module_name>)
|
||||
|
||||
<module_name>::<module_name>(Module* mod) {
|
||||
/*
|
||||
|
@ -12,10 +13,10 @@ 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, sending AT command for UART modules, or reading a version register for SPI/I2C modules
|
||||
*/
|
||||
}
|
|
@ -12,14 +12,16 @@
|
|||
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>)
|
||||
#ifndef _RADIOLIB_<module_name>_H
|
||||
#define _RADIOLIB_<module_name>_H
|
||||
|
||||
/*
|
||||
Header file for each module MUST include Module.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 "../../Module.h"
|
||||
#include "../../TypeDef.h"
|
||||
|
||||
/*
|
||||
Only use the following include if the module implements methods for OSI transport layer control.
|
||||
|
@ -29,7 +31,7 @@
|
|||
You also MUST provide crystal oscillator frequency and frequency configuration divisor step resolution
|
||||
to the TransportLayer constructor.
|
||||
*/
|
||||
//#include "../protocols/TransportLayer.h"
|
||||
//#include "../../protocols/PhysicalLayer/TransportLayer.h"
|
||||
|
||||
/*
|
||||
Only use the following include if the module implements methods for OSI physical layer control.
|
||||
|
@ -37,7 +39,7 @@
|
|||
|
||||
In this case, your class MUST implement all virtual methods of PhysicalLayer class.
|
||||
*/
|
||||
//#include "../protocols/PhysicalLayer.h"
|
||||
//#include "../../protocols/PhysicalLayer/PhysicalLayer.h"
|
||||
|
||||
/*
|
||||
Register map
|
||||
|
@ -74,7 +76,7 @@ class <module_name> {
|
|||
The class MAY implement additional overloaded constructors.
|
||||
*/
|
||||
// constructor
|
||||
<module_name>(Module* module);
|
||||
<module_name>(Module* mod);
|
||||
|
||||
/*
|
||||
The class MUST implement at least one basic method called "begin".
|
||||
|
@ -105,3 +107,5 @@ class <module_name> {
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
23
keywords.txt
23
keywords.txt
|
@ -53,6 +53,7 @@ AX25Client KEYWORD1
|
|||
AX25Frame KEYWORD1
|
||||
SSTVClient KEYWORD1
|
||||
HellClient KEYWORD1
|
||||
AFSKClient KEYWORD1
|
||||
|
||||
# SSTV modes
|
||||
Scottie1 KEYWORD1
|
||||
|
@ -123,6 +124,13 @@ disableSyncWordFiltering KEYWORD2
|
|||
setPromiscuous KEYWORD2
|
||||
setRSSIConfig KEYWORD2
|
||||
setEncoding KEYWORD2
|
||||
getIRQFlags KEYWORD2
|
||||
getModemStatus KEYWORD2
|
||||
getTempRaw KEYWORD2
|
||||
setRfSwitchPins KEYWORD2
|
||||
forceLDRO KEYWORD2
|
||||
autoLDRO KEYWORD2
|
||||
getChipVersion KEYWORD2
|
||||
|
||||
# RF69-specific
|
||||
setAESKey KEYWORD2
|
||||
|
@ -137,6 +145,7 @@ setGdo0Action KEYWORD2
|
|||
setGdo2Action KEYWORD2
|
||||
clearGdo0Action KEYWORD2
|
||||
clearGdo2Action KEYWORD2
|
||||
setCrcFiltering KEYWORD2
|
||||
|
||||
# SX126x-specific
|
||||
setTCXO KEYWORD2
|
||||
|
@ -225,6 +234,10 @@ getRangingResult KEYWORD2
|
|||
# Hellschreiber
|
||||
printGlyph KEYWORD2
|
||||
|
||||
# AFSK
|
||||
tone KEYWORD2
|
||||
noTone KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
@ -232,6 +245,16 @@ printGlyph KEYWORD2
|
|||
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
|
||||
|
||||
ERR_NONE LITERAL1
|
||||
ERR_UNKNOWN LITERAL1
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name=RadioLib
|
||||
version=3.4.0
|
||||
version=4.2.0
|
||||
author=Jan Gromes <gromes.jan@gmail.com>
|
||||
maintainer=Jan Gromes <gromes.jan@gmail.com>
|
||||
sentence=Universal wireless communication library for Arduino
|
||||
|
|
408
src/BuildOpt.h
408
src/BuildOpt.h
|
@ -10,118 +10,335 @@
|
|||
/*
|
||||
* Platform-specific configuration.
|
||||
*
|
||||
* RADIOLIB_PLATFORM - platform name, used in debugging to quickly check the correct platform is detected.
|
||||
* RADIOLIB_PIN_TYPE - which type should be used for pin numbers in functions like digitalRead().
|
||||
* RADIOLIB_PIN_MODE - which type should be used for pin modes in functions like pinMode().
|
||||
* RADIOLIB_PIN_STATUS - which type should be used for pin values in functions like digitalWrite().
|
||||
* RADIOLIB_INTERRUPT_STATUS - which type should be used for pin changes in functions like attachInterrupt().
|
||||
* RADIOLIB_DIGITAL_PIN_TO_INTERRUPT - function/macro to be used to convert digital pin number to interrupt pin number.
|
||||
* RADIOLIB_NC - alias for unused pin, usually the largest possible value of RADIOLIB_PIN_TYPE.
|
||||
* RADIOLIB_DEFAULT_SPI - default SPIClass instance to use.
|
||||
* RADIOLIB_PROGMEM - macro to place variable into program storage (usually Flash).
|
||||
* RADIOLIB_PROGMEM_READ_BYTE - function/macro to read variables saved in program storage (usually Flash).
|
||||
* RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - defined if the specific platform does not support SoftwareSerial.
|
||||
* RADIOLIB_HARDWARE_SERIAL_PORT - which hardware serial port should be used on platform that do not have SoftwareSerial support.
|
||||
* RADIOLIB_TONE_UNSUPPORTED - some platforms do not have tone()/noTone(), which is required for AFSK.
|
||||
*
|
||||
* In addition, some platforms may require RadioLib to disable specific drivers (such as ESP8266).
|
||||
*
|
||||
* Users may also specify their own configuration by uncommenting the RADIOLIB_CUSTOM_PLATFORM,
|
||||
* and then specifying all platform parameters in the section below. This will override automatic
|
||||
* platform detection.
|
||||
*/
|
||||
#if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY))
|
||||
// Arduino AVR boards (except for megaAVR) - Uno, Mega etc.
|
||||
#define RADIOLIB_PIN_TYPE uint8_t
|
||||
#define RADIOLIB_PIN_MODE uint8_t
|
||||
#define RADIOLIB_PIN_STATUS uint8_t
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
|
||||
#elif defined(ESP8266)
|
||||
// ESP8266 boards
|
||||
#define RADIOLIB_PIN_TYPE uint8_t
|
||||
#define RADIOLIB_PIN_MODE uint8_t
|
||||
#define RADIOLIB_PIN_STATUS uint8_t
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
// uncomment to enable custom platform definition
|
||||
//#define RADIOLIB_CUSTOM_PLATFORM
|
||||
|
||||
// RadioLib has ESPS8266 driver, this must be disabled to use ESP8266 as platform
|
||||
#define _RADIOLIB_ESP8266_H
|
||||
#if defined(RADIOLIB_CUSTOM_PLATFORM)
|
||||
// name for your platform
|
||||
#define RADIOLIB_PLATFORM "Custom"
|
||||
|
||||
#elif defined(ESP32)
|
||||
// ESP32 boards
|
||||
// the following parameters must always be defined
|
||||
#define RADIOLIB_PIN_TYPE uint8_t
|
||||
#define RADIOLIB_PIN_MODE uint8_t
|
||||
#define RADIOLIB_PIN_STATUS uint8_t
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32)
|
||||
// STM32duino boards
|
||||
#define RADIOLIB_PIN_TYPE uint32_t
|
||||
#define RADIOLIB_PIN_MODE uint32_t
|
||||
#define RADIOLIB_PIN_STATUS uint32_t
|
||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
// the following must be defined if the Arduino core does not support SoftwareSerial library
|
||||
//#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
//#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
|
||||
#elif defined(SAMD_SERIES)
|
||||
// Arduino SAMD boards - Zero, MKR, etc.
|
||||
#define RADIOLIB_PIN_TYPE uint32_t
|
||||
#define RADIOLIB_PIN_MODE uint32_t
|
||||
#define RADIOLIB_PIN_STATUS uint32_t
|
||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
// the following must be defined if the Arduino core does not support tone function
|
||||
//#define RADIOLIB_TONE_UNSUPPORTED
|
||||
|
||||
#elif defined(__SAM3X8E__)
|
||||
// Arduino Due
|
||||
#define RADIOLIB_PIN_TYPE uint32_t
|
||||
#define RADIOLIB_PIN_MODE uint32_t
|
||||
#define RADIOLIB_PIN_STATUS uint32_t
|
||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
|
||||
#elif (defined(NRF52832_XXAA) || defined(NRF52840_XXAA)) && !defined(ARDUINO_ARDUINO_NANO33BLE)
|
||||
// Adafruit nRF52 boards
|
||||
#define RADIOLIB_PIN_TYPE uint32_t
|
||||
#define RADIOLIB_PIN_MODE uint32_t
|
||||
#define RADIOLIB_PIN_STATUS uint32_t
|
||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
||||
|
||||
#elif defined(ARDUINO_ARC32_TOOLS)
|
||||
// Intel Curie
|
||||
#define RADIOLIB_PIN_TYPE uint8_t
|
||||
#define RADIOLIB_PIN_MODE uint8_t
|
||||
#define RADIOLIB_PIN_STATUS uint8_t
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
|
||||
#elif defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY)
|
||||
// Arduino megaAVR boards - Uno Wifi Rev.2, Nano Every
|
||||
#define RADIOLIB_PIN_TYPE uint8_t
|
||||
#define RADIOLIB_PIN_MODE PinMode
|
||||
#define RADIOLIB_PIN_STATUS PinStatus
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
|
||||
#elif defined(AM_PART_APOLLO3)
|
||||
// Sparkfun Artemis boards
|
||||
#define RADIOLIB_PIN_TYPE uint8_t
|
||||
#define RADIOLIB_PIN_MODE uint8_t
|
||||
#define RADIOLIB_PIN_STATUS uint8_t
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
|
||||
#elif defined(ARDUINO_ARDUINO_NANO33BLE)
|
||||
// Arduino Nano 33 BLE
|
||||
#define RADIOLIB_PIN_TYPE pin_size_t
|
||||
#define RADIOLIB_PIN_MODE PinMode
|
||||
#define RADIOLIB_PIN_STATUS PinStatus
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
|
||||
// Nano 33 BLE uses mbed libraries, which already contain ESP8266 driver
|
||||
#define _RADIOLIB_ESP8266_H
|
||||
// some of RadioLib drivers may be excluded, to prevent collisions with platforms (or to speed up build process)
|
||||
// the following is a complete list of all possible exclusion macros, uncomment any of them to disable that driver
|
||||
// NOTE: Some of the exclusion macros are dependent on each other. For example, it is not possible to exclude RF69
|
||||
// while keeping SX1231 (because RF69 is the base class for SX1231). The dependency is always uni-directional,
|
||||
// so excluding SX1231 and keeping RF69 is valid.
|
||||
//#define RADIOLIB_EXCLUDE_CC1101
|
||||
//#define RADIOLIB_EXCLUDE_ESP8266
|
||||
//#define RADIOLIB_EXCLUDE_HC05
|
||||
//#define RADIOLIB_EXCLUDE_JDY08
|
||||
//#define RADIOLIB_EXCLUDE_NRF24
|
||||
//#define RADIOLIB_EXCLUDE_RF69
|
||||
//#define RADIOLIB_EXCLUDE_SX1231 // dependent on RADIOLIB_EXCLUDE_RF69
|
||||
//#define RADIOLIB_EXCLUDE_SI443X
|
||||
//#define RADIOLIB_EXCLUDE_RFM2X // dependent on RADIOLIB_EXCLUDE_SI443X
|
||||
//#define RADIOLIB_EXCLUDE_SX127X
|
||||
//#define RADIOLIB_EXCLUDE_RFM9X // dependent on RADIOLIB_EXCLUDE_SX127X
|
||||
//#define RADIOLIB_EXCLUDE_SX126X
|
||||
//#define RADIOLIB_EXCLUDE_SX128X
|
||||
//#define RADIOLIB_EXCLUDE_XBEE
|
||||
//#define RADIOLIB_EXCLUDE_AFSK
|
||||
//#define RADIOLIB_EXCLUDE_AX25
|
||||
//#define RADIOLIB_EXCLUDE_HELLSCHREIBER
|
||||
//#define RADIOLIB_EXCLUDE_HTTP
|
||||
//#define RADIOLIB_EXCLUDE_MORSE
|
||||
//#define RADIOLIB_EXCLUDE_MQTT
|
||||
//#define RADIOLIB_EXCLUDE_RTTY
|
||||
//#define RADIOLIB_EXCLUDE_SSTV
|
||||
|
||||
#else
|
||||
// other platforms not covered by the above list - this may or may not work
|
||||
#define RADIOLIB_UNKNOWN_PLATFORM
|
||||
#define RADIOLIB_PIN_TYPE uint8_t
|
||||
#define RADIOLIB_PIN_MODE uint8_t
|
||||
#define RADIOLIB_PIN_STATUS uint8_t
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(ARDUINO_ARCH_MEGAAVR))
|
||||
// Arduino AVR boards (except for megaAVR) - Uno, Mega etc.
|
||||
#define RADIOLIB_PLATFORM "Arduino AVR"
|
||||
#define RADIOLIB_PIN_TYPE uint8_t
|
||||
#define RADIOLIB_PIN_MODE uint8_t
|
||||
#define RADIOLIB_PIN_STATUS uint8_t
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
|
||||
#elif defined(ESP8266)
|
||||
// ESP8266 boards
|
||||
#define RADIOLIB_PLATFORM "ESP8266"
|
||||
#define RADIOLIB_PIN_TYPE uint8_t
|
||||
#define RADIOLIB_PIN_MODE uint8_t
|
||||
#define RADIOLIB_PIN_STATUS uint8_t
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
|
||||
// RadioLib has ESP8266 driver, this must be disabled to use ESP8266 as platform
|
||||
#define RADIOLIB_EXCLUDE_ESP8266
|
||||
|
||||
#elif defined(ESP32)
|
||||
// ESP32 boards
|
||||
#define RADIOLIB_PLATFORM "ESP32"
|
||||
#define RADIOLIB_PIN_TYPE uint8_t
|
||||
#define RADIOLIB_PIN_MODE uint8_t
|
||||
#define RADIOLIB_PIN_STATUS uint8_t
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
|
||||
// ESP32 doesn't support tone(), but it can be emulated via LED control peripheral
|
||||
#define RADIOLIB_TONE_UNSUPPORTED
|
||||
#define RADIOLIB_TONE_ESP32_CHANNEL (1)
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32)
|
||||
// official STM32 Arduino core (https://github.com/stm32duino/Arduino_Core_STM32)
|
||||
#define RADIOLIB_PLATFORM "Arduino STM32 (official)"
|
||||
#define RADIOLIB_PIN_TYPE uint32_t
|
||||
#define RADIOLIB_PIN_MODE uint32_t
|
||||
#define RADIOLIB_PIN_STATUS uint32_t
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
|
||||
// slow down SX126x/8x SPI on this platform
|
||||
#define RADIOLIB_SPI_SLOWDOWN
|
||||
|
||||
#elif defined(SAMD_SERIES)
|
||||
// Adafruit SAMD boards (M0 and M4)
|
||||
#define RADIOLIB_PLATFORM "Adafruit SAMD"
|
||||
#define RADIOLIB_PIN_TYPE uint32_t
|
||||
#define RADIOLIB_PIN_MODE uint32_t
|
||||
#define RADIOLIB_PIN_STATUS uint32_t
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
|
||||
// slow down SX126x/8x SPI on this platform
|
||||
#define RADIOLIB_SPI_SLOWDOWN
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD)
|
||||
// Arduino SAMD (Zero, MKR, etc.)
|
||||
#define RADIOLIB_PLATFORM "Arduino SAMD"
|
||||
#define RADIOLIB_PIN_TYPE pin_size_t
|
||||
#define RADIOLIB_PIN_MODE PinMode
|
||||
#define RADIOLIB_PIN_STATUS PinStatus
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
|
||||
#elif defined(__SAM3X8E__)
|
||||
// Arduino Due
|
||||
#define RADIOLIB_PLATFORM "Arduino Due"
|
||||
#define RADIOLIB_PIN_TYPE uint32_t
|
||||
#define RADIOLIB_PIN_MODE uint32_t
|
||||
#define RADIOLIB_PIN_STATUS uint32_t
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
#define RADIOLIB_TONE_UNSUPPORTED
|
||||
|
||||
#elif (defined(NRF52832_XXAA) || defined(NRF52840_XXAA)) && !defined(ARDUINO_ARDUINO_NANO33BLE)
|
||||
// Adafruit nRF52 boards
|
||||
#define RADIOLIB_PLATFORM "Adafruit nRF52"
|
||||
#define RADIOLIB_PIN_TYPE uint32_t
|
||||
#define RADIOLIB_PIN_MODE uint32_t
|
||||
#define RADIOLIB_PIN_STATUS uint32_t
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
|
||||
#elif defined(ARDUINO_ARC32_TOOLS)
|
||||
// Intel Curie
|
||||
#define RADIOLIB_PLATFORM "Intel Curie"
|
||||
#define RADIOLIB_PIN_TYPE uint8_t
|
||||
#define RADIOLIB_PIN_MODE uint8_t
|
||||
#define RADIOLIB_PIN_STATUS uint8_t
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
|
||||
#elif defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY)
|
||||
// Arduino megaAVR boards - Uno Wifi Rev.2, Nano Every
|
||||
#define RADIOLIB_PLATFORM "Arduino megaAVR"
|
||||
#define RADIOLIB_PIN_TYPE uint8_t
|
||||
#define RADIOLIB_PIN_MODE PinMode
|
||||
#define RADIOLIB_PIN_STATUS PinStatus
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3)
|
||||
// Sparkfun Apollo3 boards
|
||||
#define RADIOLIB_PLATFORM "Sparkfun Apollo3"
|
||||
#define RADIOLIB_PIN_TYPE pin_size_t
|
||||
#define RADIOLIB_PIN_MODE Arduino_PinMode
|
||||
#define RADIOLIB_PIN_STATUS PinStatus
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
|
||||
// Apollo3 uses mbed libraries, which already contain ESP8266 driver
|
||||
#define RADIOLIB_EXCLUDE_ESP8266
|
||||
|
||||
// slow down SX126x/8x SPI on this platform
|
||||
#define RADIOLIB_SPI_SLOWDOWN
|
||||
|
||||
#elif defined(ARDUINO_ARDUINO_NANO33BLE)
|
||||
// Arduino Nano 33 BLE
|
||||
#define RADIOLIB_PLATFORM "Arduino Nano 33 BLE"
|
||||
#define RADIOLIB_PIN_TYPE pin_size_t
|
||||
#define RADIOLIB_PIN_MODE PinMode
|
||||
#define RADIOLIB_PIN_STATUS PinStatus
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
|
||||
// Nano 33 BLE uses mbed libraries, which already contain ESP8266 driver
|
||||
#define RADIOLIB_EXCLUDE_ESP8266
|
||||
|
||||
#elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
|
||||
// Arduino Portenta H7
|
||||
#define RADIOLIB_PLATFORM "Portenta H7"
|
||||
#define RADIOLIB_PIN_TYPE pin_size_t
|
||||
#define RADIOLIB_PIN_MODE PinMode
|
||||
#define RADIOLIB_PIN_STATUS PinStatus
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
|
||||
// Arduino Portenta H7 uses mbed libraries, which already contain ESP8266 driver
|
||||
#define RADIOLIB_EXCLUDE_ESP8266
|
||||
|
||||
#elif defined(__STM32F4__) || defined(__STM32F1__)
|
||||
// Arduino STM32 core by Roger Clark (https://github.com/rogerclarkmelbourne/Arduino_STM32)
|
||||
#define RADIOLIB_PLATFORM "STM32duino (unofficial)"
|
||||
#define RADIOLIB_PIN_TYPE uint8_t
|
||||
#define RADIOLIB_PIN_MODE WiringPinMode
|
||||
#define RADIOLIB_PIN_STATUS uint8_t
|
||||
#define RADIOLIB_INTERRUPT_STATUS ExtIntTriggerMode
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MEGAAVR)
|
||||
// MegaCoreX by MCUdude (https://github.com/MCUdude/MegaCoreX)
|
||||
#define RADIOLIB_PLATFORM "MegaCoreX"
|
||||
#define RADIOLIB_PIN_TYPE uint8_t
|
||||
#define RADIOLIB_PIN_MODE uint8_t
|
||||
#define RADIOLIB_PIN_STATUS uint8_t
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
|
||||
#else
|
||||
// other platforms not covered by the above list - this may or may not work
|
||||
#define RADIOLIB_PLATFORM "Unknown"
|
||||
#define RADIOLIB_UNKNOWN_PLATFORM
|
||||
#define RADIOLIB_PIN_TYPE uint8_t
|
||||
#define RADIOLIB_PIN_MODE uint8_t
|
||||
#define RADIOLIB_PIN_STATUS uint8_t
|
||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_PROGMEM PROGMEM
|
||||
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -138,7 +355,7 @@
|
|||
// set which Serial port should be used for debug output
|
||||
#define RADIOLIB_DEBUG_PORT Serial
|
||||
|
||||
#ifdef RADIOLIB_DEBUG
|
||||
#if defined(RADIOLIB_DEBUG)
|
||||
#define RADIOLIB_DEBUG_PRINT(...) { RADIOLIB_DEBUG_PORT.print(__VA_ARGS__); }
|
||||
#define RADIOLIB_DEBUG_PRINTLN(...) { RADIOLIB_DEBUG_PORT.println(__VA_ARGS__); }
|
||||
#else
|
||||
|
@ -146,7 +363,7 @@
|
|||
#define RADIOLIB_DEBUG_PRINTLN(...) {}
|
||||
#endif
|
||||
|
||||
#ifdef RADIOLIB_VERBOSE
|
||||
#if defined(RADIOLIB_VERBOSE)
|
||||
#define RADIOLIB_VERBOSE_PRINT(...) { RADIOLIB_DEBUG_PORT.print(__VA_ARGS__); }
|
||||
#define RADIOLIB_VERBOSE_PRINTLN(...) { RADIOLIB_DEBUG_PORT.println(__VA_ARGS__); }
|
||||
#else
|
||||
|
@ -174,7 +391,9 @@
|
|||
//#define RADIOLIB_STATIC_ONLY
|
||||
|
||||
// set the size of static arrays to use
|
||||
#if !defined(RADIOLIB_STATIC_ARRAY_SIZE)
|
||||
#define RADIOLIB_STATIC_ARRAY_SIZE 256
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\brief A simple assert macro, will return on error.
|
||||
|
@ -186,10 +405,9 @@
|
|||
*/
|
||||
#define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) { if(!(((VAR) >= (MIN)) && ((VAR) <= (MAX)))) { return(ERR); } }
|
||||
|
||||
|
||||
// version definitions
|
||||
#define RADIOLIB_VERSION_MAJOR (0x03)
|
||||
#define RADIOLIB_VERSION_MINOR (0x04)
|
||||
#define RADIOLIB_VERSION_MAJOR (0x04)
|
||||
#define RADIOLIB_VERSION_MINOR (0x02)
|
||||
#define RADIOLIB_VERSION_PATCH (0x00)
|
||||
#define RADIOLIB_VERSION_EXTRA (0x00)
|
||||
|
||||
|
|
|
@ -8,41 +8,10 @@ void ISerial::begin(long speed) {
|
|||
_mod->ModuleSerial->begin(speed);
|
||||
}
|
||||
|
||||
bool ISerial::listen() {
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
return true;
|
||||
#else
|
||||
return(_mod->ModuleSerial->listen());
|
||||
#endif
|
||||
}
|
||||
|
||||
void ISerial::end() {
|
||||
_mod->ModuleSerial->end();
|
||||
}
|
||||
|
||||
bool ISerial::isListening() {
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
return true;
|
||||
#else
|
||||
return(_mod->ModuleSerial->isListening());
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ISerial::stopListening() {
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
return true;
|
||||
#else
|
||||
return(_mod->ModuleSerial->stopListening());
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ISerial::overflow() {
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
return false;
|
||||
#else
|
||||
return(_mod->ModuleSerial->overflow());
|
||||
#endif
|
||||
}
|
||||
|
||||
int ISerial::peek() {
|
||||
return(_mod->ModuleSerial->peek());
|
||||
|
@ -64,9 +33,11 @@ void ISerial::flush() {
|
|||
_mod->ModuleSerial->flush();
|
||||
}
|
||||
|
||||
#ifndef ARDUINO_ARCH_MEGAAVR
|
||||
size_t ISerial::print(const __FlashStringHelper *ifsh) {
|
||||
return(_mod->ModuleSerial->print(ifsh));
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t ISerial::print(const String &s) {
|
||||
return(_mod->ModuleSerial->print(s));
|
||||
|
@ -108,9 +79,11 @@ size_t ISerial::print(const Printable& x) {
|
|||
return(_mod->ModuleSerial->print(x));
|
||||
}
|
||||
|
||||
#ifndef ARDUINO_ARCH_MEGAAVR
|
||||
size_t ISerial::println(const __FlashStringHelper *ifsh) {
|
||||
return(_mod->ModuleSerial->println(ifsh));
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t ISerial::println(const String &s) {
|
||||
return(_mod->ModuleSerial->println(s));
|
||||
|
|
|
@ -3,11 +3,6 @@
|
|||
|
||||
#include "Module.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "WString.h"
|
||||
#include "Printable.h"
|
||||
|
||||
/*!
|
||||
\class ISerial
|
||||
|
||||
|
@ -15,21 +10,19 @@
|
|||
*/
|
||||
class ISerial {
|
||||
public:
|
||||
ISerial(Module* mod);
|
||||
explicit ISerial(Module* mod);
|
||||
|
||||
void begin(long);
|
||||
bool listen();
|
||||
void end();
|
||||
bool isListening();
|
||||
bool stopListening();
|
||||
bool overflow();
|
||||
int peek();
|
||||
size_t write(uint8_t);
|
||||
int read();
|
||||
int available();
|
||||
void flush();
|
||||
|
||||
#ifndef ARDUINO_ARCH_MEGAAVR
|
||||
size_t print(const __FlashStringHelper *);
|
||||
#endif
|
||||
size_t print(const String &);
|
||||
size_t print(const char[]);
|
||||
size_t print(char);
|
||||
|
@ -41,7 +34,9 @@ class ISerial {
|
|||
size_t print(double, int = 2);
|
||||
size_t print(const Printable&);
|
||||
|
||||
#ifndef ARDUINO_ARCH_MEGAAVR
|
||||
size_t println(const __FlashStringHelper *);
|
||||
#endif
|
||||
size_t println(const String &s);
|
||||
size_t println(const char[]);
|
||||
size_t println(char);
|
||||
|
|
246
src/Module.cpp
246
src/Module.cpp
|
@ -1,83 +1,115 @@
|
|||
#include "Module.h"
|
||||
|
||||
Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst) {
|
||||
_cs = cs;
|
||||
_rx = RADIOLIB_NC;
|
||||
_tx = RADIOLIB_NC;
|
||||
_irq = irq;
|
||||
_rst = rst;
|
||||
_spi = &SPI;
|
||||
_spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0);
|
||||
Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst):
|
||||
_cs(cs),
|
||||
_irq(irq),
|
||||
_rst(rst),
|
||||
_rx(RADIOLIB_NC),
|
||||
_tx(RADIOLIB_NC),
|
||||
_spiSettings(SPISettings(2000000, MSBFIRST, SPI_MODE0))
|
||||
{
|
||||
_spi = &RADIOLIB_DEFAULT_SPI;
|
||||
_initInterface = true;
|
||||
ModuleSerial = NULL;
|
||||
}
|
||||
|
||||
Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio) {
|
||||
_cs = cs;
|
||||
_rx = gpio;
|
||||
_tx = RADIOLIB_NC;
|
||||
_irq = irq;
|
||||
_rst = rst;
|
||||
_spi = &SPI;
|
||||
_spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0);
|
||||
Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio):
|
||||
_cs(cs),
|
||||
_irq(irq),
|
||||
_rst(rst),
|
||||
_rx(gpio),
|
||||
_tx(RADIOLIB_NC),
|
||||
_spiSettings(SPISettings(2000000, MSBFIRST, SPI_MODE0))
|
||||
{
|
||||
_spi = &RADIOLIB_DEFAULT_SPI;
|
||||
_initInterface = true;
|
||||
ModuleSerial = NULL;
|
||||
}
|
||||
|
||||
Module::Module(RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, HardwareSerial* useSer, RADIOLIB_PIN_TYPE rst) {
|
||||
_cs = RADIOLIB_NC;
|
||||
_rx = rx;
|
||||
_tx = tx;
|
||||
_irq = RADIOLIB_NC;
|
||||
_rst = rst;
|
||||
Module::Module(RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, HardwareSerial* serial, RADIOLIB_PIN_TYPE rst):
|
||||
_cs(RADIOLIB_NC),
|
||||
_irq(RADIOLIB_NC),
|
||||
_rst(rst),
|
||||
_rx(rx),
|
||||
_tx(tx),
|
||||
_spiSettings(SPISettings(2000000, MSBFIRST, SPI_MODE0))
|
||||
{
|
||||
_initInterface = true;
|
||||
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
ModuleSerial = useSer;
|
||||
ModuleSerial = serial;
|
||||
#else
|
||||
ModuleSerial = new SoftwareSerial(_rx, _tx);
|
||||
(void)useSer;
|
||||
(void)serial;
|
||||
#endif
|
||||
}
|
||||
|
||||
Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, SPIClass& spi, SPISettings spiSettings) {
|
||||
_cs = cs;
|
||||
_rx = RADIOLIB_NC;
|
||||
_tx = RADIOLIB_NC;
|
||||
_irq = irq;
|
||||
_rst = rst;
|
||||
Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, SPIClass& spi, SPISettings spiSettings):
|
||||
_cs(cs),
|
||||
_irq(irq),
|
||||
_rst(rst),
|
||||
_rx(RADIOLIB_NC),
|
||||
_tx(RADIOLIB_NC),
|
||||
_spiSettings(spiSettings)
|
||||
{
|
||||
_spi = &spi;
|
||||
_spiSettings = spiSettings;
|
||||
_initInterface = false;
|
||||
ModuleSerial = NULL;
|
||||
}
|
||||
|
||||
Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio, SPIClass& spi, SPISettings spiSettings) {
|
||||
_cs = cs;
|
||||
_rx = gpio;
|
||||
_tx = RADIOLIB_NC;
|
||||
_irq = irq;
|
||||
_rst = rst;
|
||||
Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio, SPIClass& spi, SPISettings spiSettings):
|
||||
_cs(cs),
|
||||
_irq(irq),
|
||||
_rst(rst),
|
||||
_rx(gpio),
|
||||
_tx(RADIOLIB_NC),
|
||||
_spiSettings(spiSettings)
|
||||
{
|
||||
_spi = &spi;
|
||||
_spiSettings = spiSettings;
|
||||
_initInterface = false;
|
||||
ModuleSerial = NULL;
|
||||
}
|
||||
|
||||
Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, SPIClass& spi, SPISettings spiSettings, HardwareSerial* useSer) {
|
||||
_cs = cs;
|
||||
_rx = rx;
|
||||
_tx = tx;
|
||||
_irq = irq;
|
||||
_rst = rst;
|
||||
Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, SPIClass& spi, SPISettings spiSettings, HardwareSerial* serial):
|
||||
_cs(cs),
|
||||
_irq(irq),
|
||||
_rst(rst),
|
||||
_rx(rx),
|
||||
_tx(tx),
|
||||
_spiSettings(spiSettings)
|
||||
{
|
||||
_spi = &spi;
|
||||
_spiSettings = spiSettings;
|
||||
_initInterface = false;
|
||||
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
ModuleSerial = useSer;
|
||||
ModuleSerial = serial;
|
||||
#else
|
||||
ModuleSerial = new SoftwareSerial(_rx, _tx);
|
||||
(void)useSer;
|
||||
(void)serial;
|
||||
#endif
|
||||
}
|
||||
|
||||
Module::Module(const Module& mod) {
|
||||
*this = mod;
|
||||
}
|
||||
|
||||
Module& Module::operator=(const Module& mod) {
|
||||
this->ModuleSerial = mod.ModuleSerial;
|
||||
this->baudrate = mod.baudrate;
|
||||
memcpy(this->AtLineFeed, mod.AtLineFeed, strlen(mod.AtLineFeed));
|
||||
this->SPIreadCommand = mod.SPIreadCommand;
|
||||
this->SPIwriteCommand = mod.SPIwriteCommand;
|
||||
this->_cs = mod.getCs();
|
||||
this->_irq = mod.getIrq();
|
||||
this->_rst = mod.getRst();
|
||||
this->_rx = mod.getRx();
|
||||
this->_tx = mod.getTx();
|
||||
this->_spiSettings = mod.getSpiSettings();
|
||||
this->_spi = mod.getSpi();
|
||||
|
||||
return(*this);
|
||||
}
|
||||
|
||||
void Module::init(uint8_t interface) {
|
||||
// select interface
|
||||
switch(interface) {
|
||||
|
@ -102,13 +134,17 @@ void Module::init(uint8_t interface) {
|
|||
}
|
||||
}
|
||||
|
||||
void Module::term() {
|
||||
// stop hardware interfaces
|
||||
if(_spi != nullptr) {
|
||||
void Module::term(uint8_t interface) {
|
||||
// stop hardware interfaces (if they were initialized by the library)
|
||||
if(!_initInterface) {
|
||||
return;
|
||||
}
|
||||
|
||||
if((interface == RADIOLIB_USE_SPI) && (_spi != nullptr)) {
|
||||
_spi->end();
|
||||
}
|
||||
|
||||
if(ModuleSerial != nullptr) {
|
||||
if(((interface == RADIOLIB_USE_UART) && ModuleSerial != nullptr)) {
|
||||
ModuleSerial->end();
|
||||
}
|
||||
}
|
||||
|
@ -139,8 +175,8 @@ bool Module::ATsendData(uint8_t* data, uint32_t len) {
|
|||
bool Module::ATgetResponse() {
|
||||
char data[128];
|
||||
char* dataPtr = data;
|
||||
uint32_t start = millis();
|
||||
while(millis() - start < _ATtimeout) {
|
||||
uint32_t start = Module::millis();
|
||||
while(Module::millis() - start < _ATtimeout) {
|
||||
while(ModuleSerial->available() > 0) {
|
||||
char c = ModuleSerial->read();
|
||||
RADIOLIB_VERBOSE_PRINT(c);
|
||||
|
@ -182,9 +218,9 @@ int16_t Module::SPIsetRegValue(uint8_t reg, uint8_t value, uint8_t msb, uint8_t
|
|||
|
||||
// check register value each millisecond until check interval is reached
|
||||
// some registers need a bit of time to process the change (e.g. SX127X_REG_OP_MODE)
|
||||
uint32_t start = micros();
|
||||
uint8_t readValue = 0;
|
||||
while(micros() - start < (checkInterval * 1000)) {
|
||||
uint32_t start = Module::micros();
|
||||
uint8_t readValue = 0x00;
|
||||
while(Module::micros() - start < (checkInterval * 1000)) {
|
||||
readValue = SPIreadRegister(reg);
|
||||
if(readValue == newValue) {
|
||||
// check passed, we can stop the loop
|
||||
|
@ -255,16 +291,20 @@ void Module::SPItransfer(uint8_t cmd, uint8_t reg, uint8_t* dataOut, uint8_t* da
|
|||
|
||||
// send data or get response
|
||||
if(cmd == SPIwriteCommand) {
|
||||
for(size_t n = 0; n < numBytes; n++) {
|
||||
_spi->transfer(dataOut[n]);
|
||||
RADIOLIB_VERBOSE_PRINT(dataOut[n], HEX);
|
||||
RADIOLIB_VERBOSE_PRINT('\t');
|
||||
if(dataOut != NULL) {
|
||||
for(size_t n = 0; n < numBytes; n++) {
|
||||
_spi->transfer(dataOut[n]);
|
||||
RADIOLIB_VERBOSE_PRINT(dataOut[n], HEX);
|
||||
RADIOLIB_VERBOSE_PRINT('\t');
|
||||
}
|
||||
}
|
||||
} else if (cmd == SPIreadCommand) {
|
||||
for(size_t n = 0; n < numBytes; n++) {
|
||||
dataIn[n] = _spi->transfer(0x00);
|
||||
RADIOLIB_VERBOSE_PRINT(dataIn[n], HEX);
|
||||
RADIOLIB_VERBOSE_PRINT('\t');
|
||||
if(dataIn != NULL) {
|
||||
for(size_t n = 0; n < numBytes; n++) {
|
||||
dataIn[n] = _spi->transfer(0x00);
|
||||
RADIOLIB_VERBOSE_PRINT(dataIn[n], HEX);
|
||||
RADIOLIB_VERBOSE_PRINT('\t');
|
||||
}
|
||||
}
|
||||
}
|
||||
RADIOLIB_VERBOSE_PRINTLN();
|
||||
|
@ -294,3 +334,81 @@ RADIOLIB_PIN_STATUS Module::digitalRead(RADIOLIB_PIN_TYPE pin) {
|
|||
}
|
||||
return(LOW);
|
||||
}
|
||||
|
||||
void Module::tone(RADIOLIB_PIN_TYPE pin, uint16_t value) {
|
||||
if(pin == RADIOLIB_NC) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if !defined(RADIOLIB_TONE_UNSUPPORTED)
|
||||
::tone(pin, value);
|
||||
#else
|
||||
#if defined(ESP32)
|
||||
// ESP32 tone() emulation
|
||||
ledcAttachPin(pin, RADIOLIB_TONE_ESP32_CHANNEL);
|
||||
ledcWriteTone(RADIOLIB_TONE_ESP32_CHANNEL, value);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void Module::noTone(RADIOLIB_PIN_TYPE pin) {
|
||||
if(pin == RADIOLIB_NC) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if !defined(RADIOLIB_TONE_UNSUPPORTED)
|
||||
::noTone(pin);
|
||||
#else
|
||||
#if defined(ESP32)
|
||||
ledcDetachPin(pin);
|
||||
ledcWrite(RADIOLIB_TONE_ESP32_CHANNEL, 0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void Module::attachInterrupt(RADIOLIB_PIN_TYPE interruptNum, void (*userFunc)(void), RADIOLIB_INTERRUPT_STATUS mode) {
|
||||
::attachInterrupt(interruptNum, userFunc, mode);
|
||||
}
|
||||
|
||||
void Module::detachInterrupt(RADIOLIB_PIN_TYPE interruptNum) {
|
||||
::detachInterrupt(interruptNum);
|
||||
}
|
||||
|
||||
void Module::yield() {
|
||||
::yield();
|
||||
}
|
||||
|
||||
void Module::delay(uint32_t ms) {
|
||||
::delay(ms);
|
||||
}
|
||||
|
||||
void Module::delayMicroseconds(uint32_t us) {
|
||||
::delayMicroseconds(us);
|
||||
}
|
||||
|
||||
uint32_t Module::millis() {
|
||||
return(::millis());
|
||||
}
|
||||
|
||||
uint32_t Module::micros() {
|
||||
return(::micros());
|
||||
}
|
||||
|
||||
void Module::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
|
||||
_useRfSwitch = true;
|
||||
_rxEn = rxEn;
|
||||
_txEn = txEn;
|
||||
Module::pinMode(rxEn, OUTPUT);
|
||||
Module::pinMode(txEn, OUTPUT);
|
||||
}
|
||||
|
||||
void Module::setRfSwitchState(RADIOLIB_PIN_STATUS rxPinState, RADIOLIB_PIN_STATUS txPinState) {
|
||||
// check RF switch control is enabled
|
||||
if(!_useRfSwitch) {
|
||||
return;
|
||||
}
|
||||
|
||||
// set pins
|
||||
Module::digitalWrite(_rxEn, rxPinState);
|
||||
Module::digitalWrite(_txEn, txPinState);
|
||||
}
|
||||
|
|
140
src/Module.h
140
src/Module.h
|
@ -4,7 +4,6 @@
|
|||
#include "TypeDef.h"
|
||||
|
||||
#include <SPI.h>
|
||||
//#include <Wire.h>
|
||||
#ifndef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#include <SoftwareSerial.h>
|
||||
#endif
|
||||
|
@ -21,18 +20,18 @@ class Module {
|
|||
/*!
|
||||
\brief UART-based module constructor.
|
||||
|
||||
\param tx Arduino pin to be used as Tx pin for SoftwareSerial communication.
|
||||
|
||||
\param rx Arduino pin to be used as Rx pin for SoftwareSerial communication.
|
||||
|
||||
\param tx Arduino pin to be used as Tx pin for SoftwareSerial communication.
|
||||
|
||||
\param serial HardwareSerial to be used on platforms that do not support SoftwareSerial. Defaults to Serial1.
|
||||
|
||||
\param rst Arduino pin to be used as hardware reset for the module. Defaults to NC (unused).
|
||||
*/
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
Module(RADIOLIB_PIN_TYPE tx, RADIOLIB_PIN_TYPE rx, HardwareSerial* serial = &RADIOLIB_HARDWARE_SERIAL_PORT, RADIOLIB_PIN_TYPE rst = RADIOLIB_NC);
|
||||
Module(RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, HardwareSerial* serial = &RADIOLIB_HARDWARE_SERIAL_PORT, RADIOLIB_PIN_TYPE rst = RADIOLIB_NC);
|
||||
#else
|
||||
Module(RADIOLIB_PIN_TYPE tx, RADIOLIB_PIN_TYPE rx, HardwareSerial* serial = nullptr, RADIOLIB_PIN_TYPE rst = RADIOLIB_NC);
|
||||
Module(RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, HardwareSerial* serial = nullptr, RADIOLIB_PIN_TYPE rst = RADIOLIB_NC);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
|
@ -87,9 +86,9 @@ class Module {
|
|||
|
||||
\param spi SPI interface to be used, can also use software SPI implementations.
|
||||
|
||||
\param spiSettings SPI interface settings.
|
||||
\param spiSettings SPI interface settings. Defaults to 2 MHz clock, MSB first, mode 0.
|
||||
*/
|
||||
Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio, SPIClass& spi, SPISettings spiSettings);
|
||||
Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio, SPIClass& spi, SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0));
|
||||
|
||||
/*!
|
||||
\brief Generic module constructor.
|
||||
|
@ -111,11 +110,24 @@ class Module {
|
|||
\param serial HardwareSerial to be used on ESP32 and SAMD. Defaults to 1
|
||||
*/
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, SPIClass& spi = SPI, SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0), HardwareSerial* serial = &RADIOLIB_HARDWARE_SERIAL_PORT);
|
||||
Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, SPIClass& spi = RADIOLIB_DEFAULT_SPI, SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0), HardwareSerial* serial = &RADIOLIB_HARDWARE_SERIAL_PORT);
|
||||
#else
|
||||
Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, SPIClass& spi = SPI, SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0), HardwareSerial* serial = nullptr);
|
||||
Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE rx, RADIOLIB_PIN_TYPE tx, SPIClass& spi = RADIOLIB_DEFAULT_SPI, SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0), HardwareSerial* serial = nullptr);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\brief Copy constructor.
|
||||
|
||||
\param mod Module instance to copy.
|
||||
*/
|
||||
Module(const Module& mod);
|
||||
|
||||
/*!
|
||||
\brief Overload for assignment operator.
|
||||
|
||||
\param frame rvalue Module.
|
||||
*/
|
||||
Module& operator=(const Module& mod);
|
||||
|
||||
// public member variables
|
||||
|
||||
|
@ -136,7 +148,7 @@ class Module {
|
|||
/*!
|
||||
\brief Line feed to be used when sending AT commands. Defaults to CR+LF.
|
||||
*/
|
||||
const char* AtLineFeed = "\r\n";
|
||||
char AtLineFeed[3] = {'\r', '\n'};
|
||||
|
||||
/*!
|
||||
\brief Basic SPI read command. Defaults to 0x00.
|
||||
|
@ -159,8 +171,10 @@ class Module {
|
|||
|
||||
/*!
|
||||
\brief Terminate low-level module control.
|
||||
|
||||
\param interface Interface to be terminated. See \ref shield_config for details.
|
||||
*/
|
||||
void term();
|
||||
void term(uint8_t interface);
|
||||
|
||||
// AT methods
|
||||
|
||||
|
@ -341,6 +355,27 @@ class Module {
|
|||
*/
|
||||
SPISettings getSpiSettings() const { return(_spiSettings); }
|
||||
|
||||
/*!
|
||||
\brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state.
|
||||
When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch!
|
||||
|
||||
\param rxEn RX enable pin.
|
||||
|
||||
\param txEn TX enable pin.
|
||||
*/
|
||||
void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn);
|
||||
|
||||
/*!
|
||||
\brief Set RF switch state.
|
||||
|
||||
\param rxPinState Pin state to set on Tx enable pin (usually high to transmit).
|
||||
|
||||
\param txPinState Pin state to set on Rx enable pin (usually high to receive).
|
||||
*/
|
||||
void setRfSwitchState(RADIOLIB_PIN_STATUS rxPinState, RADIOLIB_PIN_STATUS txPinState);
|
||||
|
||||
// Arduino core overrides
|
||||
|
||||
/*!
|
||||
\brief Arduino core pinMode override that checks RADIOLIB_NC as alias for unused pin.
|
||||
|
||||
|
@ -368,18 +403,85 @@ class Module {
|
|||
*/
|
||||
static RADIOLIB_PIN_STATUS digitalRead(RADIOLIB_PIN_TYPE pin);
|
||||
|
||||
/*!
|
||||
\brief Arduino core tone override that checks RADIOLIB_NC as alias for unused pin and RADIOLIB_TONE_UNSUPPORTED to make sure the platform does support tone.
|
||||
|
||||
\param pin Pin to write to.
|
||||
|
||||
\param value Frequency to output.
|
||||
*/
|
||||
static void tone(RADIOLIB_PIN_TYPE pin, uint16_t value);
|
||||
|
||||
/*!
|
||||
\brief Arduino core noTone override that checks RADIOLIB_NC as alias for unused pin and RADIOLIB_TONE_UNSUPPORTED to make sure the platform does support tone.
|
||||
|
||||
\param pin Pin to write to.
|
||||
*/
|
||||
static void noTone(RADIOLIB_PIN_TYPE pin);
|
||||
|
||||
/*!
|
||||
\brief Arduino core attachInterrupt override.
|
||||
|
||||
\param interruptNum Interrupt number.
|
||||
|
||||
\param userFunc Interrupt service routine.
|
||||
|
||||
\param mode Pin hcange direction.
|
||||
*/
|
||||
static void attachInterrupt(RADIOLIB_PIN_TYPE interruptNum, void (*userFunc)(void), RADIOLIB_INTERRUPT_STATUS mode);
|
||||
|
||||
/*!
|
||||
\brief Arduino core detachInterrupt override.
|
||||
|
||||
\param interruptNum Interrupt number.
|
||||
*/
|
||||
static void detachInterrupt(RADIOLIB_PIN_TYPE interruptNum);
|
||||
|
||||
/*!
|
||||
\brief Arduino core yield override.
|
||||
*/
|
||||
static void yield();
|
||||
|
||||
/*!
|
||||
\brief Arduino core delay override.
|
||||
|
||||
\param ms Delay length in milliseconds.
|
||||
*/
|
||||
static void delay(uint32_t ms);
|
||||
|
||||
/*!
|
||||
\brief Arduino core delayMicroseconds override.
|
||||
|
||||
\param us Delay length in microseconds.
|
||||
*/
|
||||
static void delayMicroseconds(uint32_t us);
|
||||
|
||||
/*!
|
||||
\brief Arduino core millis override.
|
||||
*/
|
||||
static uint32_t millis();
|
||||
|
||||
/*!
|
||||
\brief Arduino core micros override.
|
||||
*/
|
||||
static uint32_t micros();
|
||||
|
||||
#ifndef RADIOLIB_GODMODE
|
||||
private:
|
||||
#endif
|
||||
RADIOLIB_PIN_TYPE _cs;
|
||||
RADIOLIB_PIN_TYPE _tx;
|
||||
RADIOLIB_PIN_TYPE _rx;
|
||||
RADIOLIB_PIN_TYPE _irq;
|
||||
RADIOLIB_PIN_TYPE _rst;
|
||||
RADIOLIB_PIN_TYPE _cs = RADIOLIB_NC;
|
||||
RADIOLIB_PIN_TYPE _irq = RADIOLIB_NC;
|
||||
RADIOLIB_PIN_TYPE _rst = RADIOLIB_NC;
|
||||
RADIOLIB_PIN_TYPE _rx = RADIOLIB_NC;
|
||||
RADIOLIB_PIN_TYPE _tx = RADIOLIB_NC;
|
||||
|
||||
bool _initInterface;
|
||||
SPIClass* _spi;
|
||||
SPISettings _spiSettings;
|
||||
SPISettings _spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0);
|
||||
|
||||
bool _initInterface = false;
|
||||
SPIClass* _spi = NULL;
|
||||
|
||||
bool _useRfSwitch = false;
|
||||
RADIOLIB_PIN_TYPE _rxEn = RADIOLIB_NC, _txEn = RADIOLIB_NC;
|
||||
|
||||
uint32_t _ATtimeout = 15000;
|
||||
};
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
- Morse Code (MorseClient)
|
||||
- AX.25 (AX25Client)
|
||||
- SSTV (SSTVClient)
|
||||
- Hellschreiber (HellClient)
|
||||
- TransportLayer protocols
|
||||
- HTTP (HTTPClient)
|
||||
- MQTT (MQTTClient)
|
||||
|
@ -49,6 +50,11 @@
|
|||
#warning "God mode active, I hope it was intentional. Buckle up, lads."
|
||||
#endif
|
||||
|
||||
// print debug info
|
||||
#ifdef RADIOLIB_DEBUG
|
||||
#pragma message "RADIOLIB_PLATFORM: " RADIOLIB_PLATFORM
|
||||
#endif
|
||||
|
||||
// check unknown/unsupported platform
|
||||
#ifdef RADIOLIB_UNKNOWN_PLATFORM
|
||||
#warning "RadioLib might not be compatible with this Arduino board - check supported platforms at https://github.com/jgromes/RadioLib!"
|
||||
|
@ -85,6 +91,7 @@
|
|||
|
||||
// physical layer protocols
|
||||
#include "protocols/PhysicalLayer/PhysicalLayer.h"
|
||||
#include "protocols/AFSK/AFSK.h"
|
||||
#include "protocols/AX25/AX25.h"
|
||||
#include "protocols/Hellschreiber/Hellschreiber.h"
|
||||
#include "protocols/Morse/Morse.h"
|
||||
|
|
|
@ -88,6 +88,66 @@
|
|||
\}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\defgroup config_shaping Data shaping filter values aliases.
|
||||
|
||||
\{
|
||||
*/
|
||||
|
||||
/*!
|
||||
\brief No shaping.
|
||||
*/
|
||||
#define RADIOLIB_SHAPING_NONE 0x00
|
||||
|
||||
/*!
|
||||
\brief Gaussin shaping filter, BT = 0.3
|
||||
*/
|
||||
#define RADIOLIB_SHAPING_0_3 0x01
|
||||
|
||||
/*!
|
||||
\brief Gaussin shaping filter, BT = 0.5
|
||||
*/
|
||||
#define RADIOLIB_SHAPING_0_5 0x02
|
||||
|
||||
/*!
|
||||
\brief Gaussin shaping filter, BT = 0.7
|
||||
*/
|
||||
#define RADIOLIB_SHAPING_0_7 0x03
|
||||
|
||||
/*!
|
||||
\brief Gaussin shaping filter, BT = 1.0
|
||||
*/
|
||||
#define RADIOLIB_SHAPING_1_0 0x04
|
||||
|
||||
/*!
|
||||
\}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\defgroup config_encoding Encoding type aliases.
|
||||
|
||||
\{
|
||||
*/
|
||||
|
||||
/*!
|
||||
\brief Non-return to zero - no encoding.
|
||||
*/
|
||||
#define RADIOLIB_ENCODING_NRZ 0x00
|
||||
|
||||
/*!
|
||||
\brief Manchester encoding.
|
||||
*/
|
||||
#define RADIOLIB_ENCODING_MANCHESTER 0x01
|
||||
|
||||
/*!
|
||||
\brief Whitening.
|
||||
*/
|
||||
#define RADIOLIB_ENCODING_WHITENING 0x02
|
||||
|
||||
/*!
|
||||
\}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\defgroup status_codes Status Codes
|
||||
|
||||
|
@ -223,6 +283,11 @@
|
|||
*/
|
||||
#define ERR_INVALID_ENCODING -23
|
||||
|
||||
/*!
|
||||
\brief LoRa packet header has been damaged.
|
||||
*/
|
||||
#define ERR_LORA_HEADER_DAMAGED -24
|
||||
|
||||
// RF69-specific status codes
|
||||
|
||||
/*!
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
#include "CC1101.h"
|
||||
#if !defined(RADIOLIB_EXCLUDE_CC1101)
|
||||
|
||||
CC1101::CC1101(Module* module) : PhysicalLayer(CC1101_FREQUENCY_STEP_SIZE, CC1101_MAX_PACKET_LENGTH) {
|
||||
_mod = module;
|
||||
_packetLengthQueried = false;
|
||||
_packetLengthConfig = CC1101_LENGTH_CONFIG_VARIABLE;
|
||||
_modulation = CC1101_MOD_FORMAT_2_FSK;
|
||||
|
||||
_syncWordLength = 2;
|
||||
}
|
||||
|
||||
int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLength) {
|
||||
|
@ -20,8 +16,8 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po
|
|||
uint8_t i = 0;
|
||||
bool flagFound = false;
|
||||
while((i < 10) && !flagFound) {
|
||||
uint8_t version = SPIreadRegister(CC1101_REG_VERSION);
|
||||
if(version == 0x14) {
|
||||
int16_t version = getChipVersion();
|
||||
if((version == CC1101_VERSION_CURRENT) || (version == CC1101_VERSION_LEGACY)) {
|
||||
flagFound = true;
|
||||
} else {
|
||||
#ifdef RADIOLIB_DEBUG
|
||||
|
@ -32,20 +28,20 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po
|
|||
char buffHex[7];
|
||||
sprintf(buffHex, "0x%04X", version);
|
||||
RADIOLIB_DEBUG_PRINT(buffHex);
|
||||
RADIOLIB_DEBUG_PRINT(F(", expected 0x0014"));
|
||||
RADIOLIB_DEBUG_PRINT(F(", expected 0x0004/0x0014"));
|
||||
RADIOLIB_DEBUG_PRINTLN();
|
||||
#endif
|
||||
delay(1000);
|
||||
Module::delay(10);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if(!flagFound) {
|
||||
RADIOLIB_DEBUG_PRINTLN(F("No CC1101 found!"));
|
||||
_mod->term();
|
||||
_mod->term(RADIOLIB_USE_SPI);
|
||||
return(ERR_CHIP_NOT_FOUND);
|
||||
} else {
|
||||
RADIOLIB_DEBUG_PRINTLN(F("Found CC1101! (match by CC1101_REG_VERSION == 0x14)"));
|
||||
RADIOLIB_DEBUG_PRINTLN(F("M\tCC1101"));
|
||||
}
|
||||
|
||||
// configure settings not accessible by API
|
||||
|
@ -81,11 +77,15 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po
|
|||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set default data shaping
|
||||
state = setDataShaping(0);
|
||||
state = setDataShaping(RADIOLIB_ENCODING_NRZ);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set default encoding
|
||||
state = setEncoding(2);
|
||||
state = setEncoding(RADIOLIB_SHAPING_NONE);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set default sync word
|
||||
state = setSyncWord(0x12, 0xAD, 0, false);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// flush FIFOs
|
||||
|
@ -101,13 +101,13 @@ int16_t CC1101::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
|||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// wait for transmission start
|
||||
while(!digitalRead(_mod->getIrq())) {
|
||||
yield();
|
||||
while(!Module::digitalRead(_mod->getIrq())) {
|
||||
Module::yield();
|
||||
}
|
||||
|
||||
// wait for transmission end
|
||||
while(digitalRead(_mod->getIrq())) {
|
||||
yield();
|
||||
while(Module::digitalRead(_mod->getIrq())) {
|
||||
Module::yield();
|
||||
}
|
||||
|
||||
// set mode to standby
|
||||
|
@ -125,13 +125,13 @@ int16_t CC1101::receive(uint8_t* data, size_t len) {
|
|||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// wait for sync word
|
||||
while(!digitalRead(_mod->getIrq())) {
|
||||
yield();
|
||||
while(!Module::digitalRead(_mod->getIrq())) {
|
||||
Module::yield();
|
||||
}
|
||||
|
||||
// wait for packet end
|
||||
while(digitalRead(_mod->getIrq())) {
|
||||
yield();
|
||||
while(Module::digitalRead(_mod->getIrq())) {
|
||||
Module::yield();
|
||||
}
|
||||
|
||||
// read packet data
|
||||
|
@ -139,11 +139,18 @@ int16_t CC1101::receive(uint8_t* data, size_t len) {
|
|||
}
|
||||
|
||||
int16_t CC1101::standby() {
|
||||
// set idle mode
|
||||
SPIsendCommand(CC1101_CMD_IDLE);
|
||||
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(LOW, LOW);
|
||||
return(ERR_NONE);
|
||||
}
|
||||
|
||||
int16_t CC1101::transmitDirect(uint32_t frf) {
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(LOW, HIGH);
|
||||
|
||||
// user requested to start transmitting immediately (required for RTTY)
|
||||
if(frf != 0) {
|
||||
SPIwriteRegister(CC1101_REG_FREQ2, (frf & 0xFF0000) >> 16);
|
||||
|
@ -163,6 +170,9 @@ int16_t CC1101::transmitDirect(uint32_t frf) {
|
|||
}
|
||||
|
||||
int16_t CC1101::receiveDirect() {
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(HIGH, LOW);
|
||||
|
||||
// activate direct mode
|
||||
int16_t state = directMode();
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
@ -179,27 +189,27 @@ int16_t CC1101::packetMode() {
|
|||
return(state);
|
||||
}
|
||||
|
||||
void CC1101::setGdo0Action(void (*func)(void), RADIOLIB_PIN_STATUS dir) {
|
||||
attachInterrupt(digitalPinToInterrupt(_mod->getIrq()), func, dir);
|
||||
void CC1101::setGdo0Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir) {
|
||||
Module::attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, dir);
|
||||
}
|
||||
|
||||
void CC1101::clearGdo0Action() {
|
||||
detachInterrupt(digitalPinToInterrupt(_mod->getIrq()));
|
||||
Module::detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()));
|
||||
}
|
||||
|
||||
void CC1101::setGdo2Action(void (*func)(void), RADIOLIB_PIN_STATUS dir) {
|
||||
void CC1101::setGdo2Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir) {
|
||||
if(_mod->getGpio() != RADIOLIB_NC) {
|
||||
return;
|
||||
}
|
||||
Module::pinMode(_mod->getGpio(), INPUT);
|
||||
attachInterrupt(digitalPinToInterrupt(_mod->getGpio()), func, dir);
|
||||
Module::attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, dir);
|
||||
}
|
||||
|
||||
void CC1101::clearGdo2Action() {
|
||||
if(_mod->getGpio() != RADIOLIB_NC) {
|
||||
return;
|
||||
}
|
||||
detachInterrupt(digitalPinToInterrupt(_mod->getGpio()));
|
||||
Module::detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()));
|
||||
}
|
||||
|
||||
int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||
|
@ -232,6 +242,9 @@ int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
|||
// write packet to FIFO
|
||||
SPIwriteRegisterBurst(CC1101_REG_FIFO, data, len);
|
||||
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(LOW, HIGH);
|
||||
|
||||
// set mode to transmit
|
||||
SPIsendCommand(CC1101_CMD_TX);
|
||||
|
||||
|
@ -249,6 +262,9 @@ int16_t CC1101::startReceive() {
|
|||
int state = SPIsetRegValue(CC1101_REG_IOCFG0, CC1101_GDOX_SYNC_WORD_SENT_OR_RECEIVED);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(HIGH, LOW);
|
||||
|
||||
// set mode to receive
|
||||
SPIsendCommand(CC1101_CMD_RX);
|
||||
|
||||
|
@ -492,28 +508,28 @@ int16_t CC1101::setPreambleLength(uint8_t preambleLength) {
|
|||
// check allowed values
|
||||
uint8_t value;
|
||||
switch(preambleLength){
|
||||
case 2:
|
||||
case 16:
|
||||
value = CC1101_NUM_PREAMBLE_2;
|
||||
break;
|
||||
case 3:
|
||||
case 24:
|
||||
value = CC1101_NUM_PREAMBLE_3;
|
||||
break;
|
||||
case 4:
|
||||
case 32:
|
||||
value = CC1101_NUM_PREAMBLE_4;
|
||||
break;
|
||||
case 6:
|
||||
case 48:
|
||||
value = CC1101_NUM_PREAMBLE_6;
|
||||
break;
|
||||
case 8:
|
||||
case 64:
|
||||
value = CC1101_NUM_PREAMBLE_8;
|
||||
break;
|
||||
case 12:
|
||||
case 96:
|
||||
value = CC1101_NUM_PREAMBLE_12;
|
||||
break;
|
||||
case 16:
|
||||
case 128:
|
||||
value = CC1101_NUM_PREAMBLE_16;
|
||||
break;
|
||||
case 24:
|
||||
case 192:
|
||||
value = CC1101_NUM_PREAMBLE_24;
|
||||
break;
|
||||
default:
|
||||
|
@ -538,7 +554,7 @@ int16_t CC1101::setNodeAddress(uint8_t nodeAddr, uint8_t numBroadcastAddrs) {
|
|||
|
||||
int16_t CC1101::disableAddressFiltering() {
|
||||
// disable address filtering
|
||||
int16_t state = _mod->SPIsetRegValue(CC1101_REG_PKTCTRL1, CC1101_ADR_CHK_NONE, 1, 0);
|
||||
int16_t state = SPIsetRegValue(CC1101_REG_PKTCTRL1, CC1101_ADR_CHK_NONE, 1, 0);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set node address to default (0x00)
|
||||
|
@ -577,7 +593,7 @@ int16_t CC1101::setOOK(bool enableOOK) {
|
|||
}
|
||||
|
||||
|
||||
float CC1101::getRSSI() {
|
||||
float CC1101::getRSSI() const {
|
||||
float rssi;
|
||||
if(_rawRSSI >= 128) {
|
||||
rssi = (((float)_rawRSSI - 256.0)/2.0) - 74.0;
|
||||
|
@ -587,16 +603,16 @@ float CC1101::getRSSI() {
|
|||
return(rssi);
|
||||
}
|
||||
|
||||
uint8_t CC1101::getLQI() {
|
||||
uint8_t CC1101::getLQI() const {
|
||||
return(_rawLQI);
|
||||
}
|
||||
|
||||
size_t CC1101::getPacketLength(bool update) {
|
||||
if(!_packetLengthQueried && update) {
|
||||
if (_packetLengthConfig == CC1101_LENGTH_CONFIG_VARIABLE) {
|
||||
_packetLength = _mod->SPIreadRegister(CC1101_REG_FIFO);
|
||||
_packetLength = SPIreadRegister(CC1101_REG_FIFO);
|
||||
} else {
|
||||
_packetLength = _mod->SPIreadRegister(CC1101_REG_PKTLEN);
|
||||
_packetLength = SPIreadRegister(CC1101_REG_PKTLEN);
|
||||
}
|
||||
|
||||
_packetLengthQueried = true;
|
||||
|
@ -614,23 +630,20 @@ int16_t CC1101::variablePacketLengthMode(uint8_t maxLen) {
|
|||
}
|
||||
|
||||
int16_t CC1101::enableSyncWordFiltering(uint8_t maxErrBits, bool requireCarrierSense) {
|
||||
switch (maxErrBits){
|
||||
switch(maxErrBits){
|
||||
case 0:
|
||||
// in 16 bit sync word, expect all 16 bits
|
||||
return (SPIsetRegValue(CC1101_REG_MDMCFG2,
|
||||
requireCarrierSense ? CC1101_SYNC_MODE_16_16_THR : CC1101_SYNC_MODE_16_16, 2, 0));
|
||||
return(SPIsetRegValue(CC1101_REG_MDMCFG2, (requireCarrierSense ? CC1101_SYNC_MODE_16_16_THR : CC1101_SYNC_MODE_16_16), 2, 0));
|
||||
case 1:
|
||||
// in 16 bit sync word, expect at least 15 bits
|
||||
return (SPIsetRegValue(CC1101_REG_MDMCFG2,
|
||||
requireCarrierSense ? CC1101_SYNC_MODE_15_16_THR : CC1101_SYNC_MODE_15_16, 2, 0));
|
||||
return(SPIsetRegValue(CC1101_REG_MDMCFG2, (requireCarrierSense ? CC1101_SYNC_MODE_15_16_THR : CC1101_SYNC_MODE_15_16), 2, 0));
|
||||
default:
|
||||
return (ERR_INVALID_SYNC_WORD);
|
||||
return(ERR_INVALID_SYNC_WORD);
|
||||
}
|
||||
}
|
||||
|
||||
int16_t CC1101::disableSyncWordFiltering(bool requireCarrierSense) {
|
||||
return(SPIsetRegValue(CC1101_REG_MDMCFG2,
|
||||
requireCarrierSense ? CC1101_SYNC_MODE_NONE_THR : CC1101_SYNC_MODE_NONE, 2, 0));
|
||||
return(SPIsetRegValue(CC1101_REG_MDMCFG2, (requireCarrierSense ? CC1101_SYNC_MODE_NONE_THR : CC1101_SYNC_MODE_NONE), 2, 0));
|
||||
}
|
||||
|
||||
int16_t CC1101::setCrcFiltering(bool crcOn) {
|
||||
|
@ -669,19 +682,21 @@ int16_t CC1101::setPromiscuousMode(bool promiscuous) {
|
|||
return(state);
|
||||
}
|
||||
|
||||
int16_t CC1101::setDataShaping(float sh) {
|
||||
int16_t CC1101::setDataShaping(uint8_t sh) {
|
||||
// set mode to standby
|
||||
int16_t state = standby();
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set data shaping
|
||||
sh *= 10.0;
|
||||
if(abs(sh - 0.0) <= 0.001) {
|
||||
state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MOD_FORMAT_2_FSK, 6, 4);
|
||||
} else if(abs(sh - 5.0) <= 0.001) {
|
||||
state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MOD_FORMAT_GFSK, 6, 4);
|
||||
} else {
|
||||
return(ERR_INVALID_DATA_SHAPING);
|
||||
switch(sh) {
|
||||
case RADIOLIB_SHAPING_NONE:
|
||||
state = SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MOD_FORMAT_2_FSK, 6, 4);
|
||||
break;
|
||||
case RADIOLIB_SHAPING_0_5:
|
||||
state = SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MOD_FORMAT_GFSK, 6, 4);
|
||||
break;
|
||||
default:
|
||||
return(ERR_INVALID_DATA_SHAPING);
|
||||
}
|
||||
return(state);
|
||||
}
|
||||
|
@ -693,29 +708,57 @@ int16_t CC1101::setEncoding(uint8_t encoding) {
|
|||
|
||||
// set encoding
|
||||
switch(encoding) {
|
||||
case 0:
|
||||
state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MANCHESTER_EN_OFF, 3, 3);
|
||||
case RADIOLIB_ENCODING_NRZ:
|
||||
state = SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MANCHESTER_EN_OFF, 3, 3);
|
||||
RADIOLIB_ASSERT(state);
|
||||
return(_mod->SPIsetRegValue(CC1101_REG_PKTCTRL0, CC1101_WHITE_DATA_OFF, 6, 6));
|
||||
case 1:
|
||||
state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MANCHESTER_EN_ON, 3, 3);
|
||||
return(SPIsetRegValue(CC1101_REG_PKTCTRL0, CC1101_WHITE_DATA_OFF, 6, 6));
|
||||
case RADIOLIB_ENCODING_MANCHESTER:
|
||||
state = SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MANCHESTER_EN_ON, 3, 3);
|
||||
RADIOLIB_ASSERT(state);
|
||||
return(_mod->SPIsetRegValue(CC1101_REG_PKTCTRL0, CC1101_WHITE_DATA_OFF, 6, 6));
|
||||
case 2:
|
||||
state = _mod->SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MANCHESTER_EN_OFF, 3, 3);
|
||||
return(SPIsetRegValue(CC1101_REG_PKTCTRL0, CC1101_WHITE_DATA_OFF, 6, 6));
|
||||
case RADIOLIB_ENCODING_WHITENING:
|
||||
state = SPIsetRegValue(CC1101_REG_MDMCFG2, CC1101_MANCHESTER_EN_OFF, 3, 3);
|
||||
RADIOLIB_ASSERT(state);
|
||||
return(_mod->SPIsetRegValue(CC1101_REG_PKTCTRL0, CC1101_WHITE_DATA_ON, 6, 6));
|
||||
return(SPIsetRegValue(CC1101_REG_PKTCTRL0, CC1101_WHITE_DATA_ON, 6, 6));
|
||||
default:
|
||||
return(ERR_INVALID_ENCODING);
|
||||
}
|
||||
}
|
||||
|
||||
void CC1101::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
|
||||
_mod->setRfSwitchPins(rxEn, txEn);
|
||||
}
|
||||
|
||||
uint8_t CC1101::random() {
|
||||
// set mode to Rx
|
||||
SPIsendCommand(CC1101_CMD_RX);
|
||||
|
||||
// wait a bit for the RSSI reading to stabilise
|
||||
Module::delay(10);
|
||||
|
||||
// read RSSI value 8 times, always keep just the least significant bit
|
||||
uint8_t randByte = 0x00;
|
||||
for(uint8_t i = 0; i < 8; i++) {
|
||||
randByte |= ((SPIreadRegister(CC1101_REG_RSSI) & 0x01) << i);
|
||||
}
|
||||
|
||||
// set mode to standby
|
||||
SPIsendCommand(CC1101_CMD_IDLE);
|
||||
|
||||
return(randByte);
|
||||
}
|
||||
|
||||
|
||||
int16_t CC1101::getChipVersion() {
|
||||
return(SPIgetRegValue(CC1101_REG_VERSION));
|
||||
}
|
||||
|
||||
int16_t CC1101::config() {
|
||||
// Reset the radio. Registers may be dirty from previous usage.
|
||||
SPIsendCommand(CC1101_CMD_RESET);
|
||||
|
||||
// Wait a ridiculous amount of time to be sure radio is ready.
|
||||
delay(150);
|
||||
Module::delay(150);
|
||||
|
||||
// enable automatic frequency synthesizer calibration
|
||||
int16_t state = SPIsetRegValue(CC1101_REG_MCSM0, CC1101_FS_AUTOCAL_IDLE_TO_RXTX, 5, 4);
|
||||
|
@ -773,11 +816,11 @@ int16_t CC1101::setPacketMode(uint8_t mode, uint8_t len) {
|
|||
}
|
||||
|
||||
// set PKTCTRL0.LENGTH_CONFIG
|
||||
int16_t state = _mod->SPIsetRegValue(CC1101_REG_PKTCTRL0, mode, 1, 0);
|
||||
int16_t state = SPIsetRegValue(CC1101_REG_PKTCTRL0, mode, 1, 0);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set length to register
|
||||
state = _mod->SPIsetRegValue(CC1101_REG_PKTLEN, len);
|
||||
state = SPIsetRegValue(CC1101_REG_PKTLEN, len);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// update the cached value
|
||||
|
@ -831,9 +874,22 @@ void CC1101::SPIwriteRegisterBurst(uint8_t reg, uint8_t* data, size_t len) {
|
|||
}
|
||||
|
||||
void CC1101::SPIsendCommand(uint8_t cmd) {
|
||||
// get pointer to used SPI interface and the settings
|
||||
SPIClass* spi = _mod->getSpi();
|
||||
SPISettings spiSettings = _mod->getSpiSettings();
|
||||
|
||||
// pull NSS low
|
||||
Module::digitalWrite(_mod->getCs(), LOW);
|
||||
SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));
|
||||
SPI.transfer(cmd);
|
||||
SPI.endTransaction();
|
||||
|
||||
// start transfer
|
||||
spi->beginTransaction(spiSettings);
|
||||
|
||||
// send the command byte
|
||||
spi->transfer(cmd);
|
||||
|
||||
// stop transfer
|
||||
spi->endTransaction();
|
||||
Module::digitalWrite(_mod->getCs(), HIGH);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef _RADIOLIB_CC1101_H
|
||||
#if !defined(_RADIOLIB_CC1101_H) && !defined(RADIOLIB_EXCLUDE_CC1101)
|
||||
#define _RADIOLIB_CC1101_H
|
||||
|
||||
#include "../../TypeDef.h"
|
||||
|
@ -455,7 +455,8 @@
|
|||
#define CC1101_PARTNUM 0x00
|
||||
|
||||
// CC1101_REG_VERSION
|
||||
#define CC1101_VERSION 0x14
|
||||
#define CC1101_VERSION_CURRENT 0x14
|
||||
#define CC1101_VERSION_LEGACY 0x04
|
||||
|
||||
// CC1101_REG_MARCSTATE
|
||||
#define CC1101_MARC_STATE_SLEEP 0x00 // 4 0 main radio control state: sleep
|
||||
|
@ -521,21 +522,21 @@ class CC1101: public PhysicalLayer {
|
|||
/*!
|
||||
\brief Initialization method.
|
||||
|
||||
\param freq Carrier frequency in MHz. Defaults to 868.0 MHz.
|
||||
\param freq Carrier frequency in MHz. Defaults to 434.0 MHz.
|
||||
|
||||
\param br Bit rate to be used in kbps. Defaults to 4.8 kbps.
|
||||
\param br Bit rate to be used in kbps. Defaults to 48.0 kbps.
|
||||
|
||||
\param freqDev Frequency deviation from carrier frequency in kHz Defaults to 48.0 kHz.
|
||||
|
||||
\param rxBw Receiver bandwidth in kHz. Defaults to 325.0 kHz.
|
||||
\param rxBw Receiver bandwidth in kHz. Defaults to 135.0 kHz.
|
||||
|
||||
\param power Output power in dBm. Defaults to 0 dBm.
|
||||
\param power Output power in dBm. Defaults to 10 dBm.
|
||||
|
||||
\param preambleLength Preamble Length in bytes. Defaults to 4 bytes.
|
||||
\param preambleLength Preamble Length in bits. Defaults to 16 bits.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t begin(float freq = 868.0, float br = 4.8, float freqDev = 48.0, float rxBw = 325.0, int8_t power = 0, uint8_t preambleLength = 4);
|
||||
int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 48.0, float rxBw = 135.0, int8_t power = 10, uint8_t preambleLength = 16);
|
||||
|
||||
/*!
|
||||
\brief Blocking binary transmit method.
|
||||
|
@ -549,7 +550,7 @@ class CC1101: public PhysicalLayer {
|
|||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0);
|
||||
int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0) override;
|
||||
|
||||
/*!
|
||||
\brief Blocking binary receive method.
|
||||
|
@ -561,14 +562,14 @@ class CC1101: public PhysicalLayer {
|
|||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t receive(uint8_t* data, size_t len);
|
||||
int16_t receive(uint8_t* data, size_t len) override;
|
||||
|
||||
/*!
|
||||
\brief Sets the module to standby mode.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t standby();
|
||||
int16_t standby() override;
|
||||
|
||||
/*!
|
||||
\brief Starts direct mode transmission.
|
||||
|
@ -577,14 +578,14 @@ class CC1101: public PhysicalLayer {
|
|||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t transmitDirect(uint32_t frf = 0);
|
||||
int16_t transmitDirect(uint32_t frf = 0) override;
|
||||
|
||||
/*!
|
||||
\brief Starts direct mode reception.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t receiveDirect();
|
||||
int16_t receiveDirect() override;
|
||||
|
||||
/*!
|
||||
\brief Stops direct mode. It is required to call this method to switch from direct transmissions to packet-based transmissions.
|
||||
|
@ -600,7 +601,7 @@ class CC1101: public PhysicalLayer {
|
|||
|
||||
\param dir Signal change direction. Defaults to FALLING.
|
||||
*/
|
||||
void setGdo0Action(void (*func)(void), RADIOLIB_PIN_STATUS dir = FALLING);
|
||||
void setGdo0Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir = FALLING);
|
||||
|
||||
/*!
|
||||
\brief Clears interrupt service routine to call when GDO0 activates.
|
||||
|
@ -614,7 +615,7 @@ class CC1101: public PhysicalLayer {
|
|||
|
||||
\param dir Signal change direction. Defaults to FALLING.
|
||||
*/
|
||||
void setGdo2Action(void (*func)(void), RADIOLIB_PIN_STATUS dir = FALLING);
|
||||
void setGdo2Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir = FALLING);
|
||||
|
||||
/*!
|
||||
\brief Clears interrupt service routine to call when GDO0 activates.
|
||||
|
@ -633,7 +634,7 @@ class CC1101: public PhysicalLayer {
|
|||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0);
|
||||
int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0) override;
|
||||
|
||||
/*!
|
||||
\brief Interrupt-driven receive method. GDO0 will be activated when full packet is received.
|
||||
|
@ -651,7 +652,7 @@ class CC1101: public PhysicalLayer {
|
|||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t readData(uint8_t* data, size_t len);
|
||||
int16_t readData(uint8_t* data, size_t len) override;
|
||||
|
||||
// configuration methods
|
||||
|
||||
|
@ -689,7 +690,7 @@ class CC1101: public PhysicalLayer {
|
|||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setFrequencyDeviation(float freqDev);
|
||||
int16_t setFrequencyDeviation(float freqDev) override;
|
||||
|
||||
/*!
|
||||
\brief Sets output power. Allowed values are -30, -20, -15, -10, 0, 5, 7 or 10 dBm.
|
||||
|
@ -733,7 +734,7 @@ class CC1101: public PhysicalLayer {
|
|||
/*!
|
||||
\brief Sets preamble length.
|
||||
|
||||
\param preambleLength Preamble length to be set (in bytes), allowed values: 2, 3, 4, 6, 8, 12, 16, 24
|
||||
\param preambleLength Preamble length to be set (in bits), allowed values: 16, 24, 32, 48, 64, 96, 128 and 192.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
|
@ -771,14 +772,14 @@ class CC1101: public PhysicalLayer {
|
|||
|
||||
\returns Last packet RSSI in dBm.
|
||||
*/
|
||||
float getRSSI();
|
||||
float getRSSI() const;
|
||||
|
||||
/*!
|
||||
\brief Gets LQI (Link Quality Indicator) of the last received packet.
|
||||
|
||||
\returns Last packet LQI (lower is better).
|
||||
*/
|
||||
uint8_t getLQI();
|
||||
uint8_t getLQI() const;
|
||||
|
||||
/*!
|
||||
\brief Query modem for the packet length of received payload.
|
||||
|
@ -787,7 +788,7 @@ class CC1101: public PhysicalLayer {
|
|||
|
||||
\returns Length of last received packet in bytes.
|
||||
*/
|
||||
size_t getPacketLength(bool update = true);
|
||||
size_t getPacketLength(bool update = true) override;
|
||||
|
||||
/*!
|
||||
\brief Set modem in fixed packet length mode.
|
||||
|
@ -847,46 +848,70 @@ class CC1101: public PhysicalLayer {
|
|||
|
||||
/*!
|
||||
\brief Sets Gaussian filter bandwidth-time product that will be used for data shaping.
|
||||
Allowed value is 0.5. Set to 0 to disable data shaping.
|
||||
Allowed value is RADIOLIB_SHAPING_0_5. Set to RADIOLIB_SHAPING_NONE to disable data shaping.
|
||||
|
||||
\param sh Gaussian shaping bandwidth-time product that will be used for data shaping
|
||||
\param sh Gaussian shaping bandwidth-time product that will be used for data shaping.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setDataShaping(float sh);
|
||||
int16_t setDataShaping(uint8_t sh) override;
|
||||
|
||||
/*!
|
||||
\brief Sets transmission encoding.
|
||||
\brief Sets transmission encoding. Allowed values are RADIOLIB_ENCODING_NRZ and RADIOLIB_ENCODING_WHITENING.
|
||||
|
||||
\param encoding Encoding to be used. Set to 0 for NRZ, 1 for Manchester and 2 for whitening.
|
||||
\param encoding Encoding to be used.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setEncoding(uint8_t encoding);
|
||||
int16_t setEncoding(uint8_t encoding) override;
|
||||
|
||||
/*!
|
||||
\brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state.
|
||||
When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch!
|
||||
|
||||
\param rxEn RX enable pin.
|
||||
|
||||
\param txEn TX enable pin.
|
||||
*/
|
||||
void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn);
|
||||
|
||||
/*!
|
||||
\brief Get one truly random byte from RSSI noise.
|
||||
|
||||
\returns TRNG byte.
|
||||
*/
|
||||
uint8_t random();
|
||||
|
||||
/*!
|
||||
\brief Read version SPI register. Should return CC1101_VERSION_LEGACY (0x04) or CC1101_VERSION_CURRENT (0x14) if CC1101 is connected and working.
|
||||
|
||||
\returns Version register contents or \ref status_codes
|
||||
*/
|
||||
int16_t getChipVersion();
|
||||
|
||||
#ifndef RADIOLIB_GODMODE
|
||||
private:
|
||||
#endif
|
||||
Module* _mod;
|
||||
|
||||
float _freq;
|
||||
uint8_t _rawRSSI;
|
||||
uint8_t _rawLQI;
|
||||
uint8_t _modulation;
|
||||
float _freq = 0;
|
||||
uint8_t _rawRSSI = 0;
|
||||
uint8_t _rawLQI = 0;
|
||||
uint8_t _modulation = CC1101_MOD_FORMAT_2_FSK;
|
||||
|
||||
size_t _packetLength;
|
||||
bool _packetLengthQueried;
|
||||
uint8_t _packetLengthConfig;
|
||||
size_t _packetLength = 0;
|
||||
bool _packetLengthQueried = false;
|
||||
uint8_t _packetLengthConfig = CC1101_LENGTH_CONFIG_VARIABLE;
|
||||
|
||||
bool _promiscuous;
|
||||
bool _promiscuous = false;
|
||||
bool _crcOn = true;
|
||||
|
||||
uint8_t _syncWordLength;
|
||||
int8_t _power;
|
||||
uint8_t _syncWordLength = 2;
|
||||
int8_t _power = 0;
|
||||
|
||||
int16_t config();
|
||||
int16_t directMode();
|
||||
void getExpMant(float target, uint16_t mantOffset, uint8_t divExp, uint8_t expMax, uint8_t& exp, uint8_t& mant);
|
||||
static void getExpMant(float target, uint16_t mantOffset, uint8_t divExp, uint8_t expMax, uint8_t& exp, uint8_t& mant);
|
||||
int16_t setPacketMode(uint8_t mode, uint8_t len);
|
||||
|
||||
// SPI read overrides to set bit for burst write and status registers access
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#if !defined(ESP8266) && !defined(ARDUINO_ARDUINO_NANO33BLE)
|
||||
#include "ESP8266.h"
|
||||
#if !defined(RADIOLIB_EXCLUDE_ESP8266) && !defined(ESP8266)
|
||||
|
||||
ESP8266::ESP8266(Module* module) {
|
||||
_mod = module;
|
||||
|
@ -7,7 +7,8 @@ ESP8266::ESP8266(Module* module) {
|
|||
|
||||
int16_t ESP8266::begin(long speed) {
|
||||
// set module properties
|
||||
_mod->AtLineFeed = "\r\n";
|
||||
char lf[3] = "\r\n";
|
||||
memcpy(_mod->AtLineFeed, lf, strlen(lf));
|
||||
_mod->baudrate = speed;
|
||||
_mod->init(RADIOLIB_USE_UART);
|
||||
|
||||
|
@ -29,13 +30,13 @@ int16_t ESP8266::reset() {
|
|||
}
|
||||
|
||||
// wait for the module to start
|
||||
delay(2000);
|
||||
Module::delay(2000);
|
||||
|
||||
// test AT setup
|
||||
uint32_t start = millis();
|
||||
while (millis() - start < 3000) {
|
||||
uint32_t start = Module::millis();
|
||||
while (Module::millis() - start < 3000) {
|
||||
if(!_mod->ATsendCommand("AT")) {
|
||||
delay(100);
|
||||
Module::delay(100);
|
||||
} else {
|
||||
return(ERR_NONE);
|
||||
}
|
||||
|
@ -83,19 +84,19 @@ int16_t ESP8266::join(const char* ssid, const char* password) {
|
|||
|
||||
int16_t ESP8266::openTransportConnection(const char* host, const char* protocol, uint16_t port, uint16_t tcpKeepAlive) {
|
||||
char portStr[6];
|
||||
itoa(port, portStr, 10);
|
||||
sprintf(portStr, "%u", port);
|
||||
char tcpKeepAliveStr[6];
|
||||
itoa(tcpKeepAlive, tcpKeepAliveStr, 10);
|
||||
sprintf(tcpKeepAliveStr, "%u", tcpKeepAlive);
|
||||
|
||||
// build AT command
|
||||
const char* atStr = "AT+CIPSTART=\"";
|
||||
uint8_t cmdLen = strlen(atStr) + strlen(protocol) + strlen(host) + strlen(portStr) + 5;
|
||||
if((strcmp(protocol, "TCP") == 0) && (tcpKeepAlive > 0)) {
|
||||
cmdLen += strlen(tcpKeepAliveStr) + 1;
|
||||
}
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
char cmd[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
uint8_t cmdLen = strlen(atStr) + strlen(protocol) + strlen(host) + strlen(portStr) + 5;
|
||||
if((strcmp(protocol, "TCP") == 0) && (tcpKeepAlive > 0)) {
|
||||
cmdLen += strlen(tcpKeepAliveStr) + 1;
|
||||
}
|
||||
char* cmd = new char[cmdLen + 1];
|
||||
#endif
|
||||
strcpy(cmd, atStr);
|
||||
|
@ -131,8 +132,8 @@ int16_t ESP8266::closeTransportConnection() {
|
|||
|
||||
int16_t ESP8266::send(const char* data) {
|
||||
// build AT command
|
||||
char lenStr[8];
|
||||
itoa(strlen(data), lenStr, 10);
|
||||
char lenStr[12];
|
||||
sprintf(lenStr, "%u", (uint16_t)strlen(data));
|
||||
const char* atStr = "AT+CIPSEND=";
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
char cmd[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
|
@ -159,10 +160,10 @@ int16_t ESP8266::send(const char* data) {
|
|||
return(ERR_NONE);
|
||||
}
|
||||
|
||||
int16_t ESP8266::send(uint8_t* data, uint32_t len) {
|
||||
int16_t ESP8266::send(uint8_t* data, size_t len) {
|
||||
// build AT command
|
||||
char lenStr[8];
|
||||
itoa(len, lenStr, 10);
|
||||
sprintf(lenStr, "%u", (uint16_t)len);
|
||||
const char atStr[] = "AT+CIPSEND=";
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
char cmd[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
|
@ -191,11 +192,11 @@ int16_t ESP8266::send(uint8_t* data, uint32_t len) {
|
|||
|
||||
size_t ESP8266::receive(uint8_t* data, size_t len, uint32_t timeout) {
|
||||
size_t i = 0;
|
||||
uint32_t start = millis();
|
||||
uint32_t start = Module::millis();
|
||||
|
||||
// wait until the required number of bytes is received or until timeout
|
||||
while((millis() - start < timeout) && (i < len)) {
|
||||
yield();
|
||||
while((Module::millis() - start < timeout) && (i < len)) {
|
||||
Module::yield();
|
||||
while(_mod->ModuleSerial->available() > 0) {
|
||||
uint8_t b = _mod->ModuleSerial->read();
|
||||
RADIOLIB_DEBUG_PRINT(b);
|
||||
|
@ -208,10 +209,10 @@ size_t ESP8266::receive(uint8_t* data, size_t len, uint32_t timeout) {
|
|||
|
||||
size_t ESP8266::getNumBytes(uint32_t timeout, size_t minBytes) {
|
||||
// wait for available data
|
||||
uint32_t start = millis();
|
||||
uint32_t start = Module::millis();
|
||||
while(_mod->ModuleSerial->available() < (int16_t)minBytes) {
|
||||
yield();
|
||||
if(millis() - start >= timeout) {
|
||||
Module::yield();
|
||||
if(Module::millis() - start >= timeout) {
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
@ -219,16 +220,16 @@ size_t ESP8266::getNumBytes(uint32_t timeout, size_t minBytes) {
|
|||
// read response
|
||||
char rawStr[20];
|
||||
uint8_t i = 0;
|
||||
start = millis();
|
||||
start = Module::millis();
|
||||
while(_mod->ModuleSerial->available() > 0) {
|
||||
yield();
|
||||
Module::yield();
|
||||
char c = _mod->ModuleSerial->read();
|
||||
rawStr[i++] = c;
|
||||
if(c == ':') {
|
||||
rawStr[i++] = 0;
|
||||
break;
|
||||
}
|
||||
if(millis() - start >= timeout) {
|
||||
if(Module::millis() - start >= timeout) {
|
||||
rawStr[i++] = 0;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#if !defined(_RADIOLIB_ESP8266_H)
|
||||
#if !defined(_RADIOLIB_ESP8266_H) && !defined(RADIOLIB_EXCLUDE_ESP8266) && !defined(ESP8266)
|
||||
#define _RADIOLIB_ESP8266_H
|
||||
|
||||
#include "../../TypeDef.h"
|
||||
#include "../../Module.h"
|
||||
|
||||
#include "../../protocols/TransportLayer/TransportLayer.h"
|
||||
|
@ -47,12 +48,12 @@ class ESP8266: public TransportLayer {
|
|||
int16_t join(const char* ssid, const char* password);
|
||||
|
||||
// transport layer methods (implementations of purely virtual methods in TransportLayer class)
|
||||
int16_t openTransportConnection(const char* host, const char* protocol, uint16_t port, uint16_t tcpKeepAlive = 0);
|
||||
int16_t closeTransportConnection();
|
||||
int16_t send(const char* data);
|
||||
int16_t send(uint8_t* data, uint32_t len);
|
||||
size_t receive(uint8_t* data, size_t len, uint32_t timeout = 10000);
|
||||
size_t getNumBytes(uint32_t timeout = 10000, size_t minBytes = 10);
|
||||
int16_t openTransportConnection(const char* host, const char* protocol, uint16_t port, uint16_t tcpKeepAlive = 0) override;
|
||||
int16_t closeTransportConnection() override;
|
||||
int16_t send(const char* data) override;
|
||||
int16_t send(uint8_t* data, size_t len) override;
|
||||
size_t receive(uint8_t* data, size_t len, uint32_t timeout = 10000) override;
|
||||
size_t getNumBytes(uint32_t timeout = 10000, size_t minBytes = 10) override;
|
||||
|
||||
#ifndef RADIOLIB_GODMODE
|
||||
private:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "HC05.h"
|
||||
#if !defined(RADIOLIB_EXCLUDE_HC05)
|
||||
|
||||
HC05::HC05(Module* mod) : ISerial(mod) {
|
||||
|
||||
|
@ -9,3 +10,5 @@ void HC05::begin(long speed) {
|
|||
_mod->baudrate = speed;
|
||||
_mod->init(RADIOLIB_USE_UART);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef _RADIOLIB_HC05_H
|
||||
#if !defined(_RADIOLIB_HC05_H) && !defined(RADIOLIB_EXCLUDE_HC05)
|
||||
#define _RADIOLIB_HC05_H
|
||||
|
||||
#include "../../ISerial.h"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#if !defined(_RADIOLIB_JDY08_H) && !defined(RADIOLIB_EXCLUDE_JDY08)
|
||||
#include "JDY08.h"
|
||||
|
||||
JDY08::JDY08(Module* mod) : ISerial(mod) {
|
||||
|
@ -6,7 +7,10 @@ JDY08::JDY08(Module* mod) : ISerial(mod) {
|
|||
|
||||
void JDY08::begin(long speed) {
|
||||
// set module properties
|
||||
_mod->AtLineFeed = "";
|
||||
char lf[3] = "";
|
||||
memcpy(_mod->AtLineFeed, lf, strlen(lf));
|
||||
_mod->baudrate = speed;
|
||||
_mod->init(RADIOLIB_USE_UART);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef _RADIOLIB_JDY08_H
|
||||
#if !defined(_RADIOLIB_JDY08_H) && !defined(RADIOLIB_EXCLUDE_JDY08)
|
||||
#define _RADIOLIB_JDY08_H
|
||||
|
||||
#include "../../ISerial.h"
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
#include "RF69.h"
|
||||
#if !defined(RADIOLIB_EXCLUDE_RF69)
|
||||
|
||||
RF69::RF69(Module* module) : PhysicalLayer(RF69_FREQUENCY_STEP_SIZE, RF69_MAX_PACKET_LENGTH) {
|
||||
_mod = module;
|
||||
_tempOffset = 0;
|
||||
|
||||
_packetLengthQueried = false;
|
||||
_packetLengthConfig = RF69_PACKET_FORMAT_VARIABLE;
|
||||
|
||||
_promiscuous = false;
|
||||
|
||||
_syncWordLength = 2;
|
||||
}
|
||||
|
||||
int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t power) {
|
||||
int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLen) {
|
||||
// set module properties
|
||||
_mod->init(RADIOLIB_USE_SPI);
|
||||
Module::pinMode(_mod->getIrq(), INPUT);
|
||||
|
@ -25,8 +18,8 @@ int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t powe
|
|||
reset();
|
||||
|
||||
// check version register
|
||||
uint8_t version = _mod->SPIreadRegister(RF69_REG_VERSION);
|
||||
if(version == 0x24) {
|
||||
int16_t version = getChipVersion();
|
||||
if(version == RF69_CHIP_VERSION) {
|
||||
flagFound = true;
|
||||
} else {
|
||||
#ifdef RADIOLIB_DEBUG
|
||||
|
@ -40,17 +33,17 @@ int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t powe
|
|||
RADIOLIB_DEBUG_PRINT(F(", expected 0x0024"));
|
||||
RADIOLIB_DEBUG_PRINTLN();
|
||||
#endif
|
||||
delay(1000);
|
||||
Module::delay(10);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if(!flagFound) {
|
||||
RADIOLIB_DEBUG_PRINTLN(F("No RF69 found!"));
|
||||
_mod->term();
|
||||
_mod->term(RADIOLIB_USE_SPI);
|
||||
return(ERR_CHIP_NOT_FOUND);
|
||||
} else {
|
||||
RADIOLIB_DEBUG_PRINTLN(F("Found RF69! (match by RF69_REG_VERSION == 0x24)"));
|
||||
RADIOLIB_DEBUG_PRINTLN(F("M\tRF69"));
|
||||
}
|
||||
|
||||
// configure settings not accessible by API
|
||||
|
@ -78,32 +71,40 @@ int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t powe
|
|||
state = setOutputPower(power);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// configure default preamble length
|
||||
state = setPreambleLength(preambleLen);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set default packet length mode
|
||||
state = variablePacketLengthMode();
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// default sync word values 0x2D01 is the same as the default in LowPowerLab RFM69 library
|
||||
uint8_t syncWord[] = {0x2D, 0x01};
|
||||
// set default sync word
|
||||
uint8_t syncWord[] = {0x12, 0xAD};
|
||||
state = setSyncWord(syncWord, sizeof(syncWord));
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set default data shaping
|
||||
state = setDataShaping(0);
|
||||
state = setDataShaping(RADIOLIB_SHAPING_NONE);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set default encoding
|
||||
state = setEncoding(0);
|
||||
state = setEncoding(RADIOLIB_ENCODING_NRZ);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
return(ERR_NONE);
|
||||
// set CRC on by default
|
||||
state = setCrcFiltering(true);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
return(state);
|
||||
}
|
||||
|
||||
void RF69::reset() {
|
||||
Module::pinMode(_mod->getRst(), OUTPUT);
|
||||
Module::digitalWrite(_mod->getRst(), HIGH);
|
||||
delay(1);
|
||||
Module::delay(1);
|
||||
Module::digitalWrite(_mod->getRst(), LOW);
|
||||
delay(10);
|
||||
Module::delay(10);
|
||||
}
|
||||
|
||||
int16_t RF69::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||
|
@ -115,11 +116,11 @@ int16_t RF69::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
|||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// wait for transmission end or timeout
|
||||
uint32_t start = micros();
|
||||
while(!digitalRead(_mod->getIrq())) {
|
||||
yield();
|
||||
uint32_t start = Module::micros();
|
||||
while(!Module::digitalRead(_mod->getIrq())) {
|
||||
Module::yield();
|
||||
|
||||
if(micros() - start > timeout) {
|
||||
if(Module::micros() - start > timeout) {
|
||||
standby();
|
||||
clearIRQFlags();
|
||||
return(ERR_TX_TIMEOUT);
|
||||
|
@ -144,11 +145,11 @@ int16_t RF69::receive(uint8_t* data, size_t len) {
|
|||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// wait for packet reception or timeout
|
||||
uint32_t start = micros();
|
||||
while(!digitalRead(_mod->getIrq())) {
|
||||
yield();
|
||||
|
||||
if(micros() - start > timeout) {
|
||||
uint32_t start = Module::micros();
|
||||
while(!Module::digitalRead(_mod->getIrq())) {
|
||||
Module::yield();
|
||||
|
||||
if(Module::micros() - start > timeout) {
|
||||
standby();
|
||||
clearIRQFlags();
|
||||
return(ERR_RX_TIMEOUT);
|
||||
|
@ -160,16 +161,25 @@ int16_t RF69::receive(uint8_t* data, size_t len) {
|
|||
}
|
||||
|
||||
int16_t RF69::sleep() {
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(LOW, LOW);
|
||||
|
||||
// set module to sleep
|
||||
return(setMode(RF69_SLEEP));
|
||||
}
|
||||
|
||||
int16_t RF69::standby() {
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(LOW, LOW);
|
||||
|
||||
// set module to standby
|
||||
return(setMode(RF69_STANDBY));
|
||||
}
|
||||
|
||||
int16_t RF69::transmitDirect(uint32_t frf) {
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(LOW, HIGH);
|
||||
|
||||
// user requested to start transmitting immediately (required for RTTY)
|
||||
if(frf != 0) {
|
||||
_mod->SPIwriteRegister(RF69_REG_FRF_MSB, (frf & 0xFF0000) >> 16);
|
||||
|
@ -188,6 +198,9 @@ int16_t RF69::transmitDirect(uint32_t frf) {
|
|||
}
|
||||
|
||||
int16_t RF69::receiveDirect() {
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(HIGH, LOW);
|
||||
|
||||
// activate direct mode
|
||||
int16_t state = directMode();
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
@ -228,6 +241,7 @@ int16_t RF69::disableAES() {
|
|||
int16_t RF69::startReceive() {
|
||||
// set mode to standby
|
||||
int16_t state = setMode(RF69_STANDBY);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set RX timeouts and DIO pin mapping
|
||||
state = _mod->SPIsetRegValue(RF69_REG_DIO_MAPPING_1, RF69_DIO0_PACK_PAYLOAD_READY, 7, 4);
|
||||
|
@ -238,35 +252,41 @@ int16_t RF69::startReceive() {
|
|||
// clear interrupt flags
|
||||
clearIRQFlags();
|
||||
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(HIGH, LOW);
|
||||
|
||||
// set mode to receive
|
||||
state = _mod->SPIsetRegValue(RF69_REG_TEST_PA1, RF69_PA1_NORMAL);
|
||||
state = _mod->SPIsetRegValue(RF69_REG_OCP, RF69_OCP_ON | RF69_OCP_TRIM);
|
||||
state |= _mod->SPIsetRegValue(RF69_REG_TEST_PA1, RF69_PA1_NORMAL);
|
||||
state |= _mod->SPIsetRegValue(RF69_REG_TEST_PA2, RF69_PA2_NORMAL);
|
||||
state |= setMode(RF69_RX);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
state = setMode(RF69_RX);
|
||||
|
||||
return(state);
|
||||
}
|
||||
|
||||
void RF69::setDio0Action(void (*func)(void)) {
|
||||
attachInterrupt(digitalPinToInterrupt(_mod->getIrq()), func, RISING);
|
||||
Module::attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING);
|
||||
}
|
||||
|
||||
void RF69::clearDio0Action() {
|
||||
detachInterrupt(digitalPinToInterrupt(_mod->getIrq()));
|
||||
Module::detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()));
|
||||
}
|
||||
|
||||
void RF69::setDio1Action(void (*func)(void)) {
|
||||
if(_mod->getGpio() != RADIOLIB_NC) {
|
||||
if(_mod->getGpio() == RADIOLIB_NC) {
|
||||
return;
|
||||
}
|
||||
Module::pinMode(_mod->getGpio(), INPUT);
|
||||
attachInterrupt(digitalPinToInterrupt(_mod->getGpio()), func, RISING);
|
||||
Module::attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, RISING);
|
||||
}
|
||||
|
||||
void RF69::clearDio1Action() {
|
||||
if(_mod->getGpio() != RADIOLIB_NC) {
|
||||
if(_mod->getGpio() == RADIOLIB_NC) {
|
||||
return;
|
||||
}
|
||||
detachInterrupt(digitalPinToInterrupt(_mod->getGpio()));
|
||||
Module::detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()));
|
||||
}
|
||||
|
||||
int16_t RF69::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||
|
@ -303,10 +323,19 @@ int16_t RF69::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
|||
// write packet to FIFO
|
||||
_mod->SPIwriteRegisterBurst(RF69_REG_FIFO, data, len);
|
||||
|
||||
// enable +20 dBm operation
|
||||
if(_power > 17) {
|
||||
state = _mod->SPIsetRegValue(RF69_REG_OCP, RF69_OCP_OFF | 0x0F);
|
||||
state |= _mod->SPIsetRegValue(RF69_REG_TEST_PA1, RF69_PA1_20_DBM);
|
||||
state |= _mod->SPIsetRegValue(RF69_REG_TEST_PA2, RF69_PA2_20_DBM);
|
||||
RADIOLIB_ASSERT(state);
|
||||
}
|
||||
|
||||
// set RF switch (if present)
|
||||
_mod->setRfSwitchState(LOW, HIGH);
|
||||
|
||||
// set mode to transmit
|
||||
state = _mod->SPIsetRegValue(RF69_REG_TEST_PA1, RF69_PA1_20_DBM);
|
||||
state |= _mod->SPIsetRegValue(RF69_REG_TEST_PA2, RF69_PA2_20_DBM);
|
||||
state |= setMode(RF69_TX);
|
||||
state = setMode(RF69_TX);
|
||||
|
||||
return(state);
|
||||
}
|
||||
|
@ -315,6 +344,7 @@ int16_t RF69::readData(uint8_t* data, size_t len) {
|
|||
// set mode to standby
|
||||
int16_t state = standby();
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// get packet length
|
||||
size_t length = len;
|
||||
if(len == RF69_MAX_PACKET_LENGTH) {
|
||||
|
@ -330,9 +360,6 @@ int16_t RF69::readData(uint8_t* data, size_t len) {
|
|||
// read packet data
|
||||
_mod->SPIreadRegisterBurst(RF69_REG_FIFO, length, data);
|
||||
|
||||
// update RSSI
|
||||
lastPacketRSSI = -1.0 * (_mod->SPIgetRegValue(RF69_REG_RSSI_VALUE)/2.0);
|
||||
|
||||
// clear internal flag so getPacketLength can return the new packet length
|
||||
_packetLengthQueried = false;
|
||||
|
||||
|
@ -355,11 +382,10 @@ int16_t RF69::setFrequency(float freq) {
|
|||
|
||||
//set carrier frequency
|
||||
uint32_t FRF = (freq * (uint32_t(1) << RF69_DIV_EXPONENT)) / RF69_CRYSTAL_FREQ;
|
||||
int16_t state = _mod->SPIsetRegValue(RF69_REG_FRF_MSB, (FRF & 0xFF0000) >> 16, 7, 0);
|
||||
state |= _mod->SPIsetRegValue(RF69_REG_FRF_MID, (FRF & 0x00FF00) >> 8, 7, 0);
|
||||
state |= _mod->SPIsetRegValue(RF69_REG_FRF_LSB, FRF & 0x0000FF, 7, 0);
|
||||
|
||||
return(state);
|
||||
_mod->SPIwriteRegister(RF69_REG_FRF_MSB, (FRF & 0xFF0000) >> 16);
|
||||
_mod->SPIwriteRegister(RF69_REG_FRF_MID, (FRF & 0x00FF00) >> 8);
|
||||
_mod->SPIwriteRegister(RF69_REG_FRF_LSB, FRF & 0x0000FF);
|
||||
return(ERR_NONE);
|
||||
}
|
||||
|
||||
int16_t RF69::setBitRate(float br) {
|
||||
|
@ -496,22 +522,41 @@ int16_t RF69::setFrequencyDeviation(float freqDev) {
|
|||
return(state);
|
||||
}
|
||||
|
||||
int16_t RF69::setOutputPower(int8_t power) {
|
||||
RADIOLIB_CHECK_RANGE(power, -18, 17, ERR_INVALID_OUTPUT_POWER);
|
||||
int16_t RF69::setOutputPower(int8_t power, bool highPower) {
|
||||
if(highPower) {
|
||||
RADIOLIB_CHECK_RANGE(power, -2, 20, ERR_INVALID_OUTPUT_POWER);
|
||||
} else {
|
||||
RADIOLIB_CHECK_RANGE(power, -18, 13, ERR_INVALID_OUTPUT_POWER);
|
||||
}
|
||||
|
||||
// set mode to standby
|
||||
setMode(RF69_STANDBY);
|
||||
|
||||
// set output power
|
||||
int16_t state;
|
||||
if(power > 13) {
|
||||
// requested output power is higher than 13 dBm, enable PA2 + PA1 on PA_BOOST
|
||||
state = _mod->SPIsetRegValue(RF69_REG_PA_LEVEL, RF69_PA0_OFF | RF69_PA1_ON | RF69_PA2_ON | (power + 14), 7, 0);
|
||||
if(highPower) {
|
||||
// check if both PA1 and PA2 are needed
|
||||
if(power <= 10) {
|
||||
// -2 to 13 dBm, PA1 is enough
|
||||
state = _mod->SPIsetRegValue(RF69_REG_PA_LEVEL, RF69_PA0_OFF | RF69_PA1_ON | RF69_PA2_OFF | (power + 18), 7, 0);
|
||||
} else if(power <= 17) {
|
||||
// 13 to 17 dBm, both PAs required
|
||||
state = _mod->SPIsetRegValue(RF69_REG_PA_LEVEL, RF69_PA0_OFF | RF69_PA1_ON | RF69_PA2_ON | (power + 14), 7, 0);
|
||||
} else {
|
||||
// 18 - 20 dBm, both PAs and hig power settings required
|
||||
state = _mod->SPIsetRegValue(RF69_REG_PA_LEVEL, RF69_PA0_OFF | RF69_PA1_ON | RF69_PA2_ON | (power + 11), 7, 0);
|
||||
}
|
||||
|
||||
} else {
|
||||
// requested output power is lower than 13 dBm, enable PA0 on RFIO
|
||||
// low power module, use only PA0
|
||||
state = _mod->SPIsetRegValue(RF69_REG_PA_LEVEL, RF69_PA0_ON | RF69_PA1_OFF | RF69_PA2_OFF | (power + 18), 7, 0);
|
||||
}
|
||||
|
||||
// cache the power value
|
||||
if(state == ERR_NONE) {
|
||||
_power = power;
|
||||
}
|
||||
|
||||
return(state);
|
||||
}
|
||||
|
||||
|
@ -538,6 +583,17 @@ int16_t RF69::setSyncWord(uint8_t* syncWord, size_t len, uint8_t maxErrBits) {
|
|||
return(ERR_NONE);
|
||||
}
|
||||
|
||||
int16_t RF69::setPreambleLength(uint8_t preambleLen) {
|
||||
// RF69 configures preamble length in bytes
|
||||
if(preambleLen % 8 != 0) {
|
||||
return(ERR_INVALID_PREAMBLE_LENGTH);
|
||||
}
|
||||
|
||||
uint8_t preLenBytes = preambleLen / 8;
|
||||
_mod->SPIwriteRegister(RF69_REG_PREAMBLE_MSB, 0x00);
|
||||
return(_mod->SPIsetRegValue(RF69_REG_PREAMBLE_LSB, preLenBytes));
|
||||
}
|
||||
|
||||
int16_t RF69::setNodeAddress(uint8_t nodeAddr) {
|
||||
// enable address filtering (node only)
|
||||
int16_t state = _mod->SPIsetRegValue(RF69_REG_PACKET_CONFIG_1, RF69_ADDRESS_FILTERING_NODE, 2, 1);
|
||||
|
@ -583,7 +639,7 @@ int16_t RF69::getTemperature() {
|
|||
// wait until measurement is finished
|
||||
while(_mod->SPIgetRegValue(RF69_REG_TEMP_1, 2, 2) == RF69_TEMP_MEAS_RUNNING) {
|
||||
// check every 10 us
|
||||
delay(10);
|
||||
Module::delay(10);
|
||||
}
|
||||
int8_t rawTemp = _mod->SPIgetRegValue(RF69_REG_TEMP_2);
|
||||
|
||||
|
@ -662,25 +718,24 @@ int16_t RF69::setPromiscuousMode(bool promiscuous) {
|
|||
return(state);
|
||||
}
|
||||
|
||||
int16_t RF69::setDataShaping(float sh) {
|
||||
int16_t RF69::setDataShaping(uint8_t sh) {
|
||||
// set mode to standby
|
||||
int16_t state = standby();
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set data shaping
|
||||
sh *= 10.0;
|
||||
if(abs(sh - 0.0) <= 0.001) {
|
||||
state = _mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_NO_SHAPING, 1, 0);
|
||||
} else if(abs(sh - 3.0) <= 0.001) {
|
||||
state = _mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_FSK_GAUSSIAN_0_3, 1, 0);
|
||||
} else if(abs(sh - 5.0) <= 0.001) {
|
||||
state = _mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_FSK_GAUSSIAN_0_5, 1, 0);
|
||||
} else if(abs(sh - 10.0) <= 0.001) {
|
||||
state = _mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_FSK_GAUSSIAN_1_0, 1, 0);
|
||||
} else {
|
||||
return(ERR_INVALID_DATA_SHAPING);
|
||||
switch(sh) {
|
||||
case RADIOLIB_SHAPING_NONE:
|
||||
return(_mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_NO_SHAPING, 1, 0));
|
||||
case RADIOLIB_SHAPING_0_3:
|
||||
return(_mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_FSK_GAUSSIAN_0_3, 1, 0));
|
||||
case RADIOLIB_SHAPING_0_5:
|
||||
return(_mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_FSK_GAUSSIAN_0_5, 1, 0));
|
||||
case RADIOLIB_SHAPING_1_0:
|
||||
return(_mod->SPIsetRegValue(RF69_REG_DATA_MODUL, RF69_FSK_GAUSSIAN_1_0, 1, 0));
|
||||
default:
|
||||
return(ERR_INVALID_DATA_SHAPING);
|
||||
}
|
||||
return(state);
|
||||
}
|
||||
|
||||
int16_t RF69::setEncoding(uint8_t encoding) {
|
||||
|
@ -690,17 +745,48 @@ int16_t RF69::setEncoding(uint8_t encoding) {
|
|||
|
||||
// set encoding
|
||||
switch(encoding) {
|
||||
case 0:
|
||||
case RADIOLIB_ENCODING_NRZ:
|
||||
return(_mod->SPIsetRegValue(RF69_REG_PACKET_CONFIG_1, RF69_DC_FREE_NONE, 6, 5));
|
||||
case 1:
|
||||
case RADIOLIB_ENCODING_MANCHESTER:
|
||||
return(_mod->SPIsetRegValue(RF69_REG_PACKET_CONFIG_1, RF69_DC_FREE_MANCHESTER, 6, 5));
|
||||
case 2:
|
||||
case RADIOLIB_ENCODING_WHITENING:
|
||||
return(_mod->SPIsetRegValue(RF69_REG_PACKET_CONFIG_1, RF69_DC_FREE_WHITENING, 6, 5));
|
||||
default:
|
||||
return(ERR_INVALID_ENCODING);
|
||||
}
|
||||
}
|
||||
|
||||
float RF69::getRSSI() {
|
||||
return(-1.0 * (_mod->SPIgetRegValue(RF69_REG_RSSI_VALUE)/2.0));
|
||||
}
|
||||
|
||||
void RF69::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
|
||||
_mod->setRfSwitchPins(rxEn, txEn);
|
||||
}
|
||||
|
||||
uint8_t RF69::random() {
|
||||
// set mode to Rx
|
||||
setMode(RF69_RX);
|
||||
|
||||
// wait a bit for the RSSI reading to stabilise
|
||||
Module::delay(10);
|
||||
|
||||
// read RSSI value 8 times, always keep just the least significant bit
|
||||
uint8_t randByte = 0x00;
|
||||
for(uint8_t i = 0; i < 8; i++) {
|
||||
randByte |= ((_mod->SPIreadRegister(RF69_REG_RSSI_VALUE) & 0x01) << i);
|
||||
}
|
||||
|
||||
// set mode to standby
|
||||
setMode(RF69_STANDBY);
|
||||
|
||||
return(randByte);
|
||||
}
|
||||
|
||||
int16_t RF69::getChipVersion() {
|
||||
return(_mod->SPIgetRegValue(RF69_REG_VERSION));
|
||||
}
|
||||
|
||||
int16_t RF69::config() {
|
||||
int16_t state = ERR_NONE;
|
||||
|
||||
|
@ -748,13 +834,13 @@ int16_t RF69::config() {
|
|||
|
||||
// set Rx timeouts
|
||||
state = _mod->SPIsetRegValue(RF69_REG_RX_TIMEOUT_1, RF69_TIMEOUT_RX_START, 7, 0);
|
||||
state = _mod->SPIsetRegValue(RF69_REG_RX_TIMEOUT_2, RF69_TIMEOUT_RSSI_THRESH, 7, 0);
|
||||
state |= _mod->SPIsetRegValue(RF69_REG_RX_TIMEOUT_2, RF69_TIMEOUT_RSSI_THRESH, 7, 0);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// enable improved fading margin
|
||||
state = _mod->SPIsetRegValue(RF69_REG_TEST_DAGC, RF69_CONTINUOUS_DAGC_LOW_BETA_OFF, 7, 0);
|
||||
|
||||
return(ERR_NONE);
|
||||
return(state);
|
||||
}
|
||||
|
||||
int16_t RF69::setPacketMode(uint8_t mode, uint8_t len) {
|
||||
|
@ -784,3 +870,5 @@ void RF69::clearIRQFlags() {
|
|||
_mod->SPIwriteRegister(RF69_REG_IRQ_FLAGS_1, 0b11111111);
|
||||
_mod->SPIwriteRegister(RF69_REG_IRQ_FLAGS_2, 0b11111111);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#ifndef _RADIOLIB_RF69_H
|
||||
#if !defined(_RADIOLIB_RF69_H)
|
||||
#define _RADIOLIB_RF69_H
|
||||
|
||||
#include "../../TypeDef.h"
|
||||
|
||||
#if !defined(RADIOLIB_EXCLUDE_RF69)
|
||||
|
||||
#include "../../Module.h"
|
||||
|
||||
#include "../../protocols/PhysicalLayer/PhysicalLayer.h"
|
||||
|
@ -159,6 +162,9 @@
|
|||
// RF69_REG_LISTEN_3
|
||||
#define RF69_LISTEN_COEF_RX 0x20 // 7 0 duration of Rx phase in Listen mode
|
||||
|
||||
// RF69_REG_VERSION
|
||||
#define RF69_CHIP_VERSION 0x24 // 7 0
|
||||
|
||||
// RF69_REG_PA_LEVEL
|
||||
#define RF69_PA0_OFF 0b00000000 // 7 7 PA0 disabled
|
||||
#define RF69_PA0_ON 0b10000000 // 7 7 PA0 enabled (default)
|
||||
|
@ -188,7 +194,7 @@
|
|||
|
||||
// RF69_REG_OCP
|
||||
#define RF69_OCP_OFF 0b00000000 // 4 4 PA overload current protection disabled
|
||||
#define RF69_OCP_ON 0b00100000 // 4 4 PA overload current protection enabled
|
||||
#define RF69_OCP_ON 0b00010000 // 4 4 PA overload current protection enabled
|
||||
#define RF69_OCP_TRIM 0b00001010 // 3 0 OCP current: I_max(OCP_TRIM = 0b1010) = 95 mA
|
||||
|
||||
// RF69_REG_LNA
|
||||
|
@ -441,11 +447,6 @@ class RF69: public PhysicalLayer {
|
|||
*/
|
||||
RF69(Module* module);
|
||||
|
||||
/*!
|
||||
\brief RSSI value of the last received packet.
|
||||
*/
|
||||
float lastPacketRSSI;
|
||||
|
||||
// basic methods
|
||||
|
||||
/*!
|
||||
|
@ -459,11 +460,13 @@ class RF69: public PhysicalLayer {
|
|||
|
||||
\param rxBw Receiver bandwidth in kHz. Defaults to 125.0 kHz.
|
||||
|
||||
\param power Output power in dBm. Defaults to 13 dBm.
|
||||
\param power Output power in dBm. Defaults to 10 dBm.
|
||||
|
||||
\param preambleLen Preamble Length in bits. Defaults to 16 bits.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 125.0, int8_t power = 13);
|
||||
int16_t begin(float freq = 434.0, float br = 48.0, float freqDev = 50.0, float rxBw = 125.0, int8_t power = 10, uint8_t preambleLen = 16);
|
||||
|
||||
/*!
|
||||
\brief Reset method. Will reset the chip to the default state using RST pin.
|
||||
|
@ -482,7 +485,7 @@ class RF69: public PhysicalLayer {
|
|||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0);
|
||||
int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0) override;
|
||||
|
||||
/*!
|
||||
\brief Blocking binary receive method.
|
||||
|
@ -494,7 +497,7 @@ class RF69: public PhysicalLayer {
|
|||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t receive(uint8_t* data, size_t len);
|
||||
int16_t receive(uint8_t* data, size_t len) override;
|
||||
|
||||
/*!
|
||||
\brief Sets the module to sleep mode.
|
||||
|
@ -508,7 +511,7 @@ class RF69: public PhysicalLayer {
|
|||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t standby();
|
||||
int16_t standby() override;
|
||||
|
||||
/*!
|
||||
\brief Starts direct mode transmission.
|
||||
|
@ -517,14 +520,14 @@ class RF69: public PhysicalLayer {
|
|||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t transmitDirect(uint32_t frf = 0);
|
||||
int16_t transmitDirect(uint32_t frf = 0) override;
|
||||
|
||||
/*!
|
||||
\brief Starts direct mode reception.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t receiveDirect();
|
||||
int16_t receiveDirect() override;
|
||||
|
||||
/*!
|
||||
\brief Stops direct mode. It is required to call this method to switch from direct transmissions to packet-based transmissions.
|
||||
|
@ -592,7 +595,7 @@ class RF69: public PhysicalLayer {
|
|||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0);
|
||||
int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0) override;
|
||||
|
||||
/*!
|
||||
\brief Interrupt-driven receive method. GDO0 will be activated when full packet is received.
|
||||
|
@ -610,7 +613,7 @@ class RF69: public PhysicalLayer {
|
|||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t readData(uint8_t* data, size_t len);
|
||||
int16_t readData(uint8_t* data, size_t len) override;
|
||||
|
||||
// configuration methods
|
||||
|
||||
|
@ -648,16 +651,18 @@ class RF69: public PhysicalLayer {
|
|||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setFrequencyDeviation(float freqDev);
|
||||
int16_t setFrequencyDeviation(float freqDev) override;
|
||||
|
||||
/*!
|
||||
\brief Sets output power. Allowed values are -30, -20, -15, -10, 0, 5, 7 or 10 dBm.
|
||||
\brief Sets output power. Allowed values range from -18 to 13 dBm for low power modules (RF69C/CW) or -2 to 20 dBm (RF69H/HC/HCW).
|
||||
|
||||
\param power Output power to be set in dBm.
|
||||
|
||||
\param highPower Set to true when using modules high power port (RF69H/HC/HCW). Defaults to false (models without high power port - RF69C/CW).
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setOutputPower(int8_t power);
|
||||
int16_t setOutputPower(int8_t power, bool highPower = false);
|
||||
|
||||
/*!
|
||||
\brief Sets sync word. Up to 8 bytes can be set as sync word.
|
||||
|
@ -670,6 +675,15 @@ class RF69: public PhysicalLayer {
|
|||
*/
|
||||
int16_t setSyncWord(uint8_t* syncWord, size_t len, uint8_t maxErrBits = 0);
|
||||
|
||||
/*!
|
||||
\brief Sets preamble length.
|
||||
|
||||
\param preambleLen Preamble length to be set (in bits), allowed values: 16, 24, 32, 48, 64, 96, 128 and 192.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setPreambleLength(uint8_t preambleLen);
|
||||
|
||||
/*!
|
||||
\brief Sets node address. Calling this method will also enable address filtering for node address only.
|
||||
|
||||
|
@ -718,7 +732,7 @@ class RF69: public PhysicalLayer {
|
|||
|
||||
\returns Length of last received packet in bytes.
|
||||
*/
|
||||
size_t getPacketLength(bool update = true);
|
||||
size_t getPacketLength(bool update = true) override;
|
||||
|
||||
/*!
|
||||
\brief Set modem in fixed packet length mode.
|
||||
|
@ -774,39 +788,72 @@ class RF69: public PhysicalLayer {
|
|||
|
||||
/*!
|
||||
\brief Sets Gaussian filter bandwidth-time product that will be used for data shaping.
|
||||
Allowed values are 0.3, 0.5 or 1.0. Set to 0 to disable data shaping.
|
||||
Allowed values are RADIOLIB_SHAPING_0_3, RADIOLIB_SHAPING_0_5 or RADIOLIB_SHAPING_1_0. Set to RADIOLIB_SHAPING_NONE to disable data shaping.
|
||||
|
||||
\param sh Gaussian shaping bandwidth-time product that will be used for data shaping
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setDataShaping(float sh);
|
||||
int16_t setDataShaping(uint8_t sh) override;
|
||||
|
||||
/*!
|
||||
\brief Sets transmission encoding.
|
||||
Allowed values are RADIOLIB_ENCODING_NRZ, RADIOLIB_ENCODING_MANCHESTER and RADIOLIB_ENCODING_WHITENING.
|
||||
|
||||
\param encoding Encoding to be used. Set to 0 for NRZ, 1 for Manchester and 2 for whitening.
|
||||
\param encoding Encoding to be used.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setEncoding(uint8_t encoding);
|
||||
int16_t setEncoding(uint8_t encoding) override;
|
||||
|
||||
/*!
|
||||
\brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet.
|
||||
|
||||
\returns Last packet RSSI in dBm.
|
||||
*/
|
||||
float getRSSI();
|
||||
|
||||
/*!
|
||||
\brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state.
|
||||
When using automatic RF switch control, DO NOT change the pin mode of rxEn or txEn from Arduino sketch!
|
||||
|
||||
\param rxEn RX enable pin.
|
||||
|
||||
\param txEn TX enable pin.
|
||||
*/
|
||||
void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn);
|
||||
|
||||
/*!
|
||||
\brief Get one truly random byte from RSSI noise.
|
||||
|
||||
\returns TRNG byte.
|
||||
*/
|
||||
uint8_t random();
|
||||
|
||||
/*!
|
||||
\brief Read version SPI register. Should return RF69_CHIP_VERSION (0x24) if SX127x is connected and working.
|
||||
|
||||
\returns Version register contents or \ref status_codes
|
||||
*/
|
||||
int16_t getChipVersion();
|
||||
|
||||
#ifndef RADIOLIB_GODMODE
|
||||
protected:
|
||||
#endif
|
||||
Module* _mod;
|
||||
|
||||
float _br;
|
||||
float _rxBw;
|
||||
int16_t _tempOffset;
|
||||
float _br = 0;
|
||||
float _rxBw = 0;
|
||||
int16_t _tempOffset = 0;
|
||||
int8_t _power = 0;
|
||||
|
||||
size_t _packetLength;
|
||||
bool _packetLengthQueried;
|
||||
uint8_t _packetLengthConfig;
|
||||
size_t _packetLength = 0;
|
||||
bool _packetLengthQueried = false;
|
||||
uint8_t _packetLengthConfig = RF69_PACKET_FORMAT_VARIABLE;
|
||||
|
||||
bool _promiscuous;
|
||||
bool _promiscuous = false;
|
||||
|
||||
uint8_t _syncWordLength;
|
||||
uint8_t _syncWordLength = 2;
|
||||
|
||||
int16_t config();
|
||||
int16_t directMode();
|
||||
|
@ -820,3 +867,5 @@ class RF69: public PhysicalLayer {
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#ifndef _RADIOLIB_RFM22_H
|
||||
#if !defined(_RADIOLIB_RFM22_H)
|
||||
#define _RADIOLIB_RFM22_H
|
||||
|
||||
#include "../../TypeDef.h"
|
||||
|
||||
#if !defined(RADIOLIB_EXCLUDE_RFM2X)
|
||||
|
||||
#include "../../Module.h"
|
||||
#include "../Si443x/Si443x.h"
|
||||
#include "../Si443x/Si4432.h"
|
||||
|
@ -14,3 +17,5 @@
|
|||
using RFM22 = Si4432;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#ifndef _RADIOLIB_RFM23_H
|
||||
#if !defined(_RADIOLIB_RFM23_H)
|
||||
#define _RADIOLIB_RFM23_H
|
||||
|
||||
#include "../../TypeDef.h"
|
||||
|
||||
#if !defined(RADIOLIB_EXCLUDE_RFM2X)
|
||||
|
||||
#include "../../Module.h"
|
||||
#include "../Si443x/Si443x.h"
|
||||
#include "../Si443x/Si4431.h"
|
||||
|
@ -14,3 +17,5 @@
|
|||
using RFM23 = Si4431;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,17 +1,23 @@
|
|||
#include "RFM95.h"
|
||||
#if !defined(RADIOLIB_EXCLUDE_RFM9X)
|
||||
|
||||
RFM95::RFM95(Module* mod) : SX1278(mod) {
|
||||
|
||||
}
|
||||
|
||||
int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint8_t currentLimit, uint16_t preambleLength, uint8_t gain) {
|
||||
int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, uint8_t gain) {
|
||||
// execute common part
|
||||
int16_t state = SX127x::begin(RFM95_CHIP_VERSION, syncWord, currentLimit, preambleLength);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// configure settings not accessible by API
|
||||
state = config();
|
||||
RADIOLIB_ASSERT(state);
|
||||
int16_t state = SX127x::begin(RFM9X_CHIP_VERSION_OFFICIAL, syncWord, preambleLength);
|
||||
if(state == ERR_CHIP_NOT_FOUND) {
|
||||
// SX127X_REG_VERSION might be set 0x12
|
||||
state = SX127x::begin(RFM9X_CHIP_VERSION_UNOFFICIAL, syncWord, preambleLength);
|
||||
RADIOLIB_ASSERT(state);
|
||||
} else if(state != ERR_NONE) {
|
||||
// some other error
|
||||
return(state);
|
||||
}
|
||||
RADIOLIB_DEBUG_PRINTLN(F("M\tSX1278"));
|
||||
RADIOLIB_DEBUG_PRINTLN(F("M\tRFM95"));
|
||||
|
||||
// configure publicly accessible settings
|
||||
state = setFrequency(freq);
|
||||
|
@ -35,8 +41,10 @@ int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncW
|
|||
}
|
||||
|
||||
int16_t RFM95::setFrequency(float freq) {
|
||||
RADIOLIB_CHECK_RANGE(freq, 868.0, 915.0, ERR_INVALID_FREQUENCY);
|
||||
RADIOLIB_CHECK_RANGE(freq, 862.0, 1020.0, ERR_INVALID_FREQUENCY);
|
||||
|
||||
// set frequency
|
||||
return(SX127x::setFrequencyRaw(freq));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue