kopia lustrzana https://github.com/meshtastic/firmware
Converted to jgromes/RadioLib upstream and pegged to latest ref (#1472)
* Converted to jgromes/RadioLib upstream and pegged to latest refpull/1477/head
rodzic
0d574e35c6
commit
0767c0b0e8
|
@ -1,146 +0,0 @@
|
||||||
name: Continuous Integration (Legacy serial build)
|
|
||||||
on:
|
|
||||||
# Triggers the workflow on push or pull request events but only for the master branch
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
ci-check:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
submodules: "recursive"
|
|
||||||
ref: ${{github.event.pull_request.head.ref}}
|
|
||||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
|
||||||
|
|
||||||
- name: Install cppcheck
|
|
||||||
run: |
|
|
||||||
sudo apt-get install -y cppcheck
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: 3.x
|
|
||||||
|
|
||||||
- name: Cache python libs
|
|
||||||
uses: actions/cache@v1
|
|
||||||
id: cache-pip # needed in if test
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pip
|
|
||||||
key: ${{ runner.os }}-pip
|
|
||||||
|
|
||||||
- name: Upgrade python tools and install platformio
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -U platformio
|
|
||||||
|
|
||||||
- name: Upgrade platformio
|
|
||||||
run: |
|
|
||||||
pio upgrade
|
|
||||||
|
|
||||||
- name: Check everything
|
|
||||||
run: bin/check-all.sh
|
|
||||||
|
|
||||||
ci-build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
submodules: "recursive"
|
|
||||||
ref: ${{github.event.pull_request.head.ref}}
|
|
||||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: 3.x
|
|
||||||
|
|
||||||
- name: Cache python libs
|
|
||||||
uses: actions/cache@v1
|
|
||||||
id: cache-pip # needed in if test
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pip
|
|
||||||
key: ${{ runner.os }}-pip
|
|
||||||
|
|
||||||
- name: Upgrade python tools
|
|
||||||
# We actually want to run this every time
|
|
||||||
# if: steps.cache-pip.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -U platformio meshtastic adafruit-nrfutil
|
|
||||||
|
|
||||||
# - name: Cache platformio
|
|
||||||
# uses: actions/cache@v1
|
|
||||||
# id: cache-platformio # needed in if test
|
|
||||||
# with:
|
|
||||||
# path: ~/.platformio
|
|
||||||
# key: ${{ runner.os }}-platformio
|
|
||||||
|
|
||||||
- name: Upgrade platformio
|
|
||||||
run: |
|
|
||||||
pio upgrade
|
|
||||||
|
|
||||||
- name: Pull web ui
|
|
||||||
uses: dsaltares/fetch-gh-release-asset@master
|
|
||||||
with:
|
|
||||||
repo: "meshtastic/meshtastic-web"
|
|
||||||
file: "build.tar"
|
|
||||||
target: "build.tar"
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Unpack web ui
|
|
||||||
run: |
|
|
||||||
tar -xf build.tar -C data/static
|
|
||||||
rm build.tar
|
|
||||||
|
|
||||||
# We now run integration test before other build steps (to quickly see runtime failures)
|
|
||||||
- name: Build for native
|
|
||||||
run: platformio run -e native
|
|
||||||
- name: Integration test
|
|
||||||
run: |
|
|
||||||
.pio/build/native/program &
|
|
||||||
sleep 20 # 5 seconds was not enough
|
|
||||||
echo "Simulator started, launching python test..."
|
|
||||||
python3 -c 'from meshtastic.test import testSimulator; testSimulator()'
|
|
||||||
|
|
||||||
- name: Cat bin/build-all.sh
|
|
||||||
run: |
|
|
||||||
cat bin/build-all.sh
|
|
||||||
|
|
||||||
- name: Build everything
|
|
||||||
run: bin/build-all.sh
|
|
||||||
|
|
||||||
- name: Get release version string
|
|
||||||
run: echo "::set-output name=version::$(./bin/buildinfo.py long)"
|
|
||||||
id: version
|
|
||||||
|
|
||||||
- name: Store binaries as an artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: firmware-${{ steps.version.outputs.version }}.zip
|
|
||||||
path: release/archive/firmware-${{ steps.version.outputs.version }}.zip
|
|
||||||
retention-days: 90
|
|
||||||
|
|
||||||
- name: Store debugging elf files as an artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: debug-elfs
|
|
||||||
path: release/archive/elfs-*.zip
|
|
||||||
retention-days: 7
|
|
||||||
|
|
||||||
- name: Download firmware.zip
|
|
||||||
uses: actions/download-artifact@master
|
|
||||||
with:
|
|
||||||
name: firmware-${{ steps.version.outputs.version }}.zip
|
|
||||||
path: ./
|
|
||||||
|
|
||||||
- name: Pull request artifacts
|
|
||||||
if: ${{ github.event_name == 'pull_request_target' || github.event_name == 'pull_request' }}
|
|
||||||
uses: gavv/pull-request-artifacts@v1.0.0
|
|
||||||
with:
|
|
||||||
commit: ${{ (github.event.pull_request_target || github.event.pull_request).head.sha }}
|
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
artifacts-branch: artifacts
|
|
||||||
artifacts: ./firmware-${{ steps.version.outputs.version }}.zip
|
|
|
@ -44,15 +44,11 @@ lib_deps =
|
||||||
mathertel/OneButton@^2.0.3 ; OneButton library for non-blocking button debounce
|
mathertel/OneButton@^2.0.3 ; OneButton library for non-blocking button debounce
|
||||||
1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib
|
1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib
|
||||||
https://github.com/meshtastic/arduino-fsm.git
|
https://github.com/meshtastic/arduino-fsm.git
|
||||||
https://github.com/meshtastic/RadioLib.git#5582ac30578ff3f53f20630a00b2a8a4b8f92c74
|
|
||||||
https://github.com/meshtastic/TinyGPSPlus.git
|
https://github.com/meshtastic/TinyGPSPlus.git
|
||||||
https://github.com/meshtastic/AXP202X_Library.git#8404abb6d4b486748636bc6ad72d2a47baaf5460
|
|
||||||
Wire ; explicitly needed here because the AXP202 library forgets to add it
|
Wire ; explicitly needed here because the AXP202 library forgets to add it
|
||||||
SPI
|
SPI
|
||||||
https://github.com/meshtastic/ArduinoThread.git#72921ac222eed6f526ba1682023cee290d9aa1b3
|
https://github.com/meshtastic/ArduinoThread.git#72921ac222eed6f526ba1682023cee290d9aa1b3
|
||||||
PubSubClient
|
|
||||||
nanopb/Nanopb@^0.4.6
|
nanopb/Nanopb@^0.4.6
|
||||||
meshtastic/json11@^1.0.2
|
|
||||||
|
|
||||||
; Used for the code analysis in PIO Home / Inspect
|
; Used for the code analysis in PIO Home / Inspect
|
||||||
check_tool = cppcheck
|
check_tool = cppcheck
|
||||||
|
@ -63,12 +59,21 @@ check_skip_packages = yes
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
|
; Portduino is using meshtastic fork for now
|
||||||
|
https://github.com/jgromes/RadioLib.git#3df3b092ebf412bd0b26524e7b296733bd6a62f7
|
||||||
build_flags = ${env.build_flags} -Os
|
build_flags = ${env.build_flags} -Os
|
||||||
# -DRADIOLIB_GODMODE
|
# -DRADIOLIB_GODMODE
|
||||||
build_src_filter = ${env.build_src_filter} -<portduino/>
|
build_src_filter = ${env.build_src_filter} -<portduino/>
|
||||||
|
|
||||||
; Common libs for environmental measurements (not included in native / portduino)
|
; Common libs for communicating over TCP/IP networks such as MQTT
|
||||||
[environmental]
|
[networking_base]
|
||||||
|
lib_deps =
|
||||||
|
PubSubClient
|
||||||
|
meshtastic/json11@^1.0.2
|
||||||
|
|
||||||
|
; Common libs for environmental measurements in telemetry module
|
||||||
|
; (not included in native / portduino)
|
||||||
|
[environmental_base]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
adafruit/Adafruit BusIO@^1.11.4
|
adafruit/Adafruit BusIO@^1.11.4
|
||||||
adafruit/DHT sensor library@^1.4.1
|
adafruit/DHT sensor library@^1.4.1
|
||||||
|
@ -97,11 +102,14 @@ build_flags =
|
||||||
-DAXP_DEBUG_PORT=Serial -DUSE_NEW_ESP32_BLUETOOTH
|
-DAXP_DEBUG_PORT=Serial -DUSE_NEW_ESP32_BLUETOOTH
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${arduino_base.lib_deps}
|
${arduino_base.lib_deps}
|
||||||
${environmental.lib_deps}
|
${networking_base.lib_deps}
|
||||||
|
${environmental_base.lib_deps}
|
||||||
https://github.com/meshtastic/esp32_https_server.git
|
https://github.com/meshtastic/esp32_https_server.git
|
||||||
h2zero/NimBLE-Arduino@1.3.7
|
h2zero/NimBLE-Arduino@1.3.7
|
||||||
arduino-libraries/NTPClient@^3.1.0
|
arduino-libraries/NTPClient@^3.1.0
|
||||||
lorol/LittleFS_esp32@^1.0.6
|
lorol/LittleFS_esp32@^1.0.6
|
||||||
|
https://github.com/meshtastic/AXP202X_Library.git#8404abb6d4b486748636bc6ad72d2a47baaf5460
|
||||||
|
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
segger_rtt
|
segger_rtt
|
||||||
ESP32 BLE Arduino
|
ESP32 BLE Arduino
|
||||||
|
@ -141,7 +149,7 @@ extends = nrf52_base
|
||||||
build_flags = ${nrf52_base.build_flags}
|
build_flags = ${nrf52_base.build_flags}
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${arduino_base.lib_deps}
|
${arduino_base.lib_deps}
|
||||||
${environmental.lib_deps}
|
${environmental_base.lib_deps}
|
||||||
https://github.com/Kongduino/Adafruit_nRFCrypto.git
|
https://github.com/Kongduino/Adafruit_nRFCrypto.git
|
||||||
|
|
||||||
; Note: By default no lora device is created for this build - it uses a simulated interface
|
; Note: By default no lora device is created for this build - it uses a simulated interface
|
||||||
|
|
|
@ -76,13 +76,13 @@ bool RF95Interface::init()
|
||||||
DEBUG_MSG("Current limit set to %f\n", currentLimit);
|
DEBUG_MSG("Current limit set to %f\n", currentLimit);
|
||||||
DEBUG_MSG("Current limit set result %d\n", res);
|
DEBUG_MSG("Current limit set result %d\n", res);
|
||||||
|
|
||||||
if (res == ERR_NONE)
|
if (res == RADIOLIB_ERR_NONE)
|
||||||
res = lora->setCRC(SX126X_LORA_CRC_ON);
|
res = lora->setCRC(RADIOLIB_SX126X_LORA_CRC_ON);
|
||||||
|
|
||||||
if (res == ERR_NONE)
|
if (res == RADIOLIB_ERR_NONE)
|
||||||
startReceive(); // start receiving
|
startReceive(); // start receiving
|
||||||
|
|
||||||
return res == ERR_NONE;
|
return res == RADIOLIB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void INTERRUPT_ATTR RF95Interface::disableInterrupt()
|
void INTERRUPT_ATTR RF95Interface::disableInterrupt()
|
||||||
|
@ -99,39 +99,39 @@ bool RF95Interface::reconfigure()
|
||||||
|
|
||||||
// configure publicly accessible settings
|
// configure publicly accessible settings
|
||||||
int err = lora->setSpreadingFactor(sf);
|
int err = lora->setSpreadingFactor(sf);
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
err = lora->setBandwidth(bw);
|
err = lora->setBandwidth(bw);
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
err = lora->setCodingRate(cr);
|
err = lora->setCodingRate(cr);
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
err = lora->setSyncWord(syncWord);
|
err = lora->setSyncWord(syncWord);
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
err = lora->setCurrentLimit(currentLimit);
|
err = lora->setCurrentLimit(currentLimit);
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
err = lora->setPreambleLength(preambleLength);
|
err = lora->setPreambleLength(preambleLength);
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
err = lora->setFrequency(getFreq());
|
err = lora->setFrequency(getFreq());
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
if (power > MAX_POWER) // This chip has lower power limits than some
|
if (power > MAX_POWER) // This chip has lower power limits than some
|
||||||
power = MAX_POWER;
|
power = MAX_POWER;
|
||||||
err = lora->setOutputPower(power);
|
err = lora->setOutputPower(power);
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
startReceive(); // restart receiving
|
startReceive(); // restart receiving
|
||||||
|
|
||||||
return ERR_NONE;
|
return RADIOLIB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,7 +147,7 @@ void RF95Interface::addReceiveMetadata(MeshPacket *mp)
|
||||||
void RF95Interface::setStandby()
|
void RF95Interface::setStandby()
|
||||||
{
|
{
|
||||||
int err = lora->standby();
|
int err = lora->standby();
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
isReceiving = false; // If we were receiving, not any more
|
isReceiving = false; // If we were receiving, not any more
|
||||||
disableInterrupt();
|
disableInterrupt();
|
||||||
|
@ -168,7 +168,7 @@ void RF95Interface::startReceive()
|
||||||
setTransmitEnable(false);
|
setTransmitEnable(false);
|
||||||
setStandby();
|
setStandby();
|
||||||
int err = lora->startReceive();
|
int err = lora->startReceive();
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
isReceiving = true;
|
isReceiving = true;
|
||||||
|
|
||||||
|
@ -184,12 +184,11 @@ bool RF95Interface::isChannelActive()
|
||||||
setStandby(); // needed for smooth transition
|
setStandby(); // needed for smooth transition
|
||||||
result = lora->scanChannel();
|
result = lora->scanChannel();
|
||||||
|
|
||||||
if (result == PREAMBLE_DETECTED) {
|
if (result == RADIOLIB_PREAMBLE_DETECTED) {
|
||||||
// DEBUG_MSG("Channel is busy!\n");
|
// DEBUG_MSG("Channel is busy!\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
assert(result != RADIOLIB_ERR_WRONG_MODEM);
|
||||||
assert(result != ERR_WRONG_MODEM);
|
|
||||||
|
|
||||||
// DEBUG_MSG("Channel is free!\n");
|
// DEBUG_MSG("Channel is free!\n");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -13,8 +13,9 @@ class RF95Interface : public RadioLibInterface
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RF95Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, SPIClass &spi);
|
RF95Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, SPIClass &spi);
|
||||||
|
|
||||||
bool isIRQPending() override { return lora->getPendingIRQ(); }
|
//TODO: Verify that this irq flag works with RFM95 / SX1276 radios the way it used to
|
||||||
|
bool isIRQPending() override { return lora->getIRQFlags() & RADIOLIB_SX127X_MASK_IRQ_FLAG_VALID_HEADER; }
|
||||||
|
|
||||||
/// Initialise the Driver transport hardware and software.
|
/// Initialise the Driver transport hardware and software.
|
||||||
/// Make sure the Driver is properly configured before calling init().
|
/// Make sure the Driver is properly configured before calling init().
|
||||||
|
|
|
@ -308,7 +308,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||||
xmitMsec = getPacketTime(length);
|
xmitMsec = getPacketTime(length);
|
||||||
|
|
||||||
int state = iface->readData(radiobuf, length);
|
int state = iface->readData(radiobuf, length);
|
||||||
if (state != ERR_NONE) {
|
if (state != RADIOLIB_ERR_NONE) {
|
||||||
DEBUG_MSG("ignoring received packet due to error=%d\n", state);
|
DEBUG_MSG("ignoring received packet due to error=%d\n", state);
|
||||||
rxBad++;
|
rxBad++;
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
|
||||||
size_t numbytes = beginSending(txp);
|
size_t numbytes = beginSending(txp);
|
||||||
|
|
||||||
int res = iface->startTransmit(radiobuf, numbytes);
|
int res = iface->startTransmit(radiobuf, numbytes);
|
||||||
if (res != ERR_NONE) {
|
if (res != RADIOLIB_ERR_NONE) {
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_RadioSpiBug);
|
RECORD_CRITICALERROR(CriticalErrorCode_RadioSpiBug);
|
||||||
|
|
||||||
// This send failed, but make sure to 'complete' it properly
|
// This send failed, but make sure to 'complete' it properly
|
||||||
|
|
|
@ -54,7 +54,7 @@ class LockingModule : public Module
|
||||||
|
|
||||||
\param numBytes Number of bytes to transfer.
|
\param numBytes Number of bytes to transfer.
|
||||||
*/
|
*/
|
||||||
virtual void SPItransfer(uint8_t cmd, uint8_t reg, uint8_t *dataOut, uint8_t *dataIn, uint8_t numBytes) override;
|
virtual void SPItransfer(uint8_t cmd, uint8_t reg, uint8_t *dataOut, uint8_t *dataIn, uint8_t numBytes);
|
||||||
};
|
};
|
||||||
|
|
||||||
class RadioLibInterface : public RadioInterface, protected concurrency::NotifiedWorkerThread
|
class RadioLibInterface : public RadioInterface, protected concurrency::NotifiedWorkerThread
|
||||||
|
|
|
@ -15,7 +15,7 @@ int16_t RadioLibRF95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_
|
||||||
{
|
{
|
||||||
// execute common part
|
// execute common part
|
||||||
int16_t state = SX127x::begin(RF95_CHIP_VERSION, syncWord, preambleLength);
|
int16_t state = SX127x::begin(RF95_CHIP_VERSION, syncWord, preambleLength);
|
||||||
if (state != ERR_NONE)
|
if (state != RADIOLIB_ERR_NONE)
|
||||||
state = SX127x::begin(RF95_ALT_VERSION, syncWord, preambleLength);
|
state = SX127x::begin(RF95_ALT_VERSION, syncWord, preambleLength);
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ int16_t RadioLibRF95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
#ifdef RF95_TCXO
|
#ifdef RF95_TCXO
|
||||||
state = _mod->SPIsetRegValue(SX127X_REG_TCXO, 0x10 | _mod->SPIgetRegValue(SX127X_REG_TCXO));
|
state = _mod->SPIsetRegValue(RADIOLIB_SX127X_REG_TCXO, 0x10 | _mod->SPIgetRegValue(RADIOLIB_SX127X_REG_TCXO));
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ int16_t RadioLibRF95::setFrequency(float freq)
|
||||||
bool RadioLibRF95::isReceiving()
|
bool RadioLibRF95::isReceiving()
|
||||||
{
|
{
|
||||||
// 0x0b == Look for header info valid, signal synchronized or signal detected
|
// 0x0b == Look for header info valid, signal synchronized or signal detected
|
||||||
uint8_t reg = readReg(SX127X_REG_MODEM_STAT);
|
uint8_t reg = readReg(RADIOLIB_SX127X_REG_MODEM_STAT);
|
||||||
// Serial.printf("reg %x\n", reg);
|
// Serial.printf("reg %x\n", reg);
|
||||||
return (reg & (RH_RF95_MODEM_STATUS_SIGNAL_DETECTED | RH_RF95_MODEM_STATUS_SIGNAL_SYNCHRONIZED |
|
return (reg & (RH_RF95_MODEM_STATUS_SIGNAL_DETECTED | RH_RF95_MODEM_STATUS_SIGNAL_SYNCHRONIZED |
|
||||||
RH_RF95_MODEM_STATUS_HEADER_INFO_VALID)) != 0;
|
RH_RF95_MODEM_STATUS_HEADER_INFO_VALID)) != 0;
|
||||||
|
|
|
@ -43,7 +43,7 @@ class RadioLibRF95: public SX1278 {
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = SX127X_SYNC_WORD, int8_t power = 17, uint16_t preambleLength = 8, uint8_t gain = 0);
|
int16_t begin(float freq = 915.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX127X_SYNC_WORD, int8_t power = 17, uint16_t preambleLength = 8, uint8_t gain = 0);
|
||||||
|
|
||||||
// configuration methods
|
// configuration methods
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ bool SX126xInterface<T>::init()
|
||||||
|
|
||||||
#ifdef SX126X_TXEN
|
#ifdef SX126X_TXEN
|
||||||
// lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX
|
// lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX
|
||||||
if (res == ERR_NONE)
|
if (res == RADIOLIB_ERR_NONE)
|
||||||
res = lora.setDio2AsRfSwitch(true);
|
res = lora.setDio2AsRfSwitch(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ bool SX126xInterface<T>::init()
|
||||||
// Read/write a register we are not using (only used for FSK mode) to test SPI comms
|
// Read/write a register we are not using (only used for FSK mode) to test SPI comms
|
||||||
uint8_t crcLSB = 0;
|
uint8_t crcLSB = 0;
|
||||||
int err = lora.readRegister(SX126X_REG_CRC_POLYNOMIAL_LSB, &crcLSB, 1);
|
int err = lora.readRegister(SX126X_REG_CRC_POLYNOMIAL_LSB, &crcLSB, 1);
|
||||||
if(err != ERR_NONE)
|
if(err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_SX1262Failure);
|
RECORD_CRITICALERROR(CriticalErrorCode_SX1262Failure);
|
||||||
|
|
||||||
//if(crcLSB != 0x0f)
|
//if(crcLSB != 0x0f)
|
||||||
|
@ -80,11 +80,11 @@ bool SX126xInterface<T>::init()
|
||||||
|
|
||||||
crcLSB = 0x5a;
|
crcLSB = 0x5a;
|
||||||
err = lora.writeRegister(SX126X_REG_CRC_POLYNOMIAL_LSB, &crcLSB, 1);
|
err = lora.writeRegister(SX126X_REG_CRC_POLYNOMIAL_LSB, &crcLSB, 1);
|
||||||
if(err != ERR_NONE)
|
if(err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_SX1262Failure);
|
RECORD_CRITICALERROR(CriticalErrorCode_SX1262Failure);
|
||||||
|
|
||||||
err = lora.readRegister(SX126X_REG_CRC_POLYNOMIAL_LSB, &crcLSB, 1);
|
err = lora.readRegister(SX126X_REG_CRC_POLYNOMIAL_LSB, &crcLSB, 1);
|
||||||
if(err != ERR_NONE)
|
if(err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_SX1262Failure);
|
RECORD_CRITICALERROR(CriticalErrorCode_SX1262Failure);
|
||||||
|
|
||||||
if(crcLSB != 0x5a)
|
if(crcLSB != 0x5a)
|
||||||
|
@ -92,13 +92,13 @@ bool SX126xInterface<T>::init()
|
||||||
// If we got this far register accesses (and therefore SPI comms) are good
|
// If we got this far register accesses (and therefore SPI comms) are good
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (res == ERR_NONE)
|
if (res == RADIOLIB_ERR_NONE)
|
||||||
res = lora.setCRC(SX126X_LORA_CRC_ON);
|
res = lora.setCRC(RADIOLIB_SX126X_LORA_CRC_ON);
|
||||||
|
|
||||||
if (res == ERR_NONE)
|
if (res == RADIOLIB_ERR_NONE)
|
||||||
startReceive(); // start receiving
|
startReceive(); // start receiving
|
||||||
|
|
||||||
return res == ERR_NONE;
|
return res == RADIOLIB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -111,42 +111,43 @@ bool SX126xInterface<T>::reconfigure()
|
||||||
|
|
||||||
// configure publicly accessible settings
|
// configure publicly accessible settings
|
||||||
int err = lora.setSpreadingFactor(sf);
|
int err = lora.setSpreadingFactor(sf);
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
err = lora.setBandwidth(bw);
|
err = lora.setBandwidth(bw);
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
err = lora.setCodingRate(cr);
|
err = lora.setCodingRate(cr);
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
// Hmm - seems to lower SNR when the signal levels are high. Leaving off for now...
|
// Hmm - seems to lower SNR when the signal levels are high. Leaving off for now...
|
||||||
err = lora.setRxGain(true);
|
// TODO: Confirm gain registers are okay now
|
||||||
assert(err == ERR_NONE);
|
// err = lora.setRxGain(true);
|
||||||
|
// assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
err = lora.setSyncWord(syncWord);
|
err = lora.setSyncWord(syncWord);
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
err = lora.setCurrentLimit(currentLimit);
|
err = lora.setCurrentLimit(currentLimit);
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
err = lora.setPreambleLength(preambleLength);
|
err = lora.setPreambleLength(preambleLength);
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
err = lora.setFrequency(getFreq());
|
err = lora.setFrequency(getFreq());
|
||||||
if (err != ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
if (power > 22) // This chip has lower power limits than some
|
if (power > 22) // This chip has lower power limits than some
|
||||||
power = 22;
|
power = 22;
|
||||||
err = lora.setOutputPower(power);
|
err = lora.setOutputPower(power);
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
startReceive(); // restart receiving
|
startReceive(); // restart receiving
|
||||||
|
|
||||||
return ERR_NONE;
|
return RADIOLIB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -161,7 +162,7 @@ void SX126xInterface<T>::setStandby()
|
||||||
checkNotification(); // handle any pending interrupts before we force standby
|
checkNotification(); // handle any pending interrupts before we force standby
|
||||||
|
|
||||||
int err = lora.standby();
|
int err = lora.standby();
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
#ifdef SX126X_RXEN // we have RXEN/TXEN control - turn off RX and TX power
|
#ifdef SX126X_RXEN // we have RXEN/TXEN control - turn off RX and TX power
|
||||||
digitalWrite(SX126X_RXEN, LOW);
|
digitalWrite(SX126X_RXEN, LOW);
|
||||||
|
@ -223,7 +224,7 @@ void SX126xInterface<T>::startReceive()
|
||||||
// int err = lora.startReceive();
|
// int err = lora.startReceive();
|
||||||
int err = lora.startReceiveDutyCycleAuto(); // We use a 32 bit preamble so this should save some power by letting radio sit in
|
int err = lora.startReceiveDutyCycleAuto(); // We use a 32 bit preamble so this should save some power by letting radio sit in
|
||||||
// standby mostly.
|
// standby mostly.
|
||||||
assert(err == ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
isReceiving = true;
|
isReceiving = true;
|
||||||
|
|
||||||
|
@ -241,10 +242,10 @@ bool SX126xInterface<T>::isChannelActive()
|
||||||
|
|
||||||
setStandby();
|
setStandby();
|
||||||
result = lora.scanChannel();
|
result = lora.scanChannel();
|
||||||
if (result == PREAMBLE_DETECTED)
|
if (result == RADIOLIB_PREAMBLE_DETECTED)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
assert(result != ERR_WRONG_MODEM);
|
assert(result != RADIOLIB_ERR_WRONG_MODEM);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -259,7 +260,7 @@ bool SX126xInterface<T>::isActivelyReceiving()
|
||||||
// never even get a valid header, so we don't want preamble to get set and stay set due to noise on the network.
|
// never even get a valid header, so we don't want preamble to get set and stay set due to noise on the network.
|
||||||
|
|
||||||
uint16_t irq = lora.getIrqStatus();
|
uint16_t irq = lora.getIrqStatus();
|
||||||
bool hasPreamble = (irq & SX126X_IRQ_HEADER_VALID);
|
bool hasPreamble = (irq & RADIOLIB_SX126X_IRQ_HEADER_VALID);
|
||||||
|
|
||||||
// this is not correct - often always true - need to add an extra conditional
|
// this is not correct - often always true - need to add an extra conditional
|
||||||
// size_t bytesPending = lora.getPacketLength();
|
// size_t bytesPending = lora.getPacketLength();
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
; The Portduino based sim environment on top of any host OS, all hardware will be simulated
|
; The Portduino based sim environment on top of any host OS, all hardware will be simulated
|
||||||
[env:native]
|
[portduino_base]
|
||||||
platform = https://github.com/meshtastic/platform-native.git
|
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
${env.build_src_filter}
|
${env.build_src_filter}
|
||||||
-<esp32/>
|
-<esp32/>
|
||||||
|
@ -10,28 +9,25 @@ build_src_filter =
|
||||||
-<modules/esp32>
|
-<modules/esp32>
|
||||||
-<modules/Telemetry>
|
-<modules/Telemetry>
|
||||||
+<../variants/portduino>
|
+<../variants/portduino>
|
||||||
|
lib_deps =
|
||||||
|
${env.lib_deps}
|
||||||
|
${networking_base.lib_deps}
|
||||||
|
rweather/Crypto
|
||||||
|
https://github.com/meshtastic/RadioLib.git#5582ac30578ff3f53f20630a00b2a8a4b8f92c74
|
||||||
|
|
||||||
|
[env:native]
|
||||||
|
platform = https://github.com/meshtastic/platform-native.git
|
||||||
build_flags = ${arduino_base.build_flags} -O0 -I variants/portduino
|
build_flags = ${arduino_base.build_flags} -O0 -I variants/portduino
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = cross_platform
|
board = cross_platform
|
||||||
lib_deps =
|
lib_deps = ${portduino_base.lib_deps}
|
||||||
${arduino_base.lib_deps}
|
build_src_filter = ${portduino_base.build_src_filter}
|
||||||
rweather/Crypto
|
|
||||||
|
|
||||||
; The Portduino based sim environment on top of a linux OS and touching linux hardware devices
|
; The Portduino based sim environment on top of a linux OS and touching linux hardware devices
|
||||||
[env:linux]
|
[env:linux]
|
||||||
platform = https://github.com/meshtastic/platform-native.git
|
platform = https://github.com/meshtastic/platform-native.git
|
||||||
build_src_filter =
|
|
||||||
${env.build_src_filter}
|
|
||||||
-<esp32/>
|
|
||||||
-<nimble/>
|
|
||||||
-<nrf52/>
|
|
||||||
-<mesh/http/>
|
|
||||||
-<modules/esp32>
|
|
||||||
-<modules/Telemetry>
|
|
||||||
+<../variants/portduino>
|
|
||||||
build_flags = ${arduino_base.build_flags} -O0 -lgpiod -I variants/portduino
|
build_flags = ${arduino_base.build_flags} -O0 -lgpiod -I variants/portduino
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = linux_hardware
|
board = linux_hardware
|
||||||
lib_deps =
|
lib_deps = ${portduino_base.lib_deps}
|
||||||
${arduino_base.lib_deps}
|
build_src_filter = ${portduino_base.build_src_filter}
|
||||||
rweather/Crypto
|
|
|
@ -23,4 +23,18 @@
|
||||||
#define SX126X_BUSY LORA_DIO2
|
#define SX126X_BUSY LORA_DIO2
|
||||||
#define SX126X_RESET LORA_RESET
|
#define SX126X_RESET LORA_RESET
|
||||||
// HOPE RFM90 does not have a TCXO therefore not SX126X_E22
|
// HOPE RFM90 does not have a TCXO therefore not SX126X_E22
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Temporary shim for radio lib macros until we upgrade to upstream for portduino
|
||||||
|
#define RADIOLIB_PREAMBLE_DETECTED PREAMBLE_DETECTED
|
||||||
|
|
||||||
|
#define RADIOLIB_ERR_NONE ERR_NONE
|
||||||
|
#define RADIOLIB_ERR_WRONG_MODEM ERR_WRONG_MODEM
|
||||||
|
|
||||||
|
#define RADIOLIB_SX126X_IRQ_HEADER_VALID SX126X_IRQ_HEADER_VALID
|
||||||
|
#define RADIOLIB_SX126X_LORA_CRC_ON SX126X_LORA_CRC_ON
|
||||||
|
|
||||||
|
#define RADIOLIB_SX127X_REG_TCXO SX127X_REG_TCXO
|
||||||
|
#define RADIOLIB_SX127X_REG_MODEM_STAT SX127X_REG_MODEM_STAT
|
||||||
|
#define RADIOLIB_SX127X_SYNC_WORD SX127X_SYNC_WORD
|
||||||
|
#define RADIOLIB_SX127X_MASK_IRQ_FLAG_VALID_HEADER SX127X_MASK_IRQ_FLAG_VALID_HEADER
|
Ładowanie…
Reference in New Issue