├── data └── static │ └── .gitkeep ├── src ├── StatusHandler.h ├── platform │ ├── nrf52 │ │ ├── main-bare.cpp │ │ ├── pgmspace.h │ │ ├── alloc.cpp │ │ ├── NRF52Bluetooth.h │ │ └── aes-256 │ │ │ └── tiny-aes.h │ ├── portduino │ │ └── architecture.h │ ├── esp32 │ │ ├── BleOta.h │ │ └── CallbackCharacteristic.h │ ├── stm32wl │ │ ├── architecture.h │ │ ├── STM32WLCryptoEngine.cpp │ │ └── main-stm32wl.cpp │ └── rp2040 │ │ └── architecture.h ├── Observer.cpp ├── mesh │ ├── generated │ │ ├── .clang-format │ │ └── meshtastic │ │ │ ├── portnums.pb.cpp │ │ │ ├── apponly.pb.cpp │ │ │ ├── paxcount.pb.cpp │ │ │ ├── rtttl.pb.cpp │ │ │ ├── xmodem.pb.cpp │ │ │ ├── clientonly.pb.cpp │ │ │ ├── remote_hardware.pb.cpp │ │ │ ├── cannedmessages.pb.cpp │ │ │ ├── mqtt.pb.cpp │ │ │ ├── localonly.pb.cpp │ │ │ ├── channel.pb.cpp │ │ │ ├── admin.pb.cpp │ │ │ ├── deviceonly.pb.cpp │ │ │ ├── atak.pb.cpp │ │ │ ├── storeforward.pb.cpp │ │ │ ├── telemetry.pb.cpp │ │ │ ├── connection_status.pb.cpp │ │ │ └── config.pb.cpp │ ├── ProtobufModule.cpp │ ├── eth │ │ └── ethClient.h │ ├── http │ │ ├── ContentHelper.h │ │ ├── WebServer.h │ │ └── ContentHelper.cpp │ ├── Throttle.h │ ├── LLCC68Interface.cpp │ ├── SX1262Interface.cpp │ ├── SX1280Interface.cpp │ ├── SX1262Interface.h │ ├── SX1280Interface.h │ ├── SX1268Interface.h │ ├── TypeConversions.h │ ├── wifi │ │ └── WiFiAPClient.h │ ├── SX1268Interface.cpp │ ├── MeshRadio.h │ ├── api │ │ ├── ethServerAPI.cpp │ │ ├── WiFiServerAPI.cpp │ │ ├── ethServerAPI.h │ │ └── WiFiServerAPI.h │ ├── LLCC68Interface.h │ ├── Default.cpp │ ├── PointerQueue.h │ ├── InterfacesTemplates.cpp │ ├── CryptoEngine.cpp │ ├── Throttle.cpp │ └── STM32WLE5JCInterface.h ├── graphics │ ├── PointStruct.h │ ├── RAKled.h │ ├── NeoPixel.h │ ├── fonts │ │ ├── OLEDDisplayFontsRU.h │ │ └── OLEDDisplayFontsUA.h │ └── ScreenFonts.h ├── buzz │ └── buzz.h ├── modules │ ├── Modules.h │ ├── Telemetry │ │ └── Sensor │ │ │ ├── bme680_iaq_33v_3s_4d │ │ │ └── bsec_iaq.h │ │ │ ├── VoltageSensor.h │ │ │ ├── TelemetrySensor.cpp │ │ │ ├── SHT31Sensor.h │ │ │ ├── BME280Sensor.h │ │ │ ├── BMP085Sensor.h │ │ │ ├── BMP280Sensor.h │ │ │ ├── MCP9808Sensor.h │ │ │ ├── SHT4XSensor.h │ │ │ ├── SHTC3Sensor.h │ │ │ ├── LPS22HBSensor.h │ │ │ ├── VEML7700Sensor.h │ │ │ ├── INA3221Sensor.h │ │ │ ├── INA219Sensor.h │ │ │ ├── INA260Sensor.h │ │ │ ├── RCWL9620Sensor.h │ │ │ ├── MCP9808Sensor.cpp │ │ │ ├── SHTC3Sensor.cpp │ │ │ ├── SHT31Sensor.cpp │ │ │ └── BMP085Sensor.cpp │ ├── ModuleDev.h │ ├── ReplyModule.h │ ├── DetectionSensorModule.h │ ├── WaypointModule.cpp │ ├── WaypointModule.h │ ├── AtakPluginModule.h │ ├── ReplyModule.cpp │ ├── TextMessageModule.h │ └── TextMessageModule.cpp ├── detect │ ├── LoRaRadioType.h │ └── axpDebug.h ├── DisplayFormatters.h ├── SPILock.cpp ├── target_specific.h ├── OSTimer.h ├── concurrency │ ├── LockGuard.cpp │ ├── LockGuard.h │ ├── BinarySemaphorePosix.h │ ├── BinarySemaphoreFreeRTOS.h │ ├── Lock.cpp │ ├── BinarySemaphorePosix.cpp │ ├── Lock.h │ ├── Periodic.h │ ├── InterruptableDelay.cpp │ ├── BinarySemaphoreFreeRTOS.cpp │ └── InterruptableDelay.h ├── SPILock.h ├── memGet.h ├── input │ ├── LinuxInputImpl.cpp │ ├── cardKbI2cImpl.cpp │ ├── UpDownInterruptImpl1.h │ ├── kbMatrixImpl.cpp │ ├── InputBroker.cpp │ ├── TrackballInterruptImpl1.h │ ├── kbMatrixBase.h │ ├── TouchScreenImpl1.h │ ├── kbI2cBase.h │ ├── cardKbI2cImpl.h │ ├── kbMatrixImpl.h │ ├── LinuxInputImpl.h │ ├── InputBroker.h │ └── RotaryEncoderInterruptImpl1.h ├── RF95Configuration.h ├── gps │ └── NMEAWPL.h ├── meshUtils.h ├── network-stubs.cpp ├── nimble │ └── NimbleBluetooth.h ├── error.h ├── commands.h ├── BluetoothCommon.cpp ├── BluetoothCommon.h └── PowerFSM.h ├── release ├── latest │ └── .gitignore └── .gitignore ├── .trunk ├── configs │ ├── .isort.cfg │ ├── .hadolint.yaml │ ├── .flake8 │ ├── .clang-format │ ├── ruff.toml │ ├── .shellcheckrc │ ├── .markdownlint.yaml │ ├── .yamllint.yaml │ └── svgo.config.js ├── .gitignore └── trunk.yaml ├── version.properties ├── images ├── face.png ├── pin.png ├── compass.png ├── textsms-24px.svg ├── room-24px.svg ├── location_searching-24px.svg └── face-24px.svg ├── .semgrepignore ├── arch ├── esp32 │ ├── esp32s3.ini │ ├── esp32c3.ini │ └── esp32s2.ini ├── nrf52 │ ├── nrf52832.ini │ ├── nrf52840.ini │ └── nrf52.ini ├── rp2040 │ └── rp2040.ini ├── stm32 │ └── stm32wl5e.ini └── portduino │ └── portduino.ini ├── .gitmodules ├── bin ├── read-system-info.sh ├── view-map.sh ├── lilygo_techo_bootloader-0.6.1.zip ├── native-run.sh ├── Meshtastic_nRF52_factory_erase_v2.uf2 ├── update-lilygo_techo_bootloader-0.6.1_nosd.uf2 ├── native-gdbserver.sh ├── dump-ram-users.sh ├── buildinfo.py ├── regen-protos.bat ├── uf2-convert.bat ├── meshtasticd.service ├── test-simulator.sh ├── native-install.sh ├── promote-release.sh ├── bump_version.py ├── regen-protos.sh ├── check-dependencies.sh ├── gen-images.sh ├── check-all.sh ├── build-rpi2040.sh ├── build-nrf52.sh ├── build-native.sh └── build-esp32.sh ├── .gitattributes ├── variants ├── xiao_ble │ ├── xiao-ble-internal-format.uf2 │ ├── xiao_nrf52840_ble_bootloader-0.7.0-22-g277a0c8_s140_7.3.0.zip │ ├── platformio.ini │ └── xiao_ble.sh ├── tlora_v1 │ ├── platformio.ini │ └── variant.h ├── tlora_v2 │ ├── platformio.ini │ └── variant.h ├── tlora_v1_3 │ ├── platformio.ini │ └── variant.h ├── portduino │ ├── variant.h │ └── platformio.ini ├── ppr │ └── platformio.ini ├── tlora_v2_1_18 │ ├── platformio.ini │ └── variant.h ├── ai-c3 │ ├── platformio.ini │ └── variant.h ├── rak11200 │ ├── platformio.ini │ └── pins_arduino.h ├── CDEBYTE_EoRa-S3 │ ├── platformio.ini │ └── pins_arduino.h ├── nano-g1 │ └── platformio.ini ├── tbeam_v07 │ ├── platformio.ini │ └── variant.h ├── station-g1 │ └── platformio.ini ├── heltec_v2 │ └── platformio.ini ├── heltec_v1 │ ├── platformio.ini │ └── variant.h ├── ppr1 │ └── platformio.ini ├── nano-g1-explorer │ └── platformio.ini ├── wio-e5 │ ├── platformio.ini │ └── variant.h ├── EBYTE_ESP32-S3 │ ├── platformio.ini │ └── pins_arduino.h ├── tlora_v2_1_16 │ ├── platformio.ini │ └── variant.h ├── heltec_esp32c3 │ ├── platformio.ini │ ├── pins_arduino.h │ └── variant.h ├── tlora_v2_1_16_tcxo │ └── platformio.ini ├── m5stack-stamp-c3 │ ├── platformio.ini │ └── pins_arduino.h ├── tlora_t3s3_v1 │ ├── platformio.ini │ └── pins_arduino.h ├── heltec_v2.1 │ └── platformio.ini ├── heltec_wsl_v3 │ ├── platformio.ini │ └── variant.h ├── heltec_v3 │ └── platformio.ini ├── chatter2 │ └── platformio.ini ├── tbeam │ └── platformio.ini ├── picomputer-s3 │ ├── platformio.ini │ └── pins_arduino.h ├── wiphone │ └── platformio.ini ├── TWC_mesh_v4 │ └── platformio.ini ├── senselora_rp2040 │ ├── platformio.ini │ └── variant.h ├── bpi_picow_esp32_s3 │ ├── platformio.ini │ └── pins_arduino.h ├── tbeam-s3-core │ └── platformio.ini ├── t-deck │ └── platformio.ini ├── betafpv_900_tx_nano │ ├── platformio.ini │ └── variant.h ├── rak11310 │ └── platformio.ini ├── station-g2 │ ├── platformio.ini │ └── pins_arduino.h ├── t-watch-s3 │ └── platformio.ini ├── pca10056-rc-clock │ └── platformio.ini ├── rpipico │ └── platformio.ini ├── betafpv_2400_tx_micro │ ├── platformio.ini │ └── variant.h ├── nano-g2-ultra │ └── platformio.ini ├── rp2040-lora │ └── platformio.ini ├── heltec_wireless_tracker │ └── platformio.ini ├── heltec_wireless_tracker_V1_0 │ └── platformio.ini ├── Dongle_nRF52840-pca10059-v1 │ └── platformio.ini ├── trackerd │ └── platformio.ini ├── MakePython_nRF52840_oled │ └── platformio.ini ├── canaryone │ └── platformio.ini ├── rpipicow │ └── platformio.ini ├── lora_isp4520 │ └── platformio.ini ├── esp32-s3-pico │ ├── platformio.ini │ └── pins_arduino.h ├── feather_diy │ ├── platformio.ini │ └── variant.cpp ├── m5stack_core │ └── platformio.ini ├── MakePython_nRF52840_eink │ └── platformio.ini ├── m5stack_coreink │ └── platformio.ini ├── unphone │ ├── variant.cpp │ └── platformio.ini ├── my_esp32s3_diy_eink │ ├── pins_arduino.h │ └── platformio.ini ├── my_esp32s3_diy_oled │ ├── pins_arduino.h │ └── platformio.ini ├── monteops_hw1 │ └── platformio.ini ├── rpipico-slowclock │ └── platformio.ini ├── rak4631_epaper │ └── platformio.ini ├── lora_relay_v1 │ └── platformio.ini ├── rak4631_epaper_onrxtx │ └── platformio.ini ├── lora_relay_v2 │ └── platformio.ini ├── rak4631 │ └── platformio.ini ├── rak10701 │ └── platformio.ini └── heltec_wireless_paper_v1 │ └── platformio.ini ├── .vscode ├── settings.json ├── extensions.json └── tasks.json ├── docker-compose.yml ├── partition-table.csv ├── .github ├── workflows │ ├── nightly.yml │ ├── trunk-check.yml │ ├── sec_sast_semgrep_pull.yml │ ├── build_rpi2040.yml │ ├── build_nrf52.yml │ ├── update_protobufs.yml │ ├── sec_sast_semgrep_cron.yml │ └── sec_sast_flawfinder.yml └── ISSUE_TEMPLATE │ └── feature.yml ├── .gitignore └── boards ├── wiscore_rak11200.json ├── generic_wl5e.json ├── wiphone.json ├── tbeam-s3-core.json ├── bpi_picow_esp32_s3.json ├── tlora-t3s3-v1.json ├── lora_isp4520.json ├── CDEBYTE_EoRa-S3.json ├── heltec_wireless_tracker.json └── t-watch-s3.json /data/static/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/StatusHandler.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /release/latest/.gitignore: -------------------------------------------------------------------------------- 1 | curfirmwareversion.xml 2 | -------------------------------------------------------------------------------- /.trunk/configs/.isort.cfg: -------------------------------------------------------------------------------- 1 | [settings] 2 | profile=black 3 | -------------------------------------------------------------------------------- /release/.gitignore: -------------------------------------------------------------------------------- 1 | *.elf 2 | *.bin 3 | *.map 4 | *.zip 5 | *.uf2 6 | -------------------------------------------------------------------------------- /src/platform/nrf52/main-bare.cpp: -------------------------------------------------------------------------------- 1 | #include "target_specific.h" 2 | -------------------------------------------------------------------------------- /src/Observer.cpp: -------------------------------------------------------------------------------- 1 | #include "Observer.h" 2 | #include "configuration.h" 3 | -------------------------------------------------------------------------------- /src/mesh/generated/.clang-format: -------------------------------------------------------------------------------- 1 | DisableFormat: true 2 | SortIncludes: false -------------------------------------------------------------------------------- /version.properties: -------------------------------------------------------------------------------- 1 | [VERSION] 2 | major = 2 3 | minor = 3 4 | build = 11 5 | -------------------------------------------------------------------------------- /images/face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1harios/firmware/HEAD/images/face.png -------------------------------------------------------------------------------- /images/pin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1harios/firmware/HEAD/images/pin.png -------------------------------------------------------------------------------- /src/graphics/PointStruct.h: -------------------------------------------------------------------------------- 1 | struct PointStruct { 2 | int x; 3 | int y; 4 | }; -------------------------------------------------------------------------------- /.semgrepignore: -------------------------------------------------------------------------------- 1 | .github/workflows/main_matrix.yml 2 | src/mesh/compression/unishox2.c 3 | -------------------------------------------------------------------------------- /images/compass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1harios/firmware/HEAD/images/compass.png -------------------------------------------------------------------------------- /src/mesh/ProtobufModule.cpp: -------------------------------------------------------------------------------- 1 | #include "ProtobufModule.h" 2 | #include "configuration.h" 3 | -------------------------------------------------------------------------------- /arch/esp32/esp32s3.ini: -------------------------------------------------------------------------------- 1 | [esp32s3_base] 2 | extends = esp32_base 3 | 4 | monitor_speed = 115200 5 | 6 | -------------------------------------------------------------------------------- /src/graphics/RAKled.h: -------------------------------------------------------------------------------- 1 | #ifdef HAS_NCP5623 2 | #include 3 | extern NCP5623 rgb; 4 | 5 | #endif -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "protobufs"] 2 | path = protobufs 3 | url = https://github.com/meshtastic/protobufs.git 4 | -------------------------------------------------------------------------------- /src/buzz/buzz.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void playBeep(); 4 | void playStartMelody(); 5 | void playShutdownMelody(); 6 | -------------------------------------------------------------------------------- /.trunk/configs/.hadolint.yaml: -------------------------------------------------------------------------------- 1 | # Following source doesn't work in most setups 2 | ignored: 3 | - SC1090 4 | - SC1091 5 | -------------------------------------------------------------------------------- /bin/read-system-info.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | esptool.py --baud 115200 read_flash 0x1000 0xf000 system-info.img 4 | -------------------------------------------------------------------------------- /bin/view-map.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo using amap tool to display memory map 4 | amap .pio/build/output.map 5 | -------------------------------------------------------------------------------- /bin/lilygo_techo_bootloader-0.6.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1harios/firmware/HEAD/bin/lilygo_techo_bootloader-0.6.1.zip -------------------------------------------------------------------------------- /bin/native-run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | pio run --environment native 5 | .pio/build/native/program "$@" 6 | -------------------------------------------------------------------------------- /src/graphics/NeoPixel.h: -------------------------------------------------------------------------------- 1 | #ifdef HAS_NEOPIXEL 2 | #include 3 | extern Adafruit_NeoPixel pixels; 4 | #endif -------------------------------------------------------------------------------- /bin/Meshtastic_nRF52_factory_erase_v2.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1harios/firmware/HEAD/bin/Meshtastic_nRF52_factory_erase_v2.uf2 -------------------------------------------------------------------------------- /.trunk/.gitignore: -------------------------------------------------------------------------------- 1 | *out 2 | *logs 3 | *actions 4 | *notifications 5 | *tools 6 | plugins 7 | user_trunk.yaml 8 | user.yaml 9 | tmp 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | *.{cmd,[cC][mM][dD]} text eol=crlf 3 | *.{bat,[bB][aA][tT]} text eol=crlf 4 | *.{sh,[sS][hH]} text eol=lf 5 | -------------------------------------------------------------------------------- /arch/esp32/esp32c3.ini: -------------------------------------------------------------------------------- 1 | [esp32c3_base] 2 | extends = esp32_base 3 | 4 | monitor_speed = 115200 5 | monitor_filters = esp32_c3_exception_decoder 6 | -------------------------------------------------------------------------------- /variants/xiao_ble/xiao-ble-internal-format.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1harios/firmware/HEAD/variants/xiao_ble/xiao-ble-internal-format.uf2 -------------------------------------------------------------------------------- /bin/update-lilygo_techo_bootloader-0.6.1_nosd.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1harios/firmware/HEAD/bin/update-lilygo_techo_bootloader-0.6.1_nosd.uf2 -------------------------------------------------------------------------------- /bin/native-gdbserver.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | pio run --environment native 5 | gdbserver --once localhost:2345 .pio/build/native/program "$@" 6 | -------------------------------------------------------------------------------- /arch/nrf52/nrf52832.ini: -------------------------------------------------------------------------------- 1 | [nrf52832_base] 2 | extends = nrf52_base 3 | 4 | build_flags = ${nrf52_base.build_flags} 5 | 6 | lib_deps = 7 | ${nrf52_base.lib_deps} 8 | -------------------------------------------------------------------------------- /.trunk/configs/.flake8: -------------------------------------------------------------------------------- 1 | # Autoformatter friendly flake8 config (all formatting rules disabled) 2 | [flake8] 3 | extend-ignore = D1, D2, E1, E2, E3, E501, W1, W2, W3, W5 4 | -------------------------------------------------------------------------------- /src/platform/nrf52/pgmspace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // dummy file to keep old arduino code happy 4 | #define PROGMEM 5 | #define pgm_read_byte(addr) (*((unsigned const char *)addr)) -------------------------------------------------------------------------------- /variants/tlora_v1/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:tlora-v1] 2 | extends = esp32_base 3 | board = ttgo-lora32-v1 4 | build_flags = 5 | ${esp32_base.build_flags} -D TLORA_V1 -I variants/tlora_v1 -------------------------------------------------------------------------------- /variants/tlora_v2/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:tlora-v2] 2 | extends = esp32_base 3 | board = ttgo-lora32-v1 4 | build_flags = 5 | ${esp32_base.build_flags} -D TLORA_V2 -I variants/tlora_v2 -------------------------------------------------------------------------------- /.trunk/configs/.clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | IndentWidth: 4 3 | ColumnLimit: 130 4 | PointerAlignment: Right 5 | BreakBeforeBraces: Linux 6 | AllowShortFunctionsOnASingleLine: Inline 7 | -------------------------------------------------------------------------------- /src/mesh/eth/ethClient.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "configuration.h" 4 | #include 5 | #include 6 | 7 | bool initEthernet(); 8 | bool isEthernetAvailable(); 9 | -------------------------------------------------------------------------------- /src/modules/Modules.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /** 4 | * Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else) 5 | */ 6 | void setupModules(); -------------------------------------------------------------------------------- /variants/tlora_v1_3/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:tlora_v1_3] 2 | extends = esp32_base 3 | board = ttgo-lora32-v1 4 | build_flags = 5 | ${esp32_base.build_flags} -D TLORA_V1_3 -I variants/tlora_v1_3 -------------------------------------------------------------------------------- /variants/portduino/variant.h: -------------------------------------------------------------------------------- 1 | #define HAS_SCREEN 1 2 | #define CANNED_MESSAGE_MODULE_ENABLE 1 3 | #define HAS_GPS 1 4 | #define MAX_NUM_NODES settingsMap[maxnodes] 5 | #define RADIOLIB_GODMODE 1 6 | -------------------------------------------------------------------------------- /bin/dump-ram-users.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | arm-none-eabi-readelf -s -e .pio/build/nrf52dk/firmware.elf | head -80 4 | 5 | nm -CSr --size-sort .pio/build/nrf52dk/firmware.elf | grep '^200' 6 | -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/bme680_iaq_33v_3s_4d/bsec_iaq.h: -------------------------------------------------------------------------------- 1 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 2 | 3 | #include 4 | 5 | extern const uint8_t bsec_config_iaq[1974]; 6 | 7 | #endif -------------------------------------------------------------------------------- /variants/ppr/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The PPR board 2 | [env:ppr] 3 | extends = nrf52_base 4 | board = ppr 5 | board_level = extra 6 | lib_deps = 7 | ${arduino_base.lib_deps} 8 | industruino/UC1701@^1.1.0 -------------------------------------------------------------------------------- /bin/buildinfo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import sys 3 | 4 | from readprops import readProps 5 | 6 | verObj = readProps("version.properties") 7 | propName = sys.argv[1] 8 | print(f"{verObj[propName]}") 9 | -------------------------------------------------------------------------------- /variants/tlora_v2_1_18/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:tlora-v2-1-1_8] 2 | extends = esp32_base 3 | board = ttgo-lora32-v21 4 | 5 | build_flags = 6 | ${esp32_base.build_flags} -D TLORA_V2_1_18 -I variants/tlora_v2_1_18 -------------------------------------------------------------------------------- /variants/xiao_ble/xiao_nrf52840_ble_bootloader-0.7.0-22-g277a0c8_s140_7.3.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1harios/firmware/HEAD/variants/xiao_ble/xiao_nrf52840_ble_bootloader-0.7.0-22-g277a0c8_s140_7.3.0.zip -------------------------------------------------------------------------------- /bin/regen-protos.bat: -------------------------------------------------------------------------------- 1 | cd protobufs && ..\nanopb-0.4.8\generator-bin\protoc.exe --experimental_allow_proto3_optional "--nanopb_out=-S.cpp -v:..\src\mesh\generated" -I=..\protobufs\ ..\protobufs\meshtastic\*.proto 2 | -------------------------------------------------------------------------------- /src/detect/LoRaRadioType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum LoRaRadioType { NO_RADIO, STM32WLx_RADIO, SIM_RADIO, RF95_RADIO, SX1262_RADIO, SX1268_RADIO, LLCC68_RADIO, SX1280_RADIO }; 4 | 5 | extern LoRaRadioType radioType; -------------------------------------------------------------------------------- /variants/ai-c3/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:ai-c3] 2 | extends = esp32c3_base 3 | board = esp32-c3-devkitm-1 4 | board_level = extra 5 | build_flags = ${esp32c3_base.build_flags} 6 | -D PRIVATE_HW 7 | -I variants/ai-c3 8 | 9 | -------------------------------------------------------------------------------- /.trunk/configs/ruff.toml: -------------------------------------------------------------------------------- 1 | # Generic, formatter-friendly config. 2 | select = ["B", "D3", "D4", "E", "F"] 3 | 4 | # Never enforce `E501` (line length violations). This should be handled by formatters. 5 | ignore = ["E501"] 6 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": true, 3 | "editor.defaultFormatter": "trunk.io", 4 | "trunk.enableWindows": true, 5 | "files.insertFinalNewline": false, 6 | "files.trimFinalNewlines": false 7 | } 8 | -------------------------------------------------------------------------------- /src/mesh/http/ContentHelper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define BoolToString(x) ((x) ? "true" : "false") 5 | 6 | void replaceAll(std::string &str, const std::string &from, const std::string &to); 7 | -------------------------------------------------------------------------------- /variants/rak11200/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:rak11200] 2 | extends = esp32_base 3 | board = wiscore_rak11200 4 | board_check = true 5 | build_flags = 6 | ${esp32_base.build_flags} -D RAK_11200 -I variants/rak11200 7 | upload_speed = 115200 -------------------------------------------------------------------------------- /bin/uf2-convert.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | if [%1]==[] (echo "Please specify a platformio NRF target (i.e. rak4631) as the first argument.") else (python3 .\bin\uf2conv.py .\.pio\build\%1\firmware.hex -c -o .\.pio\build\%1\firmware.uf2 -f 0xADA52840) -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.7" 2 | 3 | services: 4 | meshtastic-node: 5 | build: . 6 | deploy: 7 | mode: replicated 8 | replicas: 4 9 | networks: 10 | - mesh 11 | 12 | networks: 13 | mesh: 14 | -------------------------------------------------------------------------------- /src/DisplayFormatters.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "NodeDB.h" 3 | 4 | class DisplayFormatters 5 | { 6 | public: 7 | static const char *getModemPresetDisplayName(meshtastic_Config_LoRaConfig_ModemPreset preset, bool useShortName); 8 | }; 9 | -------------------------------------------------------------------------------- /variants/CDEBYTE_EoRa-S3/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:CDEBYTE_EoRa-S3] 2 | extends = esp32s3_base 3 | board = CDEBYTE_EoRa-S3 4 | build_flags = 5 | ${esp32s3_base.build_flags} 6 | -D CDEBYTE_EORA_S3 7 | -I variants/CDEBYTE_EoRa-S3 8 | -D GPS_POWER_TOGGLE -------------------------------------------------------------------------------- /src/mesh/Throttle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class Throttle 6 | { 7 | public: 8 | static bool execute(uint32_t *lastExecutionMs, uint32_t minumumIntervalMs, void (*func)(void), void (*onDefer)(void) = NULL); 9 | }; -------------------------------------------------------------------------------- /bin/meshtasticd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Meshtastic Native Daemon 3 | After=network-online.target 4 | 5 | [Service] 6 | User=root 7 | Group=root 8 | Type=simple 9 | ExecStart=/usr/sbin/meshtasticd 10 | 11 | [Install] 12 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /variants/nano-g1/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The 1.0 release of the nano-g1 board 2 | [env:nano-g1] 3 | extends = esp32_base 4 | board = ttgo-t-beam 5 | lib_deps = 6 | ${esp32_base.lib_deps} 7 | build_flags = 8 | ${esp32_base.build_flags} -D NANO_G1 -I variants/nano-g1 -------------------------------------------------------------------------------- /variants/tbeam_v07/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The original TBEAM board without the AXP power chip and a few other changes 2 | [env:tbeam0_7] 3 | extends = esp32_base 4 | board = ttgo-t-beam 5 | build_flags = 6 | ${esp32_base.build_flags} -D TBEAM_V07 -I variants/tbeam_v07 -------------------------------------------------------------------------------- /.trunk/configs/.shellcheckrc: -------------------------------------------------------------------------------- 1 | enable=all 2 | source-path=SCRIPTDIR 3 | disable=SC2154 4 | disable=SC2248 5 | disable=SC2250 6 | 7 | # If you're having issues with shellcheck following source, disable the errors via: 8 | # disable=SC1090 9 | # disable=SC1091 10 | # -------------------------------------------------------------------------------- /src/SPILock.cpp: -------------------------------------------------------------------------------- 1 | #include "SPILock.h" 2 | #include "configuration.h" 3 | #include 4 | #include 5 | 6 | concurrency::Lock *spiLock; 7 | 8 | void initSPI() 9 | { 10 | assert(!spiLock); 11 | spiLock = new concurrency::Lock(); 12 | } -------------------------------------------------------------------------------- /images/textsms-24px.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /variants/station-g1/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The 1.0 release of the nano-g1 board 2 | [env:station-g1] 3 | extends = esp32_base 4 | board = ttgo-t-beam 5 | lib_deps = 6 | ${esp32_base.lib_deps} 7 | build_flags = 8 | ${esp32_base.build_flags} -D STATION_G1 -I variants/station-g1 -------------------------------------------------------------------------------- /src/graphics/fonts/OLEDDisplayFontsRU.h: -------------------------------------------------------------------------------- 1 | #ifndef OLEDDISPLAYFONTSRU_h 2 | #define OLEDDISPLAYFONTSRU_h 3 | 4 | #ifdef ARDUINO 5 | #include 6 | #elif __MBED__ 7 | #define PROGMEM 8 | #endif 9 | 10 | extern const uint8_t ArialMT_Plain_10_RU[] PROGMEM; 11 | #endif -------------------------------------------------------------------------------- /src/graphics/fonts/OLEDDisplayFontsUA.h: -------------------------------------------------------------------------------- 1 | #ifndef OLEDDISPLAYFONTSUA_h 2 | #define OLEDDISPLAYFONTSUA_h 3 | 4 | #ifdef ARDUINO 5 | #include 6 | #elif __MBED__ 7 | #define PROGMEM 8 | #endif 9 | 10 | extern const uint8_t ArialMT_Plain_10_UA[] PROGMEM; 11 | #endif -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/VoltageSensor.h: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #pragma once 6 | 7 | class VoltageSensor 8 | { 9 | public: 10 | virtual uint16_t getBusVoltageMv() = 0; 11 | }; 12 | 13 | #endif -------------------------------------------------------------------------------- /variants/heltec_v2/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:heltec-v2_0] 2 | ;build_type = debug ; to make it possible to step through our jtag debugger 3 | extends = esp32_base 4 | board = heltec_wifi_lora_32_V2 5 | build_flags = 6 | ${esp32_base.build_flags} -D HELTEC_V2_0 -I variants/heltec_v2 -------------------------------------------------------------------------------- /src/target_specific.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // Functions that are unique to particular target types (esp32, bare, nrf52 etc...) 6 | 7 | // Enable/disable bluetooth. 8 | void setBluetoothEnable(bool enable); 9 | 10 | void getMacAddr(uint8_t *dmac); -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/TelemetrySensor.cpp: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "NodeDB.h" 7 | #include "TelemetrySensor.h" 8 | #include "main.h" 9 | 10 | #endif -------------------------------------------------------------------------------- /variants/heltec_v1/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:heltec-v1] 2 | ;build_type = debug ; to make it possible to step through our jtag debugger 3 | extends = esp32_base 4 | board_level = extra 5 | board = heltec_wifi_lora_32 6 | build_flags = 7 | ${esp32_base.build_flags} -D HELTEC_V1 -I variants/heltec_v1 -------------------------------------------------------------------------------- /.trunk/configs/.markdownlint.yaml: -------------------------------------------------------------------------------- 1 | # Autoformatter friendly markdownlint config (all formatting rules disabled) 2 | default: true 3 | blank_lines: false 4 | bullet: false 5 | html: false 6 | indentation: false 7 | line_length: false 8 | spaces: false 9 | url: false 10 | whitespace: false 11 | -------------------------------------------------------------------------------- /src/modules/ModuleDev.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | * To developers: 5 | * Use this to enable / disable features in your module that you don't want to risk checking into GitHub. 6 | * 7 | */ 8 | 9 | // Enable development more for StoreForwardModule 10 | bool StoreForward_Dev = false; -------------------------------------------------------------------------------- /variants/ppr1/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The PPR board 2 | [env:ppr1] 3 | extends = nrf52_base 4 | board = ppr1 5 | board_level = extra 6 | build_flags = ${nrf52_base.build_flags} -Ivariants/ppr1 7 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/ppr1> 8 | lib_deps = 9 | ${arduino_base.lib_deps} -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "ms-vscode.cpptools", 6 | "platformio.platformio-ide", 7 | "trunk.io" 8 | ], 9 | } 10 | -------------------------------------------------------------------------------- /arch/nrf52/nrf52840.ini: -------------------------------------------------------------------------------- 1 | [nrf52840_base] 2 | extends = nrf52_base 3 | 4 | build_flags = ${nrf52_base.build_flags} 5 | 6 | lib_deps = 7 | ${nrf52_base.lib_deps} 8 | ${environmental_base.lib_deps} 9 | https://github.com/Kongduino/Adafruit_nRFCrypto.git#e31a8825ea3300b163a0a3c1ddd5de34e10e1371 10 | -------------------------------------------------------------------------------- /images/room-24px.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /variants/nano-g1-explorer/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The 1.0 release of the nano-g1-explorer board 2 | [env:nano-g1-explorer] 3 | extends = esp32_base 4 | board = ttgo-t-beam 5 | lib_deps = 6 | ${esp32_base.lib_deps} 7 | build_flags = 8 | ${esp32_base.build_flags} -D NANO_G1_EXPLORER -I variants/nano-g1-explorer -------------------------------------------------------------------------------- /.trunk/configs/.yamllint.yaml: -------------------------------------------------------------------------------- 1 | rules: 2 | quoted-strings: 3 | required: only-when-needed 4 | extra-allowed: ["{|}"] 5 | empty-values: 6 | forbid-in-block-mappings: false 7 | forbid-in-flow-mappings: true 8 | key-duplicates: {} 9 | octal-values: 10 | forbid-implicit-octal: true 11 | -------------------------------------------------------------------------------- /bin/test-simulator.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | echo "Starting simulator" 6 | .pio/build/native/program & 7 | sleep 20 # 5 seconds was not enough 8 | 9 | echo "Simulator started, launching python test..." 10 | python3 -c 'from meshtastic.test import testSimulator; testSimulator()' 11 | 12 | -------------------------------------------------------------------------------- /variants/wio-e5/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:wio-e5] 2 | extends = stm32wl5e_base 3 | board_level = extra 4 | build_flags = 5 | ${stm32wl5e_base.build_flags} 6 | -Ivariants/wio-e5 7 | -DHAL_DAC_MODULE_ONLY 8 | -DSERIAL_UART_INSTANCE=1 9 | -DPIN_SERIAL_RX=PB7 10 | -DPIN_SERIAL_TX=PB6 11 | upload_port = stlink -------------------------------------------------------------------------------- /src/OSTimer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef void (*PendableFunction)(void *pvParameter1, uint32_t ulParameter2); 6 | 7 | /// Uses a hardware timer, but calls the handler in _interrupt_ context 8 | bool scheduleHWCallback(PendableFunction callback, void *param1, uint32_t param2, uint32_t delayMsec); -------------------------------------------------------------------------------- /src/concurrency/LockGuard.cpp: -------------------------------------------------------------------------------- 1 | #include "LockGuard.h" 2 | #include "configuration.h" 3 | 4 | namespace concurrency 5 | { 6 | 7 | LockGuard::LockGuard(Lock *lock) : lock(lock) 8 | { 9 | lock->lock(); 10 | } 11 | 12 | LockGuard::~LockGuard() 13 | { 14 | lock->unlock(); 15 | } 16 | 17 | } // namespace concurrency 18 | -------------------------------------------------------------------------------- /src/SPILock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../concurrency/LockGuard.h" 4 | 5 | /** 6 | * Used to provide mutual exclusion for access to the SPI bus. Usage: 7 | * concurrency::LockGuard g(spiLock); 8 | */ 9 | extern concurrency::Lock *spiLock; 10 | 11 | /** Setup SPI access and create the spiLock lock. */ 12 | void initSPI(); -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/portnums.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/portnums.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /variants/EBYTE_ESP32-S3/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:EBYTE_ESP32-S3] 2 | extends = esp32s3_base 3 | ; board assumes the lowest spec WROOM module: 4 MB (Quad SPI) Flash, No PSRAM 4 | board = ESP32-S3-WROOM-1-N4 5 | board_level = extra 6 | build_flags = 7 | ${esp32s3_base.build_flags} 8 | -D EBYTE_ESP32_S3 9 | -I variants/EBYTE_ESP32-S3 10 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "type": "PlatformIO", 6 | "task": "Build", 7 | "problemMatcher": ["$platformio"], 8 | "group": { 9 | "kind": "build", 10 | "isDefault": true 11 | }, 12 | "label": "PlatformIO: Build" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /variants/tlora_v2_1_16/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:tlora-v2-1-1_6] 2 | extends = esp32_base 3 | board = ttgo-lora32-v21 4 | board_check = true 5 | build_flags = 6 | ${esp32_base.build_flags} -D TLORA_V2_1_16 -I variants/tlora_v2_1_16 7 | -DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. -------------------------------------------------------------------------------- /src/memGet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _MT_MEMGET_H 3 | #define _MT_MEMGET_H 4 | 5 | #include 6 | 7 | class MemGet 8 | { 9 | public: 10 | uint32_t getFreeHeap(); 11 | uint32_t getHeapSize(); 12 | uint32_t getFreePsram(); 13 | uint32_t getPsramSize(); 14 | }; 15 | 16 | extern MemGet memGet; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /variants/heltec_esp32c3/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:heltec-ht62-esp32c3-sx1262] 2 | extends = esp32c3_base 3 | board = esp32-c3-devkitm-1 4 | build_flags = 5 | ${esp32_base.build_flags} 6 | -D HELTEC_HT62 7 | -I variants/heltec_esp32c3 8 | monitor_speed = 115200 9 | upload_protocol = esptool 10 | ;upload_port = /dev/ttyUSB0 11 | upload_speed = 921600 -------------------------------------------------------------------------------- /src/mesh/LLCC68Interface.cpp: -------------------------------------------------------------------------------- 1 | #include "LLCC68Interface.h" 2 | #include "configuration.h" 3 | #include "error.h" 4 | 5 | LLCC68Interface::LLCC68Interface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, 6 | RADIOLIB_PIN_TYPE busy) 7 | : SX126xInterface(hal, cs, irq, rst, busy) 8 | { 9 | } -------------------------------------------------------------------------------- /src/mesh/SX1262Interface.cpp: -------------------------------------------------------------------------------- 1 | #include "SX1262Interface.h" 2 | #include "configuration.h" 3 | #include "error.h" 4 | 5 | SX1262Interface::SX1262Interface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, 6 | RADIOLIB_PIN_TYPE busy) 7 | : SX126xInterface(hal, cs, irq, rst, busy) 8 | { 9 | } -------------------------------------------------------------------------------- /src/input/LinuxInputImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | #if ARCH_PORTDUINO 3 | #include "InputBroker.h" 4 | #include "LinuxInputImpl.h" 5 | 6 | LinuxInputImpl *aLinuxInputImpl; 7 | 8 | LinuxInputImpl::LinuxInputImpl() : LinuxInput("LinuxInput") {} 9 | 10 | void LinuxInputImpl::init() 11 | { 12 | inputBroker->registerSource(this); 13 | } 14 | 15 | #endif -------------------------------------------------------------------------------- /variants/tlora_v2_1_16_tcxo/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:tlora-v2-1-1_6-tcxo] 2 | extends = esp32_base 3 | board = ttgo-lora32-v21 4 | build_flags = 5 | ${esp32_base.build_flags} 6 | -D TLORA_V2_1_16 7 | -I variants/tlora_v2_1_16 8 | -D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. 9 | -D LORA_TCXO_GPIO=33 -------------------------------------------------------------------------------- /.trunk/configs/svgo.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | { 4 | name: "preset-default", 5 | params: { 6 | overrides: { 7 | removeViewBox: false, // https://github.com/svg/svgo/issues/1128 8 | sortAttrs: true, 9 | removeOffCanvasPaths: true, 10 | }, 11 | }, 12 | }, 13 | ], 14 | }; 15 | -------------------------------------------------------------------------------- /src/mesh/SX1280Interface.cpp: -------------------------------------------------------------------------------- 1 | #include "SX1280Interface.h" 2 | #include "configuration.h" 3 | #include "error.h" 4 | 5 | SX1280Interface::SX1280Interface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, 6 | RADIOLIB_PIN_TYPE busy) 7 | : SX128xInterface(hal, cs, irq, rst, busy) 8 | { 9 | } 10 | -------------------------------------------------------------------------------- /src/platform/portduino/architecture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define ARCH_PORTDUINO 1 4 | 5 | // 6 | // set HW_VENDOR 7 | // 8 | 9 | #define HW_VENDOR meshtastic_HardwareModel_PORTDUINO 10 | 11 | #ifndef HAS_WIFI 12 | #define HAS_WIFI 1 13 | #endif 14 | #ifndef HAS_RTC 15 | #define HAS_RTC 1 16 | #endif 17 | #ifndef HAS_TELEMETRY 18 | #define HAS_TELEMETRY 1 19 | #endif -------------------------------------------------------------------------------- /variants/m5stack-stamp-c3/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:m5stack-stamp-c3] 2 | extends = esp32c3_base 3 | board = esp32-c3-devkitm-1 4 | board_level = extra 5 | build_flags = 6 | ${esp32_base.build_flags} 7 | -D PRIVATE_HW 8 | -I variants/m5stack-stamp-c3 9 | monitor_speed = 115200 10 | upload_protocol = esptool 11 | ;upload_port = /dev/ttyACM2 12 | upload_speed = 921600 13 | -------------------------------------------------------------------------------- /variants/tlora_t3s3_v1/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:tlora-t3s3-v1] 2 | extends = esp32s3_base 3 | board = tlora-t3s3-v1 4 | board_check = true 5 | upload_protocol = esp-builtin 6 | 7 | build_flags = 8 | ${esp32_base.build_flags} -D TLORA_T3S3_V1 -I variants/tlora_t3s3_v1 9 | -DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. -------------------------------------------------------------------------------- /src/RF95Configuration.h: -------------------------------------------------------------------------------- 1 | // TODO refactor this out with better radio configuration system 2 | #ifdef USE_RF95 3 | #define RF95_RESET LORA_RESET 4 | #define RF95_IRQ LORA_DIO0 // on SX1262 version this is a no connect DIO0 5 | #define RF95_DIO1 LORA_DIO1 // Note: not really used for RF95, but used for pure SX127x 6 | #define RF95_DIO2 LORA_DIO2 // Note: not really used for RF95 7 | #endif -------------------------------------------------------------------------------- /src/mesh/SX1262Interface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SX126xInterface.h" 4 | 5 | /** 6 | * Our adapter for SX1262 radios 7 | */ 8 | class SX1262Interface : public SX126xInterface 9 | { 10 | public: 11 | SX1262Interface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, 12 | RADIOLIB_PIN_TYPE busy); 13 | }; -------------------------------------------------------------------------------- /images/location_searching-24px.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/input/cardKbI2cImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "cardKbI2cImpl.h" 2 | #include "InputBroker.h" 3 | 4 | CardKbI2cImpl *cardKbI2cImpl; 5 | 6 | CardKbI2cImpl::CardKbI2cImpl() : KbI2cBase("cardKB") {} 7 | 8 | void CardKbI2cImpl::init() 9 | { 10 | if (cardkb_found.address == 0x00) { 11 | disable(); 12 | return; 13 | } 14 | 15 | inputBroker->registerSource(this); 16 | } 17 | -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/apponly.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/apponly.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_ChannelSet, meshtastic_ChannelSet, 2) 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/paxcount.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/paxcount.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_Paxcount, meshtastic_Paxcount, AUTO) 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/rtttl.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/rtttl.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_RTTTLConfig, meshtastic_RTTTLConfig, AUTO) 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/xmodem.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/xmodem.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_XModem, meshtastic_XModem, AUTO) 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /variants/heltec_v2.1/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:heltec-v2_1] 2 | ;build_type = debug ; to make it possible to step through our jtag debugger 3 | extends = esp32_base 4 | board = heltec_wifi_lora_32_V2 5 | build_flags = 6 | ${esp32_base.build_flags} -D HELTEC_V2_1 -I variants/heltec_v2.1 7 | -DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. -------------------------------------------------------------------------------- /src/input/UpDownInterruptImpl1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "UpDownInterruptBase.h" 3 | 4 | class UpDownInterruptImpl1 : public UpDownInterruptBase 5 | { 6 | public: 7 | UpDownInterruptImpl1(); 8 | bool init(); 9 | static void handleIntDown(); 10 | static void handleIntUp(); 11 | static void handleIntPressed(); 12 | }; 13 | 14 | extern UpDownInterruptImpl1 *upDownInterruptImpl1; -------------------------------------------------------------------------------- /src/mesh/SX1280Interface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SX128xInterface.h" 4 | 5 | /** 6 | * Our adapter for SX1280 radios 7 | */ 8 | 9 | class SX1280Interface : public SX128xInterface 10 | { 11 | public: 12 | SX1280Interface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, 13 | RADIOLIB_PIN_TYPE busy); 14 | }; 15 | -------------------------------------------------------------------------------- /variants/heltec_wsl_v3/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:heltec-wsl-v3] 2 | extends = esp32s3_base 3 | board = heltec_wifi_lora_32_V3 4 | # Temporary until espressif creates a release with this new target 5 | build_flags = 6 | ${esp32s3_base.build_flags} -D HELTEC_WSL_V3 -I variants/heltec_wsl_v3 7 | -DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. -------------------------------------------------------------------------------- /variants/heltec_v3/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:heltec-v3] 2 | extends = esp32s3_base 3 | board = heltec_wifi_lora_32_V3 4 | board_check = true 5 | # Temporary until espressif creates a release with this new target 6 | build_flags = 7 | ${esp32s3_base.build_flags} -D HELTEC_V3 -I variants/heltec_v3 8 | -DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. -------------------------------------------------------------------------------- /src/gps/NMEAWPL.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "main.h" 4 | #include 5 | 6 | uint32_t printWPL(char *buf, size_t bufsz, const meshtastic_Position &pos, const char *name, bool isCaltopoMode = false); 7 | uint32_t printWPL(char *buf, size_t bufsz, const meshtastic_PositionLite &pos, const char *name, bool isCaltopoMode = false); 8 | uint32_t printGGA(char *buf, size_t bufsz, const meshtastic_Position &pos); -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/clientonly.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/clientonly.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_DeviceProfile, meshtastic_DeviceProfile, 2) 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /bin/native-install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cp "release/meshtasticd_linux_$(uname -m)" /usr/sbin/meshtasticd 4 | mkdir /etc/meshtasticd 5 | if [[ -f "/etc/meshtasticd/config.yaml" ]]; then 6 | cp bin/config-dist.yaml /etc/meshtasticd/config-upgrade.yaml 7 | else 8 | cp bin/config-dist.yaml /etc/meshtasticd/config.yaml 9 | fi 10 | cp bin/meshtasticd.service /usr/lib/systemd/system/meshtasticd.service 11 | -------------------------------------------------------------------------------- /variants/chatter2/platformio.ini: -------------------------------------------------------------------------------- 1 | ; CircuitMess Chatter 2 based on ESP32-WROOM-32 (38 pins) devkit & DeeamLNK DL-LLCC68 or Heltec HT RA62 SX1262/SX1268 module 2 | [env:chatter2] 3 | extends = esp32_base 4 | board = esp32doit-devkit-v1 5 | build_flags = 6 | ${esp32_base.build_flags} 7 | -D CHATTER_2 8 | -I variants/chatter2 9 | 10 | lib_deps = 11 | ${esp32_base.lib_deps} 12 | lovyan03/LovyanGFX@^1.1.8 -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/remote_hardware.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/remote_hardware.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_HardwareMessage, meshtastic_HardwareMessage, AUTO) 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/platform/esp32/BleOta.h: -------------------------------------------------------------------------------- 1 | #ifndef BLEOTA_H 2 | #define BLEOTA_H 3 | 4 | #include 5 | #include 6 | 7 | class BleOta 8 | { 9 | public: 10 | explicit BleOta(){}; 11 | 12 | static String getOtaAppVersion(); 13 | static bool switchToOtaApp(); 14 | 15 | private: 16 | String mUserAgent; 17 | static const esp_partition_t *findEspOtaAppPartition(); 18 | }; 19 | 20 | #endif // BLEOTA_H -------------------------------------------------------------------------------- /variants/tbeam/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The 1.0 release of the TBEAM board 2 | [env:tbeam] 3 | extends = esp32_base 4 | board = ttgo-t-beam 5 | board_check = true 6 | lib_deps = 7 | ${esp32_base.lib_deps} 8 | build_flags = 9 | ${esp32_base.build_flags} -D TBEAM_V10 -I variants/tbeam 10 | -DGPS_POWER_TOGGLE ; comment this line to disable double press function on the user button to turn off gps entirely. 11 | upload_speed = 921600 -------------------------------------------------------------------------------- /variants/picomputer-s3/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:picomputer-s3] 2 | extends = esp32s3_base 3 | board = bpi_picow_esp32_s3 4 | 5 | ;OpenOCD flash method 6 | ;upload_protocol = esp-builtin 7 | ;Normal method 8 | upload_protocol = esptool 9 | 10 | build_flags = 11 | ${esp32s3_base.build_flags} 12 | -DPICOMPUTER_S3 13 | -I variants/picomputer-s3 14 | 15 | lib_deps = 16 | ${esp32s3_base.lib_deps} 17 | lovyan03/LovyanGFX@^1.1.8 18 | -------------------------------------------------------------------------------- /variants/wiphone/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:wiphone] 2 | extends = esp32_base 3 | board = wiphone 4 | board_level = extra 5 | monitor_filters = esp32_exception_decoder 6 | board_build.partitions = default_16MB.csv 7 | build_flags = 8 | ${esp32_base.build_flags} -D WIPHONE -I variants/wiphone 9 | lib_deps = 10 | ${esp32_base.lib_deps} 11 | lovyan03/LovyanGFX@^1.1.8 12 | sparkfun/SX1509 IO Expander@^3.0.5 13 | pololu/APA102@^3.0.0 -------------------------------------------------------------------------------- /src/mesh/SX1268Interface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SX126xInterface.h" 4 | 5 | /** 6 | * Our adapter for SX1268 radios 7 | */ 8 | class SX1268Interface : public SX126xInterface 9 | { 10 | public: 11 | virtual float getFreq() override; 12 | 13 | SX1268Interface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, 14 | RADIOLIB_PIN_TYPE busy); 15 | }; 16 | -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/cannedmessages.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/cannedmessages.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_CannedMessageModuleConfig, meshtastic_CannedMessageModuleConfig, AUTO) 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /variants/wio-e5/variant.h: -------------------------------------------------------------------------------- 1 | /* 2 | Wio-E5 mini (formerly LoRa-E5 mini) 3 | https://www.seeedstudio.com/LoRa-E5-mini-STM32WLE5JC-p-4869.html 4 | https://www.seeedstudio.com/LoRa-E5-Wireless-Module-p-4745.html 5 | */ 6 | 7 | /* 8 | This variant is a work in progress. 9 | Do not expect a working Meshtastic device with this target. 10 | */ 11 | 12 | #ifndef _VARIANT_WIOE5_ 13 | #define _VARIANT_WIOE5_ 14 | 15 | #define USE_STM32WLx 16 | 17 | #endif -------------------------------------------------------------------------------- /arch/esp32/esp32s2.ini: -------------------------------------------------------------------------------- 1 | [esp32s2_base] 2 | extends = esp32_base 3 | 4 | build_src_filter = 5 | ${esp32_base.build_src_filter} - - - 6 | 7 | monitor_speed = 115200 8 | 9 | build_flags = 10 | ${esp32_base.build_flags} 11 | -DHAS_BLUETOOTH=0 12 | -DMESHTASTIC_EXCLUDE_PAXCOUNTER 13 | -DMESHTASTIC_EXCLUDE_BLUETOOTH 14 | 15 | lib_ignore = 16 | ${esp32_base.lib_ignore} 17 | NimBLE-Arduino 18 | libpax -------------------------------------------------------------------------------- /partition-table.csv: -------------------------------------------------------------------------------- 1 | # FIXME! using the genpartitions based table doesn't work on TTGO so for now I stay with my old memory map 2 | # This is a layout for 4MB of flash 3 | # Name, Type, SubType, Offset, Size, Flags 4 | nvs, data, nvs, 0x009000, 0x005000, 5 | otadata, data, ota, 0x00e000, 0x002000, 6 | app, app, ota_0, 0x010000, 0x250000, 7 | flashApp, app, ota_1, 0x260000, 0x0A0000, 8 | spiffs, data, spiffs, 0x300000, 0x100000, -------------------------------------------------------------------------------- /src/meshUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /// C++ v17+ clamp function, limits a given value to a range defined by lo and hi 4 | template constexpr const T &clamp(const T &v, const T &lo, const T &hi) 5 | { 6 | return (v < lo) ? lo : (hi < v) ? hi : v; 7 | } 8 | 9 | #if (defined(ARCH_PORTDUINO) && !defined(STRNSTR)) 10 | #define STRNSTR 11 | #include 12 | char *strnstr(const char *s, const char *find, size_t slen); 13 | #endif -------------------------------------------------------------------------------- /src/network-stubs.cpp: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if (HAS_WIFI == 0) 4 | 5 | bool initWifi() 6 | { 7 | return false; 8 | } 9 | 10 | void deinitWifi() {} 11 | 12 | bool isWifiAvailable() 13 | { 14 | return false; 15 | } 16 | 17 | #endif 18 | 19 | #if (HAS_ETHERNET == 0) 20 | 21 | bool initEthernet() 22 | { 23 | return false; 24 | } 25 | 26 | bool isEthernetAvailable() 27 | { 28 | return false; 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/input/kbMatrixImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "kbMatrixImpl.h" 2 | #include "InputBroker.h" 3 | 4 | #ifdef INPUTBROKER_MATRIX_TYPE 5 | 6 | KbMatrixImpl *kbMatrixImpl; 7 | 8 | KbMatrixImpl::KbMatrixImpl() : KbMatrixBase("matrixKB") {} 9 | 10 | void KbMatrixImpl::init() 11 | { 12 | if (!INPUTBROKER_MATRIX_TYPE) { 13 | disable(); 14 | return; 15 | } 16 | 17 | inputBroker->registerSource(this); 18 | } 19 | 20 | #endif // INPUTBROKER_MATRIX_TYPE -------------------------------------------------------------------------------- /variants/TWC_mesh_v4/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:TWC_mesh_v4] 2 | extends = nrf52840_base 3 | board = nordic_pca10059 4 | board_level = extra 5 | build_flags = ${nrf52840_base.build_flags} -I variants/TWC_mesh_v4 -D TWC_mesh_v4 -L".pio\libdeps\TWC_mesh_v4\bsec2\src\cortex-m4\fpv4-sp-d16-hard" 6 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/TWC_mesh_v4> 7 | lib_deps = 8 | ${nrf52840_base.lib_deps} 9 | zinggjm/GxEPD2@^1.4.9 10 | debug_tool = jlink -------------------------------------------------------------------------------- /variants/senselora_rp2040/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:senselora_rp2040] 2 | extends = rp2040_base 3 | board = rpipico 4 | upload_protocol = picotool 5 | 6 | # add our variants files to the include and src paths 7 | build_flags = ${rp2040_base.build_flags} 8 | -DSENSELORA_RP2040 9 | -Ivariants/senselora_rp2040 10 | -DDEBUG_RP2040_PORT=Serial 11 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" 12 | lib_deps = 13 | ${rp2040_base.lib_deps} -------------------------------------------------------------------------------- /src/concurrency/LockGuard.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Lock.h" 4 | 5 | namespace concurrency 6 | { 7 | 8 | /** 9 | * @brief RAII lock guard 10 | */ 11 | class LockGuard 12 | { 13 | public: 14 | explicit LockGuard(Lock *lock); 15 | ~LockGuard(); 16 | 17 | LockGuard(const LockGuard &) = delete; 18 | LockGuard &operator=(const LockGuard &) = delete; 19 | 20 | private: 21 | Lock *lock; 22 | }; 23 | 24 | } // namespace concurrency 25 | -------------------------------------------------------------------------------- /variants/bpi_picow_esp32_s3/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:bpi_picow_esp32_s3] 2 | extends = esp32s3_base 3 | board = bpi_picow_esp32_s3 4 | board_level = extra 5 | ;OpenOCD flash method 6 | ;upload_protocol = esp-builtin 7 | ;Normal method 8 | upload_protocol = esptool 9 | ;upload_port = /dev/ttyACM2 10 | lib_deps = 11 | ${esp32_base.lib_deps} 12 | caveman99/ESP32 Codec2@^1.0.1 13 | build_flags = 14 | ${esp32_base.build_flags} -D PRIVATE_HW -I variants/bpi_picow_esp32_s3 -------------------------------------------------------------------------------- /variants/tbeam-s3-core/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The 1.0 release of the LilyGo TBEAM-S3-Core board 2 | [env:tbeam-s3-core] 3 | extends = esp32s3_base 4 | board = tbeam-s3-core 5 | board_check = true 6 | 7 | lib_deps = 8 | ${esp32s3_base.lib_deps} 9 | lewisxhe/PCF8563_Library@1.0.1 10 | 11 | build_flags = 12 | ${esp32s3_base.build_flags} 13 | -Ivariants/tbeam-s3-core 14 | -DPCF8563_RTC=0x51 ;Putting definitions in variant.h does not compile correctly 15 | -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/mqtt.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/mqtt.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_ServiceEnvelope, meshtastic_ServiceEnvelope, AUTO) 10 | 11 | 12 | PB_BIND(meshtastic_MapReport, meshtastic_MapReport, AUTO) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/nimble/NimbleBluetooth.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "BluetoothCommon.h" 3 | 4 | class NimbleBluetooth : BluetoothApi 5 | { 6 | public: 7 | void setup(); 8 | void shutdown(); 9 | void deinit(); 10 | void clearBonds(); 11 | bool isActive(); 12 | bool isConnected(); 13 | int getRssi(); 14 | 15 | private: 16 | void setupService(); 17 | void startAdvertising(); 18 | }; 19 | 20 | void setBluetoothEnable(bool enable); 21 | void clearNVS(); -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/localonly.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/localonly.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_LocalConfig, meshtastic_LocalConfig, 2) 10 | 11 | 12 | PB_BIND(meshtastic_LocalModuleConfig, meshtastic_LocalModuleConfig, 2) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /bin/promote-release.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | echo "This script is only for developers who are publishing new builds on github. Most users don't need it" 6 | 7 | VERSION=`bin/buildinfo.py long` 8 | 9 | # Must have a V prefix to trigger github 10 | git tag "v${VERSION}" 11 | 12 | git push origin "v${VERSION}" # push the tag 13 | 14 | echo "Tag ${VERSION} pushed to github, github actions should now be building the draft release. If it seems good, click to publish it" 15 | -------------------------------------------------------------------------------- /src/platform/stm32wl/architecture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define ARCH_STM32WL 4 | 5 | // 6 | // defaults for STM32WL architecture 7 | // 8 | 9 | #ifndef HAS_RADIO 10 | #define HAS_RADIO 1 11 | #endif 12 | 13 | // 14 | // set HW_VENDOR 15 | // 16 | 17 | #ifndef HW_VENDOR 18 | #define HW_VENDOR meshtastic_HardwareModel_PRIVATE_HW 19 | #endif 20 | 21 | /* virtual pins */ 22 | #define SX126X_CS 1000 23 | #define SX126X_DIO1 1001 24 | #define SX126X_RESET 1003 25 | #define SX126X_BUSY 1004 26 | -------------------------------------------------------------------------------- /.github/workflows/nightly.yml: -------------------------------------------------------------------------------- 1 | name: Nightly 2 | on: 3 | schedule: 4 | - cron: 0 8 * * 1-5 5 | workflow_dispatch: {} 6 | 7 | jobs: 8 | trunk_check: 9 | name: Trunk Check Upload 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v4 15 | 16 | - name: Trunk Check 17 | uses: trunk-io/trunk-action@782e83f803ca6e369f035d64c6ba2768174ba61b 18 | with: 19 | trunk-token: ${{ secrets.TRUNK_TOKEN }} 20 | -------------------------------------------------------------------------------- /src/input/InputBroker.cpp: -------------------------------------------------------------------------------- 1 | #include "InputBroker.h" 2 | #include "PowerFSM.h" // needed for event trigger 3 | 4 | InputBroker *inputBroker; 5 | 6 | InputBroker::InputBroker(){}; 7 | 8 | void InputBroker::registerSource(Observable *source) 9 | { 10 | this->inputEventObserver.observe(source); 11 | } 12 | 13 | int InputBroker::handleInputEvent(const InputEvent *event) 14 | { 15 | powerFSM.trigger(EVENT_INPUT); 16 | this->notifyObservers(event); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /src/input/TrackballInterruptImpl1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "TrackballInterruptBase.h" 3 | 4 | class TrackballInterruptImpl1 : public TrackballInterruptBase 5 | { 6 | public: 7 | TrackballInterruptImpl1(); 8 | void init(); 9 | static void handleIntDown(); 10 | static void handleIntUp(); 11 | static void handleIntLeft(); 12 | static void handleIntRight(); 13 | static void handleIntPressed(); 14 | }; 15 | 16 | extern TrackballInterruptImpl1 *trackballInterruptImpl1; 17 | -------------------------------------------------------------------------------- /src/mesh/http/WebServer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "PhoneAPI.h" 4 | #include "concurrency/OSThread.h" 5 | #include 6 | #include 7 | 8 | void initWebServer(); 9 | void createSSLCert(); 10 | 11 | class WebServerThread : private concurrency::OSThread 12 | { 13 | 14 | public: 15 | WebServerThread(); 16 | uint32_t requestRestart = 0; 17 | 18 | protected: 19 | virtual int32_t runOnce() override; 20 | }; 21 | 22 | extern WebServerThread *webServerThread; 23 | -------------------------------------------------------------------------------- /src/input/kbMatrixBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "InputBroker.h" 4 | #include "concurrency/OSThread.h" 5 | 6 | class KbMatrixBase : public Observable, public concurrency::OSThread 7 | { 8 | public: 9 | explicit KbMatrixBase(const char *name); 10 | 11 | protected: 12 | virtual int32_t runOnce() override; 13 | 14 | private: 15 | const char *_originName; 16 | bool firstTime = 1; 17 | int shift = 0; 18 | char key = 0; 19 | char prevkey = 0; 20 | }; -------------------------------------------------------------------------------- /src/mesh/TypeConversions.h: -------------------------------------------------------------------------------- 1 | #include "mesh/generated/meshtastic/deviceonly.pb.h" 2 | #include "mesh/generated/meshtastic/mesh.pb.h" 3 | 4 | #pragma once 5 | #include "NodeDB.h" 6 | 7 | class TypeConversions 8 | { 9 | public: 10 | static meshtastic_NodeInfo ConvertToNodeInfo(const meshtastic_NodeInfoLite *lite); 11 | static meshtastic_PositionLite ConvertToPositionLite(meshtastic_Position position); 12 | static meshtastic_Position ConvertToPosition(meshtastic_PositionLite lite); 13 | }; 14 | -------------------------------------------------------------------------------- /variants/t-deck/platformio.ini: -------------------------------------------------------------------------------- 1 | ; LilyGo T-Deck 2 | [env:t-deck] 3 | extends = esp32s3_base 4 | board = t-deck 5 | board_check = true 6 | upload_protocol = esptool 7 | #upload_port = COM29 8 | 9 | build_flags = ${esp32_base.build_flags} 10 | -DT_DECK 11 | -DBOARD_HAS_PSRAM 12 | -DMAX_THREADS=40 13 | -DGPS_POWER_TOGGLE 14 | -Ivariants/t-deck 15 | 16 | lib_deps = ${esp32s3_base.lib_deps} 17 | lovyan03/LovyanGFX@^1.1.9 18 | earlephilhower/ESP8266Audio@^1.9.7 19 | earlephilhower/ESP8266SAM@^1.0.1 -------------------------------------------------------------------------------- /variants/betafpv_900_tx_nano/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:betafpv_900_tx_nano] 2 | extends = esp32_base 3 | board = esp32doit-devkit-v1 4 | board_level = extra 5 | build_flags = 6 | ${esp32_base.build_flags} 7 | -D BETAFPV_900_TX_NANO 8 | -D VTABLES_IN_FLASH=1 9 | -D CONFIG_DISABLE_HAL_LOCKS=1 10 | -O2 11 | -I variants/betafpv_900_tx_nano 12 | board_build.f_cpu = 240000000L 13 | upload_protocol = esptool 14 | ;upload_port = /dev/ttyUSB0 15 | upload_speed = 460800 16 | lib_deps = 17 | ${esp32_base.lib_deps} -------------------------------------------------------------------------------- /src/mesh/wifi/WiFiAPClient.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "concurrency/Periodic.h" 4 | #include "configuration.h" 5 | #include 6 | #include 7 | 8 | #if HAS_WIFI && !defined(ARCH_PORTDUINO) 9 | #include 10 | #endif 11 | 12 | extern bool needReconnect; 13 | extern concurrency::Periodic *wifiReconnect; 14 | 15 | /// @return true if wifi is now in use 16 | bool initWifi(); 17 | 18 | void deinitWifi(); 19 | 20 | bool isWifiAvailable(); 21 | 22 | uint8_t getWifiDisconnectReason(); -------------------------------------------------------------------------------- /src/error.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "mesh/generated/meshtastic/mesh.pb.h" // For CriticalErrorCode 6 | 7 | /// A macro that include filename and line 8 | #define RECORD_CRITICALERROR(code) recordCriticalError(code, __LINE__, __FILE__) 9 | 10 | /// Record an error that should be reported via analytics 11 | void recordCriticalError(meshtastic_CriticalErrorCode code = meshtastic_CriticalErrorCode_UNSPECIFIED, uint32_t address = 0, 12 | const char *filename = NULL); -------------------------------------------------------------------------------- /src/input/TouchScreenImpl1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "TouchScreenBase.h" 3 | 4 | class TouchScreenImpl1 : public TouchScreenBase 5 | { 6 | public: 7 | TouchScreenImpl1(uint16_t width, uint16_t height, bool (*getTouch)(int16_t *, int16_t *)); 8 | void init(void); 9 | 10 | protected: 11 | virtual bool getTouch(int16_t &x, int16_t &y); 12 | virtual void onEvent(const TouchEvent &event); 13 | 14 | bool (*_getTouch)(int16_t *, int16_t *); 15 | }; 16 | 17 | extern TouchScreenImpl1 *touchScreenImpl1; 18 | -------------------------------------------------------------------------------- /bin/bump_version.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Bump the version number""" 3 | 4 | lines = None 5 | 6 | with open('version.properties', 'r', encoding='utf-8') as f: 7 | lines = f.readlines() 8 | 9 | with open('version.properties', 'w', encoding='utf-8') as f: 10 | for line in lines: 11 | if line.lstrip().startswith("build = "): 12 | words = line.split(" = ") 13 | ver = f'build = {int(words[1]) + 1}' 14 | f.write(f'{ver}\n') 15 | else: 16 | f.write(line) 17 | -------------------------------------------------------------------------------- /variants/rak11310/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:rak11310] 2 | extends = rp2040_base 3 | board = wiscore_rak11300 4 | upload_protocol = picotool 5 | 6 | # add our variants files to the include and src paths 7 | build_flags = ${rp2040_base.build_flags} 8 | -DRAK11310 9 | -Ivariants/rak11310 10 | -DDEBUG_RP2040_PORT=Serial 11 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" 12 | lib_deps = 13 | ${rp2040_base.lib_deps} 14 | debug_build_flags = ${rp2040_base.build_flags} 15 | debug_tool = cmsis-dap ; for e.g. Picotool -------------------------------------------------------------------------------- /variants/station-g2/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:station-g2] 2 | extends = esp32s3_base 3 | board = station-g2 4 | board_check = true 5 | board_build.mcu = esp32s3 6 | upload_protocol = esptool 7 | ;upload_port = /dev/ttyACM0 8 | upload_speed = 921600 9 | lib_deps = 10 | ${esp32s3_base.lib_deps} 11 | build_unflags = 12 | ${esp32s3_base.build_unflags} 13 | -DARDUINO_USB_MODE=1 14 | build_flags = 15 | ${esp32s3_base.build_flags} -D STATION_G2 -I variants/station-g2 16 | -DBOARD_HAS_PSRAM 17 | -DSTATION_G2 18 | -DARDUINO_USB_MODE=0 -------------------------------------------------------------------------------- /src/commands.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @brief This class enables on the fly software and hardware setup. 3 | * It will contain all command messages to change internal settings. 4 | */ 5 | 6 | enum class Cmd { 7 | INVALID, 8 | SET_ON, 9 | SET_OFF, 10 | ON_PRESS, 11 | START_BLUETOOTH_PIN_SCREEN, 12 | START_FIRMWARE_UPDATE_SCREEN, 13 | STOP_BLUETOOTH_PIN_SCREEN, 14 | STOP_BOOT_SCREEN, 15 | PRINT, 16 | START_SHUTDOWN_SCREEN, 17 | START_REBOOT_SCREEN, 18 | SHOW_PREV_FRAME, 19 | SHOW_NEXT_FRAME 20 | }; -------------------------------------------------------------------------------- /variants/t-watch-s3/platformio.ini: -------------------------------------------------------------------------------- 1 | ; LilyGo T-Watch S3 2 | [env:t-watch-s3] 3 | extends = esp32s3_base 4 | board = t-watch-s3 5 | board_check = true 6 | upload_protocol = esptool 7 | 8 | build_flags = ${esp32_base.build_flags} 9 | -DT_WATCH_S3 10 | -Ivariants/t-watch-s3 11 | -DPCF8563_RTC=0x51 12 | 13 | lib_deps = ${esp32s3_base.lib_deps} 14 | lovyan03/LovyanGFX@^1.1.9 15 | lewisxhe/PCF8563_Library@1.0.1 16 | adafruit/Adafruit DRV2605 Library@^1.2.2 17 | earlephilhower/ESP8266Audio@^1.9.7 18 | earlephilhower/ESP8266SAM@^1.0.1 -------------------------------------------------------------------------------- /src/mesh/http/ContentHelper.cpp: -------------------------------------------------------------------------------- 1 | #include "mesh/http/ContentHelper.h" 2 | // #include 3 | // #include "main.h" 4 | 5 | void replaceAll(std::string &str, const std::string &from, const std::string &to) 6 | { 7 | if (from.empty()) 8 | return; 9 | size_t start_pos = 0; 10 | while ((start_pos = str.find(from, start_pos)) != std::string::npos) { 11 | str.replace(start_pos, from.length(), to); 12 | start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx' 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/platform/esp32/CallbackCharacteristic.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "BLECharacteristic.h" 3 | #include "PowerFSM.h" // FIXME - someday I want to make this OTA thing a separate lb at at that point it can't touch this 4 | 5 | /** 6 | * A characteristic with a set of overridable callbacks 7 | */ 8 | class CallbackCharacteristic : public BLECharacteristic, public BLECharacteristicCallbacks 9 | { 10 | public: 11 | CallbackCharacteristic(const char *uuid, uint32_t btprops) : BLECharacteristic(uuid, btprops) { setCallbacks(this); } 12 | }; 13 | -------------------------------------------------------------------------------- /variants/pca10056-rc-clock/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The NRF52840-dk development board, but @geeksville's board - which has a busted oscilliator 2 | [env:nrf52840dk-geeksville] 3 | board_level = extra 4 | extends = nrf52840_base 5 | board = nrf52840_dk_modified 6 | # add our variants files to the include and src paths 7 | build_flags = ${nrf52_base.build_flags} -Ivariants/pca10056-rc-clock 8 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" 9 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/pca10056-rc-clock> -------------------------------------------------------------------------------- /variants/rpipico/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:pico] 2 | extends = rp2040_base 3 | board = rpipico 4 | upload_protocol = picotool 5 | 6 | # add our variants files to the include and src paths 7 | build_flags = ${rp2040_base.build_flags} 8 | -DRPI_PICO 9 | -Ivariants/rpipico 10 | -DDEBUG_RP2040_PORT=Serial 11 | -DHW_SPI1_DEVICE 12 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" 13 | lib_deps = 14 | ${rp2040_base.lib_deps} 15 | debug_build_flags = ${rp2040_base.build_flags} 16 | debug_tool = cmsis-dap ; for e.g. Picotool -------------------------------------------------------------------------------- /variants/portduino/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:native] 2 | extends = portduino_base 3 | ; The pkg-config commands below optionally add link flags. 4 | ; the || : is just a "or run the null command" to avoid returning an error code 5 | build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino -I /usr/include 6 | !pkg-config --libs libulfius --silence-errors || : 7 | !pkg-config --libs openssl --silence-errors || : 8 | board = cross_platform 9 | lib_deps = ${portduino_base.lib_deps} 10 | build_src_filter = ${portduino_base.build_src_filter} 11 | -------------------------------------------------------------------------------- /images/face-24px.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /variants/betafpv_2400_tx_micro/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:betafpv_2400_tx_micro] 2 | extends = esp32_base 3 | board = esp32doit-devkit-v1 4 | board_level = extra 5 | build_flags = 6 | ${esp32_base.build_flags} 7 | -D BETAFPV_2400_TX 8 | -D VTABLES_IN_FLASH=1 9 | -D CONFIG_DISABLE_HAL_LOCKS=1 10 | -O2 11 | -I variants/betafpv_2400_tx_micro 12 | board_build.f_cpu = 240000000L 13 | upload_protocol = esptool 14 | ;upload_port = /dev/ttyUSB0 15 | upload_speed = 460800 16 | lib_deps = 17 | ${esp32_base.lib_deps} 18 | adafruit/Adafruit NeoPixel @ ^1.12.0 -------------------------------------------------------------------------------- /src/input/kbI2cBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BBQ10Keyboard.h" 4 | #include "InputBroker.h" 5 | #include "Wire.h" 6 | #include "concurrency/OSThread.h" 7 | 8 | class KbI2cBase : public Observable, public concurrency::OSThread 9 | { 10 | public: 11 | explicit KbI2cBase(const char *name); 12 | 13 | protected: 14 | virtual int32_t runOnce() override; 15 | 16 | private: 17 | const char *_originName; 18 | 19 | TwoWire *i2cBus = 0; 20 | 21 | BBQ10Keyboard Q10keyboard; 22 | bool is_sym = false; 23 | }; 24 | -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/channel.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/channel.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_ChannelSettings, meshtastic_ChannelSettings, AUTO) 10 | 11 | 12 | PB_BIND(meshtastic_ModuleSettings, meshtastic_ModuleSettings, AUTO) 13 | 14 | 15 | PB_BIND(meshtastic_Channel, meshtastic_Channel, AUTO) 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /variants/nano-g2-ultra/platformio.ini: -------------------------------------------------------------------------------- 1 | ; First prototype eink/nrf52840/sx1262 device 2 | [env:nano-g2-ultra] 3 | extends = nrf52840_base 4 | board = nano-g2-ultra 5 | debug_tool = jlink 6 | 7 | build_flags = ${nrf52840_base.build_flags} -Ivariants/nano-g2-ultra -D NANO_G2_ULTRA 8 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" 9 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nano-g2-ultra> 10 | lib_deps = 11 | ${nrf52840_base.lib_deps} 12 | lewisxhe/PCF8563_Library@^1.0.1 13 | ;upload_protocol = fs 14 | -------------------------------------------------------------------------------- /variants/rp2040-lora/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:rp2040-lora] 2 | extends = rp2040_base 3 | board = rpipico 4 | upload_protocol = picotool 5 | 6 | # add our variants files to the include and src paths 7 | build_flags = ${rp2040_base.build_flags} 8 | -DRP2040_LORA 9 | -Ivariants/rp2040-lora 10 | -DDEBUG_RP2040_PORT=Serial 11 | -DHW_SPI1_DEVICE 12 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" 13 | lib_deps = 14 | ${rp2040_base.lib_deps} 15 | debug_build_flags = ${rp2040_base.build_flags} 16 | debug_tool = cmsis-dap ; for e.g. Picotool -------------------------------------------------------------------------------- /variants/heltec_wireless_tracker/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:heltec-wireless-tracker] 2 | extends = esp32s3_base 3 | board = heltec_wireless_tracker 4 | upload_protocol = esp-builtin 5 | 6 | build_flags = 7 | ${esp32s3_base.build_flags} -I variants/heltec_wireless_tracker 8 | -D HELTEC_TRACKER_V1_1 9 | -D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. 10 | ;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output 11 | 12 | lib_deps = 13 | ${esp32s3_base.lib_deps} 14 | lovyan03/LovyanGFX@^1.1.8 -------------------------------------------------------------------------------- /variants/picomputer-s3/pins_arduino.h: -------------------------------------------------------------------------------- 1 | #ifndef Pins_Arduino_h 2 | #define Pins_Arduino_h 3 | 4 | #include 5 | 6 | #define USB_VID 0x303a 7 | #define USB_PID 0x1001 8 | 9 | static const uint8_t TX = 43; 10 | static const uint8_t RX = 44; 11 | 12 | // The default Wire will be mapped to PMU and RTC 13 | static const uint8_t SDA = 8; 14 | static const uint8_t SCL = 9; 15 | 16 | // Default SPI 17 | static const uint8_t MISO = 39; 18 | static const uint8_t SCK = 21; 19 | static const uint8_t MOSI = 38; 20 | static const uint8_t SS = 40; 21 | 22 | #endif /* Pins_Arduino_h */ -------------------------------------------------------------------------------- /variants/heltec_wireless_tracker_V1_0/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:heltec-wireless-tracker-V1-0] 2 | extends = esp32s3_base 3 | board = heltec_wireless_tracker 4 | upload_protocol = esptool 5 | 6 | build_flags = 7 | ${esp32s3_base.build_flags} -I variants/heltec_wireless_tracker_V1_0 8 | -D HELTEC_TRACKER_V1_0 9 | -D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. 10 | ;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output 11 | 12 | lib_deps = 13 | ${esp32s3_base.lib_deps} 14 | lovyan03/LovyanGFX@^1.1.8 -------------------------------------------------------------------------------- /src/concurrency/BinarySemaphorePosix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../freertosinc.h" 4 | 5 | namespace concurrency 6 | { 7 | 8 | #ifndef HAS_FREE_RTOS 9 | 10 | class BinarySemaphorePosix 11 | { 12 | // SemaphoreHandle_t semaphore; 13 | 14 | public: 15 | BinarySemaphorePosix(); 16 | ~BinarySemaphorePosix(); 17 | 18 | /** 19 | * Returns false if we timed out 20 | */ 21 | bool take(uint32_t msec); 22 | 23 | void give(); 24 | 25 | void giveFromISR(BaseType_t *pxHigherPriorityTaskWoken); 26 | }; 27 | 28 | #endif 29 | 30 | } // namespace concurrency -------------------------------------------------------------------------------- /.github/workflows/trunk-check.yml: -------------------------------------------------------------------------------- 1 | name: Pull Request 2 | on: [pull_request] 3 | concurrency: 4 | group: ${{ github.head_ref || github.run_id }} 5 | cancel-in-progress: true 6 | 7 | permissions: read-all 8 | 9 | jobs: 10 | trunk_check: 11 | name: Trunk Check Runner 12 | runs-on: ubuntu-latest 13 | permissions: 14 | checks: write # For trunk to post annotations 15 | contents: read # For repo checkout 16 | 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v4 20 | 21 | - name: Trunk Check 22 | uses: trunk-io/trunk-action@v1 23 | -------------------------------------------------------------------------------- /bin/regen-protos.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | echo "This script requires https://jpa.kapsi.fi/nanopb/download/ version 0.4.8 to be located in the" 6 | echo "firmware root directory if the following step fails, you should download the correct" 7 | echo "prebuilt binaries for your computer into nanopb-0.4.8" 8 | 9 | # the nanopb tool seems to require that the .options file be in the current directory! 10 | cd protobufs 11 | ../nanopb-0.4.8/generator-bin/protoc --experimental_allow_proto3_optional "--nanopb_out=-S.cpp -v:../src/mesh/generated/" -I=../protobufs meshtastic/*.proto 12 | -------------------------------------------------------------------------------- /src/concurrency/BinarySemaphoreFreeRTOS.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../freertosinc.h" 4 | 5 | namespace concurrency 6 | { 7 | 8 | #ifdef HAS_FREE_RTOS 9 | 10 | class BinarySemaphoreFreeRTOS 11 | { 12 | SemaphoreHandle_t semaphore; 13 | 14 | public: 15 | BinarySemaphoreFreeRTOS(); 16 | ~BinarySemaphoreFreeRTOS(); 17 | 18 | /** 19 | * Returns false if we timed out 20 | */ 21 | bool take(uint32_t msec); 22 | 23 | void give(); 24 | 25 | void giveFromISR(BaseType_t *pxHigherPriorityTaskWoken); 26 | }; 27 | 28 | #endif 29 | 30 | } // namespace concurrency -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/admin.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/admin.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_AdminMessage, meshtastic_AdminMessage, 2) 10 | 11 | 12 | PB_BIND(meshtastic_HamParameters, meshtastic_HamParameters, AUTO) 13 | 14 | 15 | PB_BIND(meshtastic_NodeRemoteHardwarePinsResponse, meshtastic_NodeRemoteHardwarePinsResponse, 2) 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | main/configuration.h 3 | main/credentials.h 4 | 5 | # ignore vscode IDE settings files 6 | .vscode/* 7 | !.vscode/settings.json 8 | !.vscode/tasks.json 9 | !.vscode/extensions.json 10 | *.code-workspace 11 | 12 | .idea 13 | 14 | .DS_Store 15 | Thumbs.db 16 | .autotools 17 | .built 18 | .context 19 | .cproject 20 | .vagrant 21 | nanopb* 22 | flash.uf2 23 | cmake-build* 24 | __pycache__ 25 | 26 | *.swp 27 | *.swo 28 | *~ 29 | 30 | venv/ 31 | release/ 32 | .vscode/extensions.json 33 | /compile_commands.json 34 | src/mesh/raspihttp/certificate.pem 35 | src/mesh/raspihttp/private_key.pem -------------------------------------------------------------------------------- /variants/Dongle_nRF52840-pca10059-v1/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:pca10059_diy_eink] 2 | extends = nrf52840_base 3 | board = nordic_pca10059 4 | build_flags = ${nrf52840_base.build_flags} -Ivariants/Dongle_nRF52840-pca10059-v1 -D NORDIC_PCA10059 5 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" 6 | -DEINK_DISPLAY_MODEL=GxEPD2_420_M01 7 | -DEINK_WIDTH=300 8 | -DEINK_HEIGHT=400 9 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/Dongle_nRF52840-pca10059-v1> 10 | lib_deps = 11 | ${nrf52840_base.lib_deps} 12 | zinggjm/GxEPD2@^1.4.9 13 | debug_tool = jlink -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/SHT31Sensor.h: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "TelemetrySensor.h" 7 | #include 8 | 9 | class SHT31Sensor : public TelemetrySensor 10 | { 11 | private: 12 | Adafruit_SHT31 sht31; 13 | 14 | protected: 15 | virtual void setup() override; 16 | 17 | public: 18 | SHT31Sensor(); 19 | virtual int32_t runOnce() override; 20 | virtual bool getMetrics(meshtastic_Telemetry *measurement) override; 21 | }; 22 | 23 | #endif -------------------------------------------------------------------------------- /variants/trackerd/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:trackerd] 2 | extends = esp32_base 3 | ;platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream 4 | platform = espressif32 5 | board = pico32 6 | board_build.f_flash = 80000000L 7 | board_level = extra 8 | build_flags = 9 | ${esp32_base.build_flags} -D PRIVATE_HW -I variants/trackerd -D BSFILE=\"boards/dragino_lbt2.h\" 10 | ;board_build.partitions = no_ota.csv 11 | ;platform_packages = 12 | ; platformio/framework-arduinoespressif32@3 13 | ;platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1-RC1 -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/BME280Sensor.h: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "TelemetrySensor.h" 7 | #include 8 | 9 | class BME280Sensor : public TelemetrySensor 10 | { 11 | private: 12 | Adafruit_BME280 bme280; 13 | 14 | protected: 15 | virtual void setup() override; 16 | 17 | public: 18 | BME280Sensor(); 19 | virtual int32_t runOnce() override; 20 | virtual bool getMetrics(meshtastic_Telemetry *measurement) override; 21 | }; 22 | 23 | #endif -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/BMP085Sensor.h: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "TelemetrySensor.h" 7 | #include 8 | 9 | class BMP085Sensor : public TelemetrySensor 10 | { 11 | private: 12 | Adafruit_BMP085 bmp085; 13 | 14 | protected: 15 | virtual void setup() override; 16 | 17 | public: 18 | BMP085Sensor(); 19 | virtual int32_t runOnce() override; 20 | virtual bool getMetrics(meshtastic_Telemetry *measurement) override; 21 | }; 22 | 23 | #endif -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/BMP280Sensor.h: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "TelemetrySensor.h" 7 | #include 8 | 9 | class BMP280Sensor : public TelemetrySensor 10 | { 11 | private: 12 | Adafruit_BMP280 bmp280; 13 | 14 | protected: 15 | virtual void setup() override; 16 | 17 | public: 18 | BMP280Sensor(); 19 | virtual int32_t runOnce() override; 20 | virtual bool getMetrics(meshtastic_Telemetry *measurement) override; 21 | }; 22 | 23 | #endif -------------------------------------------------------------------------------- /variants/MakePython_nRF52840_oled/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:makerpython_nrf52840_sx1280_oled] 2 | board_level = extra 3 | extends = nrf52840_base 4 | board = nordic_pca10059 5 | build_flags = ${nrf52840_base.build_flags} -Ivariants/MakePython_nRF52840_oled -D PRIVATE_HW 6 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" 7 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/MakePython_nRF52840_oled> 8 | lib_deps = 9 | ${nrf52840_base.lib_deps} 10 | https://github.com/meshtastic/ESP32_Codec2.git#633326c78ac251c059ab3a8c430fcdf25b41672f 11 | debug_tool = jlink 12 | -------------------------------------------------------------------------------- /variants/betafpv_900_tx_nano/variant.h: -------------------------------------------------------------------------------- 1 | // https://betafpv.com/products/elrs-nano-tx-module 2 | 3 | // no screen 4 | #define HAS_SCREEN 0 5 | 6 | // NO GPS 7 | #undef GPS_RX_PIN 8 | #undef GPS_TX_PIN 9 | 10 | #define USE_RF95 11 | 12 | #define LORA_SCK 18 13 | #define LORA_MISO 19 14 | #define LORA_MOSI 23 15 | #define LORA_CS 5 16 | 17 | #define LORA_DIO0 4 18 | #define LORA_RESET 14 19 | #define LORA_DIO1 2 20 | #define LORA_DIO2 21 | #define LORA_DIO3 22 | 23 | #define LED_PIN 16 // green - blue is at 17 24 | 25 | #define BUTTON_PIN 25 26 | #define BUTTON_NEED_PULLUP 27 | 28 | #undef EXT_NOTIFY_OUT 29 | -------------------------------------------------------------------------------- /variants/canaryone/platformio.ini: -------------------------------------------------------------------------------- 1 | ; Public Beta oled/nrf52840/sx1262 device 2 | [env:canaryone] 3 | extends = nrf52840_base 4 | board = canaryone 5 | debug_tool = jlink 6 | 7 | # add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling. 8 | build_flags = ${nrf52840_base.build_flags} -Ivariants/canaryone 9 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" 10 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/canaryone> 11 | lib_deps = 12 | ${nrf52840_base.lib_deps} 13 | lewisxhe/PCF8563_Library@^1.0.1 14 | ;upload_protocol = fs 15 | -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/MCP9808Sensor.h: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "TelemetrySensor.h" 7 | #include 8 | 9 | class MCP9808Sensor : public TelemetrySensor 10 | { 11 | private: 12 | Adafruit_MCP9808 mcp9808; 13 | 14 | protected: 15 | virtual void setup() override; 16 | 17 | public: 18 | MCP9808Sensor(); 19 | virtual int32_t runOnce() override; 20 | virtual bool getMetrics(meshtastic_Telemetry *measurement) override; 21 | }; 22 | 23 | #endif -------------------------------------------------------------------------------- /variants/station-g2/pins_arduino.h: -------------------------------------------------------------------------------- 1 | #ifndef Pins_Arduino_h 2 | #define Pins_Arduino_h 3 | 4 | #include 5 | 6 | #define USB_VID 0x303a 7 | #define USB_PID 0x1001 8 | 9 | // GPIO48 Reference: https://github.com/espressif/arduino-esp32/pull/8600 10 | 11 | // The default Wire will be mapped to Screen and Sensors 12 | static const uint8_t SDA = 5; 13 | static const uint8_t SCL = 6; 14 | 15 | // Default SPI will be mapped to Radio 16 | static const uint8_t MISO = 14; 17 | static const uint8_t SCK = 12; 18 | static const uint8_t MOSI = 13; 19 | static const uint8_t SS = 11; 20 | 21 | #endif /* Pins_Arduino_h */ -------------------------------------------------------------------------------- /src/concurrency/Lock.cpp: -------------------------------------------------------------------------------- 1 | #include "Lock.h" 2 | #include "configuration.h" 3 | #include 4 | 5 | namespace concurrency 6 | { 7 | 8 | #ifdef HAS_FREE_RTOS 9 | Lock::Lock() : handle(xSemaphoreCreateBinary()) 10 | { 11 | assert(handle); 12 | assert(xSemaphoreGive(handle)); 13 | } 14 | 15 | void Lock::lock() 16 | { 17 | assert(xSemaphoreTake(handle, portMAX_DELAY)); 18 | } 19 | 20 | void Lock::unlock() 21 | { 22 | assert(xSemaphoreGive(handle)); 23 | } 24 | #else 25 | Lock::Lock() {} 26 | 27 | void Lock::lock() {} 28 | 29 | void Lock::unlock() {} 30 | #endif 31 | 32 | } // namespace concurrency 33 | -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/SHT4XSensor.h: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "TelemetrySensor.h" 7 | #include 8 | 9 | class SHT4XSensor : public TelemetrySensor 10 | { 11 | private: 12 | Adafruit_SHT4x sht4x = Adafruit_SHT4x(); 13 | 14 | protected: 15 | virtual void setup() override; 16 | 17 | public: 18 | SHT4XSensor(); 19 | virtual int32_t runOnce() override; 20 | virtual bool getMetrics(meshtastic_Telemetry *measurement) override; 21 | }; 22 | 23 | #endif -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/SHTC3Sensor.h: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "TelemetrySensor.h" 7 | #include 8 | 9 | class SHTC3Sensor : public TelemetrySensor 10 | { 11 | private: 12 | Adafruit_SHTC3 shtc3 = Adafruit_SHTC3(); 13 | 14 | protected: 15 | virtual void setup() override; 16 | 17 | public: 18 | SHTC3Sensor(); 19 | virtual int32_t runOnce() override; 20 | virtual bool getMetrics(meshtastic_Telemetry *measurement) override; 21 | }; 22 | 23 | #endif -------------------------------------------------------------------------------- /src/platform/nrf52/alloc.cpp: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | #include "rtos.h" 3 | #include 4 | #include 5 | 6 | /** 7 | * Custom new/delete to panic if out out memory 8 | */ 9 | 10 | void *operator new(size_t size) 11 | { 12 | auto p = rtos_malloc(size); 13 | assert(p); 14 | return p; 15 | } 16 | 17 | void *operator new[](size_t size) 18 | { 19 | auto p = rtos_malloc(size); 20 | assert(p); 21 | return p; 22 | } 23 | 24 | void operator delete(void *ptr) 25 | { 26 | rtos_free(ptr); 27 | } 28 | 29 | void operator delete[](void *ptr) 30 | { 31 | rtos_free(ptr); 32 | } -------------------------------------------------------------------------------- /src/mesh/SX1268Interface.cpp: -------------------------------------------------------------------------------- 1 | #include "SX1268Interface.h" 2 | #include "configuration.h" 3 | #include "error.h" 4 | 5 | SX1268Interface::SX1268Interface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, 6 | RADIOLIB_PIN_TYPE busy) 7 | : SX126xInterface(hal, cs, irq, rst, busy) 8 | { 9 | } 10 | 11 | float SX1268Interface::getFreq() 12 | { 13 | // Set frequency to default of EU_433 if outside of allowed range (e.g. when region is UNSET) 14 | if (savedFreq < 410 || savedFreq > 810) 15 | return 433.125f; 16 | else 17 | return savedFreq; 18 | } -------------------------------------------------------------------------------- /variants/senselora_rp2040/variant.h: -------------------------------------------------------------------------------- 1 | #define ARDUINO_ARCH_AVR 2 | 3 | #define USE_SSD1306 4 | 5 | #define BUTTON_PIN 2 6 | #define BUTTON_NEED_PULLUP 7 | 8 | #define LED_PIN PIN_LED 9 | 10 | #undef BATTERY_PIN 11 | #define BATTERY_SENSE_RESOLUTION_BITS ADC_RESOLUTION 12 | 13 | #undef LORA_SCK 14 | #undef LORA_MISO 15 | #undef LORA_MOSI 16 | #undef LORA_CS 17 | 18 | #define USE_RF95 19 | #define LORA_SCK PIN_SPI0_SCK 20 | #define LORA_MISO PIN_SPI0_MISO 21 | #define LORA_MOSI PIN_SPI0_MOSI 22 | #define LORA_CS PIN_SPI0_SS 23 | 24 | #define LORA_DIO0 21 25 | #define LORA_DIO1 22 26 | #define LORA_DIO2 RADIOLIB_NC 27 | #define LORA_RESET 20 -------------------------------------------------------------------------------- /src/modules/ReplyModule.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SinglePortModule.h" 3 | 4 | /** 5 | * A simple example module that just replies with "Message received" to any message it receives. 6 | */ 7 | class ReplyModule : public SinglePortModule 8 | { 9 | public: 10 | /** Constructor 11 | * name is for debugging output 12 | */ 13 | ReplyModule() : SinglePortModule("reply", meshtastic_PortNum_REPLY_APP) {} 14 | 15 | protected: 16 | /** For reply module we do all of our processing in the (normally optional) 17 | * want_replies handling 18 | */ 19 | virtual meshtastic_MeshPacket *allocReply() override; 20 | }; 21 | -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/LPS22HBSensor.h: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "TelemetrySensor.h" 7 | #include 8 | #include 9 | 10 | class LPS22HBSensor : public TelemetrySensor 11 | { 12 | private: 13 | Adafruit_LPS22 lps22hb; 14 | 15 | protected: 16 | virtual void setup() override; 17 | 18 | public: 19 | LPS22HBSensor(); 20 | virtual int32_t runOnce() override; 21 | virtual bool getMetrics(meshtastic_Telemetry *measurement) override; 22 | }; 23 | 24 | #endif -------------------------------------------------------------------------------- /variants/heltec_esp32c3/pins_arduino.h: -------------------------------------------------------------------------------- 1 | #ifndef Pins_Arduino_h 2 | #define Pins_Arduino_h 3 | 4 | #include 5 | 6 | static const uint8_t TX = 21; 7 | static const uint8_t RX = 20; 8 | 9 | static const uint8_t SDA = 1; 10 | static const uint8_t SCL = 0; 11 | 12 | static const uint8_t SS = 8; 13 | static const uint8_t MOSI = 7; 14 | static const uint8_t MISO = 6; 15 | static const uint8_t SCK = 10; 16 | 17 | static const uint8_t A0 = 0; 18 | static const uint8_t A1 = 1; 19 | static const uint8_t A2 = 2; 20 | static const uint8_t A3 = 3; 21 | static const uint8_t A4 = 4; 22 | static const uint8_t A5 = 5; 23 | 24 | #endif /* Pins_Arduino_h */ -------------------------------------------------------------------------------- /src/detect/axpDebug.h: -------------------------------------------------------------------------------- 1 | #if 0 2 | // Turn off for now 3 | uint32_t axpDebugRead() 4 | { 5 | axp.debugCharging(); 6 | LOG_DEBUG("vbus current %f\n", axp.getVbusCurrent()); 7 | LOG_DEBUG("charge current %f\n", axp.getBattChargeCurrent()); 8 | LOG_DEBUG("bat voltage %f\n", axp.getBattVoltage()); 9 | LOG_DEBUG("batt pct %d\n", axp.getBattPercentage()); 10 | LOG_DEBUG("is battery connected %d\n", axp.isBatteryConnect()); 11 | LOG_DEBUG("is USB connected %d\n", axp.isVBUSPlug()); 12 | LOG_DEBUG("is charging %d\n", axp.isChargeing()); 13 | 14 | return 30 * 1000; 15 | } 16 | 17 | Periodic axpDebugOutput(axpDebugRead); 18 | axpDebugOutput.setup(); 19 | #endif -------------------------------------------------------------------------------- /src/input/cardKbI2cImpl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "kbI2cBase.h" 3 | #include "main.h" 4 | 5 | /** 6 | * @brief The idea behind this class to have static methods for the event handlers. 7 | * Check attachInterrupt() at RotaryEncoderInteruptBase.cpp 8 | * Technically you can have as many rotary encoders hardver attached 9 | * to your device as you wish, but you always need to have separate event 10 | * handlers, thus you need to have a RotaryEncoderInterrupt implementation. 11 | */ 12 | class CardKbI2cImpl : public KbI2cBase 13 | { 14 | public: 15 | CardKbI2cImpl(); 16 | void init(); 17 | }; 18 | 19 | extern CardKbI2cImpl *cardKbI2cImpl; -------------------------------------------------------------------------------- /src/input/kbMatrixImpl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "kbMatrixBase.h" 3 | #include "main.h" 4 | 5 | /** 6 | * @brief The idea behind this class to have static methods for the event handlers. 7 | * Check attachInterrupt() at RotaryEncoderInteruptBase.cpp 8 | * Technically you can have as many rotary encoders hardver attached 9 | * to your device as you wish, but you always need to have separate event 10 | * handlers, thus you need to have a RotaryEncoderInterrupt implementation. 11 | */ 12 | class KbMatrixImpl : public KbMatrixBase 13 | { 14 | public: 15 | KbMatrixImpl(); 16 | void init(); 17 | }; 18 | 19 | extern KbMatrixImpl *kbMatrixImpl; -------------------------------------------------------------------------------- /variants/m5stack-stamp-c3/pins_arduino.h: -------------------------------------------------------------------------------- 1 | #ifndef Pins_Arduino_h 2 | #define Pins_Arduino_h 3 | 4 | #include 5 | 6 | static const uint8_t TX = -1; // 21; 7 | static const uint8_t RX = -1; // 20; 8 | 9 | static const uint8_t SDA = 1; 10 | static const uint8_t SCL = 0; 11 | 12 | static const uint8_t SS = 7; 13 | static const uint8_t MOSI = 6; 14 | static const uint8_t MISO = 5; 15 | static const uint8_t SCK = 4; 16 | 17 | static const uint8_t A0 = 0; 18 | static const uint8_t A1 = 1; 19 | static const uint8_t A2 = 2; 20 | static const uint8_t A3 = 3; 21 | static const uint8_t A4 = 4; 22 | static const uint8_t A5 = 5; 23 | 24 | #endif /* Pins_Arduino_h */ 25 | -------------------------------------------------------------------------------- /variants/rpipicow/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:picow] 2 | extends = rp2040_base 3 | board = rpipicow 4 | upload_protocol = picotool 5 | 6 | # add our variants files to the include and src paths 7 | build_flags = ${rp2040_base.build_flags} 8 | -DRPI_PICO 9 | -Ivariants/rpipicow 10 | -DHW_SPI1_DEVICE 11 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" 12 | -fexceptions # for exception handling in MQTT 13 | build_src_filter = ${rp2040_base.build_src_filter} + 14 | lib_deps = 15 | ${rp2040_base.lib_deps} 16 | ${networking_base.lib_deps} 17 | debug_build_flags = ${rp2040_base.build_flags} 18 | debug_tool = cmsis-dap ; for e.g. Picotool -------------------------------------------------------------------------------- /src/concurrency/BinarySemaphorePosix.cpp: -------------------------------------------------------------------------------- 1 | #include "concurrency/BinarySemaphorePosix.h" 2 | #include "configuration.h" 3 | 4 | #ifndef HAS_FREE_RTOS 5 | 6 | namespace concurrency 7 | { 8 | 9 | BinarySemaphorePosix::BinarySemaphorePosix() {} 10 | 11 | BinarySemaphorePosix::~BinarySemaphorePosix() {} 12 | 13 | /** 14 | * Returns false if we timed out 15 | */ 16 | bool BinarySemaphorePosix::take(uint32_t msec) 17 | { 18 | delay(msec); // FIXME 19 | return false; 20 | } 21 | 22 | void BinarySemaphorePosix::give() {} 23 | 24 | IRAM_ATTR void BinarySemaphorePosix::giveFromISR(BaseType_t *pxHigherPriorityTaskWoken) {} 25 | 26 | } // namespace concurrency 27 | 28 | #endif -------------------------------------------------------------------------------- /variants/tlora_t3s3_v1/pins_arduino.h: -------------------------------------------------------------------------------- 1 | #ifndef Pins_Arduino_h 2 | #define Pins_Arduino_h 3 | 4 | #include 5 | 6 | #define USB_VID 0x303a 7 | #define USB_PID 0x1001 8 | 9 | // The default Wire will be mapped to PMU and RTC 10 | static const uint8_t SDA = 18; 11 | static const uint8_t SCL = 17; 12 | 13 | // Default SPI will be mapped to Radio 14 | static const uint8_t SS = 7; 15 | static const uint8_t MOSI = 6; 16 | static const uint8_t MISO = 3; 17 | static const uint8_t SCK = 5; 18 | 19 | #define SPI_MOSI (11) 20 | #define SPI_SCK (14) 21 | #define SPI_MISO (2) 22 | #define SPI_CS (13) 23 | 24 | #define SDCARD_CS SPI_CS 25 | 26 | #endif /* Pins_Arduino_h */ 27 | -------------------------------------------------------------------------------- /src/platform/nrf52/NRF52Bluetooth.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BluetoothCommon.h" 4 | #include 5 | 6 | class NRF52Bluetooth : BluetoothApi 7 | { 8 | public: 9 | void setup(); 10 | void shutdown(); 11 | void resumeAdvertising(); 12 | void clearBonds(); 13 | bool isConnected(); 14 | int getRssi(); 15 | 16 | private: 17 | static void onConnectionSecured(uint16_t conn_handle); 18 | void convertToUint8(uint8_t target[4], uint32_t source); 19 | static bool onPairingPasskey(uint16_t conn_handle, uint8_t const passkey[6], bool match_request); 20 | static void onPairingCompleted(uint16_t conn_handle, uint8_t auth_status); 21 | }; -------------------------------------------------------------------------------- /variants/lora_isp4520/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:lora_isp4520] 2 | extends = nrf52_base 3 | board = lora_isp4520 4 | board_level = extra 5 | 6 | # add our variants files to the include and src paths 7 | build_flags = ${nrf52_base.build_flags} -Ivariants/lora_isp4520 8 | 9 | # No screen and GPS on the board. We still need RTC.cpp for the RTC clock. 10 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/lora_isp4520> - - + + 11 | lib_ignore = ${nrf52_base.lib_ignore} 12 | ESP8266_SSD1306 13 | SparkFun Ublox Arduino Library 14 | AXP202X_Library 15 | TinyGPSPlus 16 | 17 | upload_protocol = jlink 18 | monitor_port = /dev/ttyUSB0 -------------------------------------------------------------------------------- /src/mesh/MeshRadio.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MemoryPool.h" 4 | #include "MeshTypes.h" 5 | #include "PointerQueue.h" 6 | #include "configuration.h" 7 | 8 | // Map from old region names to new region enums 9 | struct RegionInfo { 10 | meshtastic_Config_LoRaConfig_RegionCode code; 11 | float freqStart; 12 | float freqEnd; 13 | float dutyCycle; 14 | float spacing; 15 | uint8_t powerLimit; // Or zero for not set 16 | bool audioPermitted; 17 | bool freqSwitching; 18 | bool wideLora; 19 | const char *name; // EU433 etc 20 | }; 21 | 22 | extern const RegionInfo regions[]; 23 | extern const RegionInfo *myRegion; 24 | 25 | extern void initRegion(); -------------------------------------------------------------------------------- /.github/workflows/sec_sast_semgrep_pull.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Semgrep Differential Scan 3 | on: pull_request 4 | 5 | jobs: 6 | semgrep-diff: 7 | runs-on: ubuntu-latest 8 | container: 9 | image: returntocorp/semgrep 10 | 11 | steps: 12 | # step 1 13 | - name: clone application source code 14 | uses: actions/checkout@v4 15 | with: 16 | fetch-depth: 0 17 | 18 | # step 2 19 | - name: differential scan 20 | run: | 21 | semgrep scan \ 22 | --error \ 23 | --metrics=off \ 24 | --baseline-commit ${{ github.event.pull_request.base.sha }} \ 25 | --config="p/default" 26 | -------------------------------------------------------------------------------- /src/mesh/api/ethServerAPI.cpp: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | #include 3 | 4 | #if HAS_ETHERNET 5 | 6 | #include "ethServerAPI.h" 7 | 8 | static ethServerPort *apiPort; 9 | 10 | void initApiServer(int port) 11 | { 12 | // Start API server on port 4403 13 | if (!apiPort) { 14 | apiPort = new ethServerPort(port); 15 | LOG_INFO("API server listening on TCP port %d\n", port); 16 | apiPort->init(); 17 | } 18 | } 19 | 20 | ethServerAPI::ethServerAPI(EthernetClient &_client) : ServerAPI(_client) 21 | { 22 | LOG_INFO("Incoming ethernet connection\n"); 23 | } 24 | 25 | ethServerPort::ethServerPort(int port) : APIServerPort(port) {} 26 | 27 | #endif -------------------------------------------------------------------------------- /src/mesh/LLCC68Interface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SX126xInterface.h" 4 | 5 | /** 6 | * Our adapter for LLCC68 radios 7 | * https://www.semtech.com/products/wireless-rf/lora-core/llcc68 8 | * ⚠️⚠️⚠️ 9 | * Be aware that LLCC68 does not support Spreading Factor 12 (SF12) and will not work on the "LongSlow" and "VLongSlow" channels. 10 | * You must change the channel if you get `Critical Error #3` with this module. 11 | * ⚠️⚠️⚠️ 12 | */ 13 | class LLCC68Interface : public SX126xInterface 14 | { 15 | public: 16 | LLCC68Interface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, 17 | RADIOLIB_PIN_TYPE busy); 18 | }; -------------------------------------------------------------------------------- /variants/esp32-s3-pico/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:ESP32-S3-Pico] 2 | 3 | board_level = extra 4 | extends = esp32s3_base 5 | upload_protocol = esptool 6 | board = esp32-s3-pico 7 | 8 | board_upload.use_1200bps_touch = yes 9 | board_upload.wait_for_upload_port = yes 10 | board_upload.require_upload_port = yes 11 | 12 | ;upload_port = /dev/ttyACM0 13 | 14 | build_flags = ${esp32_base.build_flags} 15 | -DESP32_S3_PICO 16 | ;-DPRIVATE_HW 17 | -Ivariants/esp32-s3-pico 18 | -DBOARD_HAS_PSRAM 19 | -DEINK_DISPLAY_MODEL=GxEPD2_290_T94_V2 20 | -DEINK_WIDTH=296 21 | -DEINK_HEIGHT=128 22 | 23 | lib_deps = ${esp32s3_base.lib_deps} 24 | zinggjm/GxEPD2@^1.5.3 25 | adafruit/Adafruit NeoPixel @ ^1.12.0 -------------------------------------------------------------------------------- /bin/check-dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Note: This is a prototype for how we could add static code analysis to the CI. 4 | 5 | set -e 6 | 7 | if [[ $# -gt 0 ]]; then 8 | # can override which environment by passing arg 9 | BOARDS="$@" 10 | else 11 | BOARDS="rak4631 rak4631_eink t-echo canaryone pca10059_diy_eink pico rak11200 tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v2.0 heltec-v2.1 tbeam0.7 meshtastic-diy-v1 nano-g1 station-g1 m5stack-core m5stack-coreink tbeam-s3-core" 12 | fi 13 | 14 | echo "BOARDS:${BOARDS}" 15 | 16 | CHECK="" 17 | for BOARD in $BOARDS; do 18 | CHECK="${CHECK} -e ${BOARD}" 19 | done 20 | 21 | echo $CHECK 22 | 23 | pio pkg outdated -e $CHECK 24 | -------------------------------------------------------------------------------- /src/modules/DetectionSensorModule.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SinglePortModule.h" 3 | 4 | class DetectionSensorModule : public SinglePortModule, private concurrency::OSThread 5 | { 6 | public: 7 | DetectionSensorModule() 8 | : SinglePortModule("detection", meshtastic_PortNum_DETECTION_SENSOR_APP), OSThread("DetectionSensorModule") 9 | { 10 | } 11 | 12 | protected: 13 | virtual int32_t runOnce() override; 14 | 15 | private: 16 | bool firstTime = true; 17 | uint32_t lastSentToMesh = 0; 18 | void sendDetectionMessage(); 19 | void sendCurrentStateMessage(); 20 | bool hasDetectionEvent(); 21 | }; 22 | 23 | extern DetectionSensorModule *detectionSensorModule; -------------------------------------------------------------------------------- /variants/feather_diy/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The very slick RAK wireless RAK 4631 / 4630 board - Unified firmware for 5005/19003, with or without OLED RAK 1921 2 | [env:feather_diy] 3 | extends = nrf52840_base 4 | board = adafruit_feather_nrf52840 5 | build_flags = ${nrf52840_base.build_flags} -Ivariants/feather_diy -Dfeather_diy 6 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" 7 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/feather_diy> 8 | lib_deps = 9 | ${nrf52840_base.lib_deps} 10 | debug_tool = jlink 11 | ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) 12 | ;upload_protocol = jlink -------------------------------------------------------------------------------- /variants/xiao_ble/platformio.ini: -------------------------------------------------------------------------------- 1 | ; Seeed Xiao BLE: https://www.digikey.com/en/products/detail/seeed-technology-co-ltd/102010448/16652893 2 | [env:xiao_ble] 3 | extends = nrf52840_base 4 | board = xiao_ble_sense 5 | board_level = extra 6 | build_flags = ${nrf52840_base.build_flags} -Ivariants/xiao_ble -Dxiao_ble -D EBYTE_E22 7 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" 8 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/xiao_ble> 9 | lib_deps = 10 | ${nrf52840_base.lib_deps} 11 | debug_tool = jlink 12 | ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) 13 | ;upload_protocol = jlink -------------------------------------------------------------------------------- /src/mesh/Default.cpp: -------------------------------------------------------------------------------- 1 | #include "Default.h" 2 | 3 | uint32_t Default::getConfiguredOrDefaultMs(uint32_t configuredInterval) 4 | { 5 | if (configuredInterval > 0) 6 | return configuredInterval * 1000; 7 | return default_broadcast_interval_secs * 1000; 8 | } 9 | 10 | uint32_t Default::getConfiguredOrDefaultMs(uint32_t configuredInterval, uint32_t defaultInterval) 11 | { 12 | if (configuredInterval > 0) 13 | return configuredInterval * 1000; 14 | return defaultInterval * 1000; 15 | } 16 | 17 | uint32_t Default::getConfiguredOrDefault(uint32_t configured, uint32_t defaultValue) 18 | { 19 | if (configured > 0) 20 | return configured; 21 | 22 | return defaultValue; 23 | } -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/deviceonly.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/deviceonly.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_PositionLite, meshtastic_PositionLite, AUTO) 10 | 11 | 12 | PB_BIND(meshtastic_NodeInfoLite, meshtastic_NodeInfoLite, AUTO) 13 | 14 | 15 | PB_BIND(meshtastic_DeviceState, meshtastic_DeviceState, 2) 16 | 17 | 18 | PB_BIND(meshtastic_ChannelFile, meshtastic_ChannelFile, 2) 19 | 20 | 21 | PB_BIND(meshtastic_OEMStore, meshtastic_OEMStore, 2) 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/input/LinuxInputImpl.h: -------------------------------------------------------------------------------- 1 | #ifdef ARCH_PORTDUINO 2 | #pragma once 3 | #include "LinuxInput.h" 4 | #include "main.h" 5 | 6 | /** 7 | * @brief The idea behind this class to have static methods for the event handlers. 8 | * Check attachInterrupt() at RotaryEncoderInteruptBase.cpp 9 | * Technically you can have as many rotary encoders hardver attached 10 | * to your device as you wish, but you always need to have separate event 11 | * handlers, thus you need to have a RotaryEncoderInterrupt implementation. 12 | */ 13 | 14 | class LinuxInputImpl : public LinuxInput 15 | { 16 | public: 17 | LinuxInputImpl(); 18 | void init(); 19 | }; 20 | extern LinuxInputImpl *aLinuxInputImpl; 21 | #endif -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/VEML7700Sensor.h: -------------------------------------------------------------------------------- 1 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 2 | #include "TelemetrySensor.h" 3 | #include 4 | 5 | class VEML7700Sensor : public TelemetrySensor 6 | { 7 | private: 8 | const float MAX_RES = 0.0036; 9 | const float GAIN_MAX = 2; 10 | const float IT_MAX = 800; 11 | Adafruit_VEML7700 veml7700; 12 | float computeLux(uint16_t rawALS, bool corrected); 13 | float getResolution(void); 14 | 15 | protected: 16 | virtual void setup() override; 17 | 18 | public: 19 | VEML7700Sensor(); 20 | virtual int32_t runOnce() override; 21 | virtual bool getMetrics(meshtastic_Telemetry *measurement) override; 22 | }; -------------------------------------------------------------------------------- /src/concurrency/Lock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../freertosinc.h" 4 | 5 | namespace concurrency 6 | { 7 | 8 | /** 9 | * @brief Simple wrapper around FreeRTOS API for implementing a mutex lock 10 | */ 11 | class Lock 12 | { 13 | public: 14 | Lock(); 15 | 16 | Lock(const Lock &) = delete; 17 | Lock &operator=(const Lock &) = delete; 18 | 19 | /// Locks the lock. 20 | // 21 | // Must not be called from an ISR. 22 | void lock(); 23 | 24 | // Unlocks the lock. 25 | // 26 | // Must not be called from an ISR. 27 | void unlock(); 28 | 29 | private: 30 | #ifdef HAS_FREE_RTOS 31 | SemaphoreHandle_t handle; 32 | #endif 33 | }; 34 | 35 | } // namespace concurrency 36 | -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/INA3221Sensor.h: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "TelemetrySensor.h" 7 | #include "VoltageSensor.h" 8 | #include 9 | 10 | class INA3221Sensor : public TelemetrySensor, VoltageSensor 11 | { 12 | private: 13 | INA3221 ina3221 = INA3221(INA3221_ADDR42_SDA); 14 | 15 | protected: 16 | void setup() override; 17 | 18 | public: 19 | INA3221Sensor(); 20 | int32_t runOnce() override; 21 | bool getMetrics(meshtastic_Telemetry *measurement) override; 22 | virtual uint16_t getBusVoltageMv() override; 23 | }; 24 | 25 | #endif -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/INA219Sensor.h: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "TelemetrySensor.h" 7 | #include "VoltageSensor.h" 8 | #include 9 | 10 | class INA219Sensor : public TelemetrySensor, VoltageSensor 11 | { 12 | private: 13 | Adafruit_INA219 ina219; 14 | 15 | protected: 16 | virtual void setup() override; 17 | 18 | public: 19 | INA219Sensor(); 20 | virtual int32_t runOnce() override; 21 | virtual bool getMetrics(meshtastic_Telemetry *measurement) override; 22 | virtual uint16_t getBusVoltageMv() override; 23 | }; 24 | 25 | #endif -------------------------------------------------------------------------------- /src/concurrency/Periodic.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "concurrency/OSThread.h" 4 | 5 | namespace concurrency 6 | { 7 | 8 | /** 9 | * @brief Periodically invoke a callback. This just provides C-style callback conventions 10 | * rather than a virtual function - FIXME, remove? 11 | */ 12 | class Periodic : public OSThread 13 | { 14 | int32_t (*callback)(); 15 | 16 | public: 17 | // callback returns the period for the next callback invocation (or 0 if we should no longer be called) 18 | Periodic(const char *name, int32_t (*_callback)()) : OSThread(name), callback(_callback) {} 19 | 20 | protected: 21 | int32_t runOnce() override { return callback(); } 22 | }; 23 | 24 | } // namespace concurrency 25 | -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/atak.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/atak.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_TAKPacket, meshtastic_TAKPacket, 2) 10 | 11 | 12 | PB_BIND(meshtastic_GeoChat, meshtastic_GeoChat, 2) 13 | 14 | 15 | PB_BIND(meshtastic_Group, meshtastic_Group, AUTO) 16 | 17 | 18 | PB_BIND(meshtastic_Status, meshtastic_Status, AUTO) 19 | 20 | 21 | PB_BIND(meshtastic_Contact, meshtastic_Contact, AUTO) 22 | 23 | 24 | PB_BIND(meshtastic_PLI, meshtastic_PLI, AUTO) 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/storeforward.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/storeforward.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_StoreAndForward, meshtastic_StoreAndForward, AUTO) 10 | 11 | 12 | PB_BIND(meshtastic_StoreAndForward_Statistics, meshtastic_StoreAndForward_Statistics, AUTO) 13 | 14 | 15 | PB_BIND(meshtastic_StoreAndForward_History, meshtastic_StoreAndForward_History, AUTO) 16 | 17 | 18 | PB_BIND(meshtastic_StoreAndForward_Heartbeat, meshtastic_StoreAndForward_Heartbeat, AUTO) 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/platform/nrf52/aes-256/tiny-aes.h: -------------------------------------------------------------------------------- 1 | #ifndef _TINY_AES_H_ 2 | #define _TINY_AES_H_ 3 | 4 | #include 5 | #include 6 | 7 | #define AES_BLOCKLEN 16 // Block length in bytes - AES is 128b block only 8 | // #define AES_KEYLEN 32 9 | #define AES_keyExpSize 240 10 | 11 | struct AES_ctx { 12 | uint8_t RoundKey[AES_keyExpSize]; 13 | uint8_t Iv[AES_BLOCKLEN]; 14 | }; 15 | 16 | void AES_init_ctx(struct AES_ctx *ctx, const uint8_t *key); 17 | void AES_init_ctx_iv(struct AES_ctx *ctx, const uint8_t *key, const uint8_t *iv); 18 | void AES_ctx_set_iv(struct AES_ctx *ctx, const uint8_t *iv); 19 | 20 | void AES_CTR_xcrypt_buffer(struct AES_ctx *ctx, uint8_t *buf, size_t length); 21 | 22 | #endif // _TINY_AES_H_ 23 | -------------------------------------------------------------------------------- /bin/gen-images.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # regen the design bins first 6 | cd design 7 | bin/generate-pngs.sh 8 | cd .. 9 | 10 | # assumes 50 wide, 28 high 11 | convert design/logo/png/Mesh_Logo_Black_Small.png -background white -alpha Background src/graphics/img/icon.xbm 12 | 13 | inkscape --batch-process -o images/compass.png -w 48 -h 48 images/location_searching-24px.svg 14 | convert compass.png -background white -alpha Background src/graphics/img/compass.xbm 15 | 16 | inkscape --batch-process -o images/face.png -w 13 -h 13 images/face-24px.svg 17 | 18 | inkscape --batch-process -o images/pin.png -w 13 -h 13 images/room-24px.svg 19 | convert pin.png -background white -alpha Background src/graphics/img/pin.xbm 20 | -------------------------------------------------------------------------------- /src/mesh/api/WiFiServerAPI.cpp: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | #include 3 | 4 | #if HAS_WIFI 5 | #include "WiFiServerAPI.h" 6 | 7 | static WiFiServerPort *apiPort; 8 | 9 | void initApiServer(int port) 10 | { 11 | // Start API server on port 4403 12 | if (!apiPort) { 13 | apiPort = new WiFiServerPort(port); 14 | LOG_INFO("API server listening on TCP port %d\n", port); 15 | apiPort->init(); 16 | } 17 | } 18 | void deInitApiServer() 19 | { 20 | delete apiPort; 21 | } 22 | 23 | WiFiServerAPI::WiFiServerAPI(WiFiClient &_client) : ServerAPI(_client) 24 | { 25 | LOG_INFO("Incoming wifi connection\n"); 26 | } 27 | 28 | WiFiServerPort::WiFiServerPort(int port) : APIServerPort(port) {} 29 | #endif -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/telemetry.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/telemetry.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_DeviceMetrics, meshtastic_DeviceMetrics, AUTO) 10 | 11 | 12 | PB_BIND(meshtastic_EnvironmentMetrics, meshtastic_EnvironmentMetrics, AUTO) 13 | 14 | 15 | PB_BIND(meshtastic_PowerMetrics, meshtastic_PowerMetrics, AUTO) 16 | 17 | 18 | PB_BIND(meshtastic_AirQualityMetrics, meshtastic_AirQualityMetrics, AUTO) 19 | 20 | 21 | PB_BIND(meshtastic_Telemetry, meshtastic_Telemetry, AUTO) 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/INA260Sensor.h: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "TelemetrySensor.h" 7 | #include "VoltageSensor.h" 8 | #include 9 | 10 | class INA260Sensor : public TelemetrySensor, VoltageSensor 11 | { 12 | private: 13 | Adafruit_INA260 ina260 = Adafruit_INA260(); 14 | 15 | protected: 16 | virtual void setup() override; 17 | 18 | public: 19 | INA260Sensor(); 20 | virtual int32_t runOnce() override; 21 | virtual bool getMetrics(meshtastic_Telemetry *measurement) override; 22 | virtual uint16_t getBusVoltageMv() override; 23 | }; 24 | 25 | #endif -------------------------------------------------------------------------------- /variants/m5stack_core/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:m5stack-core] 2 | extends = esp32_base 3 | board = m5stack-core-esp32 4 | monitor_filters = esp32_exception_decoder 5 | build_src_filter = 6 | ${esp32_base.build_src_filter} 7 | build_flags = 8 | ${esp32_base.build_flags} -I variants/m5stack_core 9 | -DILI9341_DRIVER 10 | -DM5STACK 11 | -DUSER_SETUP_LOADED 12 | -DTFT_SDA_READ 13 | -DTFT_DRIVER=0x9341 14 | -DTFT_MISO=19 15 | -DTFT_MOSI=23 16 | -DTFT_SCLK=18 17 | -DTFT_CS=14 18 | -DTFT_DC=27 19 | -DTFT_RST=33 20 | -DTFT_BL=32 21 | -DSPI_FREQUENCY=40000000 22 | -DSPI_READ_FREQUENCY=16000000 23 | -DDISABLE_ALL_LIBRARY_WARNINGS 24 | lib_ignore = 25 | m5stack-core 26 | lib_deps = 27 | ${esp32_base.lib_deps} 28 | lovyan03/LovyanGFX@^1.1.8 -------------------------------------------------------------------------------- /variants/tlora_v2_1_18/variant.h: -------------------------------------------------------------------------------- 1 | #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage 2 | // ratio of voltage divider = 2.0 (R42=100k, R43=100k) 3 | #define ADC_MULTIPLIER 2.11 // 2.0 + 10% for correction of display undervoltage. 4 | #define ADC_CHANNEL ADC1_GPIO35_CHANNEL 5 | 6 | #define I2C_SDA 21 // I2C pins for this board 7 | #define I2C_SCL 22 8 | 9 | #define LED_PIN 25 // If defined we will blink this LED 10 | #define BUTTON_PIN 12 // If defined, this will be used for user button presses, 11 | 12 | #define BUTTON_NEED_PULLUP 13 | 14 | #define USE_SX1280 15 | #define LORA_RESET 23 16 | 17 | #define SX128X_CS 18 18 | #define SX128X_DIO1 26 19 | #define SX128X_BUSY 32 20 | #define SX128X_RESET LORA_RESET -------------------------------------------------------------------------------- /variants/MakePython_nRF52840_eink/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:makerpython_nrf52840_sx1280_eink] 2 | board_level = extra 3 | extends = nrf52840_base 4 | board = nordic_pca10059 5 | build_flags = ${nrf52840_base.build_flags} -Ivariants/MakePython_nRF52840_eink -D PRIVATE_HW 6 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" 7 | -D PIN_EINK_EN 8 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/MakePython_nRF52840_eink> 9 | lib_deps = 10 | ${nrf52840_base.lib_deps} 11 | https://github.com/meshtastic/ESP32_Codec2.git#633326c78ac251c059ab3a8c430fcdf25b41672f 12 | zinggjm/GxEPD2@^1.4.9 13 | -DEINK_DISPLAY_MODEL=GxEPD2_290_T5D 14 | -DEINK_WIDTH=296 15 | -DEINK_HEIGHT=128 16 | debug_tool = jlink 17 | ;upload_port = /dev/ttyACM4 18 | -------------------------------------------------------------------------------- /variants/m5stack_coreink/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:m5stack-coreink] 2 | extends = esp32_base 3 | board = m5stack-coreink 4 | board_check = true 5 | build_src_filter = 6 | ${esp32_base.build_src_filter} 7 | build_flags = 8 | ${esp32_base.build_flags} -I variants/m5stack_coreink 9 | ;-D RADIOLIB_VERBOSE 10 | -Ofast 11 | -D__MCUXPRESSO 12 | -DEINK_DISPLAY_MODEL=GxEPD2_154_M09 13 | -DEINK_WIDTH=200 14 | -DEINK_HEIGHT=200 15 | -DUSER_SETUP_LOADED 16 | -DM5_COREINK 17 | -DM5STACK 18 | lib_deps = 19 | ${esp32_base.lib_deps} 20 | zinggjm/GxEPD2@^1.5.3 21 | lewisxhe/PCF8563_Library@^1.0.1 22 | lib_ignore = 23 | m5stack-coreink 24 | monitor_filters = esp32_exception_decoder 25 | board_build.f_cpu = 240000000L 26 | upload_protocol = esptool 27 | upload_port = /dev/ttyACM0 -------------------------------------------------------------------------------- /src/input/InputBroker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Observer.h" 3 | 4 | #define ANYKEY 0xFF 5 | #define MATRIXKEY 0xFE 6 | 7 | typedef struct _InputEvent { 8 | const char *source; 9 | char inputEvent; 10 | char kbchar; 11 | uint16_t touchX; 12 | uint16_t touchY; 13 | } InputEvent; 14 | class InputBroker : public Observable 15 | { 16 | CallbackObserver inputEventObserver = 17 | CallbackObserver(this, &InputBroker::handleInputEvent); 18 | 19 | public: 20 | InputBroker(); 21 | void registerSource(Observable *source); 22 | 23 | protected: 24 | int handleInputEvent(const InputEvent *event); 25 | }; 26 | 27 | extern InputBroker *inputBroker; -------------------------------------------------------------------------------- /variants/unphone/variant.cpp: -------------------------------------------------------------------------------- 1 | // meshtastic/firmware/variants/unphone/variant.cpp 2 | 3 | #include "unPhone.h" 4 | unPhone unphone = unPhone("meshtastic_unphone"); 5 | 6 | void initVariant() 7 | { 8 | unphone.begin(); // initialise hardware etc. 9 | unphone.store(unphone.buildTime); 10 | unphone.printWakeupReason(); // what woke us up? (stored, not printed :|) 11 | unphone.checkPowerSwitch(); // if power switch is off, shutdown 12 | unphone.backlight(false); // setup backlight and make sure its off 13 | unphone.expanderPower(true); // enable power to expander / hat / sheild 14 | 15 | for (int i = 0; i < 3; i++) { // buzz a bit 16 | unphone.vibe(true); 17 | delay(150); 18 | unphone.vibe(false); 19 | delay(150); 20 | } 21 | } -------------------------------------------------------------------------------- /variants/my_esp32s3_diy_eink/pins_arduino.h: -------------------------------------------------------------------------------- 1 | #ifndef Pins_Arduino_h 2 | #define Pins_Arduino_h 3 | 4 | #include 5 | 6 | #define USB_VID 0x303a 7 | #define USB_PID 0x1001 8 | 9 | // The default Wire will be mapped to PMU and RTC 10 | static const uint8_t SDA = 18; 11 | static const uint8_t SCL = 17; 12 | 13 | // Default SPI will be mapped to Radio 14 | static const uint8_t MISO = 3; 15 | static const uint8_t SCK = 5; 16 | static const uint8_t MOSI = 6; 17 | static const uint8_t SS = 7; 18 | 19 | // #define SPI_MOSI (11) 20 | // #define SPI_SCK (14) 21 | // #define SPI_MISO (2) 22 | // #define SPI_CS (13) 23 | 24 | // #define SDCARD_CS SPI_CS 25 | 26 | #endif /* Pins_Arduino_h */ 27 | -------------------------------------------------------------------------------- /variants/my_esp32s3_diy_oled/pins_arduino.h: -------------------------------------------------------------------------------- 1 | #ifndef Pins_Arduino_h 2 | #define Pins_Arduino_h 3 | 4 | #include 5 | 6 | #define USB_VID 0x303a 7 | #define USB_PID 0x1001 8 | 9 | // The default Wire will be mapped to PMU and RTC 10 | static const uint8_t SDA = 18; 11 | static const uint8_t SCL = 17; 12 | 13 | // Default SPI will be mapped to Radio 14 | static const uint8_t MISO = 3; 15 | static const uint8_t SCK = 5; 16 | static const uint8_t MOSI = 6; 17 | static const uint8_t SS = 7; 18 | 19 | // #define SPI_MOSI (11) 20 | // #define SPI_SCK (14) 21 | // #define SPI_MISO (2) 22 | // #define SPI_CS (13) 23 | 24 | // #define SDCARD_CS SPI_CS 25 | 26 | #endif /* Pins_Arduino_h */ 27 | -------------------------------------------------------------------------------- /variants/my_esp32s3_diy_oled/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:my-esp32s3-diy-oled] 2 | board_level = extra 3 | extends = esp32s3_base 4 | board = my-esp32s3-diy-oled 5 | board_build.arduino.memory_type = dio_opi 6 | board_build.mcu = esp32s3 7 | board_build.f_cpu = 240000000L 8 | upload_protocol = esptool 9 | ;upload_port = /dev/ttyACM0 10 | upload_speed = 921600 11 | platform_packages = 12 | tool-esptoolpy@^1.40500.0 13 | lib_deps = 14 | ${esp32_base.lib_deps} 15 | adafruit/Adafruit NeoPixel @ ^1.12.0 16 | build_unflags = -DARDUINO_USB_MODE=1 17 | build_flags = 18 | ;${esp32_base.build_flags} -D MY_ESP32S3_DIY -I variants/my_esp32s3_diy_oled 19 | ${esp32_base.build_flags} -D PRIVATE_HW -I variants/my_esp32s3_diy_oled 20 | -DBOARD_HAS_PSRAM 21 | -mfix-esp32-psram-cache-issue 22 | -DARDUINO_USB_MODE=0 -------------------------------------------------------------------------------- /variants/monteops_hw1/platformio.ini: -------------------------------------------------------------------------------- 1 | ; MonteOps M.Node/M.Backbone/M.Eagle hardware based on hardware variant #1 (RAK4630 based) 2 | [env:monteops_hw1] 3 | extends = nrf52840_base 4 | board = wiscore_rak4631 5 | build_flags = ${nrf52840_base.build_flags} -Ivariants/monteops_hw1 -D MONTEOPS_HW1 6 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" 7 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/monteops_hw1> + + + 8 | lib_deps = 9 | ${nrf52840_base.lib_deps} 10 | ${networking_base.lib_deps} 11 | https://github.com/RAKWireless/RAK13800-W5100S.git#1.0.2 12 | debug_tool = jlink 13 | ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) 14 | ;upload_protocol = jlink -------------------------------------------------------------------------------- /arch/nrf52/nrf52.ini: -------------------------------------------------------------------------------- 1 | [nrf52_base] 2 | ; Instead of the standard nordicnrf52 platform, we use our fork which has our added variant files 3 | platform = platformio/nordicnrf52@^10.4.0 4 | extends = arduino_base 5 | 6 | build_type = debug 7 | build_flags = 8 | ${arduino_base.build_flags} 9 | -DSERIAL_BUFFER_SIZE=1024 10 | -Wno-unused-variable 11 | -Isrc/platform/nrf52 12 | -DLFS_NO_ASSERT ; Disable LFS assertions , see https://github.com/meshtastic/firmware/pull/3818 13 | 14 | build_src_filter = 15 | ${arduino_base.build_src_filter} - - - - - - - - - - 16 | 17 | lib_deps= 18 | ${arduino_base.lib_deps} 19 | 20 | lib_ignore = 21 | BluetoothOTA -------------------------------------------------------------------------------- /src/platform/rp2040/architecture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define ARCH_RP2040 4 | 5 | #ifndef HAS_BUTTON 6 | #define HAS_BUTTON 1 7 | #endif 8 | #ifndef HAS_TELEMETRY 9 | #define HAS_TELEMETRY 1 10 | #endif 11 | #ifndef HAS_SCREEN 12 | #define HAS_SCREEN 1 13 | #endif 14 | #ifndef HAS_WIRE 15 | #define HAS_WIRE 1 16 | #endif 17 | #ifndef HAS_SENSOR 18 | #define HAS_SENSOR 1 19 | #endif 20 | #ifndef HAS_RADIO 21 | #define HAS_RADIO 1 22 | #endif 23 | 24 | #if defined(RPI_PICO) 25 | #define HW_VENDOR meshtastic_HardwareModel_RPI_PICO 26 | #elif defined(RAK11310) 27 | #define HW_VENDOR meshtastic_HardwareModel_RAK11310 28 | #elif defined(SENSELORA_RP2040) 29 | #define HW_VENDOR meshtastic_HardwareModel_SENSELORA_RP2040 30 | #elif defined(RP2040_LORA) 31 | #define HW_VENDOR meshtastic_HardwareModel_RP2040_LORA 32 | #endif -------------------------------------------------------------------------------- /variants/ai-c3/variant.h: -------------------------------------------------------------------------------- 1 | #define SDA 0 2 | #define SCL 1 3 | #define I2C_SDA SDA 4 | #define I2C_SCL SCL 5 | 6 | #define BUTTON_PIN 9 // BOOT button 7 | #define LED_PIN 30 // RGB LED 8 | 9 | #define USE_RF95 10 | #define LORA_SCK 4 11 | #define LORA_MISO 5 12 | #define LORA_MOSI 6 13 | #define LORA_CS 7 14 | 15 | #define LORA_DIO0 10 16 | #define LORA_DIO1 3 17 | #define LORA_RESET 2 18 | 19 | // WaveShare Core1262-868M 20 | // https://www.waveshare.com/wiki/Core1262-868M 21 | #define USE_SX1262 22 | #define SX126X_CS LORA_CS 23 | #define SX126X_DIO1 LORA_DIO1 24 | #define SX126X_BUSY 10 25 | #define SX126X_RESET LORA_RESET 26 | 27 | #define SX126X_DIO2_AS_RF_SWITCH // use DIO2 as RF switch 28 | #define SX126X_DIO3_TCXO_VOLTAGE 1.8 29 | 30 | #define HAS_GPS 0 31 | #undef GPS_RX_PIN 32 | #undef GPS_TX_PIN 33 | -------------------------------------------------------------------------------- /variants/tbeam_v07/variant.h: -------------------------------------------------------------------------------- 1 | // #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep 2 | 3 | #define I2C_SDA 21 4 | #define I2C_SCL 22 5 | 6 | #define BUTTON_PIN 39 7 | #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage 8 | #define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module. 9 | #define ADC_CHANNEL ADC1_GPIO35_CHANNEL 10 | 11 | #define USE_RF95 12 | #define LORA_DIO0 26 // a No connect on the SX1262 module 13 | #define LORA_RESET 23 14 | #define LORA_DIO1 33 15 | #define LORA_DIO2 32 // Not really used 16 | 17 | // This board has different GPS pins than all other boards 18 | #undef GPS_RX_PIN 19 | #undef GPS_TX_PIN 20 | #define GPS_RX_PIN 12 21 | #define GPS_TX_PIN 15 22 | #define GPS_UBLOX -------------------------------------------------------------------------------- /src/mesh/api/ethServerAPI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ServerAPI.h" 4 | #include 5 | 6 | /** 7 | * Provides both debug printing and, if the client starts sending protobufs to us, switches to send/receive protobufs 8 | * (and starts dropping debug printing - FIXME, eventually those prints should be encapsulated in protobufs). 9 | */ 10 | class ethServerAPI : public ServerAPI 11 | { 12 | public: 13 | explicit ethServerAPI(EthernetClient &_client); 14 | }; 15 | 16 | /** 17 | * Listens for incoming connections and does accepts and creates instances of WiFiServerAPI as needed 18 | */ 19 | class ethServerPort : public APIServerPort 20 | { 21 | public: 22 | explicit ethServerPort(int port); 23 | }; 24 | 25 | void initApiServer(int port = 4403); 26 | -------------------------------------------------------------------------------- /variants/tlora_v1/variant.h: -------------------------------------------------------------------------------- 1 | #define I2C_SDA 4 // I2C pins for this board 2 | #define I2C_SCL 15 3 | 4 | #define RESET_OLED 16 // If defined, this pin will be used to reset the display controller 5 | 6 | #define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost 7 | #define LED_PIN 2 // If defined we will blink this LED 8 | #define BUTTON_PIN 0 // If defined, this will be used for user button presses 9 | #define BUTTON_NEED_PULLUP 10 | #define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module. 11 | 12 | #define USE_RF95 13 | #define LORA_DIO0 26 // a No connect on the SX1262 module 14 | #define LORA_RESET 14 15 | #define LORA_DIO1 33 // Must be manually wired: https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436 16 | #define LORA_DIO2 32 // Not really used -------------------------------------------------------------------------------- /src/mesh/api/WiFiServerAPI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ServerAPI.h" 4 | #include 5 | 6 | /** 7 | * Provides both debug printing and, if the client starts sending protobufs to us, switches to send/receive protobufs 8 | * (and starts dropping debug printing - FIXME, eventually those prints should be encapsulated in protobufs). 9 | */ 10 | class WiFiServerAPI : public ServerAPI 11 | { 12 | public: 13 | explicit WiFiServerAPI(WiFiClient &_client); 14 | }; 15 | 16 | /** 17 | * Listens for incoming connections and does accepts and creates instances of WiFiServerAPI as needed 18 | */ 19 | class WiFiServerPort : public APIServerPort 20 | { 21 | public: 22 | explicit WiFiServerPort(int port); 23 | }; 24 | 25 | void initApiServer(int port = 4403); 26 | void deInitApiServer(); -------------------------------------------------------------------------------- /variants/esp32-s3-pico/pins_arduino.h: -------------------------------------------------------------------------------- 1 | #ifndef Pins_Arduino_h 2 | #define Pins_Arduino_h 3 | 4 | #include 5 | 6 | #define USB_VID 0x303a 7 | #define USB_PID 0x1001 8 | 9 | // The default Wire will be mapped to PMU and RTC 10 | static const uint8_t SDA = 15; 11 | static const uint8_t SCL = 16; 12 | 13 | // Default SPI will be mapped to Radio 14 | static const uint8_t MISO = 37; 15 | static const uint8_t SCK = 35; 16 | static const uint8_t MOSI = 36; 17 | static const uint8_t SS = 14; 18 | 19 | static const uint8_t BAT_ADC_PIN = 26; 20 | 21 | // #define SPI_MOSI (11) 22 | // #define SPI_SCK (14) 23 | // #define SPI_MISO (2) 24 | // #define SPI_CS (13) 25 | 26 | // #define SDCARD_CS SPI_CS 27 | 28 | #endif /* Pins_Arduino_h */ -------------------------------------------------------------------------------- /src/mesh/PointerQueue.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "TypedQueue.h" 4 | 5 | /** 6 | * A wrapper for freertos queues that assumes each element is a pointer 7 | */ 8 | template class PointerQueue : public TypedQueue 9 | { 10 | public: 11 | explicit PointerQueue(int maxElements) : TypedQueue(maxElements) {} 12 | 13 | // returns a ptr or null if the queue was empty 14 | T *dequeuePtr(TickType_t maxWait = portMAX_DELAY) 15 | { 16 | T *p; 17 | 18 | return this->dequeue(&p, maxWait) ? p : nullptr; 19 | } 20 | 21 | #ifdef HAS_FREE_RTOS 22 | // returns a ptr or null if the queue was empty 23 | T *dequeuePtrFromISR(BaseType_t *higherPriWoken) 24 | { 25 | T *p; 26 | 27 | return this->dequeueFromISR(&p, higherPriWoken) ? p : nullptr; 28 | } 29 | #endif 30 | }; 31 | -------------------------------------------------------------------------------- /boards/wiscore_rak11200.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "ldscript": "esp32_out.ld" 5 | }, 6 | "core": "esp32", 7 | "extra_flags": ["-DBOARD_HAS_PSRAM", "-DARDUINO_ESP32_DEV"], 8 | "f_cpu": "240000000L", 9 | "f_flash": "40000000L", 10 | "flash_mode": "dio", 11 | "mcu": "esp32", 12 | "variant": "WisCore_RAK11200_Board" 13 | }, 14 | "connectivity": ["wifi", "bluetooth", "ethernet", "can"], 15 | "frameworks": ["arduino", "espidf"], 16 | "name": "WisCore RAK11200 Board", 17 | "upload": { 18 | "flash_size": "4MB", 19 | "maximum_ram_size": 327680, 20 | "maximum_size": 4194304, 21 | "protocols": ["esptool", "espota", "ftdi"], 22 | "require_upload_port": true, 23 | "speed": 460800 24 | }, 25 | "url": "https://www.rakwireless.com", 26 | "vendor": "RAKwireless" 27 | } 28 | -------------------------------------------------------------------------------- /src/modules/WaypointModule.cpp: -------------------------------------------------------------------------------- 1 | #include "WaypointModule.h" 2 | #include "NodeDB.h" 3 | #include "PowerFSM.h" 4 | #include "configuration.h" 5 | 6 | WaypointModule *waypointModule; 7 | 8 | ProcessMessage WaypointModule::handleReceived(const meshtastic_MeshPacket &mp) 9 | { 10 | #ifdef DEBUG_PORT 11 | auto &p = mp.decoded; 12 | LOG_INFO("Received waypoint msg from=0x%0x, id=0x%x, msg=%.*s\n", mp.from, mp.id, p.payload.size, p.payload.bytes); 13 | #endif 14 | 15 | // We only store/display messages destined for us. 16 | // Keep a copy of the most recent text message. 17 | devicestate.rx_waypoint = mp; 18 | devicestate.has_rx_waypoint = true; 19 | 20 | powerFSM.trigger(EVENT_RECEIVED_MSG); 21 | notifyObservers(&mp); 22 | 23 | return ProcessMessage::CONTINUE; // Let others look at this message also if they want 24 | } 25 | -------------------------------------------------------------------------------- /src/modules/WaypointModule.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Observer.h" 3 | #include "SinglePortModule.h" 4 | 5 | /** 6 | * Waypoint message handling for meshtastic 7 | */ 8 | class WaypointModule : public SinglePortModule, public Observable 9 | { 10 | public: 11 | /** Constructor 12 | * name is for debugging output 13 | */ 14 | WaypointModule() : SinglePortModule("waypoint", meshtastic_PortNum_WAYPOINT_APP) {} 15 | 16 | protected: 17 | /** Called to handle a particular incoming message 18 | 19 | @return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for 20 | it 21 | */ 22 | virtual ProcessMessage handleReceived(const meshtastic_MeshPacket &mp) override; 23 | }; 24 | 25 | extern WaypointModule *waypointModule; 26 | -------------------------------------------------------------------------------- /src/input/RotaryEncoderInterruptImpl1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "RotaryEncoderInterruptBase.h" 3 | 4 | /** 5 | * @brief The idea behind this class to have static methods for the event handlers. 6 | * Check attachInterrupt() at RotaryEncoderInteruptBase.cpp 7 | * Technically you can have as many rotary encoders hardver attached 8 | * to your device as you wish, but you always need to have separate event 9 | * handlers, thus you need to have a RotaryEncoderInterrupt implementation. 10 | */ 11 | class RotaryEncoderInterruptImpl1 : public RotaryEncoderInterruptBase 12 | { 13 | public: 14 | RotaryEncoderInterruptImpl1(); 15 | bool init(); 16 | static void handleIntA(); 17 | static void handleIntB(); 18 | static void handleIntPressed(); 19 | }; 20 | 21 | extern RotaryEncoderInterruptImpl1 *rotaryEncoderInterruptImpl1; -------------------------------------------------------------------------------- /variants/rak11200/pins_arduino.h: -------------------------------------------------------------------------------- 1 | #ifndef Pins_Arduino_h 2 | #define Pins_Arduino_h 3 | 4 | #include 5 | 6 | #define LED_GREEN 12 7 | #define LED_BLUE 2 8 | 9 | #define LED_BUILTIN LED_GREEN 10 | 11 | static const uint8_t TX = 1; 12 | static const uint8_t RX = 3; 13 | 14 | #define TX1 21 15 | #define RX1 19 16 | 17 | #define WB_IO1 14 18 | #define WB_IO2 27 19 | #define WB_IO3 26 20 | #define WB_IO4 23 21 | #define WB_IO5 13 22 | #define WB_IO6 22 23 | #define WB_SW1 34 24 | #define WB_A0 36 25 | #define WB_A1 39 26 | #define WB_CS 32 27 | #define WB_LED1 12 28 | #define WB_LED2 2 29 | 30 | static const uint8_t SDA = 4; 31 | static const uint8_t SCL = 5; 32 | 33 | static const uint8_t SS = 32; 34 | static const uint8_t MOSI = 25; 35 | static const uint8_t MISO = 35; 36 | static const uint8_t SCK = 33; 37 | 38 | #endif /* Pins_Arduino_h */ 39 | -------------------------------------------------------------------------------- /variants/bpi_picow_esp32_s3/pins_arduino.h: -------------------------------------------------------------------------------- 1 | #ifndef Pins_Arduino_h 2 | #define Pins_Arduino_h 3 | 4 | #include 5 | 6 | #define USB_VID 0x303a 7 | #define USB_PID 0x1001 8 | 9 | static const uint8_t TX = 43; 10 | static const uint8_t RX = 44; 11 | 12 | // The default Wire will be mapped to PMU and RTC 13 | static const uint8_t SDA = 12; 14 | static const uint8_t SCL = 14; 15 | 16 | // Default SPI will be mapped to Radio 17 | static const uint8_t MISO = 39; 18 | static const uint8_t SCK = 21; 19 | static const uint8_t MOSI = 38; 20 | static const uint8_t SS = 17; 21 | 22 | // #define SPI_MOSI (11) 23 | // #define SPI_SCK (14) 24 | // #define SPI_MISO (2) 25 | // #define SPI_CS (13) 26 | 27 | // #define SDCARD_CS SPI_CS 28 | 29 | #endif /* Pins_Arduino_h */ 30 | -------------------------------------------------------------------------------- /variants/rpipico-slowclock/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:pico_slowclock] 2 | extends = rp2040_base 3 | board = rpipico 4 | board_level = extra 5 | upload_protocol = jlink 6 | # debug settings for external openocd with RP2040 support (custom build) 7 | debug_tool = custom 8 | debug_init_cmds = 9 | target extended-remote localhost:3333 10 | $INIT_BREAK 11 | monitor reset halt 12 | $LOAD_CMDS 13 | monitor init 14 | monitor reset halt 15 | 16 | # add our variants files to the include and src paths 17 | build_flags = ${rp2040_base.build_flags} 18 | -DRPI_PICO 19 | -Ivariants/rpipico-slowclock 20 | -DDEBUG_RP2040_PORT=Serial2 21 | -DHW_SPI1_DEVICE 22 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" 23 | -g 24 | -DNO_USB 25 | lib_deps = 26 | ${rp2040_base.lib_deps} 27 | debug_build_flags = ${rp2040_base.build_flags} 28 | -g 29 | -DNO_USB -------------------------------------------------------------------------------- /src/modules/AtakPluginModule.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ProtobufModule.h" 3 | #include "meshtastic/atak.pb.h" 4 | 5 | /** 6 | * Waypoint message handling for meshtastic 7 | */ 8 | class AtakPluginModule : public ProtobufModule, private concurrency::OSThread 9 | { 10 | public: 11 | /** Constructor 12 | * name is for debugging output 13 | */ 14 | AtakPluginModule(); 15 | 16 | protected: 17 | virtual bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_TAKPacket *t) override; 18 | virtual void alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtastic_TAKPacket *t) override; 19 | /* Does our periodic broadcast */ 20 | int32_t runOnce() override; 21 | 22 | private: 23 | meshtastic_TAKPacket cloneTAKPacketData(meshtastic_TAKPacket *t); 24 | }; 25 | 26 | extern AtakPluginModule *atakPluginModule; -------------------------------------------------------------------------------- /variants/tlora_v1_3/variant.h: -------------------------------------------------------------------------------- 1 | #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage 2 | #define ADC_CHANNEL ADC1_GPIO35_CHANNEL 3 | 4 | #define I2C_SDA 21 // I2C pins for this board 5 | #define I2C_SCL 22 6 | 7 | #define RESET_OLED 16 // If defined, this pin will be used to reset the display controller 8 | 9 | #define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost 10 | #define LED_PIN 25 // If defined we will blink this LED 11 | #define BUTTON_PIN 36 12 | #define BUTTON_NEED_PULLUP 13 | 14 | #define USE_RF95 15 | #define LORA_DIO0 26 // a No connect on the SX1262 module 16 | #define LORA_RESET 14 17 | #define LORA_DIO1 33 // Prob. must be manually wired: https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436 18 | #define LORA_DIO2 32 // Not really used -------------------------------------------------------------------------------- /bin/check-all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Note: This is a prototype for how we could add static code analysis to the CI. 4 | 5 | set -e 6 | 7 | VERSION=$(bin/buildinfo.py long) 8 | 9 | # The shell vars the build tool expects to find 10 | export APP_VERSION=$VERSION 11 | 12 | if [[ $# -gt 0 ]]; then 13 | # can override which environment by passing arg 14 | BOARDS="$@" 15 | else 16 | BOARDS="tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v2.0 heltec-v2.1 tbeam0.7 meshtastic-diy-v1 rak4631 rak4631_eink rak11200 t-echo canaryone pca10059_diy_eink" 17 | fi 18 | 19 | echo "BOARDS:${BOARDS}" 20 | 21 | CHECK="" 22 | for BOARD in $BOARDS; do 23 | CHECK="${CHECK} -e ${BOARD}" 24 | done 25 | 26 | pio check --flags "-DAPP_VERSION=${APP_VERSION} --suppressions-list=suppressions.txt" $CHECK --skip-packages --pattern="src/" --fail-on-defect=medium --fail-on-defect=high 27 | -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/RCWL9620Sensor.h: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "TelemetrySensor.h" 7 | #include 8 | 9 | class RCWL9620Sensor : public TelemetrySensor 10 | { 11 | private: 12 | uint8_t _addr = 0x57; 13 | TwoWire *_wire = &Wire; 14 | uint8_t _scl = -1; 15 | uint8_t _sda = -1; 16 | uint32_t _speed = 200000UL; 17 | 18 | protected: 19 | virtual void setup() override; 20 | void begin(TwoWire *wire = &Wire, uint8_t addr = 0x57, uint8_t sda = -1, uint8_t scl = -1, uint32_t speed = 200000UL); 21 | float getDistance(); 22 | 23 | public: 24 | RCWL9620Sensor(); 25 | virtual int32_t runOnce() override; 26 | virtual bool getMetrics(meshtastic_Telemetry *measurement) override; 27 | }; 28 | 29 | #endif -------------------------------------------------------------------------------- /boards/generic_wl5e.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "stm32", 4 | "cpu": "cortex-m4", 5 | "extra_flags": "-DSTM32WLxx -DSTM32WLE5xx -DARDUINO_GENERIC_WLE5CCUX", 6 | "f_cpu": "48000000L", 7 | "mcu": "stm32wle5ccu", 8 | "variant": "STM32WLxx/WL54CCU_WL55CCU_WLE4C(8-B-C)U_WLE5C(8-B-C)U", 9 | "product_line": "STM32WLE5xx" 10 | }, 11 | "debug": { 12 | "default_tools": ["stlink"], 13 | "jlink_device": "STM32WLE5CC", 14 | "openocd_target": "stm32wlx", 15 | "svd_path": "STM32WLE5_CM4.svd" 16 | }, 17 | "frameworks": ["arduino"], 18 | "name": "BB-STM32WL", 19 | "upload": { 20 | "maximum_ram_size": 65536, 21 | "maximum_size": 262144, 22 | "protocol": "cmsis-dap", 23 | "protocols": ["cmsis-dap", "stlink"] 24 | }, 25 | "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32wl-series.html", 26 | "vendor": "ST" 27 | } 28 | -------------------------------------------------------------------------------- /bin/build-rpi2040.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | VERSION=`bin/buildinfo.py long` 6 | SHORT_VERSION=`bin/buildinfo.py short` 7 | 8 | OUTDIR=release/ 9 | 10 | rm -f $OUTDIR/firmware* 11 | rm -r $OUTDIR/* || true 12 | 13 | # Important to pull latest version of libs into all device flavors, otherwise some devices might be stale 14 | platformio pkg update 15 | 16 | echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS" 17 | rm -f .pio/build/$1/firmware.* 18 | 19 | # The shell vars the build tool expects to find 20 | export APP_VERSION=$VERSION 21 | 22 | basename=firmware-$1-$VERSION 23 | 24 | pio run --environment $1 # -v 25 | SRCELF=.pio/build/$1/firmware.elf 26 | cp $SRCELF $OUTDIR/$basename.elf 27 | 28 | echo "Copying uf2 file" 29 | SRCBIN=.pio/build/$1/firmware.uf2 30 | cp $SRCBIN $OUTDIR/$basename.uf2 31 | 32 | cp bin/device-install.* $OUTDIR 33 | cp bin/device-update.* $OUTDIR 34 | -------------------------------------------------------------------------------- /variants/heltec_esp32c3/variant.h: -------------------------------------------------------------------------------- 1 | #define BUTTON_PIN 9 2 | 3 | // LED pin on HT-DEV-ESP_V2 and HT-DEV-ESP_V3 4 | // https://resource.heltec.cn/download/HT-CT62/HT-CT62_Reference_Design.pdf 5 | // https://resource.heltec.cn/download/HT-DEV-ESP/HT-DEV-ESP_V3_Sch.pdf 6 | #define LED_PIN 2 // LED 7 | #define LED_INVERTED 0 8 | 9 | #define HAS_SCREEN 0 10 | #define HAS_GPS 0 11 | #undef GPS_RX_PIN 12 | #undef GPS_TX_PIN 13 | 14 | #define USE_SX1262 15 | #define LORA_SCK 10 16 | #define LORA_MISO 6 17 | #define LORA_MOSI 7 18 | #define LORA_CS 8 19 | #define LORA_DIO0 RADIOLIB_NC 20 | #define LORA_RESET 5 21 | #define LORA_DIO1 3 22 | #define LORA_DIO2 RADIOLIB_NC 23 | #define LORA_BUSY 4 24 | #define SX126X_CS LORA_CS 25 | #define SX126X_DIO1 LORA_DIO1 26 | #define SX126X_BUSY LORA_BUSY 27 | #define SX126X_RESET LORA_RESET 28 | #define SX126X_DIO2_AS_RF_SWITCH 29 | #define SX126X_DIO3_TCXO_VOLTAGE 1.8 30 | -------------------------------------------------------------------------------- /variants/rak4631_epaper/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The very slick RAK wireless RAK 4631 / 4630 board - Firmware for 5005 with the RAK 14000 ePaper 2 | [env:rak4631_eink] 3 | extends = nrf52840_base 4 | board = wiscore_rak4631 5 | build_flags = ${nrf52840_base.build_flags} -Ivariants/rak4631_epaper -D RAK_4631 6 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" 7 | -DEINK_DISPLAY_MODEL=GxEPD2_213_BN 8 | -DEINK_WIDTH=250 9 | -DEINK_HEIGHT=122 10 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak4631_epaper> 11 | lib_deps = 12 | ${nrf52840_base.lib_deps} 13 | zinggjm/GxEPD2@^1.4.9 14 | melopero/Melopero RV3028@^1.1.0 15 | rakwireless/RAKwireless NCP5623 RGB LED library@^1.0.2 16 | debug_tool = jlink 17 | ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) 18 | ;upload_protocol = jlink -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature.yml: -------------------------------------------------------------------------------- 1 | name: Feature Request 2 | description: Request a new feature 3 | title: "[Feature Request]: " 4 | labels: ["enhancement"] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thanks for your request this will not gurantee that we will implement it, but it will be reviewed. 10 | - type: dropdown 11 | id: soc 12 | attributes: 13 | label: Platform 14 | description: What device platform will support your feature? 15 | multiple: true 16 | options: 17 | - NRF52 18 | - ESP32 19 | - RP2040 20 | - Linux Native 21 | - other 22 | validations: 23 | required: true 24 | - type: textarea 25 | id: body 26 | attributes: 27 | label: Description 28 | description: Please provide details about your enhancement. 29 | validations: 30 | required: true 31 | -------------------------------------------------------------------------------- /src/mesh/InterfacesTemplates.cpp: -------------------------------------------------------------------------------- 1 | #include "SX126xInterface.cpp" 2 | #include "SX126xInterface.h" 3 | #include "SX128xInterface.cpp" 4 | #include "SX128xInterface.h" 5 | #include "api/ServerAPI.cpp" 6 | #include "api/ServerAPI.h" 7 | 8 | // We need this declaration for proper linking in derived classes 9 | template class SX126xInterface; 10 | template class SX126xInterface; 11 | template class SX126xInterface; 12 | template class SX128xInterface; 13 | #ifdef ARCH_STM32WL 14 | template class SX126xInterface; 15 | #endif 16 | 17 | #if HAS_ETHERNET 18 | #include "api/ethServerAPI.h" 19 | template class ServerAPI; 20 | template class APIServerPort; 21 | #endif 22 | 23 | #if HAS_WIFI 24 | #include "api/WiFiServerAPI.h" 25 | template class ServerAPI; 26 | template class APIServerPort; 27 | #endif -------------------------------------------------------------------------------- /src/concurrency/InterruptableDelay.cpp: -------------------------------------------------------------------------------- 1 | #include "concurrency/InterruptableDelay.h" 2 | #include "configuration.h" 3 | 4 | namespace concurrency 5 | { 6 | 7 | InterruptableDelay::InterruptableDelay() {} 8 | 9 | InterruptableDelay::~InterruptableDelay() {} 10 | 11 | /** 12 | * Returns false if we were interrupted 13 | */ 14 | bool InterruptableDelay::delay(uint32_t msec) 15 | { 16 | // LOG_DEBUG("delay %u ", msec); 17 | 18 | // sem take will return false if we timed out (i.e. were not interrupted) 19 | bool r = semaphore.take(msec); 20 | 21 | // LOG_DEBUG("interrupt=%d\n", r); 22 | return !r; 23 | } 24 | 25 | void InterruptableDelay::interrupt() 26 | { 27 | semaphore.give(); 28 | } 29 | 30 | IRAM_ATTR void InterruptableDelay::interruptFromISR(BaseType_t *pxHigherPriorityTaskWoken) 31 | { 32 | semaphore.giveFromISR(pxHigherPriorityTaskWoken); 33 | } 34 | 35 | } // namespace concurrency -------------------------------------------------------------------------------- /arch/rp2040/rp2040.ini: -------------------------------------------------------------------------------- 1 | ; Common settings for rp2040 Processor based targets 2 | [rp2040_base] 3 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git#60d6ae81fcc73c34b1493ca9e261695e471bc0c2 4 | extends = arduino_base 5 | platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#3.7.2 6 | 7 | board_build.core = earlephilhower 8 | board_build.filesystem_size = 0.5m 9 | build_flags = 10 | ${arduino_base.build_flags} -Wno-unused-variable 11 | -Isrc/platform/rp2040 12 | -D__PLAT_RP2040__ 13 | # -D _POSIX_THREADS 14 | build_src_filter = 15 | ${arduino_base.build_src_filter} - - - - - - - - - 16 | 17 | lib_ignore = 18 | BluetoothOTA 19 | 20 | lib_deps = 21 | ${arduino_base.lib_deps} 22 | ${environmental_base.lib_deps} 23 | rweather/Crypto -------------------------------------------------------------------------------- /variants/CDEBYTE_EoRa-S3/pins_arduino.h: -------------------------------------------------------------------------------- 1 | // Need this file for ESP32-S3 2 | // No need to modify this file, changes to pins imported from variant.h 3 | // Most is similar to https://github.com/espressif/arduino-esp32/blob/master/variants/esp32s3/pins_arduino.h 4 | 5 | #ifndef Pins_Arduino_h 6 | #define Pins_Arduino_h 7 | 8 | #include 9 | #include 10 | 11 | #define USB_VID 0x303a 12 | #define USB_PID 0x1001 13 | 14 | // Serial 15 | static const uint8_t TX = UART_TX; 16 | static const uint8_t RX = UART_RX; 17 | 18 | // Default SPI will be mapped to Radio 19 | static const uint8_t SS = LORA_CS; 20 | static const uint8_t SCK = LORA_SCK; 21 | static const uint8_t MOSI = LORA_MOSI; 22 | static const uint8_t MISO = LORA_MISO; 23 | 24 | // The default Wire will be mapped to PMU and RTC 25 | static const uint8_t SCL = I2C_SCL; 26 | static const uint8_t SDA = I2C_SDA; 27 | 28 | #endif /* Pins_Arduino_h */ 29 | -------------------------------------------------------------------------------- /variants/EBYTE_ESP32-S3/pins_arduino.h: -------------------------------------------------------------------------------- 1 | // Need this file for ESP32-S3 2 | // No need to modify this file, changes to pins imported from variant.h 3 | // Most is similar to https://github.com/espressif/arduino-esp32/blob/master/variants/esp32s3/pins_arduino.h 4 | 5 | #ifndef Pins_Arduino_h 6 | #define Pins_Arduino_h 7 | 8 | #include 9 | #include 10 | 11 | #define USB_VID 0x303a 12 | #define USB_PID 0x1001 13 | 14 | // Serial 15 | static const uint8_t TX = UART_TX; 16 | static const uint8_t RX = UART_RX; 17 | 18 | // Default SPI will be mapped to Radio 19 | static const uint8_t SS = LORA_CS; 20 | static const uint8_t SCK = LORA_SCK; 21 | static const uint8_t MOSI = LORA_MOSI; 22 | static const uint8_t MISO = LORA_MISO; 23 | 24 | // The default Wire will be mapped to PMU and RTC 25 | static const uint8_t SCL = I2C_SCL; 26 | static const uint8_t SDA = I2C_SDA; 27 | 28 | #endif /* Pins_Arduino_h */ 29 | -------------------------------------------------------------------------------- /variants/my_esp32s3_diy_eink/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:my-esp32s3-diy-eink] 2 | board_level = extra 3 | extends = esp32s3_base 4 | board = my_esp32s3_diy_eink 5 | board_build.arduino.memory_type = dio_opi 6 | board_build.mcu = esp32s3 7 | board_build.f_cpu = 240000000L 8 | upload_protocol = esptool 9 | ;upload_port = /dev/ttyACM1 10 | upload_speed = 921600 11 | platform_packages = 12 | tool-esptoolpy@^1.40500.0 13 | lib_deps = 14 | ${esp32_base.lib_deps} 15 | zinggjm/GxEPD2@^1.5.1 16 | adafruit/Adafruit NeoPixel @ ^1.12.0 17 | build_unflags = -DARDUINO_USB_MODE=1 18 | build_flags = 19 | ;${esp32_base.build_flags} -D MY_ESP32S3_DIY -I variants/my_esp32s3_diy_eink 20 | ${esp32_base.build_flags} -D PRIVATE_HW -I variants/my_esp32s3_diy_eink 21 | -Dmy 22 | -DEINK_DISPLAY_MODEL=GxEPD2_290_T5D 23 | -DEINK_WIDTH=296 24 | -DEINK_HEIGHT=128 25 | -DBOARD_HAS_PSRAM 26 | -mfix-esp32-psram-cache-issue 27 | -DARDUINO_USB_MODE=0 -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/connection_status.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/connection_status.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_DeviceConnectionStatus, meshtastic_DeviceConnectionStatus, AUTO) 10 | 11 | 12 | PB_BIND(meshtastic_WifiConnectionStatus, meshtastic_WifiConnectionStatus, AUTO) 13 | 14 | 15 | PB_BIND(meshtastic_EthernetConnectionStatus, meshtastic_EthernetConnectionStatus, AUTO) 16 | 17 | 18 | PB_BIND(meshtastic_NetworkConnectionStatus, meshtastic_NetworkConnectionStatus, AUTO) 19 | 20 | 21 | PB_BIND(meshtastic_BluetoothConnectionStatus, meshtastic_BluetoothConnectionStatus, AUTO) 22 | 23 | 24 | PB_BIND(meshtastic_SerialConnectionStatus, meshtastic_SerialConnectionStatus, AUTO) 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/BluetoothCommon.cpp: -------------------------------------------------------------------------------- 1 | #include "BluetoothCommon.h" 2 | #include "configuration.h" 3 | 4 | // NRF52 wants these constants as byte arrays 5 | // Generated here https://yupana-engineering.com/online-uuid-to-c-array-converter - but in REVERSE BYTE ORDER 6 | const uint8_t MESH_SERVICE_UUID_16[16u] = {0xfd, 0xea, 0x73, 0xe2, 0xca, 0x5d, 0xa8, 0x9f, 7 | 0x1f, 0x46, 0xa8, 0x15, 0x18, 0xb2, 0xa1, 0x6b}; 8 | const uint8_t TORADIO_UUID_16[16u] = {0xe7, 0x01, 0x44, 0x12, 0x66, 0x78, 0xdd, 0xa1, 9 | 0xad, 0x4d, 0x9e, 0x12, 0xd2, 0x76, 0x5c, 0xf7}; 10 | const uint8_t FROMRADIO_UUID_16[16u] = {0x02, 0x00, 0x12, 0xac, 0x42, 0x02, 0x78, 0xb8, 11 | 0xed, 0x11, 0x93, 0x49, 0x9e, 0xe6, 0x55, 0x2c}; 12 | const uint8_t FROMNUM_UUID_16[16u] = {0x53, 0x44, 0xe3, 0x47, 0x75, 0xaa, 0x70, 0xa6, 13 | 0x66, 0x4f, 0x00, 0xa8, 0x8c, 0xa1, 0x9d, 0xed}; -------------------------------------------------------------------------------- /src/modules/ReplyModule.cpp: -------------------------------------------------------------------------------- 1 | #include "ReplyModule.h" 2 | #include "MeshService.h" 3 | #include "configuration.h" 4 | #include "main.h" 5 | 6 | #include 7 | 8 | meshtastic_MeshPacket *ReplyModule::allocReply() 9 | { 10 | assert(currentRequest); // should always be !NULL 11 | #ifdef DEBUG_PORT 12 | auto req = *currentRequest; 13 | auto &p = req.decoded; 14 | // The incoming message is in p.payload 15 | LOG_INFO("Received message from=0x%0x, id=%d, msg=%.*s\n", req.from, req.id, p.payload.size, p.payload.bytes); 16 | #endif 17 | 18 | screen->print("Sending reply\n"); 19 | 20 | const char *replyStr = "Message Received"; 21 | auto reply = allocDataPacket(); // Allocate a packet for sending 22 | reply->decoded.payload.size = strlen(replyStr); // You must specify how many bytes are in the reply 23 | memcpy(reply->decoded.payload.bytes, replyStr, reply->decoded.payload.size); 24 | 25 | return reply; 26 | } 27 | -------------------------------------------------------------------------------- /.github/workflows/build_rpi2040.yml: -------------------------------------------------------------------------------- 1 | name: Build RPI2040 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | board: 7 | required: true 8 | type: string 9 | 10 | jobs: 11 | build-rpi2040: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Build base 16 | id: base 17 | uses: ./.github/actions/setup-base 18 | 19 | - name: Build Raspberry Pi 2040 20 | run: ./bin/build-rpi2040.sh ${{ inputs.board }} 21 | 22 | - name: Get release version string 23 | run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT 24 | id: version 25 | 26 | - name: Store binaries as an artifact 27 | uses: actions/upload-artifact@v4 28 | with: 29 | name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip 30 | overwrite: true 31 | path: | 32 | release/*.uf2 33 | release/*.elf 34 | -------------------------------------------------------------------------------- /.github/workflows/build_nrf52.yml: -------------------------------------------------------------------------------- 1 | name: Build NRF52 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | board: 7 | required: true 8 | type: string 9 | 10 | jobs: 11 | build-nrf52: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Build base 16 | id: base 17 | uses: ./.github/actions/setup-base 18 | 19 | - name: Build NRF52 20 | run: bin/build-nrf52.sh ${{ inputs.board }} 21 | 22 | - name: Get release version string 23 | run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT 24 | id: version 25 | 26 | - name: Store binaries as an artifact 27 | uses: actions/upload-artifact@v4 28 | with: 29 | name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip 30 | overwrite: true 31 | path: | 32 | release/*.uf2 33 | release/*.elf 34 | release/*.zip 35 | -------------------------------------------------------------------------------- /boards/wiphone.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "ldscript": "esp32_out.ld", 5 | "partitions": "default_16MB.csv" 6 | }, 7 | "core": "esp32", 8 | "extra_flags": [ 9 | "-DARDUINO_WIPHONE14", 10 | "-DBOARD_HAS_PSRAM", 11 | "-mfix-esp32-psram-cache-issue", 12 | "-mfix-esp32-psram-cache-strategy=memw" 13 | ], 14 | "f_cpu": "240000000L", 15 | "f_flash": "40000000L", 16 | "flash_mode": "dio", 17 | "mcu": "esp32", 18 | "variant": "wiphone", 19 | "board": "WiPhone" 20 | }, 21 | "connectivity": ["wifi", "bluetooth"], 22 | "frameworks": ["arduino", "espidf"], 23 | "name": "WIPhone Integrated 1.4", 24 | "upload": { 25 | "flash_size": "16MB", 26 | "maximum_ram_size": 532480, 27 | "maximum_size": 6553600, 28 | "maximum_data_size": 4521984, 29 | "require_upload_port": true, 30 | "speed": 921600 31 | }, 32 | "url": "https://www.wiphone.io/", 33 | "vendor": "HackEDA" 34 | } 35 | -------------------------------------------------------------------------------- /src/modules/TextMessageModule.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Observer.h" 3 | #include "SinglePortModule.h" 4 | 5 | /** 6 | * Text message handling for meshtastic - draws on the OLED display the most recent received message 7 | */ 8 | class TextMessageModule : public SinglePortModule, public Observable 9 | { 10 | public: 11 | /** Constructor 12 | * name is for debugging output 13 | */ 14 | TextMessageModule() : SinglePortModule("text", meshtastic_PortNum_TEXT_MESSAGE_APP) {} 15 | 16 | protected: 17 | /** Called to handle a particular incoming message 18 | 19 | @return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for 20 | it 21 | */ 22 | virtual ProcessMessage handleReceived(const meshtastic_MeshPacket &mp) override; 23 | virtual bool wantPacket(const meshtastic_MeshPacket *p) override; 24 | }; 25 | 26 | extern TextMessageModule *textMessageModule; -------------------------------------------------------------------------------- /variants/lora_relay_v1/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The https://github.com/BigCorvus/SX1262-LoRa-BLE-Relay board by @BigCorvus 2 | [env:lora-relay-v1] 3 | extends = nrf52840_base 4 | board = lora-relay-v1 5 | board_level = extra 6 | # add our variants files to the include and src paths 7 | # define build flags for the TFT_eSPI library 8 | build_flags = ${nrf52840_base.build_flags} -Ivariants/lora_relay_v1 9 | -DUSER_SETUP_LOADED 10 | -DTFT_WIDTH=80 11 | -DTFT_HEIGHT=160 12 | -DST7735_GREENTAB160x80 13 | -DST7735_DRIVER 14 | -DTFT_CS=ST7735_CS 15 | -DTFT_DC=ST7735_RS 16 | -DTFT_RST=ST7735_RESET 17 | -DSPI_FREQUENCY=27000000 18 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" 19 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/lora_relay_v1> 20 | lib_deps = 21 | ${nrf52840_base.lib_deps} 22 | sparkfun/SparkFun BQ27441 LiPo Fuel Gauge Arduino Library@^1.1.0 23 | bodmer/TFT_eSPI@^2.4.76 24 | adafruit/Adafruit NeoPixel @ ^1.12.0 -------------------------------------------------------------------------------- /.github/workflows/update_protobufs.yml: -------------------------------------------------------------------------------- 1 | name: "Update protobufs and regenerate classes" 2 | on: workflow_dispatch 3 | 4 | jobs: 5 | update-protobufs: 6 | runs-on: ubuntu-latest 7 | 8 | steps: 9 | - name: Checkout code 10 | uses: actions/checkout@v4 11 | with: 12 | submodules: true 13 | 14 | - name: Update submodule 15 | run: | 16 | git submodule update --remote protobufs 17 | 18 | - name: Download nanopb 19 | run: | 20 | wget https://jpa.kapsi.fi/nanopb/download/nanopb-0.4.8-linux-x86.tar.gz 21 | tar xvzf nanopb-0.4.8-linux-x86.tar.gz 22 | mv nanopb-0.4.8-linux-x86 nanopb-0.4.8 23 | 24 | - name: Re-generate protocol buffers 25 | run: | 26 | ./bin/regen-protos.sh 27 | 28 | - name: Create pull request 29 | uses: peter-evans/create-pull-request@v6 30 | with: 31 | add-paths: | 32 | protobufs 33 | src/mesh 34 | -------------------------------------------------------------------------------- /src/concurrency/BinarySemaphoreFreeRTOS.cpp: -------------------------------------------------------------------------------- 1 | #include "concurrency/BinarySemaphoreFreeRTOS.h" 2 | #include "configuration.h" 3 | #include 4 | 5 | #ifdef HAS_FREE_RTOS 6 | 7 | namespace concurrency 8 | { 9 | 10 | BinarySemaphoreFreeRTOS::BinarySemaphoreFreeRTOS() : semaphore(xSemaphoreCreateBinary()) 11 | { 12 | assert(semaphore); 13 | } 14 | 15 | BinarySemaphoreFreeRTOS::~BinarySemaphoreFreeRTOS() 16 | { 17 | vSemaphoreDelete(semaphore); 18 | } 19 | 20 | /** 21 | * Returns false if we were interrupted 22 | */ 23 | bool BinarySemaphoreFreeRTOS::take(uint32_t msec) 24 | { 25 | return xSemaphoreTake(semaphore, pdMS_TO_TICKS(msec)); 26 | } 27 | 28 | void BinarySemaphoreFreeRTOS::give() 29 | { 30 | xSemaphoreGive(semaphore); 31 | } 32 | 33 | IRAM_ATTR void BinarySemaphoreFreeRTOS::giveFromISR(BaseType_t *pxHigherPriorityTaskWoken) 34 | { 35 | xSemaphoreGiveFromISR(semaphore, pxHigherPriorityTaskWoken); 36 | } 37 | 38 | } // namespace concurrency 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /variants/rak4631_epaper_onrxtx/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The very slick RAK wireless RAK 4631 / 4630 board - Firmware for 5005 with the RAK 14000 ePaper 2 | [env:rak4631_eink_onrxtx] 3 | board_level = extra 4 | extends = nrf52840_base 5 | board = wiscore_rak4631 6 | build_flags = ${nrf52840_base.build_flags} -Ivariants/rak4631_epaper -D RAK_4631 7 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" 8 | -D PIN_EINK_EN=34 9 | -D EINK_DISPLAY_MODEL=GxEPD2_213_BN 10 | -D EINK_WIDTH=250 11 | -D EINK_HEIGHT=122 12 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak4631_epaper_onrxtx> 13 | lib_deps = 14 | ${nrf52840_base.lib_deps} 15 | zinggjm/GxEPD2@^1.5.1 16 | melopero/Melopero RV3028@^1.1.0 17 | rakwireless/RAKwireless NCP5623 RGB LED library@^1.0.2 18 | debug_tool = jlink 19 | ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) 20 | ;upload_protocol = jlink 21 | ;upload_port = /dev/ttyACM3 22 | -------------------------------------------------------------------------------- /variants/tlora_v2_1_16/variant.h: -------------------------------------------------------------------------------- 1 | #define BATTERY_PIN 35 2 | #define ADC_CHANNEL ADC1_GPIO35_CHANNEL 3 | #define BATTERY_SENSE_SAMPLES 30 4 | 5 | // ratio of voltage divider = 2.0 (R42=100k, R43=100k) 6 | #define ADC_MULTIPLIER 2 7 | 8 | #define I2C_SDA 21 // I2C pins for this board 9 | #define I2C_SCL 22 10 | 11 | #define LED_PIN 25 // If defined we will blink this LED 12 | #define BUTTON_PIN 12 // If defined, this will be used for user button presses, 13 | 14 | #define BUTTON_NEED_PULLUP 15 | 16 | #define USE_RF95 17 | #define LORA_DIO0 26 // a No connect on the SX1262 module 18 | #define LORA_RESET 23 19 | 20 | // In the T3 V1.6.1 TXCO version, GPIO 33 is connected to Radio’s 21 | // internal temperature-compensated crystal oscillator enable 22 | #ifdef LORA_TCXO_GPIO 23 | #define LORA_DIO1 RADIOLIB_NC // no-connect on sx127x module 24 | #else 25 | #define LORA_DIO1 33 // https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436 26 | #endif 27 | 28 | #define LORA_DIO2 32 // Not really used -------------------------------------------------------------------------------- /variants/unphone/platformio.ini: -------------------------------------------------------------------------------- 1 | ; platformio.ini for unphone meshtastic 2 | 3 | [env:unphone] 4 | 5 | extends = esp32s3_base 6 | board = unphone9 7 | upload_speed = 921600 8 | monitor_speed = 115200 9 | monitor_filters = esp32_exception_decoder 10 | 11 | build_unflags = 12 | ${esp32s3_base.build_unflags} 13 | -D ARDUINO_USB_MODE 14 | 15 | build_flags = ${esp32_base.build_flags} 16 | ;-D BOARD_HAS_PSRAM // what's up with this - doesn't seem to be recognised at boot 17 | -D UNPHONE 18 | -I variants/unphone 19 | -D ARDUINO_USB_MODE=0 20 | -D UNPHONE_ACCEL=0 21 | -D UNPHONE_TOUCHS=0 22 | -D UNPHONE_SDCARD=0 23 | -D UNPHONE_UI0=0 24 | -D UNPHONE_LORA=0 25 | -D UNPHONE_FACTORY_MODE=0 26 | 27 | build_src_filter = ${esp32_base.build_src_filter} +<../variants/unphone> 28 | 29 | lib_deps = ${esp32s3_base.lib_deps} 30 | lovyan03/LovyanGFX @ ^1.1.8 31 | https://gitlab.com/hamishcunningham/unphonelibrary#meshtastic @ ^9.0.0 32 | adafruit/Adafruit NeoPixel @ ^1.12.0 -------------------------------------------------------------------------------- /variants/xiao_ble/xiao_ble.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # adapted from the script linked in this very helpful article: https://enzolombardi.net/low-power-bluetooth-advertising-with-xiao-ble-and-platformio-e8e7d0da80d2 3 | 4 | # source: https://gist.githubusercontent.com/turing-complete-labs/b3105ee653782183c54b4fdbe18f411f/raw/d86779ba7702775d3b79781da63d85442acd9de6/xiao_ble.sh 5 | # download the core for arduino from seeedstudio. Softdevice 7.3.0, linker and variants folder are what we need 6 | curl https://files.seeedstudio.com/arduino/core/nRF52840/Arduino_core_nRF52840.tar.bz2 -o arduino.core.1.0.0.tar.bz2 7 | tar -xjf arduino.core.1.0.0.tar.bz2 8 | rm arduino.core.1.0.0.tar.bz2 9 | 10 | # copy the needed files 11 | cp 1.0.0/cores/nRF5/linker/nrf52840_s140_v7.ld ~/.platformio/packages/framework-arduinoadafruitnrf52/cores/nRF5/linker 12 | cp -r 1.0.0/cores/nRF5/nordic/softdevice/s140_nrf52_7.3.0_API ~/.platformio/packages/framework-arduinoadafruitnrf52/cores/nRF5/nordic/softdevice 13 | 14 | rm -rf 1.0.0 15 | echo done! 16 | -------------------------------------------------------------------------------- /src/modules/TextMessageModule.cpp: -------------------------------------------------------------------------------- 1 | #include "TextMessageModule.h" 2 | #include "MeshService.h" 3 | #include "NodeDB.h" 4 | #include "PowerFSM.h" 5 | #include "configuration.h" 6 | 7 | TextMessageModule *textMessageModule; 8 | 9 | ProcessMessage TextMessageModule::handleReceived(const meshtastic_MeshPacket &mp) 10 | { 11 | #ifdef DEBUG_PORT 12 | auto &p = mp.decoded; 13 | LOG_INFO("Received text msg from=0x%0x, id=0x%x, msg=%.*s\n", mp.from, mp.id, p.payload.size, p.payload.bytes); 14 | #endif 15 | 16 | // We only store/display messages destined for us. 17 | // Keep a copy of the most recent text message. 18 | devicestate.rx_text_message = mp; 19 | devicestate.has_rx_text_message = true; 20 | 21 | powerFSM.trigger(EVENT_RECEIVED_MSG); 22 | notifyObservers(&mp); 23 | 24 | return ProcessMessage::CONTINUE; // Let others look at this message also if they want 25 | } 26 | 27 | bool TextMessageModule::wantPacket(const meshtastic_MeshPacket *p) 28 | { 29 | return MeshService::isTextPayload(p); 30 | } -------------------------------------------------------------------------------- /boards/tbeam-s3-core.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "ldscript": "esp32s3_out.ld" 5 | }, 6 | "core": "esp32", 7 | "extra_flags": [ 8 | "-DBOARD_HAS_PSRAM", 9 | "-DLILYGO_TBEAM_S3_CORE", 10 | "-DARDUINO_USB_CDC_ON_BOOT=1", 11 | "-DARDUINO_USB_MODE=0", 12 | "-DARDUINO_RUNNING_CORE=1", 13 | "-DARDUINO_EVENT_RUNNING_CORE=1" 14 | ], 15 | "f_cpu": "240000000L", 16 | "f_flash": "80000000L", 17 | "flash_mode": "dio", 18 | "hwids": [["0x303A", "0x1001"]], 19 | "mcu": "esp32s3", 20 | "variant": "tbeam-s3-core" 21 | }, 22 | "connectivity": ["wifi"], 23 | "debug": { 24 | "openocd_target": "esp32s3.cfg" 25 | }, 26 | "frameworks": ["arduino"], 27 | "name": "LilyGo TBeam-S3-Core", 28 | "upload": { 29 | "flash_size": "8MB", 30 | "maximum_ram_size": 327680, 31 | "maximum_size": 8388608, 32 | "require_upload_port": true, 33 | "speed": 921600 34 | }, 35 | "url": "http://www.lilygo.cn/", 36 | "vendor": "LilyGo" 37 | } 38 | -------------------------------------------------------------------------------- /src/BluetoothCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | /** 6 | * Common lib functions for all platforms that have bluetooth 7 | */ 8 | 9 | #define MESH_SERVICE_UUID "6ba1b218-15a8-461f-9fa8-5dcae273eafd" 10 | 11 | #define TORADIO_UUID "f75c76d2-129e-4dad-a1dd-7866124401e7" 12 | #define FROMRADIO_UUID "2c55e69e-4993-11ed-b878-0242ac120002" 13 | #define FROMNUM_UUID "ed9da18c-a800-4f66-a670-aa7547e34453" 14 | 15 | // NRF52 wants these constants as byte arrays 16 | // Generated here https://yupana-engineering.com/online-uuid-to-c-array-converter - but in REVERSE BYTE ORDER 17 | extern const uint8_t MESH_SERVICE_UUID_16[], TORADIO_UUID_16[16u], FROMRADIO_UUID_16[], FROMNUM_UUID_16[]; 18 | 19 | /// Given a level between 0-100, update the BLE attribute 20 | void updateBatteryLevel(uint8_t level); 21 | 22 | class BluetoothApi 23 | { 24 | public: 25 | virtual void setup(); 26 | virtual void shutdown(); 27 | virtual void clearBonds(); 28 | virtual bool isConnected(); 29 | virtual int getRssi() = 0; 30 | }; -------------------------------------------------------------------------------- /variants/lora_relay_v2/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The https://github.com/BigCorvus/LoRa-BLE-Relay-v2 board by @BigCorvus 2 | [env:lora-relay-v2] 3 | extends = nrf52840_base 4 | board = lora-relay-v2 5 | board_level = extra 6 | # add our variants files to the include and src paths 7 | # define build flags for the TFT_eSPI library 8 | build_flags = ${nrf52840_base.build_flags} -Ivariants/lora_relay_v2 9 | -DUSER_SETUP_LOADED 10 | -DTFT_WIDTH=80 11 | -DTFT_HEIGHT=160 12 | -DST7735_GREENTAB160x80 13 | -DST7735_DRIVER 14 | -DTFT_CS=ST7735_CS 15 | -DTFT_DC=ST7735_RS 16 | -DTFT_RST=ST7735_RESET 17 | -DSPI_FREQUENCY=27000000 18 | -DTFT_WR=ST7735_SDA 19 | -DTFT_SCLK=ST7735_SCK 20 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" 21 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/lora_relay_v2> 22 | lib_deps = 23 | ${nrf52840_base.lib_deps} 24 | sparkfun/SparkFun BQ27441 LiPo Fuel Gauge Arduino Library@^1.1.0 25 | bodmer/TFT_eSPI@^2.4.76 26 | adafruit/Adafruit NeoPixel @ ^1.12.0 -------------------------------------------------------------------------------- /variants/tlora_v2/variant.h: -------------------------------------------------------------------------------- 1 | #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage 2 | #define ADC_CHANNEL ADC1_GPIO35_CHANNEL 3 | 4 | #define I2C_SDA 21 // I2C pins for this board 5 | #define I2C_SCL 22 6 | 7 | #define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost 8 | #define LED_PIN 25 // If defined we will blink this LED 9 | #define BUTTON_PIN \ 10 | 0 // If defined, this will be used for user button presses, if your board doesn't have a physical switch, you can wire one 11 | // between this pin and ground 12 | #define BUTTON_NEED_PULLUP 13 | 14 | #define USE_RF95 15 | #define LORA_DIO0 26 // a No connect on the SX1262 module 16 | #define LORA_RESET 14 17 | #define LORA_DIO1 33 // Must be manually wired: https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436 18 | #define LORA_DIO2 32 // Not really used -------------------------------------------------------------------------------- /bin/build-nrf52.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | VERSION=`bin/buildinfo.py long` 6 | SHORT_VERSION=`bin/buildinfo.py short` 7 | 8 | OUTDIR=release/ 9 | 10 | rm -f $OUTDIR/firmware* 11 | rm -r $OUTDIR/* || true 12 | 13 | # Important to pull latest version of libs into all device flavors, otherwise some devices might be stale 14 | platformio pkg update 15 | 16 | echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS" 17 | rm -f .pio/build/$1/firmware.* 18 | 19 | # The shell vars the build tool expects to find 20 | export APP_VERSION=$VERSION 21 | 22 | basename=firmware-$1-$VERSION 23 | 24 | pio run --environment $1 # -v 25 | SRCELF=.pio/build/$1/firmware.elf 26 | DFUPKG=.pio/build/$1/firmware.zip 27 | cp $SRCELF $OUTDIR/$basename.elf 28 | cp $DFUPKG $OUTDIR/$basename-ota.zip 29 | 30 | echo "Generating NRF52 uf2 file" 31 | SRCHEX=.pio/build/$1/firmware.hex 32 | bin/uf2conv.py $SRCHEX -c -o $OUTDIR/$basename.uf2 -f 0xADA52840 33 | 34 | cp bin/device-install.* $OUTDIR 35 | cp bin/device-update.* $OUTDIR 36 | cp bin/*.uf2 $OUTDIR 37 | -------------------------------------------------------------------------------- /src/mesh/CryptoEngine.cpp: -------------------------------------------------------------------------------- 1 | #include "CryptoEngine.h" 2 | #include "configuration.h" 3 | 4 | concurrency::Lock *cryptLock; 5 | 6 | void CryptoEngine::setKey(const CryptoKey &k) 7 | { 8 | LOG_DEBUG("Using AES%d key!\n", k.length * 8); 9 | key = k; 10 | } 11 | 12 | /** 13 | * Encrypt a packet 14 | * 15 | * @param bytes is updated in place 16 | */ 17 | void CryptoEngine::encrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) 18 | { 19 | LOG_WARN("noop encryption!\n"); 20 | } 21 | 22 | void CryptoEngine::decrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) 23 | { 24 | LOG_WARN("noop decryption!\n"); 25 | } 26 | 27 | /** 28 | * Init our 128 bit nonce for a new packet 29 | */ 30 | void CryptoEngine::initNonce(uint32_t fromNode, uint64_t packetId) 31 | { 32 | memset(nonce, 0, sizeof(nonce)); 33 | 34 | // use memcpy to avoid breaking strict-aliasing 35 | memcpy(nonce, &packetId, sizeof(uint64_t)); 36 | memcpy(nonce + sizeof(uint64_t), &fromNode, sizeof(uint32_t)); 37 | } -------------------------------------------------------------------------------- /boards/bpi_picow_esp32_s3.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "ldscript": "esp32s3_out.ld" 5 | }, 6 | "core": "esp32", 7 | "extra_flags": [ 8 | "-DARDUINO_USB_CDC_ON_BOOT=1", 9 | "-DARDUINO_USB_MODE=0", 10 | "-DARDUINO_RUNNING_CORE=1", 11 | "-DARDUINO_EVENT_RUNNING_CORE=1", 12 | "-DBOARD_HAS_PSRAM" 13 | ], 14 | "f_cpu": "240000000L", 15 | "f_flash": "80000000L", 16 | "flash_mode": "dio", 17 | "hwids": [["0x303A", "0x1001"]], 18 | "mcu": "esp32s3", 19 | "variant": "bpi_picow_esp32_s3" 20 | }, 21 | "connectivity": ["wifi"], 22 | "debug": { 23 | "openocd_target": "esp32s3.cfg" 24 | }, 25 | "frameworks": ["arduino", "espidf"], 26 | "name": "BPI-PicoW-S3 (8 MB FLASH, 2 MB PSRAM)", 27 | "upload": { 28 | "flash_size": "8MB", 29 | "maximum_ram_size": 327680, 30 | "maximum_size": 8388608, 31 | "require_upload_port": true, 32 | "speed": 921600 33 | }, 34 | "url": "https://wiki.banana-pi.org/BPI-PicoW-S3", 35 | "vendor": "BPI" 36 | } 37 | -------------------------------------------------------------------------------- /.trunk/trunk.yaml: -------------------------------------------------------------------------------- 1 | version: 0.1 2 | cli: 3 | version: 1.22.1 4 | plugins: 5 | sources: 6 | - id: trunk 7 | ref: v1.5.0 8 | uri: https://github.com/trunk-io/plugins 9 | lint: 10 | enabled: 11 | - trufflehog@3.76.3 12 | - yamllint@1.35.1 13 | - bandit@1.7.8 14 | - checkov@3.2.95 15 | - terrascan@1.19.1 16 | - trivy@0.51.1 17 | #- trufflehog@3.63.2-rc0 18 | - taplo@0.8.1 19 | - ruff@0.4.4 20 | - isort@5.13.2 21 | - markdownlint@0.40.0 22 | - oxipng@9.1.1 23 | - svgo@3.3.2 24 | - actionlint@1.7.0 25 | - flake8@7.0.0 26 | - hadolint@2.12.0 27 | - shfmt@3.6.0 28 | - shellcheck@0.10.0 29 | - black@24.4.2 30 | - git-diff-check 31 | - gitleaks@8.18.2 32 | - clang-format@16.0.3 33 | - prettier@3.2.5 34 | runtimes: 35 | enabled: 36 | - python@3.10.8 37 | - go@1.21.0 38 | - node@18.12.1 39 | actions: 40 | disabled: 41 | - trunk-announce 42 | enabled: 43 | - trunk-fmt-pre-commit 44 | - trunk-check-pre-push 45 | - trunk-upgrade-available 46 | -------------------------------------------------------------------------------- /boards/tlora-t3s3-v1.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "ldscript": "esp32s3_out.ld" 5 | }, 6 | "core": "esp32", 7 | "extra_flags": [ 8 | "-DLILYGO_T3S3_V1", 9 | "-DARDUINO_USB_CDC_ON_BOOT=1", 10 | "-DARDUINO_USB_MODE=0", 11 | "-DARDUINO_RUNNING_CORE=1", 12 | "-DARDUINO_EVENT_RUNNING_CORE=1", 13 | "-DBOARD_HAS_PSRAM" 14 | ], 15 | "f_cpu": "240000000L", 16 | "f_flash": "80000000L", 17 | "flash_mode": "dio", 18 | "hwids": [["0x303A", "0x1001"]], 19 | "mcu": "esp32s3", 20 | "variant": "tlora-t3s3-v1" 21 | }, 22 | "connectivity": ["wifi"], 23 | "debug": { 24 | "openocd_target": "esp32s3.cfg" 25 | }, 26 | "frameworks": ["arduino", "espidf"], 27 | "name": "LilyGo TLora-T3S3-V1", 28 | "upload": { 29 | "flash_size": "4MB", 30 | "maximum_ram_size": 327680, 31 | "maximum_size": 4194304, 32 | "wait_for_upload_port": true, 33 | "require_upload_port": true, 34 | "speed": 921600 35 | }, 36 | "url": "http://www.lilygo.cn/", 37 | "vendor": "LilyGo" 38 | } 39 | -------------------------------------------------------------------------------- /boards/lora_isp4520.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "ldscript": "nrf52832_s132_v6.ld" 5 | }, 6 | "core": "nRF5", 7 | "cpu": "cortex-m4", 8 | "extra_flags": "-DNRF52832_XXAA -DNRF52", 9 | "f_cpu": "64000000L", 10 | "mcu": "nrf52832", 11 | "variant": "lora_isp4520", 12 | "bsp": { 13 | "name": "adafruit" 14 | }, 15 | "softdevice": { 16 | "sd_flags": "-DS132", 17 | "sd_name": "s132", 18 | "sd_version": "6.1.1", 19 | "sd_fwid": "0x00B7" 20 | } 21 | }, 22 | "connectivity": ["bluetooth"], 23 | "debug": { 24 | "jlink_device": "nRF52832_xxAA", 25 | "svd_path": "nrf52.svd", 26 | "openocd_target": "nrf52840-mdk-rs" 27 | }, 28 | "frameworks": ["arduino"], 29 | "name": "lora ISP4520", 30 | "upload": { 31 | "maximum_ram_size": 65536, 32 | "maximum_size": 524288, 33 | "require_upload_port": true, 34 | "speed": 115200, 35 | "protocol": "nrfutil", 36 | "protocols": ["jlink", "nrfjprog", "nrfutil", "stlink"] 37 | }, 38 | "url": "", 39 | "vendor": "PsiSoft" 40 | } 41 | -------------------------------------------------------------------------------- /src/mesh/Throttle.cpp: -------------------------------------------------------------------------------- 1 | #include "Throttle.h" 2 | #include 3 | 4 | /// @brief Execute a function throttled to a minimum interval 5 | /// @param lastExecutionMs Pointer to the last execution time in milliseconds 6 | /// @param minumumIntervalMs Minimum execution interval in milliseconds 7 | /// @param throttleFunc Function to execute if the execution is not deferred 8 | /// @param onDefer Default to NULL, execute the function if the execution is deferred 9 | /// @return true if the function was executed, false if it was deferred 10 | bool Throttle::execute(uint32_t *lastExecutionMs, uint32_t minumumIntervalMs, void (*throttleFunc)(void), void (*onDefer)(void)) 11 | { 12 | if (*lastExecutionMs == 0) { 13 | *lastExecutionMs = millis(); 14 | throttleFunc(); 15 | return true; 16 | } 17 | uint32_t now = millis(); 18 | 19 | if ((now - *lastExecutionMs) >= minumumIntervalMs) { 20 | throttleFunc(); 21 | *lastExecutionMs = now; 22 | return true; 23 | } else if (onDefer != NULL) { 24 | onDefer(); 25 | } 26 | return false; 27 | } -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/MCP9808Sensor.cpp: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "MCP9808Sensor.h" 7 | #include "TelemetrySensor.h" 8 | #include 9 | 10 | MCP9808Sensor::MCP9808Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_MCP9808, "MCP9808") {} 11 | 12 | int32_t MCP9808Sensor::runOnce() 13 | { 14 | LOG_INFO("Init sensor: %s\n", sensorName); 15 | if (!hasSensor()) { 16 | return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; 17 | } 18 | status = mcp9808.begin(nodeTelemetrySensorsMap[sensorType].first, nodeTelemetrySensorsMap[sensorType].second); 19 | return initI2CSensor(); 20 | } 21 | 22 | void MCP9808Sensor::setup() 23 | { 24 | mcp9808.setResolution(2); 25 | } 26 | 27 | bool MCP9808Sensor::getMetrics(meshtastic_Telemetry *measurement) 28 | { 29 | LOG_DEBUG("MCP9808Sensor::getMetrics\n"); 30 | measurement->variant.environment_metrics.temperature = mcp9808.readTempC(); 31 | return true; 32 | } 33 | 34 | #endif -------------------------------------------------------------------------------- /src/platform/stm32wl/STM32WLCryptoEngine.cpp: -------------------------------------------------------------------------------- 1 | #include "CryptoEngine.h" 2 | #include "aes.hpp" 3 | #include "configuration.h" 4 | 5 | class STM32WLCryptoEngine : public CryptoEngine 6 | { 7 | public: 8 | STM32WLCryptoEngine() {} 9 | 10 | ~STM32WLCryptoEngine() {} 11 | 12 | /** 13 | * Encrypt a packet 14 | * 15 | * @param bytes is updated in place 16 | */ 17 | virtual void encrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes) override 18 | { 19 | if (key.length > 0) { 20 | AES_ctx ctx; 21 | initNonce(fromNode, packetNum); 22 | AES_init_ctx_iv(&ctx, key.bytes, nonce); 23 | AES_CTR_xcrypt_buffer(&ctx, bytes, numBytes); 24 | } 25 | } 26 | 27 | virtual void decrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes) override 28 | { 29 | // For CTR, the implementation is the same 30 | encrypt(fromNode, packetNum, numBytes, bytes); 31 | } 32 | 33 | private: 34 | }; 35 | 36 | CryptoEngine *crypto = new STM32WLCryptoEngine(); 37 | -------------------------------------------------------------------------------- /boards/CDEBYTE_EoRa-S3.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "ldscript": "esp32s3_out.ld" 5 | }, 6 | "core": "esp32", 7 | "extra_flags": [ 8 | "-D CDEBYTE_EORA_S3", 9 | "-D ARDUINO_USB_CDC_ON_BOOT=1", 10 | "-D ARDUINO_USB_MODE=0", 11 | "-D ARDUINO_RUNNING_CORE=1", 12 | "-D ARDUINO_EVENT_RUNNING_CORE=1", 13 | "-D BOARD_HAS_PSRAM" 14 | ], 15 | "f_cpu": "240000000L", 16 | "f_flash": "80000000L", 17 | "flash_mode": "dio", 18 | "hwids": [["0x303A", "0x1001"]], 19 | "mcu": "esp32s3", 20 | "variant": "CDEBYTE_EoRa-S3" 21 | }, 22 | "connectivity": ["wifi"], 23 | "debug": { 24 | "openocd_target": "esp32s3.cfg" 25 | }, 26 | "frameworks": ["arduino", "espidf"], 27 | "name": "CDEBYTE EoRa-S3", 28 | "upload": { 29 | "flash_size": "4MB", 30 | "maximum_ram_size": 327680, 31 | "maximum_size": 4194304, 32 | "wait_for_upload_port": true, 33 | "require_upload_port": true, 34 | "speed": 921600 35 | }, 36 | "url": "https://www.cdebyte.com/Module-Testkits-EoRaPI", 37 | "vendor": "CDEBYTE" 38 | } 39 | -------------------------------------------------------------------------------- /src/platform/stm32wl/main-stm32wl.cpp: -------------------------------------------------------------------------------- 1 | #include "RTC.h" 2 | #include "configuration.h" 3 | #include 4 | #include 5 | 6 | void setBluetoothEnable(bool enable) {} 7 | 8 | void playStartMelody() {} 9 | 10 | void updateBatteryLevel(uint8_t level) {} 11 | 12 | void getMacAddr(uint8_t *dmac) 13 | { 14 | // https://flit.github.io/2020/06/06/mcu-unique-id-survey.html 15 | const uint32_t uid0 = HAL_GetUIDw0(); // X/Y coordinate on wafer 16 | const uint32_t uid1 = HAL_GetUIDw1(); // [31:8] Lot number (23:0), [7:0] Wafer number 17 | const uint32_t uid2 = HAL_GetUIDw2(); // Lot number (55:24) 18 | 19 | // Need to go from 96-bit to 48-bit unique ID 20 | dmac[5] = (uint8_t)uid0; 21 | dmac[4] = (uint8_t)(uid0 >> 16); 22 | dmac[3] = (uint8_t)uid1; 23 | dmac[2] = (uint8_t)(uid1 >> 8); 24 | dmac[1] = (uint8_t)uid2; 25 | dmac[0] = (uint8_t)(uid2 >> 8); 26 | } 27 | 28 | void cpuDeepSleep(uint32_t msecToWake) {} 29 | 30 | /* pacify libc_nano */ 31 | extern "C" { 32 | int _gettimeofday(struct timeval *tv, void *tzvp) 33 | { 34 | return -1; 35 | } 36 | } -------------------------------------------------------------------------------- /arch/stm32/stm32wl5e.ini: -------------------------------------------------------------------------------- 1 | [stm32wl5e_base] 2 | platform_packages = platformio/framework-arduinoststm32 @ https://github.com/stm32duino/Arduino_Core_STM32.git#6e3f9910d0122e82a6c3438507dfac3d2fd80a39 3 | platform = ststm32 4 | board = generic_wl5e 5 | framework = arduino 6 | 7 | build_type = debug 8 | 9 | build_flags = 10 | ${arduino_base.build_flags} 11 | -Isrc/platform/stm32wl -g 12 | -DconfigUSE_CMSIS_RTOS_V2=1 13 | -DVECT_TAB_OFFSET=0x08000000 14 | 15 | build_src_filter = 16 | ${arduino_base.build_src_filter} - - - - - - - - - - - - - - 17 | 18 | board_upload.offset_address = 0x08000000 19 | upload_protocol = stlink 20 | 21 | lib_deps = 22 | ${env.lib_deps} 23 | https://github.com/kokke/tiny-AES-c.git#f06ac37fc31dfdaca2e0d9bec83f90d5663c319b 24 | https://github.com/littlefs-project/littlefs.git#v2.5.1 25 | https://github.com/stm32duino/STM32FreeRTOS.git#10.3.1 26 | 27 | lib_ignore = 28 | mathertel/OneButton -------------------------------------------------------------------------------- /.github/workflows/sec_sast_semgrep_cron.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Semgrep Full Scan 3 | 4 | on: 5 | workflow_dispatch: 6 | branches: 7 | - master 8 | schedule: 9 | - cron: "0 1 * * 6" 10 | 11 | jobs: 12 | semgrep-full: 13 | runs-on: ubuntu-latest 14 | container: 15 | image: returntocorp/semgrep 16 | 17 | steps: 18 | # step 1 19 | - name: clone application source code 20 | uses: actions/checkout@v4 21 | 22 | # step 2 23 | - name: full scan 24 | run: | 25 | semgrep \ 26 | --sarif --output report.sarif \ 27 | --metrics=off \ 28 | --config="p/default" 29 | 30 | # step 3 31 | - name: save report as pipeline artifact 32 | uses: actions/upload-artifact@v4 33 | with: 34 | name: report.sarif 35 | overwrite: true 36 | path: report.sarif 37 | 38 | # step 4 39 | - name: publish code scanning alerts 40 | uses: github/codeql-action/upload-sarif@v3 41 | with: 42 | sarif_file: report.sarif 43 | category: semgrep 44 | -------------------------------------------------------------------------------- /variants/feather_diy/variant.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014-2015 Arduino LLC. All right reserved. 3 | Copyright (c) 2016 Sandeep Mistry All right reserved. 4 | Copyright (c) 2018, Adafruit Industries (adafruit.com) 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | See the GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "variant.h" 22 | #include "nrf.h" 23 | #include "wiring_constants.h" 24 | #include "wiring_digital.h" 25 | -------------------------------------------------------------------------------- /bin/build-native.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | platformioFailed() { 6 | [[ $VIRTUAL_ENV != "" ]] && exit 1 # don't hint at virtualenv if it's already in use 7 | echo -e "\nThere were issues running platformio and you are not using a virtual environment." \ 8 | "\nYou may try setting up virtualenv and downloading the latest platformio from pip:" \ 9 | "\n\tvirtualenv venv" \ 10 | "\n\tsource venv/bin/activate" \ 11 | "\n\tpip install platformio" \ 12 | "\n\t./bin/build-native.sh # retry building" 13 | exit 1 14 | } 15 | 16 | VERSION=$(bin/buildinfo.py long) 17 | SHORT_VERSION=$(bin/buildinfo.py short) 18 | 19 | OUTDIR=release/ 20 | 21 | rm -f $OUTDIR/firmware* 22 | 23 | mkdir -p $OUTDIR/ 24 | rm -r $OUTDIR/* || true 25 | 26 | # Important to pull latest version of libs into all device flavors, otherwise some devices might be stale 27 | platformio pkg update --environment native || platformioFailed 28 | pio run --environment native || platformioFailed 29 | cp .pio/build/native/program "$OUTDIR/meshtasticd_linux_$(uname -m)" 30 | cp bin/device-install.* $OUTDIR 31 | cp bin/device-update.* $OUTDIR 32 | -------------------------------------------------------------------------------- /.github/workflows/sec_sast_flawfinder.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Flawfinder Scan 3 | 4 | on: 5 | push: 6 | branches: [master, develop] 7 | paths-ignore: 8 | - "**.md" 9 | - "version.properties" 10 | 11 | jobs: 12 | flawfinder: 13 | runs-on: ubuntu-latest 14 | name: Flawfinder 15 | 16 | steps: 17 | # step 1 18 | - name: clone application source code 19 | uses: actions/checkout@v4 20 | 21 | # step 2 22 | - name: flawfinder_scan 23 | uses: david-a-wheeler/flawfinder@2.0.19 24 | with: 25 | arguments: "--sarif ./" 26 | output: "flawfinder_report.sarif" 27 | 28 | # step 3 29 | - name: save report as pipeline artifact 30 | uses: actions/upload-artifact@v4 31 | with: 32 | name: flawfinder_report.sarif 33 | overwrite: true 34 | path: flawfinder_report.sarif 35 | 36 | # step 4 37 | - name: publish code scanning alerts 38 | uses: github/codeql-action/upload-sarif@v3 39 | with: 40 | sarif_file: flawfinder_report.sarif 41 | category: flawfinder 42 | -------------------------------------------------------------------------------- /variants/rak4631/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The very slick RAK wireless RAK 4631 / 4630 board - Unified firmware for 5005/19003, with or without OLED RAK 1921 2 | [env:rak4631] 3 | extends = nrf52840_base 4 | board = wiscore_rak4631 5 | board_check = true 6 | build_flags = ${nrf52840_base.build_flags} -Ivariants/rak4631 -D RAK_4631 7 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" 8 | -DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. 9 | -DEINK_DISPLAY_MODEL=GxEPD2_213_BN 10 | -DEINK_WIDTH=250 11 | -DEINK_HEIGHT=122 12 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak4631> + + + 13 | lib_deps = 14 | ${nrf52840_base.lib_deps} 15 | ${networking_base.lib_deps} 16 | melopero/Melopero RV3028@^1.1.0 17 | https://github.com/RAKWireless/RAK13800-W5100S.git#1.0.2 18 | rakwireless/RAKwireless NCP5623 RGB LED library@^1.0.2 19 | debug_tool = jlink 20 | ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) 21 | ;upload_protocol = jlink -------------------------------------------------------------------------------- /arch/portduino/portduino.ini: -------------------------------------------------------------------------------- 1 | ; The Portduino based sim environment on top of any host OS, all hardware will be simulated 2 | [portduino_base] 3 | platform = https://github.com/meshtastic/platform-native.git#ad8112adf82ce1f5b917092cf32be07a077801a0 4 | framework = arduino 5 | 6 | build_src_filter = 7 | ${env.build_src_filter} 8 | - 9 | - 10 | - 11 | - 12 | - 13 | - 14 | - 15 | + 16 | - 17 | - 18 | - 19 | - 20 | - 21 | +<../variants/portduino> 22 | 23 | lib_deps = 24 | ${env.lib_deps} 25 | ${networking_base.lib_deps} 26 | rweather/Crypto@^0.4.0 27 | https://github.com/lovyan03/LovyanGFX.git#5a39989aa2c9492572255b22f033843ec8900233 28 | 29 | build_flags = 30 | ${arduino_base.build_flags} 31 | -fPIC 32 | -Isrc/platform/portduino 33 | -DRADIOLIB_EEPROM_UNSUPPORTED 34 | -DPORTDUINO_LINUX_HARDWARE 35 | -lbluetooth 36 | -lgpiod 37 | -lyaml-cpp 38 | -------------------------------------------------------------------------------- /variants/betafpv_2400_tx_micro/variant.h: -------------------------------------------------------------------------------- 1 | // https://betafpv.com/products/elrs-micro-tx-module 2 | 3 | // 0.96" OLED 4 | #define I2C_SDA 22 5 | #define I2C_SCL 32 6 | 7 | // NO GPS 8 | #undef GPS_RX_PIN 9 | #undef GPS_TX_PIN 10 | 11 | #define LORA_SCK 18 12 | #define LORA_MISO 19 13 | #define LORA_MOSI 23 14 | #define LORA_CS 5 15 | #define RF95_FAN_EN 17 16 | 17 | // #define LED_PIN 16 // This is a LED_WS2812 not a standard LED 18 | #define HAS_NEOPIXEL // Enable the use of neopixels 19 | #define NEOPIXEL_COUNT 1 // How many neopixels are connected 20 | #define NEOPIXEL_DATA 16 // gpio pin used to send data to the neopixels 21 | #define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use 22 | 23 | #define BUTTON_PIN 25 24 | #define BUTTON_NEED_PULLUP 25 | 26 | #undef EXT_NOTIFY_OUT 27 | 28 | // SX128X 2.4 Ghz LoRa module 29 | #define USE_SX1280 30 | #define LORA_RESET 14 31 | #define SX128X_CS 5 32 | #define SX128X_DIO1 4 33 | #define SX128X_BUSY 21 34 | #define SX128X_TXEN 26 35 | #define SX128X_RXEN 27 36 | #define SX128X_RESET LORA_RESET 37 | #define SX128X_MAX_POWER 13 -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/SHTC3Sensor.cpp: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "SHTC3Sensor.h" 7 | #include "TelemetrySensor.h" 8 | #include 9 | 10 | SHTC3Sensor::SHTC3Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHTC3, "SHTC3") {} 11 | 12 | int32_t SHTC3Sensor::runOnce() 13 | { 14 | LOG_INFO("Init sensor: %s\n", sensorName); 15 | if (!hasSensor()) { 16 | return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; 17 | } 18 | status = shtc3.begin(); 19 | return initI2CSensor(); 20 | } 21 | 22 | void SHTC3Sensor::setup() 23 | { 24 | // Set up oversampling and filter initialization 25 | } 26 | 27 | bool SHTC3Sensor::getMetrics(meshtastic_Telemetry *measurement) 28 | { 29 | sensors_event_t humidity, temp; 30 | shtc3.getEvent(&humidity, &temp); 31 | 32 | measurement->variant.environment_metrics.temperature = temp.temperature; 33 | measurement->variant.environment_metrics.relative_humidity = humidity.relative_humidity; 34 | 35 | return true; 36 | } 37 | 38 | #endif -------------------------------------------------------------------------------- /boards/heltec_wireless_tracker.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "ldscript": "esp32s3_out.ld", 5 | "partitions": "default_8MB.csv" 6 | }, 7 | "core": "esp32", 8 | "extra_flags": [ 9 | "-DHELTEC_WIRELESS_TRACKER", 10 | "-DARDUINO_USB_CDC_ON_BOOT=1", 11 | "-DARDUINO_USB_MODE=0", 12 | "-DARDUINO_RUNNING_CORE=1", 13 | "-DARDUINO_EVENT_RUNNING_CORE=1" 14 | ], 15 | "f_cpu": "240000000L", 16 | "f_flash": "80000000L", 17 | "flash_mode": "qio", 18 | "hwids": [["0x303A", "0x1001"]], 19 | "mcu": "esp32s3", 20 | "variant": "heltec_wireless_tracker" 21 | }, 22 | "connectivity": ["wifi", "bluetooth", "lora"], 23 | "debug": { 24 | "openocd_target": "esp32s3.cfg" 25 | }, 26 | "frameworks": ["arduino", "espidf"], 27 | "name": "Heltec Wireless Tracker", 28 | "upload": { 29 | "flash_size": "8MB", 30 | "maximum_ram_size": 327680, 31 | "maximum_size": 8388608, 32 | "wait_for_upload_port": true, 33 | "require_upload_port": true, 34 | "speed": 921600 35 | }, 36 | "url": "https://heltec.org/project/wireless-tracker/", 37 | "vendor": "Heltec" 38 | } 39 | -------------------------------------------------------------------------------- /src/concurrency/InterruptableDelay.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../freertosinc.h" 4 | 5 | #ifdef HAS_FREE_RTOS 6 | #include "concurrency/BinarySemaphoreFreeRTOS.h" 7 | #define BinarySemaphore BinarySemaphoreFreeRTOS 8 | #else 9 | #include "concurrency/BinarySemaphorePosix.h" 10 | #define BinarySemaphore BinarySemaphorePosix 11 | #endif 12 | 13 | namespace concurrency 14 | { 15 | 16 | /** 17 | * An object that provides delay(msec) like functionality, but can be interrupted by calling interrupt(). 18 | * 19 | * Useful for they top level loop() delay call to keep the CPU powered down until our next scheduled event or some external event. 20 | * 21 | * This is implemented for FreeRTOS but should be easy to port to other operating systems. 22 | */ 23 | class InterruptableDelay 24 | { 25 | BinarySemaphore semaphore; 26 | 27 | public: 28 | InterruptableDelay(); 29 | ~InterruptableDelay(); 30 | 31 | /** 32 | * Returns false if we were interrupted 33 | */ 34 | bool delay(uint32_t msec); 35 | 36 | void interrupt(); 37 | 38 | void interruptFromISR(BaseType_t *pxHigherPriorityTaskWoken); 39 | }; 40 | 41 | } // namespace concurrency -------------------------------------------------------------------------------- /variants/heltec_v1/variant.h: -------------------------------------------------------------------------------- 1 | // the default ESP32 Pin of 15 is the Oled SCL, set to 36 and 37 and works fine. 2 | // Tested on Neo6m module. 3 | #undef GPS_RX_PIN 4 | #undef GPS_TX_PIN 5 | #define GPS_RX_PIN 36 6 | #define GPS_TX_PIN 33 7 | 8 | #ifndef USE_JTAG // gpio15 is TDO for JTAG, so no I2C on this board while doing jtag 9 | #define I2C_SDA 4 // I2C pins for this board 10 | #define I2C_SCL 15 11 | #endif 12 | 13 | #define RESET_OLED 16 // If defined, this pin will be used to reset the display controller 14 | 15 | #define LED_PIN 25 // If defined we will blink this LED 16 | #define BUTTON_PIN 0 // If defined, this will be used for user button presses 17 | 18 | #define USE_RF95 19 | #define LORA_DIO0 26 // a No connect on the SX1262 module 20 | #ifndef USE_JTAG 21 | #define LORA_RESET 14 22 | #endif 23 | #define LORA_DIO1 RADIOLIB_NC 24 | #define LORA_DIO2 32 // Not really used 25 | 26 | // ratio of voltage divider = 3.20 (R1=100k, R2=220k) 27 | #define ADC_MULTIPLIER 3.2 28 | 29 | #define BATTERY_PIN 13 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage 30 | #define ADC_CHANNEL ADC2_GPIO13_CHANNEL 31 | #define BAT_MEASURE_ADC_UNIT 2 -------------------------------------------------------------------------------- /src/mesh/STM32WLE5JCInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SX126xInterface.h" 4 | 5 | #ifdef ARCH_STM32WL 6 | 7 | /** 8 | * Our adapter for STM32WLE5JC radios 9 | */ 10 | class STM32WLE5JCInterface : public SX126xInterface 11 | { 12 | public: 13 | STM32WLE5JCInterface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, 14 | RADIOLIB_PIN_TYPE busy); 15 | 16 | virtual bool init() override; 17 | }; 18 | 19 | // https://github.com/Seeed-Studio/LoRaWan-E5-Node/blob/main/Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver/radio_driver.c 20 | static const float tcxoVoltage = 1.7; 21 | 22 | /* https://wiki.seeedstudio.com/LoRa-E5_STM32WLE5JC_Module/ 23 | * Wio-E5 module ONLY transmits through RFO_HP 24 | * Receive: PA4=1, PA5=0 25 | * Transmit(high output power, SMPS mode): PA4=0, PA5=1 */ 26 | static const RADIOLIB_PIN_TYPE rfswitch_pins[3] = {PA4, PA5, RADIOLIB_NC}; 27 | 28 | static const Module::RfSwitchMode_t rfswitch_table[4] = { 29 | {STM32WLx::MODE_IDLE, {LOW, LOW}}, {STM32WLx::MODE_RX, {HIGH, LOW}}, {STM32WLx::MODE_TX_HP, {LOW, HIGH}}, END_OF_MODE_TABLE}; 30 | 31 | #endif // ARCH_STM32WL -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/SHT31Sensor.cpp: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "SHT31Sensor.h" 7 | #include "TelemetrySensor.h" 8 | #include 9 | 10 | SHT31Sensor::SHT31Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHT31, "SHT31") {} 11 | 12 | int32_t SHT31Sensor::runOnce() 13 | { 14 | LOG_INFO("Init sensor: %s\n", sensorName); 15 | if (!hasSensor()) { 16 | return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; 17 | } 18 | sht31 = Adafruit_SHT31(nodeTelemetrySensorsMap[sensorType].second); 19 | status = sht31.begin(nodeTelemetrySensorsMap[sensorType].first); 20 | return initI2CSensor(); 21 | } 22 | 23 | void SHT31Sensor::setup() 24 | { 25 | // Set up oversampling and filter initialization 26 | } 27 | 28 | bool SHT31Sensor::getMetrics(meshtastic_Telemetry *measurement) 29 | { 30 | measurement->variant.environment_metrics.temperature = sht31.readTemperature(); 31 | measurement->variant.environment_metrics.relative_humidity = sht31.readHumidity(); 32 | 33 | return true; 34 | } 35 | 36 | #endif -------------------------------------------------------------------------------- /bin/build-esp32.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | VERSION=`bin/buildinfo.py long` 6 | SHORT_VERSION=`bin/buildinfo.py short` 7 | 8 | OUTDIR=release/ 9 | 10 | rm -f $OUTDIR/firmware* 11 | rm -r $OUTDIR/* || true 12 | 13 | # Important to pull latest version of libs into all device flavors, otherwise some devices might be stale 14 | platformio pkg update 15 | 16 | echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS" 17 | rm -f .pio/build/$1/firmware.* 18 | 19 | # The shell vars the build tool expects to find 20 | export APP_VERSION=$VERSION 21 | 22 | basename=firmware-$1-$VERSION 23 | 24 | pio run --environment $1 # -v 25 | SRCELF=.pio/build/$1/firmware.elf 26 | cp $SRCELF $OUTDIR/$basename.elf 27 | 28 | echo "Copying ESP32 bin file" 29 | SRCBIN=.pio/build/$1/firmware.factory.bin 30 | cp $SRCBIN $OUTDIR/$basename.bin 31 | 32 | echo "Copying ESP32 update bin file" 33 | SRCBIN=.pio/build/$1/firmware.bin 34 | cp $SRCBIN $OUTDIR/$basename-update.bin 35 | 36 | echo "Building Filesystem for ESP32 targets" 37 | pio run --environment $1 -t buildfs 38 | cp .pio/build/$1/littlefs.bin $OUTDIR/littlefs-$VERSION.bin 39 | cp bin/device-install.* $OUTDIR 40 | cp bin/device-update.* $OUTDIR 41 | -------------------------------------------------------------------------------- /src/graphics/ScreenFonts.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef OLED_RU 4 | #include "graphics/fonts/OLEDDisplayFontsRU.h" 5 | #endif 6 | 7 | #ifdef OLED_UA 8 | #include "graphics/fonts/OLEDDisplayFontsUA.h" 9 | #endif 10 | 11 | #if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(ST7789_CS) || defined(HX8357_CS)) && \ 12 | !defined(DISPLAY_FORCE_SMALL_FONTS) 13 | // The screen is bigger so use bigger fonts 14 | #define FONT_SMALL ArialMT_Plain_16 // Height: 19 15 | #define FONT_MEDIUM ArialMT_Plain_24 // Height: 28 16 | #define FONT_LARGE ArialMT_Plain_24 // Height: 28 17 | #else 18 | #ifdef OLED_RU 19 | #define FONT_SMALL ArialMT_Plain_10_RU 20 | #else 21 | #ifdef OLED_UA 22 | #define FONT_SMALL ArialMT_Plain_10_UA 23 | #else 24 | #define FONT_SMALL ArialMT_Plain_10 // Height: 13 25 | #endif 26 | #endif 27 | #define FONT_MEDIUM ArialMT_Plain_16 // Height: 19 28 | #define FONT_LARGE ArialMT_Plain_24 // Height: 28 29 | #endif 30 | 31 | #define fontHeight(font) ((font)[1] + 1) // height is position 1 32 | 33 | #define FONT_HEIGHT_SMALL fontHeight(FONT_SMALL) 34 | #define FONT_HEIGHT_MEDIUM fontHeight(FONT_MEDIUM) 35 | #define FONT_HEIGHT_LARGE fontHeight(FONT_LARGE) 36 | -------------------------------------------------------------------------------- /boards/t-watch-s3.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "arduino": { 4 | "ldscript": "esp32s3_out.ld", 5 | "memory_type": "qio_opi" 6 | }, 7 | "core": "esp32", 8 | "extra_flags": [ 9 | "-DBOARD_HAS_PSRAM", 10 | "-DT_WATCH_S3", 11 | "-DARDUINO_USB_CDC_ON_BOOT=1", 12 | "-DARDUINO_USB_MODE=0", 13 | "-DARDUINO_RUNNING_CORE=1", 14 | "-DARDUINO_EVENT_RUNNING_CORE=1" 15 | ], 16 | "f_cpu": "240000000L", 17 | "f_flash": "80000000L", 18 | "flash_mode": "qio", 19 | "hwids": [ 20 | ["0x303A", "0x1001"], 21 | ["0x303A", "0x0002"] 22 | ], 23 | "mcu": "esp32s3", 24 | "variant": "t-watch-s3" 25 | }, 26 | "connectivity": ["wifi"], 27 | "debug": { 28 | "openocd_target": "esp32s3.cfg" 29 | }, 30 | "frameworks": ["arduino"], 31 | "name": "LilyGo T-Watch 2020 V3", 32 | "upload": { 33 | "flash_size": "8MB", 34 | "maximum_ram_size": 327680, 35 | "maximum_size": 8388608, 36 | "require_upload_port": true, 37 | "use_1200bps_touch": true, 38 | "wait_for_upload_port": true, 39 | "speed": 921600 40 | }, 41 | "url": "https://www.lilygo.cc/en-pl/products/t-watch-s3", 42 | "vendor": "LilyGo" 43 | } 44 | -------------------------------------------------------------------------------- /src/PowerFSM.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // See sw-design.md for documentation 6 | 7 | #define EVENT_PRESS 1 8 | #define EVENT_WAKE_TIMER 2 9 | // #define EVENT_RECEIVED_PACKET 3 10 | #define EVENT_PACKET_FOR_PHONE 4 11 | #define EVENT_RECEIVED_MSG 5 12 | // #define EVENT_BOOT 6 // now done with a timed transition 13 | #define EVENT_BLUETOOTH_PAIR 7 14 | #define EVENT_NODEDB_UPDATED 8 // NodeDB has a big enough change that we think you should turn on the screen 15 | #define EVENT_CONTACT_FROM_PHONE 9 // the phone just talked to us over bluetooth 16 | #define EVENT_LOW_BATTERY 10 // Battery is critically low, go to sleep 17 | #define EVENT_SERIAL_CONNECTED 11 18 | #define EVENT_SERIAL_DISCONNECTED 12 19 | #define EVENT_POWER_CONNECTED 13 20 | #define EVENT_POWER_DISCONNECTED 14 21 | #define EVENT_FIRMWARE_UPDATE 15 // We just received a new firmware update packet from the phone 22 | #define EVENT_SHUTDOWN 16 // force a full shutdown now (not just sleep) 23 | #define EVENT_INPUT 17 // input broker wants something, we need to wake up and enable screen 24 | 25 | extern Fsm powerFSM; 26 | extern State stateON, statePOWER, stateSERIAL, stateDARK; 27 | 28 | void PowerFSM_setup(); 29 | -------------------------------------------------------------------------------- /src/mesh/generated/meshtastic/config.pb.cpp: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.8 */ 3 | 4 | #include "meshtastic/config.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(meshtastic_Config, meshtastic_Config, AUTO) 10 | 11 | 12 | PB_BIND(meshtastic_Config_DeviceConfig, meshtastic_Config_DeviceConfig, AUTO) 13 | 14 | 15 | PB_BIND(meshtastic_Config_PositionConfig, meshtastic_Config_PositionConfig, AUTO) 16 | 17 | 18 | PB_BIND(meshtastic_Config_PowerConfig, meshtastic_Config_PowerConfig, AUTO) 19 | 20 | 21 | PB_BIND(meshtastic_Config_NetworkConfig, meshtastic_Config_NetworkConfig, AUTO) 22 | 23 | 24 | PB_BIND(meshtastic_Config_NetworkConfig_IpV4Config, meshtastic_Config_NetworkConfig_IpV4Config, AUTO) 25 | 26 | 27 | PB_BIND(meshtastic_Config_DisplayConfig, meshtastic_Config_DisplayConfig, AUTO) 28 | 29 | 30 | PB_BIND(meshtastic_Config_LoRaConfig, meshtastic_Config_LoRaConfig, 2) 31 | 32 | 33 | PB_BIND(meshtastic_Config_BluetoothConfig, meshtastic_Config_BluetoothConfig, AUTO) 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/modules/Telemetry/Sensor/BMP085Sensor.cpp: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR 4 | 5 | #include "../mesh/generated/meshtastic/telemetry.pb.h" 6 | #include "BMP085Sensor.h" 7 | #include "TelemetrySensor.h" 8 | #include 9 | #include 10 | 11 | BMP085Sensor::BMP085Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BMP085, "BMP085") {} 12 | 13 | int32_t BMP085Sensor::runOnce() 14 | { 15 | LOG_INFO("Init sensor: %s\n", sensorName); 16 | if (!hasSensor()) { 17 | return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; 18 | } 19 | bmp085 = Adafruit_BMP085(); 20 | status = bmp085.begin(nodeTelemetrySensorsMap[sensorType].first, nodeTelemetrySensorsMap[sensorType].second); 21 | 22 | return initI2CSensor(); 23 | } 24 | 25 | void BMP085Sensor::setup() {} 26 | 27 | bool BMP085Sensor::getMetrics(meshtastic_Telemetry *measurement) 28 | { 29 | LOG_DEBUG("BMP085Sensor::getMetrics\n"); 30 | measurement->variant.environment_metrics.temperature = bmp085.readTemperature(); 31 | measurement->variant.environment_metrics.barometric_pressure = bmp085.readPressure() / 100.0F; 32 | 33 | return true; 34 | } 35 | 36 | #endif -------------------------------------------------------------------------------- /variants/rak10701/platformio.ini: -------------------------------------------------------------------------------- 1 | ; The very slick RAK wireless RAK10701 Field Tester device. Note you will have to flash to Arduino bootloader to use this firmware. Be aware touch is not currently working. 2 | [env:rak10701] 3 | extends = nrf52840_base 4 | board_level = extra 5 | board = wiscore_rak4631 6 | build_flags = ${nrf52840_base.build_flags} -Ivariants/rak10701 -D RAK_4631 7 | -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard" 8 | -DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. 9 | -DEINK_DISPLAY_MODEL=GxEPD2_213_BN 10 | -DEINK_WIDTH=250 11 | -DEINK_HEIGHT=122 12 | build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak10701> + + + 13 | lib_deps = 14 | ${nrf52840_base.lib_deps} 15 | ${networking_base.lib_deps} 16 | melopero/Melopero RV3028@^1.1.0 17 | https://github.com/RAKWireless/RAK13800-W5100S.git#1.0.2 18 | rakwireless/RAKwireless NCP5623 RGB LED library@^1.0.2 19 | bodmer/TFT_eSPI 20 | debug_tool = jlink 21 | ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) 22 | ;upload_protocol = jlink -------------------------------------------------------------------------------- /variants/heltec_wireless_paper_v1/platformio.ini: -------------------------------------------------------------------------------- 1 | [env:heltec-wireless-paper-v1_0] 2 | extends = esp32s3_base 3 | board = heltec_wifi_lora_32_V3 4 | build_flags = 5 | ${esp32s3_base.build_flags} 6 | -I variants/heltec_wireless_paper_v1 7 | -D HELTEC_WIRELESS_PAPER_V1_0 8 | -D EINK_DISPLAY_MODEL=GxEPD2_213_BN 9 | -D EINK_WIDTH=250 10 | -D EINK_HEIGHT=122 11 | -D USE_EINK_DYNAMICDISPLAY ; Enable Dynamic EInk 12 | -D EINK_LIMIT_FASTREFRESH=5 ; How many consecutive fast-refreshes are permitted 13 | -D EINK_LIMIT_RATE_BACKGROUND_SEC=30 ; Minimum interval between BACKGROUND updates 14 | -D EINK_LIMIT_RATE_RESPONSIVE_SEC=1 ; Minimum interval between RESPONSIVE updates 15 | -D EINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated 16 | ;-D EINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached. 17 | -D EINK_HASQUIRK_VICIOUSFASTREFRESH ; Identify that pixels drawn by fast-refresh are harder to clear 18 | lib_deps = 19 | ${esp32s3_base.lib_deps} 20 | https://github.com/meshtastic/GxEPD2#55f618961db45a23eff0233546430f1e5a80f63a 21 | lewisxhe/PCF8563_Library@^1.0.1 22 | upload_speed = 115200 -------------------------------------------------------------------------------- /variants/heltec_wsl_v3/variant.h: -------------------------------------------------------------------------------- 1 | #define I2C_SCL SCL 2 | #define I2C_SDA SDA 3 | 4 | #define LED_PIN LED 5 | 6 | #define VEXT_ENABLE Vext // active low, powers the oled display and the lora antenna boost 7 | #define BUTTON_PIN 0 8 | 9 | #define ADC_CTRL 37 10 | #define ADC_CTRL_ENABLED LOW 11 | #define BATTERY_PIN 1 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage 12 | #define ADC_CHANNEL ADC1_GPIO1_CHANNEL 13 | #define ADC_ATTENUATION ADC_ATTEN_DB_2_5 // lower dB for high resistance voltage divider 14 | #define ADC_MULTIPLIER 4.9 15 | 16 | #define USE_SX1262 17 | 18 | #define LORA_DIO0 -1 // a No connect on the SX1262 module 19 | #define LORA_RESET 12 20 | #define LORA_DIO1 14 // SX1262 IRQ 21 | #define LORA_DIO2 13 // SX1262 BUSY 22 | #define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled 23 | 24 | #define LORA_SCK 9 25 | #define LORA_MISO 11 26 | #define LORA_MOSI 10 27 | #define LORA_CS 8 28 | 29 | #define SX126X_CS LORA_CS 30 | #define SX126X_DIO1 LORA_DIO1 31 | #define SX126X_BUSY LORA_DIO2 32 | #define SX126X_RESET LORA_RESET 33 | 34 | #define SX126X_DIO2_AS_RF_SWITCH 35 | #define SX126X_DIO3_TCXO_VOLTAGE 1.8 36 | --------------------------------------------------------------------------------