mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-13 17:00:54 +00:00
Merge branch 'master' into NextHopRouter
This commit is contained in:
commit
81f57b65e1
45
.github/workflows/build_raspbian.yml
vendored
Normal file
45
.github/workflows/build_raspbian.yml
vendored
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
name: Build Raspbian
|
||||||
|
|
||||||
|
on: workflow_call
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-raspbian:
|
||||||
|
runs-on: [self-hosted, linux, ARM64]
|
||||||
|
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: Upgrade python tools
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install -U platformio adafruit-nrfutil
|
||||||
|
pip install -U meshtastic --pre
|
||||||
|
|
||||||
|
- name: Upgrade platformio
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
pio upgrade
|
||||||
|
|
||||||
|
- name: Build Raspbian
|
||||||
|
run: bin/build-native.sh
|
||||||
|
|
||||||
|
- name: Get release version string
|
||||||
|
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||||
|
id: version
|
||||||
|
|
||||||
|
- name: Store binaries as an artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: firmware-raspbian-${{ steps.version.outputs.version }}.zip
|
||||||
|
path: |
|
||||||
|
release/meshtasticd_linux_arm64
|
||||||
|
bin/config-dist.yaml
|
44
.github/workflows/main_matrix.yml
vendored
44
.github/workflows/main_matrix.yml
vendored
@ -103,7 +103,6 @@ jobs:
|
|||||||
build-nrf52:
|
build-nrf52:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
max-parallel: 2
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- board: rak4631
|
- board: rak4631
|
||||||
@ -129,6 +128,15 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
board: ${{ matrix.board }}
|
board: ${{ matrix.board }}
|
||||||
|
|
||||||
|
build-raspbian:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
max-parallel: 1
|
||||||
|
uses: ./.github/workflows/build_raspbian.yml
|
||||||
|
|
||||||
|
package-raspbian:
|
||||||
|
uses: ./.github/workflows/package_raspbian.yml
|
||||||
|
|
||||||
build-native:
|
build-native:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@ -204,7 +212,15 @@ jobs:
|
|||||||
gather-artifacts:
|
gather-artifacts:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
needs:
|
||||||
[build-esp32, build-esp32-s3, build-nrf52, build-native, build-rpi2040]
|
[
|
||||||
|
build-esp32,
|
||||||
|
build-esp32-s3,
|
||||||
|
build-nrf52,
|
||||||
|
build-raspbian,
|
||||||
|
build-native,
|
||||||
|
build-rpi2040,
|
||||||
|
package-raspbian,
|
||||||
|
]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@ -216,12 +232,15 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
path: ./
|
path: ./
|
||||||
|
|
||||||
|
- name: Display structure of downloaded files
|
||||||
|
run: ls -R
|
||||||
|
|
||||||
- name: Get release version string
|
- name: Get release version string
|
||||||
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||||
id: version
|
id: version
|
||||||
|
|
||||||
- name: Move files up
|
- name: Move files up
|
||||||
run: mv -b -t ./ ./*tbeam-2*/littlefs*.bin ./*tbeam-2*/bleota.bin ./*tbeam-s3*/bleota-s3.bin ./**/firmware*.bin ./*t-echo*/Meshtastic_nRF52_factory_erase.uf2 ./**/firmware-*.uf2 ./**/firmware-*-ota.zip ./**/*.elf ./*native*/*device-*.sh ./*native*/*device-*.bat
|
run: mv -b -t ./ ./*tbeam-2*/littlefs*.bin ./*tbeam-2*/bleota.bin ./*tbeam-s3*/bleota-s3.bin ./**/firmware*.bin ./*t-echo*/Meshtastic_nRF52_factory_erase.uf2 ./**/firmware-*.uf2 ./**/firmware-*-ota.zip ./**/*.elf ./*native*/*device-*.sh ./*native*/*device-*.bat ./firmware-raspbian-*/release/meshtasticd_linux_arm64 ./firmware-raspbian-*/bin/config-dist.yaml
|
||||||
|
|
||||||
- name: Repackage in single firmware zip
|
- name: Repackage in single firmware zip
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
@ -233,6 +252,8 @@ jobs:
|
|||||||
./firmware-*-ota.zip
|
./firmware-*-ota.zip
|
||||||
./device-*.sh
|
./device-*.sh
|
||||||
./device-*.bat
|
./device-*.bat
|
||||||
|
./meshtasticd_linux_arm64
|
||||||
|
./config-dist.yaml
|
||||||
retention-days: 90
|
retention-days: 90
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
@ -294,6 +315,13 @@ jobs:
|
|||||||
name: firmware-${{ steps.version.outputs.version }}
|
name: firmware-${{ steps.version.outputs.version }}
|
||||||
path: ./output
|
path: ./output
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifact-deb
|
||||||
|
|
||||||
|
- name: Display structure of downloaded files
|
||||||
|
run: ls -R
|
||||||
|
|
||||||
- name: Device scripts permissions
|
- name: Device scripts permissions
|
||||||
run: |
|
run: |
|
||||||
chmod +x ./output/device-install.sh
|
chmod +x ./output/device-install.sh
|
||||||
@ -347,6 +375,16 @@ jobs:
|
|||||||
asset_name: debug-elfs-${{ steps.version.outputs.version }}.zip
|
asset_name: debug-elfs-${{ steps.version.outputs.version }}.zip
|
||||||
asset_content_type: application/zip
|
asset_content_type: application/zip
|
||||||
|
|
||||||
|
- name: Add raspbian .deb
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./meshtasticd_${{ steps.version.outputs.version }}_arm64.deb
|
||||||
|
asset_name: meshtasticd_${{ steps.version.outputs.version }}_arm64.deb
|
||||||
|
asset_content_type: application/vnd.debian.binary-package
|
||||||
|
|
||||||
- name: Bump version.properties
|
- name: Bump version.properties
|
||||||
run: >-
|
run: >-
|
||||||
bin/bump_version.py
|
bin/bump_version.py
|
||||||
|
62
.github/workflows/package_raspbian.yml
vendored
Normal file
62
.github/workflows/package_raspbian.yml
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
name: Package Raspbian
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-raspbian:
|
||||||
|
uses: ./.github/workflows/build_raspbian.yml
|
||||||
|
|
||||||
|
package-raspbian:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build-raspbian
|
||||||
|
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: Get release version string
|
||||||
|
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||||
|
id: version
|
||||||
|
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: firmware-raspbian-${{ steps.version.outputs.version }}.zip
|
||||||
|
|
||||||
|
- name: Display structure of downloaded files
|
||||||
|
run: ls -R
|
||||||
|
|
||||||
|
- name: build .debpkg
|
||||||
|
run: |
|
||||||
|
mkdir -p .debpkg/usr/sbin
|
||||||
|
mkdir -p .debpkg/etc/meshtasticd
|
||||||
|
mkdir -p .debpkg/usr/lib/systemd/system/
|
||||||
|
cp release/meshtasticd_linux_arm64 .debpkg/usr/sbin/meshtasticd
|
||||||
|
cp bin/config-dist.yaml .debpkg/etc/meshtasticd/config.yaml
|
||||||
|
chmod +x .debpkg/usr/sbin/meshtasticd
|
||||||
|
cp bin/meshtasticd.service .debpkg/usr/lib/systemd/system/meshtasticd.service
|
||||||
|
|
||||||
|
- uses: jiro4989/build-deb-action@v3
|
||||||
|
with:
|
||||||
|
package: meshtasticd
|
||||||
|
package_root: .debpkg
|
||||||
|
maintainer: Jonathan Bennett
|
||||||
|
version: ${{ steps.version.outputs.version }} # refs/tags/v*.*.*
|
||||||
|
arch: arm64
|
||||||
|
depends: libyaml-cpp0.7
|
||||||
|
desc: Native Linux Meshtastic binary.
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifact-deb
|
||||||
|
path: |
|
||||||
|
./*.deb
|
@ -1,7 +1,10 @@
|
|||||||
enable=all
|
enable=all
|
||||||
source-path=SCRIPTDIR
|
source-path=SCRIPTDIR
|
||||||
disable=SC2154
|
disable=SC2154
|
||||||
|
disable=SC2248
|
||||||
|
disable=SC2250
|
||||||
|
|
||||||
# If you're having issues with shellcheck following source, disable the errors via:
|
# If you're having issues with shellcheck following source, disable the errors via:
|
||||||
# disable=SC1090
|
# disable=SC1090
|
||||||
# disable=SC1091
|
# disable=SC1091
|
||||||
|
#
|
@ -3,7 +3,7 @@ rules:
|
|||||||
required: only-when-needed
|
required: only-when-needed
|
||||||
extra-allowed: ["{|}"]
|
extra-allowed: ["{|}"]
|
||||||
empty-values:
|
empty-values:
|
||||||
forbid-in-block-mappings: true
|
forbid-in-block-mappings: false
|
||||||
forbid-in-flow-mappings: true
|
forbid-in-flow-mappings: true
|
||||||
key-duplicates: {}
|
key-duplicates: {}
|
||||||
octal-values:
|
octal-values:
|
||||||
|
@ -21,4 +21,4 @@ lib_deps =
|
|||||||
${arduino_base.lib_deps}
|
${arduino_base.lib_deps}
|
||||||
${environmental_base.lib_deps}
|
${environmental_base.lib_deps}
|
||||||
jgromes/RadioLib@^6.1.0
|
jgromes/RadioLib@^6.1.0
|
||||||
https://github.com/kokke/tiny-AES-c.git#f06ac37fc31dfdaca2e0d9bec83f90d5663c319b
|
rweather/Crypto
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
VERSION=`bin/buildinfo.py long`
|
VERSION=$(bin/buildinfo.py long)
|
||||||
SHORT_VERSION=`bin/buildinfo.py short`
|
SHORT_VERSION=$(bin/buildinfo.py short)
|
||||||
|
|
||||||
OUTDIR=release/
|
OUTDIR=release/
|
||||||
|
|
||||||
@ -15,9 +15,13 @@ rm -r $OUTDIR/* || true
|
|||||||
# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
|
# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
|
||||||
platformio pkg update
|
platformio pkg update
|
||||||
|
|
||||||
pio run --environment native
|
if command -v raspi-config &>/dev/null; then
|
||||||
cp .pio/build/native/program $OUTDIR/meshtasticd_linux_amd64
|
pio run --environment raspbian
|
||||||
|
cp .pio/build/raspbian/program $OUTDIR/meshtasticd_linux_arm64
|
||||||
|
else
|
||||||
|
pio run --environment native
|
||||||
|
cp .pio/build/native/program $OUTDIR/meshtasticd_linux_amd64
|
||||||
|
fi
|
||||||
|
|
||||||
cp bin/device-install.* $OUTDIR
|
cp bin/device-install.* $OUTDIR
|
||||||
cp bin/device-update.* $OUTDIR
|
cp bin/device-update.* $OUTDIR
|
||||||
|
|
||||||
|
26
bin/config-dist.yaml
Normal file
26
bin/config-dist.yaml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Define your devices here using Broadcom pin numbering
|
||||||
|
# Uncomment the block that corresponds to your hardware
|
||||||
|
---
|
||||||
|
Lora:
|
||||||
|
# Module: sx1262 # Waveshare SX126X XXXM
|
||||||
|
# DIO2_AS_RF_SWITCH: true
|
||||||
|
# CS: 21
|
||||||
|
# IRQ: 16
|
||||||
|
# Busy: 20
|
||||||
|
# Reset: 18
|
||||||
|
|
||||||
|
# Module: sx1262 # Waveshare SX1302 LISTEN ONLY AT THIS TIME!
|
||||||
|
# CS: 7
|
||||||
|
# IRQ: 17
|
||||||
|
# Reset: 22
|
||||||
|
|
||||||
|
# Module: RF95 # Adafruit RFM9x
|
||||||
|
# Reset: 25
|
||||||
|
# CS: 7
|
||||||
|
# IRQ: 22
|
||||||
|
# Busy: 23
|
||||||
|
|
||||||
|
# Module: RF95 # Elecrow Lora RFM95 IOT https://www.elecrow.com/lora-rfm95-iot-board-for-rpi.html
|
||||||
|
# Reset: 22
|
||||||
|
# CS: 7
|
||||||
|
# IRQ: 25
|
9
bin/meshtasticd.service
Normal file
9
bin/meshtasticd.service
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[unit]
|
||||||
|
description=Meshtastic Native Daemon
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/sbin/meshtasticd
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
10
bin/native-install.sh
Executable file
10
bin/native-install.sh
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
cp release/meshtasticd_linux_arm64 /usr/sbin/meshtasticd
|
||||||
|
mkdir /etc/meshtasticd
|
||||||
|
if [[ -f "/etc/meshtasticd/config.yaml" ]]; then
|
||||||
|
cp bin/config-dist.yaml /etc/meshtasticd/config-upgrade.yaml
|
||||||
|
else
|
||||||
|
cp bin/config-dist.yaml /etc/meshtasticd/config.yaml
|
||||||
|
fi
|
||||||
|
cp bin/meshtasticd.service /usr/lib/systemd/system/meshtasticd.service
|
@ -19,6 +19,11 @@
|
|||||||
#include "meshUtils.h"
|
#include "meshUtils.h"
|
||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
|
|
||||||
|
// Working USB detection for powered/charging states on the RAK platform
|
||||||
|
#ifdef NRF_APM
|
||||||
|
#include "nrfx_power.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_HEAP_MQTT
|
#ifdef DEBUG_HEAP_MQTT
|
||||||
#include "mqtt/MQTT.h"
|
#include "mqtt/MQTT.h"
|
||||||
#include "target_specific.h"
|
#include "target_specific.h"
|
||||||
@ -52,6 +57,7 @@ static const adc_atten_t atten = ADC_ATTENUATION;
|
|||||||
#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO)
|
#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO)
|
||||||
INA260Sensor ina260Sensor;
|
INA260Sensor ina260Sensor;
|
||||||
INA219Sensor ina219Sensor;
|
INA219Sensor ina219Sensor;
|
||||||
|
INA3221Sensor ina3221Sensor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_PMU
|
#ifdef HAS_PMU
|
||||||
@ -286,6 +292,9 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
|||||||
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA260].first ==
|
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA260].first ==
|
||||||
config.power.device_battery_ina_address) {
|
config.power.device_battery_ina_address) {
|
||||||
return ina260Sensor.getBusVoltageMv();
|
return ina260Sensor.getBusVoltageMv();
|
||||||
|
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA3221].first ==
|
||||||
|
config.power.device_battery_ina_address) {
|
||||||
|
return ina3221Sensor.getBusVoltageMv();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -456,10 +465,25 @@ void Power::readPowerStatus()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OptionalBool NRF_USB = OptFalse;
|
||||||
|
|
||||||
|
#ifdef NRF_APM // Section of code detects USB power on the RAK4631 and updates the power states. Takes 20 seconds or so to detect
|
||||||
|
// changes.
|
||||||
|
|
||||||
|
nrfx_power_usb_state_t nrf_usb_state = nrfx_power_usbstatus_get();
|
||||||
|
|
||||||
|
if (nrf_usb_state == NRFX_POWER_USB_STATE_DISCONNECTED) {
|
||||||
|
powerFSM.trigger(EVENT_POWER_DISCONNECTED);
|
||||||
|
NRF_USB = OptFalse;
|
||||||
|
} else {
|
||||||
|
powerFSM.trigger(EVENT_POWER_CONNECTED);
|
||||||
|
NRF_USB = OptTrue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
// Notify any status instances that are observing us
|
// Notify any status instances that are observing us
|
||||||
const PowerStatus powerStatus2 =
|
const PowerStatus powerStatus2 = PowerStatus(
|
||||||
PowerStatus(hasBattery ? OptTrue : OptFalse, batteryLevel->isVbusIn() ? OptTrue : OptFalse,
|
hasBattery ? OptTrue : OptFalse, batteryLevel->isVbusIn() || NRF_USB == OptTrue ? OptTrue : OptFalse,
|
||||||
batteryLevel->isCharging() ? OptTrue : OptFalse, batteryVoltageMv, batteryChargePercent);
|
batteryLevel->isCharging() || NRF_USB == OptTrue ? OptTrue : OptFalse, batteryVoltageMv, batteryChargePercent);
|
||||||
LOG_DEBUG("Battery: usbPower=%d, isCharging=%d, batMv=%d, batPct=%d\n", powerStatus2.getHasUSB(),
|
LOG_DEBUG("Battery: usbPower=%d, isCharging=%d, batMv=%d, batPct=%d\n", powerStatus2.getHasUSB(),
|
||||||
powerStatus2.getIsCharging(), powerStatus2.getBatteryVoltageMv(), powerStatus2.getBatteryChargePercent());
|
powerStatus2.getIsCharging(), powerStatus2.getBatteryVoltageMv(), powerStatus2.getBatteryChargePercent());
|
||||||
newStatus.notifyObservers(&powerStatus2);
|
newStatus.notifyObservers(&powerStatus2);
|
||||||
|
@ -57,8 +57,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define REQUIRE_RADIO true // If true, we will fail to start if the radio is not found
|
#define REQUIRE_RADIO true // If true, we will fail to start if the radio is not found
|
||||||
|
|
||||||
/// Convert a preprocessor name into a quoted string
|
/// Convert a preprocessor name into a quoted string
|
||||||
#define xstr(s) str(s)
|
#define xstr(s) ystr(s)
|
||||||
#define str(s) #s
|
#define ystr(s) #s
|
||||||
|
|
||||||
/// Convert a preprocessor name into a quoted string and if that string is empty use "unset"
|
/// Convert a preprocessor name into a quoted string and if that string is empty use "unset"
|
||||||
#define optstr(s) (xstr(s)[0] ? xstr(s) : "unset")
|
#define optstr(s) (xstr(s)[0] ? xstr(s) : "unset")
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
|
|
||||||
#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(ARCH_ESP32)
|
#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(ARCH_ESP32)
|
||||||
HardwareSerial *GPS::_serial_gps = &Serial1;
|
HardwareSerial *GPS::_serial_gps = &Serial1;
|
||||||
|
#elif defined(ARCH_RASPBERRY_PI)
|
||||||
|
// need a translation layer to make _serial_gps work with pigpio https://abyz.me.uk/rpi/pigpio/cif.html#serOpen
|
||||||
|
HardwareSerial *GPS::_serial_gps = NULL;
|
||||||
#else
|
#else
|
||||||
HardwareSerial *GPS::_serial_gps = NULL;
|
HardwareSerial *GPS::_serial_gps = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
36
src/main.cpp
36
src/main.cpp
@ -69,6 +69,7 @@ NRF52Bluetooth *nrf52Bluetooth;
|
|||||||
|
|
||||||
#ifdef ARCH_RASPBERRY_PI
|
#ifdef ARCH_RASPBERRY_PI
|
||||||
#include "platform/portduino/PiHal.h"
|
#include "platform/portduino/PiHal.h"
|
||||||
|
#include "platform/portduino/PortduinoGlue.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -693,15 +694,32 @@ void setup()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ARCH_RASPBERRY_PI
|
#ifdef ARCH_RASPBERRY_PI
|
||||||
PiHal *RadioLibHAL = new PiHal(1);
|
if (settingsMap[use_sx1262]) {
|
||||||
if (!rIf) {
|
if (!rIf) {
|
||||||
rIf = new SX1262Interface((LockingArduinoHal *)RadioLibHAL, 21, 16, 18, 20);
|
PiHal *RadioLibHAL = new PiHal(1);
|
||||||
if (!rIf->init()) {
|
rIf = new SX1262Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
|
||||||
LOG_WARN("Failed to find SX1262 radio\n");
|
settingsMap[busy]);
|
||||||
delete rIf;
|
if (!rIf->init()) {
|
||||||
rIf = NULL;
|
LOG_ERROR("Failed to find SX1262 radio\n");
|
||||||
} else {
|
delete rIf;
|
||||||
LOG_INFO("SX1262 Radio init succeeded, using SX1262 radio\n");
|
exit(EXIT_FAILURE);
|
||||||
|
} else {
|
||||||
|
LOG_INFO("SX1262 Radio init succeeded, using SX1262 radio\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (settingsMap[use_rf95]) {
|
||||||
|
if (!rIf) {
|
||||||
|
PiHal *RadioLibHAL = new PiHal(1);
|
||||||
|
rIf = new RF95Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
|
||||||
|
settingsMap[busy]);
|
||||||
|
if (!rIf->init()) {
|
||||||
|
LOG_ERROR("Failed to find RF95 radio\n");
|
||||||
|
delete rIf;
|
||||||
|
rIf = NULL;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
} else {
|
||||||
|
LOG_INFO("RF95 Radio init succeeded, using RF95 radio\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ void NodeDB::installDefaultConfig()
|
|||||||
config.position.position_flags =
|
config.position.position_flags =
|
||||||
(meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE | meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE_MSL |
|
(meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE | meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE_MSL |
|
||||||
meshtastic_Config_PositionConfig_PositionFlags_SPEED | meshtastic_Config_PositionConfig_PositionFlags_HEADING |
|
meshtastic_Config_PositionConfig_PositionFlags_SPEED | meshtastic_Config_PositionConfig_PositionFlags_HEADING |
|
||||||
meshtastic_Config_PositionConfig_PositionFlags_DOP);
|
meshtastic_Config_PositionConfig_PositionFlags_DOP | meshtastic_Config_PositionConfig_PositionFlags_SATINVIEW);
|
||||||
|
|
||||||
#ifdef T_WATCH_S3
|
#ifdef T_WATCH_S3
|
||||||
config.display.screen_on_secs = 30;
|
config.display.screen_on_secs = 30;
|
||||||
@ -316,8 +316,8 @@ void NodeDB::installDefaultChannels()
|
|||||||
|
|
||||||
void NodeDB::resetNodes()
|
void NodeDB::resetNodes()
|
||||||
{
|
{
|
||||||
devicestate.node_db_lite_count = 0;
|
devicestate.node_db_lite_count = 1;
|
||||||
memset(devicestate.node_db_lite, 0, sizeof(devicestate.node_db_lite));
|
std::fill(&devicestate.node_db_lite[1], &devicestate.node_db_lite[MAX_NUM_NODES - 1], meshtastic_NodeInfoLite());
|
||||||
saveDeviceStateToDisk();
|
saveDeviceStateToDisk();
|
||||||
if (neighborInfoModule && moduleConfig.neighbor_info.enabled)
|
if (neighborInfoModule && moduleConfig.neighbor_info.enabled)
|
||||||
neighborInfoModule->resetNeighbors();
|
neighborInfoModule->resetNeighbors();
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "mesh/NodeDB.h"
|
#include "mesh/NodeDB.h"
|
||||||
|
#ifdef ARCH_RASPBERRY_PI
|
||||||
|
#include "PortduinoGlue.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// Particular boards might define a different max power based on what their hardware can do, default to max power output if not
|
// Particular boards might define a different max power based on what their hardware can do, default to max power output if not
|
||||||
// specified (may be dangerous if using external PA and SX126x power config forgotten)
|
// specified (may be dangerous if using external PA and SX126x power config forgotten)
|
||||||
@ -74,6 +77,12 @@ template <typename T> bool SX126xInterface<T>::init()
|
|||||||
#ifdef SX126X_DIO2_AS_RF_SWITCH
|
#ifdef SX126X_DIO2_AS_RF_SWITCH
|
||||||
LOG_DEBUG("Setting DIO2 as RF switch\n");
|
LOG_DEBUG("Setting DIO2 as RF switch\n");
|
||||||
bool dio2AsRfSwitch = true;
|
bool dio2AsRfSwitch = true;
|
||||||
|
#elif defined(ARCH_RASPBERRY_PI)
|
||||||
|
bool dio2AsRfSwitch = false;
|
||||||
|
if (settingsMap[dio2_as_rf_switch]) {
|
||||||
|
LOG_DEBUG("Setting DIO2 as RF switch\n");
|
||||||
|
dio2AsRfSwitch = true;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
LOG_DEBUG("Setting DIO2 as not RF switch\n");
|
LOG_DEBUG("Setting DIO2 as not RF switch\n");
|
||||||
bool dio2AsRfSwitch = false;
|
bool dio2AsRfSwitch = false;
|
||||||
|
@ -11,11 +11,6 @@
|
|||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
#include "target_specific.h"
|
#include "target_specific.h"
|
||||||
|
|
||||||
#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO)
|
|
||||||
#include "Sensor/INA3221Sensor.h"
|
|
||||||
INA3221Sensor ina3221Sensor;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10
|
#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10
|
||||||
#define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true
|
#define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true
|
||||||
|
|
||||||
|
@ -13,8 +13,9 @@ int32_t INA3221Sensor::runOnce()
|
|||||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||||
}
|
}
|
||||||
if (!status) {
|
if (!status) {
|
||||||
ina3221.setAddr(INA3221_ADDR42_SDA);
|
ina3221.setAddr(INA3221_ADDR42_SDA); // i2c address 0x42
|
||||||
ina3221.begin();
|
ina3221.begin();
|
||||||
|
ina3221.setShuntRes(100, 100, 100); // 0.1 Ohm shunt resistors
|
||||||
status = true;
|
status = true;
|
||||||
} else {
|
} else {
|
||||||
status = true;
|
status = true;
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
||||||
#include "TelemetrySensor.h"
|
#include "TelemetrySensor.h"
|
||||||
|
#include "VoltageSensor.h"
|
||||||
#include <INA3221.h>
|
#include <INA3221.h>
|
||||||
|
|
||||||
class INA3221Sensor : public TelemetrySensor
|
class INA3221Sensor : public TelemetrySensor, VoltageSensor
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
INA3221 ina3221 = INA3221(INA3221_ADDR42_SDA);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void setup() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
INA3221Sensor();
|
INA3221Sensor();
|
||||||
int32_t runOnce() override;
|
int32_t runOnce() override;
|
||||||
void setup() override;
|
|
||||||
bool getMetrics(meshtastic_Telemetry *measurement) override;
|
bool getMetrics(meshtastic_Telemetry *measurement) override;
|
||||||
virtual uint16_t getBusVoltageMv();
|
virtual uint16_t getBusVoltageMv() override;
|
||||||
|
|
||||||
private:
|
|
||||||
INA3221 ina3221 = INA3221(INA3221_ADDR42_SDA);
|
|
||||||
};
|
};
|
@ -9,6 +9,7 @@
|
|||||||
#include <NimBLEDevice.h>
|
#include <NimBLEDevice.h>
|
||||||
|
|
||||||
NimBLECharacteristic *fromNumCharacteristic;
|
NimBLECharacteristic *fromNumCharacteristic;
|
||||||
|
NimBLECharacteristic *BatteryCharacteristic;
|
||||||
NimBLEServer *bleServer;
|
NimBLEServer *bleServer;
|
||||||
|
|
||||||
static bool passkeyShowing;
|
static bool passkeyShowing;
|
||||||
@ -181,6 +182,18 @@ void NimbleBluetooth::setupService()
|
|||||||
FromRadioCharacteristic->setCallbacks(fromRadioCallbacks);
|
FromRadioCharacteristic->setCallbacks(fromRadioCallbacks);
|
||||||
|
|
||||||
bleService->start();
|
bleService->start();
|
||||||
|
|
||||||
|
// Setup the battery service
|
||||||
|
NimBLEService *batteryService = bleServer->createService(NimBLEUUID((uint16_t)0x180f)); // 0x180F is the Battery Service
|
||||||
|
BatteryCharacteristic = batteryService->createCharacteristic( // 0x2A19 is the Battery Level characteristic)
|
||||||
|
(uint16_t)0x2a19, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY);
|
||||||
|
|
||||||
|
NimBLE2904 *batteryLevelDescriptor = (NimBLE2904 *)BatteryCharacteristic->createDescriptor((uint16_t)0x2904);
|
||||||
|
batteryLevelDescriptor->setFormat(NimBLE2904::FORMAT_UINT8);
|
||||||
|
batteryLevelDescriptor->setNamespace(1);
|
||||||
|
batteryLevelDescriptor->setUnit(0x27ad);
|
||||||
|
|
||||||
|
batteryService->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NimbleBluetooth::startAdvertising()
|
void NimbleBluetooth::startAdvertising()
|
||||||
@ -188,13 +201,15 @@ void NimbleBluetooth::startAdvertising()
|
|||||||
NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising();
|
NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising();
|
||||||
pAdvertising->reset();
|
pAdvertising->reset();
|
||||||
pAdvertising->addServiceUUID(MESH_SERVICE_UUID);
|
pAdvertising->addServiceUUID(MESH_SERVICE_UUID);
|
||||||
|
pAdvertising->addServiceUUID(NimBLEUUID((uint16_t)0x180f)); // 0x180F is the Battery Service
|
||||||
pAdvertising->start(0);
|
pAdvertising->start(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given a level between 0-100, update the BLE attribute
|
/// Given a level between 0-100, update the BLE attribute
|
||||||
void updateBatteryLevel(uint8_t level)
|
void updateBatteryLevel(uint8_t level)
|
||||||
{
|
{
|
||||||
// blebas.write(level);
|
BatteryCharacteristic->setValue(&level, 1);
|
||||||
|
BatteryCharacteristic->notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NimbleBluetooth::clearBonds()
|
void NimbleBluetooth::clearBonds()
|
||||||
|
@ -9,7 +9,14 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#ifdef ARCH_RASPBERRY_PI
|
#ifdef ARCH_RASPBERRY_PI
|
||||||
|
#include "PortduinoGlue.h"
|
||||||
#include "pigpio.h"
|
#include "pigpio.h"
|
||||||
|
#include "yaml-cpp/yaml.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <map>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
std::map<int, int> settingsMap;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include <linux/gpio/LinuxGPIOPin.h>
|
#include <linux/gpio/LinuxGPIOPin.h>
|
||||||
@ -27,7 +34,7 @@ void cpuDeepSleep(uint32_t msecs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateBatteryLevel(uint8_t level) NOT_IMPLEMENTED("updateBatteryLevel");
|
void updateBatteryLevel(uint8_t level) NOT_IMPLEMENTED("updateBatteryLevel");
|
||||||
|
#ifndef ARCH_RASPBERRY_PI
|
||||||
/** a simulated pin for busted IRQ hardware
|
/** a simulated pin for busted IRQ hardware
|
||||||
* Porduino helper class to do this i2c based polling:
|
* Porduino helper class to do this i2c based polling:
|
||||||
*/
|
*/
|
||||||
@ -54,7 +61,7 @@ class PolledIrqPin : public GPIOPin
|
|||||||
};
|
};
|
||||||
|
|
||||||
static GPIOPin *loraIrq;
|
static GPIOPin *loraIrq;
|
||||||
|
#endif
|
||||||
int TCPPort = 4403;
|
int TCPPort = 4403;
|
||||||
|
|
||||||
static error_t parse_opt(int key, char *arg, struct argp_state *state)
|
static error_t parse_opt(int key, char *arg, struct argp_state *state)
|
||||||
@ -94,6 +101,52 @@ void portduinoSetup()
|
|||||||
printf("Setting up Meshtastic on Portduino...\n");
|
printf("Setting up Meshtastic on Portduino...\n");
|
||||||
|
|
||||||
#ifdef ARCH_RASPBERRY_PI
|
#ifdef ARCH_RASPBERRY_PI
|
||||||
|
YAML::Node yamlConfig;
|
||||||
|
|
||||||
|
if (access("config.yaml", R_OK) == 0) {
|
||||||
|
try {
|
||||||
|
yamlConfig = YAML::LoadFile("config.yaml");
|
||||||
|
} catch (YAML::Exception e) {
|
||||||
|
std::cout << "*** Exception " << e.what() << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
} else if (access("/etc/meshtasticd/config.yaml", R_OK) == 0) {
|
||||||
|
try {
|
||||||
|
yamlConfig = YAML::LoadFile("/etc/meshtasticd/config.yaml");
|
||||||
|
} catch (YAML::Exception e) {
|
||||||
|
std::cout << "*** Exception " << e.what() << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cout << "No 'config.yaml' found, exiting." << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (yamlConfig["Lora"]) {
|
||||||
|
settingsMap[use_sx1262] = false;
|
||||||
|
settingsMap[use_rf95] = false;
|
||||||
|
|
||||||
|
if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as<std::string>("") == "sx1262") {
|
||||||
|
settingsMap[use_sx1262] = true;
|
||||||
|
} else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as<std::string>("") == "RF95") {
|
||||||
|
settingsMap[use_rf95] = true;
|
||||||
|
}
|
||||||
|
settingsMap[dio2_as_rf_switch] = yamlConfig["Lora"]["DIO2_AS_RF_SWITCH"].as<bool>(false);
|
||||||
|
settingsMap[cs] = yamlConfig["Lora"]["CS"].as<int>(RADIOLIB_NC);
|
||||||
|
settingsMap[irq] = yamlConfig["Lora"]["IRQ"].as<int>(RADIOLIB_NC);
|
||||||
|
settingsMap[busy] = yamlConfig["Lora"]["Busy"].as<int>(RADIOLIB_NC);
|
||||||
|
settingsMap[reset] = yamlConfig["Lora"]["Reset"].as<int>(RADIOLIB_NC);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (YAML::Exception e) {
|
||||||
|
std::cout << "*** Exception " << e.what() << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
if (access("/sys/kernel/debug/bluetooth/hci0/identity", R_OK) != 0) {
|
||||||
|
std::cout << "Cannot read Bluetooth MAC Address. Please run as root" << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -121,7 +174,7 @@ void portduinoSetup()
|
|||||||
gpioBind(loraCs);
|
gpioBind(loraCs);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef ARCH_RASPBERRY_PI
|
||||||
{
|
{
|
||||||
// Set the random seed equal to TCPPort to have a different seed per instance
|
// Set the random seed equal to TCPPort to have a different seed per instance
|
||||||
randomSeed(TCPPort);
|
randomSeed(TCPPort);
|
||||||
@ -140,4 +193,5 @@ void portduinoSetup()
|
|||||||
}
|
}
|
||||||
// gpioBind((new SimGPIOPin(LORA_RESET, "LORA_RESET")));
|
// gpioBind((new SimGPIOPin(LORA_RESET, "LORA_RESET")));
|
||||||
// gpioBind((new SimGPIOPin(RF95_NSS, "RF95_NSS"))->setSilent());
|
// gpioBind((new SimGPIOPin(RF95_NSS, "RF95_NSS"))->setSilent());
|
||||||
|
#endif
|
||||||
}
|
}
|
9
src/platform/portduino/PortduinoGlue.h
Normal file
9
src/platform/portduino/PortduinoGlue.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifdef ARCH_RASPBERRY_PI
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
extern std::map<int, int> settingsMap;
|
||||||
|
|
||||||
|
enum { use_sx1262, cs, irq, busy, reset, dio2_as_rf_switch, use_rf95 };
|
||||||
|
|
||||||
|
#endif
|
@ -1,33 +1,63 @@
|
|||||||
|
#include "AES.h"
|
||||||
|
#include "CTR.h"
|
||||||
#include "CryptoEngine.h"
|
#include "CryptoEngine.h"
|
||||||
#include "aes.hpp"
|
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
class RP2040CryptoEngine : public CryptoEngine
|
class RP2040CryptoEngine : public CryptoEngine
|
||||||
{
|
{
|
||||||
|
|
||||||
|
CTRCommon *ctr = NULL;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RP2040CryptoEngine() {}
|
RP2040CryptoEngine() {}
|
||||||
|
|
||||||
~RP2040CryptoEngine() {}
|
~RP2040CryptoEngine() {}
|
||||||
|
|
||||||
|
virtual void setKey(const CryptoKey &k) override
|
||||||
|
{
|
||||||
|
CryptoEngine::setKey(k);
|
||||||
|
LOG_DEBUG("Installing AES%d key!\n", key.length * 8);
|
||||||
|
if (ctr) {
|
||||||
|
delete ctr;
|
||||||
|
ctr = NULL;
|
||||||
|
}
|
||||||
|
if (key.length != 0) {
|
||||||
|
if (key.length == 16)
|
||||||
|
ctr = new CTR<AES128>();
|
||||||
|
else
|
||||||
|
ctr = new CTR<AES256>();
|
||||||
|
|
||||||
|
ctr->setKey(key.bytes, key.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Encrypt a packet
|
* Encrypt a packet
|
||||||
*
|
*
|
||||||
* @param bytes is updated in place
|
* @param bytes is updated in place
|
||||||
*/
|
*/
|
||||||
virtual void encrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes) override
|
virtual void encrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override
|
||||||
{
|
{
|
||||||
if (key.length > 0) {
|
if (key.length > 0) {
|
||||||
AES_ctx ctx;
|
initNonce(fromNode, packetId);
|
||||||
initNonce(fromNode, packetNum);
|
if (numBytes <= MAX_BLOCKSIZE) {
|
||||||
AES_init_ctx_iv(&ctx, key.bytes, nonce);
|
static uint8_t scratch[MAX_BLOCKSIZE];
|
||||||
AES_CTR_xcrypt_buffer(&ctx, bytes, numBytes);
|
memcpy(scratch, bytes, numBytes);
|
||||||
|
memset(scratch + numBytes, 0,
|
||||||
|
sizeof(scratch) - numBytes); // Fill rest of buffer with zero (in case cypher looks at it)
|
||||||
|
|
||||||
|
ctr->setIV(nonce, sizeof(nonce));
|
||||||
|
ctr->setCounterSize(4);
|
||||||
|
ctr->encrypt(bytes, scratch, numBytes);
|
||||||
|
} else {
|
||||||
|
LOG_ERROR("Packet too large for crypto engine: %d. noop encryption!\n", numBytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void decrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes) override
|
virtual void decrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override
|
||||||
{
|
{
|
||||||
// For CTR, the implementation is the same
|
// For CTR, the implementation is the same
|
||||||
encrypt(fromNode, packetNum, numBytes, bytes);
|
encrypt(fromNode, packetId, numBytes, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -25,8 +25,10 @@ extern RTC_NOINIT_ATTR uint64_t RTC_reg_b;
|
|||||||
#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO)
|
#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO)
|
||||||
#include "modules/Telemetry/Sensor/INA219Sensor.h"
|
#include "modules/Telemetry/Sensor/INA219Sensor.h"
|
||||||
#include "modules/Telemetry/Sensor/INA260Sensor.h"
|
#include "modules/Telemetry/Sensor/INA260Sensor.h"
|
||||||
|
#include "modules/Telemetry/Sensor/INA3221Sensor.h"
|
||||||
extern INA260Sensor ina260Sensor;
|
extern INA260Sensor ina260Sensor;
|
||||||
extern INA219Sensor ina219Sensor;
|
extern INA219Sensor ina219Sensor;
|
||||||
|
extern INA3221Sensor ina3221Sensor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class Power : private concurrency::OSThread
|
class Power : private concurrency::OSThread
|
||||||
|
@ -16,7 +16,7 @@ build_src_filter = ${portduino_base.build_src_filter}
|
|||||||
; The Raspberry Pi actually has accessible SPI and GPIO, so we can support real hardware there.
|
; The Raspberry Pi actually has accessible SPI and GPIO, so we can support real hardware there.
|
||||||
[env:raspbian]
|
[env:raspbian]
|
||||||
extends = portduino_base
|
extends = portduino_base
|
||||||
build_flags = ${portduino_base.build_flags} -O0 -lgpiod -I variants/portduino -DARCH_RASPBERRY_PI -DRADIOLIB_DEBUG -lpigpio
|
build_flags = ${portduino_base.build_flags} -O0 -lgpiod -I variants/portduino -DARCH_RASPBERRY_PI -lpigpio -lyaml-cpp
|
||||||
board = linux_arm
|
board = linux_arm
|
||||||
lib_deps = ${portduino_base.lib_deps}
|
lib_deps = ${portduino_base.lib_deps}
|
||||||
build_src_filter = ${portduino_base.build_src_filter}
|
build_src_filter = ${portduino_base.build_src_filter}
|
@ -1,34 +1,6 @@
|
|||||||
#if defined(ARCH_RASPBERRY_PI)
|
#if defined(ARCH_RASPBERRY_PI)
|
||||||
#define HAS_RADIO 1
|
|
||||||
#define GPIOD_CHIP_LABEL "pinctrl-bcm2711"
|
|
||||||
|
|
||||||
// define USE_RF95
|
|
||||||
#define USE_SX1262
|
|
||||||
#define SX126X_TXEN 6
|
|
||||||
#define SX126X_DIO2_AS_RF_SWITCH
|
|
||||||
#define NO_SCREEN
|
#define NO_SCREEN
|
||||||
|
|
||||||
#define RF95_SCK 11
|
|
||||||
#define RF95_MISO 9
|
|
||||||
#define RF95_MOSI 10
|
|
||||||
#define RF95_NSS RADIOLIB_NC
|
|
||||||
|
|
||||||
// #define LORA_DIO0 4 // a No connect on the SX1262 module
|
|
||||||
// #define LORA_DIO0_LABEL "GPIO_GCLK"
|
|
||||||
#define LORA_RESET 18
|
|
||||||
#define LORA_RESET_LABEL "GPIO18"
|
|
||||||
#define LORA_DIO1 16 // SX1262 IRQ, called DIO0 on pinelora schematic, pin 7 on ch341f "ack" - FIXME, enable hwints in linux
|
|
||||||
// #define LORA_DIO2 20 // SX1262 BUSY, actually connected to "DIO5" on pinelora schematic, pin 8 on ch341f "slct"
|
|
||||||
// #define LORA_DIO3 6 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled
|
|
||||||
|
|
||||||
#ifdef USE_SX1262
|
|
||||||
#define SX126X_CS 21
|
|
||||||
#define SX126X_DIO1 16
|
|
||||||
#define SX126X_BUSY 20
|
|
||||||
#define SX126X_RESET LORA_RESET
|
|
||||||
// HOPE RFM90 does not have a TCXO therefore not SX126X_E22
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else // Pine64 mode.
|
#else // Pine64 mode.
|
||||||
|
|
||||||
// Pine64 uses a common pinout for their SX1262 vs RF95 modules - both can be enabled and we will probe at runtime for RF95 and if
|
// Pine64 uses a common pinout for their SX1262 vs RF95 modules - both can be enabled and we will probe at runtime for RF95 and if
|
||||||
|
@ -234,6 +234,9 @@ SO GPIO 39/TXEN MAY NOT BE DEFINED FOR SUCCESSFUL OPERATION OF THE SX1262 - TG
|
|||||||
#define SX126X_DIO2_AS_RF_SWITCH
|
#define SX126X_DIO2_AS_RF_SWITCH
|
||||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
||||||
|
|
||||||
|
// Testing USB detection
|
||||||
|
#define NRF_APM
|
||||||
|
|
||||||
// enables 3.3V periphery like GPS or IO Module
|
// enables 3.3V periphery like GPS or IO Module
|
||||||
#define PIN_3V3_EN (34)
|
#define PIN_3V3_EN (34)
|
||||||
|
|
||||||
|
@ -4,13 +4,6 @@
|
|||||||
|
|
||||||
#define ARDUINO_ARCH_AVR
|
#define ARDUINO_ARCH_AVR
|
||||||
|
|
||||||
#undef CBC
|
|
||||||
#define CBC 0
|
|
||||||
#undef CTR
|
|
||||||
#define CTR 1
|
|
||||||
#undef ECB
|
|
||||||
#define ECB 0
|
|
||||||
|
|
||||||
#define LED_CONN PIN_LED2
|
#define LED_CONN PIN_LED2
|
||||||
#define LED_PIN LED_BUILTIN
|
#define LED_PIN LED_BUILTIN
|
||||||
|
|
||||||
|
@ -215,6 +215,9 @@ SO GPIO 39/TXEN MAY NOT BE DEFINED FOR SUCCESSFUL OPERATION OF THE SX1262 - TG
|
|||||||
#define SX126X_DIO2_AS_RF_SWITCH
|
#define SX126X_DIO2_AS_RF_SWITCH
|
||||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
||||||
|
|
||||||
|
// Testing USB detection
|
||||||
|
#define NRF_APM
|
||||||
|
|
||||||
// enables 3.3V periphery like GPS or IO Module
|
// enables 3.3V periphery like GPS or IO Module
|
||||||
#define PIN_3V3_EN (34)
|
#define PIN_3V3_EN (34)
|
||||||
|
|
||||||
|
@ -209,6 +209,9 @@ static const uint8_t SCK = PIN_SPI_SCK;
|
|||||||
// RAK12002 RTC Module
|
// RAK12002 RTC Module
|
||||||
#define RV3028_RTC (uint8_t)0b1010010
|
#define RV3028_RTC (uint8_t)0b1010010
|
||||||
|
|
||||||
|
// Testing USB detection
|
||||||
|
#define NRF_APM
|
||||||
|
|
||||||
// Battery
|
// Battery
|
||||||
// The battery sense is hooked to pin A0 (5)
|
// The battery sense is hooked to pin A0 (5)
|
||||||
#define BATTERY_PIN PIN_A0
|
#define BATTERY_PIN PIN_A0
|
||||||
|
@ -84,6 +84,9 @@ static const uint8_t AREF = PIN_AREF;
|
|||||||
#define PIN_SERIAL2_RX (-1)
|
#define PIN_SERIAL2_RX (-1)
|
||||||
#define PIN_SERIAL2_TX (-1)
|
#define PIN_SERIAL2_TX (-1)
|
||||||
|
|
||||||
|
// Testing USB detection
|
||||||
|
#define NRF_APM
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SPI Interfaces
|
* SPI Interfaces
|
||||||
*/
|
*/
|
||||||
|
@ -4,13 +4,6 @@
|
|||||||
|
|
||||||
#define ARDUINO_ARCH_AVR
|
#define ARDUINO_ARCH_AVR
|
||||||
|
|
||||||
#undef CBC
|
|
||||||
#define CBC 0
|
|
||||||
#undef CTR
|
|
||||||
#define CTR 1
|
|
||||||
#undef ECB
|
|
||||||
#define ECB 0
|
|
||||||
|
|
||||||
#define USE_SH1106 1
|
#define USE_SH1106 1
|
||||||
|
|
||||||
// default I2C pins:
|
// default I2C pins:
|
||||||
|
@ -4,13 +4,6 @@
|
|||||||
|
|
||||||
#define ARDUINO_ARCH_AVR
|
#define ARDUINO_ARCH_AVR
|
||||||
|
|
||||||
#undef CBC
|
|
||||||
#define CBC 0
|
|
||||||
#undef CTR
|
|
||||||
#define CTR 1
|
|
||||||
#undef ECB
|
|
||||||
#define ECB 0
|
|
||||||
|
|
||||||
#define USE_SH1106 1
|
#define USE_SH1106 1
|
||||||
|
|
||||||
// default I2C pins:
|
// default I2C pins:
|
||||||
|
Loading…
Reference in New Issue
Block a user