mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-19 01:41:30 +10:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e3dae36d5 | ||
|
|
2f92eb8499 |
@@ -4,17 +4,19 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
uint32_t getPositionPrecisionForChannel(uint8_t channelIndex)
|
uint32_t getPositionPrecisionForChannel(const meshtastic_Channel &channel)
|
||||||
{
|
{
|
||||||
const meshtastic_Channel &channel = channels.getByIndex(channelIndex);
|
|
||||||
|
|
||||||
if (channel.settings.has_module_settings) {
|
if (channel.settings.has_module_settings) {
|
||||||
return channel.settings.module_settings.position_precision;
|
return channel.settings.module_settings.position_precision;
|
||||||
} else if (channel.role == meshtastic_Channel_Role_PRIMARY) {
|
|
||||||
return 32;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
// No module settings: fail closed. A PRIMARY channel used to default to 32
|
||||||
|
// here, leaking an exact position on a sharing-disabled channel. See #10509.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t getPositionPrecisionForChannel(uint8_t channelIndex)
|
||||||
|
{
|
||||||
|
return getPositionPrecisionForChannel(channels.getByIndex(channelIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t truncateCoordinate(int32_t coordinate, uint32_t precision)
|
static int32_t truncateCoordinate(int32_t coordinate, uint32_t precision)
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "meshtastic/channel.pb.h"
|
||||||
#include "meshtastic/mesh.pb.h"
|
#include "meshtastic/mesh.pb.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
uint32_t getPositionPrecisionForChannel(const meshtastic_Channel &channel);
|
||||||
uint32_t getPositionPrecisionForChannel(uint8_t channelIndex);
|
uint32_t getPositionPrecisionForChannel(uint8_t channelIndex);
|
||||||
void applyPositionPrecision(meshtastic_Position &position, uint32_t precision);
|
void applyPositionPrecision(meshtastic_Position &position, uint32_t precision);
|
||||||
bool applyPositionPrecision(meshtastic_MeshPacket &packet, uint32_t precision);
|
bool applyPositionPrecision(meshtastic_MeshPacket &packet, uint32_t precision);
|
||||||
|
|||||||
@@ -19,6 +19,16 @@ static meshtastic_Position makePosition()
|
|||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static meshtastic_Channel makeChannel(meshtastic_Channel_Role role, bool hasModuleSettings, uint32_t positionPrecision)
|
||||||
|
{
|
||||||
|
meshtastic_Channel channel = meshtastic_Channel_init_default;
|
||||||
|
channel.has_settings = true;
|
||||||
|
channel.role = role;
|
||||||
|
channel.settings.has_module_settings = hasModuleSettings;
|
||||||
|
channel.settings.module_settings.position_precision = positionPrecision;
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
static void test_applyPositionPrecision_clampsLatLonAndSetsPrecisionBits()
|
static void test_applyPositionPrecision_clampsLatLonAndSetsPrecisionBits()
|
||||||
{
|
{
|
||||||
meshtastic_Position position = makePosition();
|
meshtastic_Position position = makePosition();
|
||||||
@@ -80,6 +90,35 @@ static void test_applyPositionPrecision_reencodesPositionPacket()
|
|||||||
TEST_ASSERT_EQUAL_UINT32(16, decoded.precision_bits);
|
TEST_ASSERT_EQUAL_UINT32(16, decoded.precision_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_getPositionPrecisionForChannel_explicitPrecisionIsHonored()
|
||||||
|
{
|
||||||
|
meshtastic_Channel channel = makeChannel(meshtastic_Channel_Role_PRIMARY, true, 16);
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_UINT32(16, getPositionPrecisionForChannel(channel));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_getPositionPrecisionForChannel_explicitZeroDisablesPrimary()
|
||||||
|
{
|
||||||
|
meshtastic_Channel channel = makeChannel(meshtastic_Channel_Role_PRIMARY, true, 0);
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_UINT32(0, getPositionPrecisionForChannel(channel));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_getPositionPrecisionForChannel_primaryWithoutModuleSettingsFailsClosed()
|
||||||
|
{
|
||||||
|
// Regression guard for #10509: precision 32 below must be ignored (no module settings).
|
||||||
|
meshtastic_Channel channel = makeChannel(meshtastic_Channel_Role_PRIMARY, false, 32);
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_UINT32(0, getPositionPrecisionForChannel(channel));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_getPositionPrecisionForChannel_secondaryWithoutModuleSettingsFailsClosed()
|
||||||
|
{
|
||||||
|
meshtastic_Channel channel = makeChannel(meshtastic_Channel_Role_SECONDARY, false, 32);
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_UINT32(0, getPositionPrecisionForChannel(channel));
|
||||||
|
}
|
||||||
|
|
||||||
void setUp(void) {}
|
void setUp(void) {}
|
||||||
|
|
||||||
void tearDown(void) {}
|
void tearDown(void) {}
|
||||||
@@ -93,6 +132,10 @@ void setup()
|
|||||||
RUN_TEST(test_applyPositionPrecision_fullPrecisionKeepsLatLon);
|
RUN_TEST(test_applyPositionPrecision_fullPrecisionKeepsLatLon);
|
||||||
RUN_TEST(test_applyPositionPrecision_zeroScrubsLocationButKeepsTime);
|
RUN_TEST(test_applyPositionPrecision_zeroScrubsLocationButKeepsTime);
|
||||||
RUN_TEST(test_applyPositionPrecision_reencodesPositionPacket);
|
RUN_TEST(test_applyPositionPrecision_reencodesPositionPacket);
|
||||||
|
RUN_TEST(test_getPositionPrecisionForChannel_explicitPrecisionIsHonored);
|
||||||
|
RUN_TEST(test_getPositionPrecisionForChannel_explicitZeroDisablesPrimary);
|
||||||
|
RUN_TEST(test_getPositionPrecisionForChannel_primaryWithoutModuleSettingsFailsClosed);
|
||||||
|
RUN_TEST(test_getPositionPrecisionForChannel_secondaryWithoutModuleSettingsFailsClosed);
|
||||||
exit(UNITY_END());
|
exit(UNITY_END());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,14 +16,6 @@ custom_sdkconfig =
|
|||||||
CONFIG_ETH_ENABLED=y
|
CONFIG_ETH_ENABLED=y
|
||||||
CONFIG_ARDUINO_SELECTIVE_Ethernet=y
|
CONFIG_ARDUINO_SELECTIVE_Ethernet=y
|
||||||
|
|
||||||
lib_ignore =
|
|
||||||
Ethernet
|
|
||||||
|
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
${esp32s3_base.build_src_filter}
|
${esp32s3_base.build_src_filter}
|
||||||
+<../variants/esp32s3/ELECROW-ThinkNode-G3/*>
|
+<../variants/esp32s3/ELECROW-ThinkNode-G3/*>
|
||||||
|
|
||||||
lib_deps =
|
|
||||||
${esp32s3_base.lib_deps}
|
|
||||||
# renovate: datasource=github-tags depName=ESP32-CH390 packageName=meshtastic/ESP32-CH390
|
|
||||||
https://github.com/meshtastic/ESP32-CH390/archive/refs/tags/v1.0.1.zip
|
|
||||||
|
|||||||
@@ -15,14 +15,6 @@ custom_sdkconfig =
|
|||||||
CONFIG_ETH_ENABLED=y
|
CONFIG_ETH_ENABLED=y
|
||||||
CONFIG_ARDUINO_SELECTIVE_Ethernet=y
|
CONFIG_ARDUINO_SELECTIVE_Ethernet=y
|
||||||
|
|
||||||
lib_ignore =
|
|
||||||
Ethernet
|
|
||||||
|
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
${esp32s3_base.build_src_filter}
|
${esp32s3_base.build_src_filter}
|
||||||
+<../variants/esp32s3/ELECROW-ThinkNode-M7/*>
|
+<../variants/esp32s3/ELECROW-ThinkNode-M7/*>
|
||||||
|
|
||||||
lib_deps =
|
|
||||||
${esp32s3_base.lib_deps}
|
|
||||||
# renovate: datasource=github-tags depName=ESP32-CH390 packageName=meshtastic/ESP32-CH390
|
|
||||||
https://github.com/meshtastic/ESP32-CH390/archive/refs/tags/v1.0.1.zip
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#ifndef Pins_Arduino_h
|
|
||||||
#define Pins_Arduino_h
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#define USB_VID 0x303a
|
|
||||||
#define USB_PID 0x1001
|
|
||||||
|
|
||||||
static const uint8_t TX = 43;
|
|
||||||
static const uint8_t RX = 44;
|
|
||||||
|
|
||||||
static const uint8_t SDA = 7;
|
|
||||||
static const uint8_t SCL = 6;
|
|
||||||
|
|
||||||
static const uint8_t SS = 39;
|
|
||||||
static const uint8_t MOSI = 47;
|
|
||||||
static const uint8_t MISO = 38;
|
|
||||||
static const uint8_t SCK = 40;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
[thinknode_m9_base]
|
|
||||||
extends = esp32s3_base
|
|
||||||
board = crowpanel
|
|
||||||
board_check = true
|
|
||||||
board_build.partitions = default_16MB.csv
|
|
||||||
upload_protocol = esptool
|
|
||||||
build_src_filter =
|
|
||||||
${esp32s3_base.build_src_filter}
|
|
||||||
+<../variants/esp32s3/ELECROW-ThinkNode-M9>
|
|
||||||
build_flags =
|
|
||||||
${esp32s3_base.build_flags}
|
|
||||||
-I variants/esp32s3/ELECROW-ThinkNode-M9
|
|
||||||
-D ELECROW_ThinkNode_M9
|
|
||||||
-D BOARD_HAS_PSRAM
|
|
||||||
-D HAS_SDCARD=1
|
|
||||||
-D SDCARD_USE_SPI1
|
|
||||||
-D SDCARD_USER_SPI_BEGIN
|
|
||||||
-D HAS_SCREEN=1
|
|
||||||
; -L variants/esp32s3/ELECROW-ThinkNode-M9/lib
|
|
||||||
; -lqst
|
|
||||||
lib_deps = ${esp32s3_base.lib_deps}
|
|
||||||
lovyan03/LovyanGFX@1.2.19
|
|
||||||
lewisxhe/SensorLib@0.3.4
|
|
||||||
|
|
||||||
[env:thinknode_m9]
|
|
||||||
extends = thinknode_m9_base
|
|
||||||
build_flags =
|
|
||||||
${thinknode_m9_base.build_flags}
|
|
||||||
|
|
||||||
[env:thinknode_m9-tft]
|
|
||||||
extends = thinknode_m9_base
|
|
||||||
build_flags =
|
|
||||||
${thinknode_m9_base.build_flags}
|
|
||||||
-D RADIOLIB_SPI_PARANOID=0
|
|
||||||
-D CONFIG_DISABLE_HAL_LOCKS=1
|
|
||||||
-D HAS_TFT=1
|
|
||||||
-D USE_PACKET_API
|
|
||||||
-D USE_PIN_BUZZER=PIN_BUZZER
|
|
||||||
-D LV_LVGL_H_INCLUDE_SIMPLE
|
|
||||||
-D LV_CONF_INCLUDE_SIMPLE
|
|
||||||
-D LV_COMP_CONF_INCLUDE_SIMPLE
|
|
||||||
-D LV_USE_SYSMON=0
|
|
||||||
-D LV_USE_PROFILER=0
|
|
||||||
-D LV_USE_PERF_MONITOR=0
|
|
||||||
-D LV_USE_MEM_MONITOR=0
|
|
||||||
-D LV_USE_LOG=0
|
|
||||||
-D LV_BUILD_TEST=0
|
|
||||||
-D USE_LOG_DEBUG
|
|
||||||
-D LOG_DEBUG_INC=\"DebugConfiguration.h\"
|
|
||||||
-D RAM_SIZE=5120
|
|
||||||
-D LGFX_DRIVER_TEMPLATE
|
|
||||||
-D LGFX_DRIVER=LGFX_GENERIC
|
|
||||||
-D GFX_DRIVER_INC=\"graphics/LGFX/LGFX_GENERIC.h\"
|
|
||||||
-D VIEW_320x240
|
|
||||||
-D LGFX_PANEL=ST7789
|
|
||||||
-D DISPLAY_SIZE=320x240
|
|
||||||
-D LGFX_ROTATION=3
|
|
||||||
-D LGFX_CFG_HOST=SPI3_HOST
|
|
||||||
-D LGFX_PIN_SCK=40
|
|
||||||
-D LGFX_PIN_MOSI=47
|
|
||||||
-D LGFX_PIN_DC=15
|
|
||||||
-D LGFX_PIN_CS=16
|
|
||||||
-D LGFX_PIN_BL=17
|
|
||||||
-D LGFX_PIN_RST=14
|
|
||||||
-D LGFX_SCREEN_WIDTH=240
|
|
||||||
-D LGFX_SCREEN_HEIGHT=320
|
|
||||||
-D LGFX_INVERT_LIGHT=true
|
|
||||||
-D SPI_FREQUENCY=80000000
|
|
||||||
-D MAP_FULL_REDRAW
|
|
||||||
|
|
||||||
lib_deps =
|
|
||||||
${thinknode_m9_base.lib_deps}
|
|
||||||
${device-ui_base.lib_deps}
|
|
||||||
https://github.com/mverch67/ESPWebDAV/archive/a57dedfac243b1c47db90c712db664f896752467.zip
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#include "RadioLib.h"
|
|
||||||
|
|
||||||
static const uint32_t rfswitch_dio_pins[] = {RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC};
|
|
||||||
|
|
||||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
|
||||||
// mode DIO5 DIO6
|
|
||||||
{LR11x0::MODE_STBY, {LOW, LOW}}, {LR11x0::MODE_RX, {HIGH, LOW}},
|
|
||||||
{LR11x0::MODE_TX, {HIGH, HIGH}}, {LR11x0::MODE_TX_HP, {LOW, HIGH}},
|
|
||||||
{LR11x0::MODE_TX_HF, {LOW, LOW}}, {LR11x0::MODE_GNSS, {LOW, LOW}},
|
|
||||||
{LR11x0::MODE_WIFI, {LOW, LOW}}, END_OF_MODE_TABLE,
|
|
||||||
};
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#include "configuration.h"
|
|
||||||
|
|
||||||
void earlyInitVariant()
|
|
||||||
{
|
|
||||||
pinMode(LORA_CS, OUTPUT);
|
|
||||||
digitalWrite(LORA_CS, HIGH);
|
|
||||||
pinMode(SDCARD_CS, OUTPUT);
|
|
||||||
digitalWrite(SDCARD_CS, HIGH);
|
|
||||||
pinMode(TFT_CS, OUTPUT);
|
|
||||||
digitalWrite(TFT_CS, HIGH);
|
|
||||||
}
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
#define CANNED_MESSAGE_MODULE_ENABLE 1
|
|
||||||
#define PRESET_MESSAGE_MODULE_ENABLE 1
|
|
||||||
|
|
||||||
/*Power*/
|
|
||||||
#define VEXT_ENABLE 18
|
|
||||||
#define VEXT_ON_VALUE LOW
|
|
||||||
#define PIN_GPS_EN 11
|
|
||||||
#define GPS_EN_ACTIVE LOW
|
|
||||||
|
|
||||||
/*Wire Interface*/
|
|
||||||
#define WIRE_INTERFACES_COUNT 2
|
|
||||||
// I2C keybuttons
|
|
||||||
#define I2C_SCL1 21
|
|
||||||
#define I2C_SDA1 20
|
|
||||||
#define KB_INT 12
|
|
||||||
// I2C peripheral`
|
|
||||||
#define I2C_SCL 6
|
|
||||||
#define I2C_SDA 7
|
|
||||||
|
|
||||||
/*LED*/
|
|
||||||
#define PIN_LED 13
|
|
||||||
#define KB_LED 46
|
|
||||||
|
|
||||||
/*BUZZER*/
|
|
||||||
#define PIN_BUZZER 9
|
|
||||||
|
|
||||||
/*CHARGE_CHECK*/
|
|
||||||
#define DONE 8
|
|
||||||
#define EXT_PWR_DETECT 1
|
|
||||||
#define EXT_CHRG_DETECT 1
|
|
||||||
#define EXT_CHRG_DETECT_VALUE LOW
|
|
||||||
|
|
||||||
/*GPS*/
|
|
||||||
#define HAS_GPS 1
|
|
||||||
#define GPS_L76K
|
|
||||||
#define GPS_BAUDRATE 9600
|
|
||||||
#define PIN_GPS_RESET 5
|
|
||||||
#define PIN_GPS_PPS 4
|
|
||||||
#define PIN_GPS_STANDBY 10 // An output to wake GPS, low means allow sleep, high means force wake
|
|
||||||
#define GPS_TX_PIN 3
|
|
||||||
#define GPS_RX_PIN 2
|
|
||||||
#define GPS_THREAD_INTERVAL 50
|
|
||||||
|
|
||||||
/*SPI*/
|
|
||||||
#define SPI_MOSI 47
|
|
||||||
#define SPI_SCK 40
|
|
||||||
#define SPI_MISO 38
|
|
||||||
|
|
||||||
/*SD Card*/
|
|
||||||
#define SDCARD_CS 48
|
|
||||||
#define SD_SPI_FREQUENCY 80000000U
|
|
||||||
|
|
||||||
/*Screen*/
|
|
||||||
// #define USE_ST7789 1
|
|
||||||
#define ST7789_CS 16
|
|
||||||
#define ST7789_RS 15
|
|
||||||
#define ST7789_TE 19
|
|
||||||
#define ST7789_SDA SPI_MOSI // MOSI
|
|
||||||
#define ST7789_SCK SPI_SCK
|
|
||||||
#define ST7789_RESET 14
|
|
||||||
#define ST7789_MISO SPI_MISO
|
|
||||||
#define ST7789_BUSY -1
|
|
||||||
#define ST7789_BL 17
|
|
||||||
#define ST7789_SPI_HOST SPI3_HOST
|
|
||||||
#define SPI_FREQUENCY 80000000
|
|
||||||
#define SPI_READ_FREQUENCY 16000000
|
|
||||||
|
|
||||||
#define USE_TFTDISPLAY 1
|
|
||||||
#define TFT_CS ST7789_CS
|
|
||||||
#define TFT_BL ST7789_BL
|
|
||||||
#define TFT_HEIGHT 320
|
|
||||||
#define TFT_WIDTH 240
|
|
||||||
#define TFT_OFFSET_X 0
|
|
||||||
#define TFT_OFFSET_Y 0
|
|
||||||
#define TFT_OFFSET_ROTATION 0
|
|
||||||
#define TFT_PWM_FREQ 44000
|
|
||||||
#define TFT_PWM_CHANNEL 7
|
|
||||||
#define TFT_INVERT_LIGHT true
|
|
||||||
#define TFT_BACKLIGHT_ON LOW
|
|
||||||
#define SCREEN_ROTATE
|
|
||||||
#define SCREEN_TRANSITION_FRAMERATE 5
|
|
||||||
#define BRIGHTNESS_DEFAULT 128
|
|
||||||
|
|
||||||
/*Lora radio*/
|
|
||||||
#define HW_SPI1_DEVICE
|
|
||||||
#define LORA_SCK SPI_SCK
|
|
||||||
#define LORA_MISO SPI_MISO
|
|
||||||
#define LORA_MOSI SPI_MOSI
|
|
||||||
#define LORA_CS 39
|
|
||||||
#define LORA_RESET 45
|
|
||||||
#define LORA_DIO0 41
|
|
||||||
|
|
||||||
#define USE_LR1110
|
|
||||||
#define LR1110_IRQ_PIN 42
|
|
||||||
#define LR1110_NRESET_PIN LORA_RESET
|
|
||||||
#define LR1110_BUSY_PIN LORA_DIO0
|
|
||||||
#define LR1110_SPI_NSS_PIN LORA_CS
|
|
||||||
#define LR1110_SPI_SCK_PIN LORA_SCK
|
|
||||||
#define LR1110_SPI_MOSI_PIN LORA_MOSI
|
|
||||||
#define LR1110_SPI_MISO_PIN LORA_MISO
|
|
||||||
#define LR11X0_DIO3_TCXO_VOLTAGE 3.3
|
|
||||||
#define LR11X0_DIO_AS_RF_SWITCH
|
|
||||||
|
|
||||||
/*RTC*/
|
|
||||||
#define PCF8563_RTC 0x51
|
|
||||||
@@ -14,11 +14,3 @@ custom_sdkconfig =
|
|||||||
${esp32s3_base.custom_sdkconfig}
|
${esp32s3_base.custom_sdkconfig}
|
||||||
CONFIG_ETH_ENABLED=y
|
CONFIG_ETH_ENABLED=y
|
||||||
CONFIG_ARDUINO_SELECTIVE_Ethernet=y
|
CONFIG_ARDUINO_SELECTIVE_Ethernet=y
|
||||||
|
|
||||||
; lib_ignore =
|
|
||||||
; Ethernet
|
|
||||||
|
|
||||||
; lib_deps =
|
|
||||||
; ${esp32s3_base.lib_deps}
|
|
||||||
; # renovate: datasource=github-tags depName=ETHClass2 packageName=meshtastic/ETHClass2
|
|
||||||
; https://github.com/meshtastic/ETHClass2/archive/v1.0.0.zip
|
|
||||||
|
|||||||
Reference in New Issue
Block a user