From d11bcda2923d40159c6cc09fb99c7cb7339579ff Mon Sep 17 00:00:00 2001 From: code8buster Date: Sat, 13 May 2023 20:38:37 -0400 Subject: [PATCH 01/11] Implementing a calibrated ESP32 ADC reading --- src/Power.cpp | 98 ++++++++++++++++++++++++-------- src/power.h | 9 ++- variants/tlora_v2_1_16/variant.h | 10 +++- 3 files changed, 89 insertions(+), 28 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index b129fbcd0..1eb668f00 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -6,6 +6,7 @@ #include "main.h" #include "sleep.h" #include "utils.h" +static const char *TAG = "ADCmod"; #ifdef DEBUG_HEAP_MQTT #include "mqtt/MQTT.h" @@ -17,6 +18,22 @@ #define DELAY_FOREVER portMAX_DELAY #endif +#ifdef BATTERY_PIN + +#ifndef BAT_MEASURE_ADC_UNIT // ADC1 +static const adc1_channel_t adc_channel = ADC_CHANNEL; +#else // make adc1 default +static const adc2_channel_t adc_channel = ADC_CHANNEL; +RTC_NOINIT_ATTR uint64_t RTC_reg_b; +#include "soc/sens_reg.h" // needed for adc pin reset +#endif + +esp_adc_cal_characteristics_t *adc_characs = (esp_adc_cal_characteristics_t *)calloc(1, sizeof(esp_adc_cal_characteristics_t)); + +static const adc_atten_t atten = ADC_ATTEN_DB_11; +static const adc_unit_t unit = adc_unit_name; +#endif // BATTERY_PIN + #ifdef HAS_PMU #include "XPowersAXP192.tpp" #include "XPowersAXP2101.tpp" @@ -36,7 +53,7 @@ class HasBatteryLevel /** * The raw voltage of the battery or NAN if unknown */ - virtual uint16_t getBattVoltage() { return 0; } + virtual uint32_t getBattVoltage() { return 0; } /** * return true if there is a battery installed in this unit @@ -105,7 +122,7 @@ class AnalogBatteryLevel : public HasBatteryLevel /** * The raw voltage of the batteryin millivolts or NAN if unknown */ - virtual uint16_t getBattVoltage() override + virtual uint32_t getBattVoltage() override { #ifndef ADC_MULTIPLIER @@ -128,18 +145,27 @@ class AnalogBatteryLevel : public HasBatteryLevel // Set the number of samples, it has an effect of increasing sensitivity, especially in complex electromagnetic // environment. uint32_t raw = 0; - for (uint32_t i = 0; i < BATTERY_SENSE_SAMPLES; i++) { - raw += analogRead(BATTERY_PIN); +#ifndef BAT_MEASURE_ADC_UNIT // ADC1 + for (int i = 0; i < BATTERY_SENSE_SAMPLES; i++) { + raw += adc1_get_raw(adc_channel); } +#else // ADC2 + uint32_t adc_buf = 0; + for (int i = 0; i < BATTERY_SENSE_SAMPLES; i++) { + // ADC2 wifi bug workaround, see + // https://github.com/espressif/arduino-esp32/issues/102 + WRITE_PERI_REG(SENS_SAR_READ_CTRL2_REG, RTC_reg_b); + SET_PERI_REG_MASK(SENS_SAR_READ_CTRL2_REG, SENS_SAR2_DATA_INV); + adc2_get_raw(adc_channel, ADC_WIDTH_BIT_12, &adc_buf); + raw += adc_buf; + } +#endif // BAT_MEASURE_ADC_UNIT raw = raw / BATTERY_SENSE_SAMPLES; - float scaled; -#ifndef VBAT_RAW_TO_SCALED - scaled = 1000.0 * operativeAdcMultiplier * (AREF_VOLTAGE / 1024.0) * raw; -#else - scaled = VBAT_RAW_TO_SCALED(raw); // defined in variant.h -#endif + scaled = esp_adc_cal_raw_to_voltage(raw, adc_characs); + scaled *= operativeAdcMultiplier; // LOG_DEBUG("battery gpio %d raw val=%u scaled=%u\n", BATTERY_PIN, raw, (uint32_t)(scaled)); + last_read_value = scaled; return scaled; } else { @@ -147,7 +173,7 @@ class AnalogBatteryLevel : public HasBatteryLevel } #else return 0; -#endif +#endif // BATTERY_PIN } /** @@ -222,36 +248,62 @@ bool Power::analogInit() pinMode(EXT_PWR_DETECT, INPUT); #endif +#ifndef HAS_PMU + #ifdef BATTERY_PIN LOG_DEBUG("Using analog input %d for battery level\n", BATTERY_PIN); // disable any internal pullups - pinMode(BATTERY_PIN, INPUT); + pinMode(35, INPUT); +#endif // BATTERY PIN + +#ifndef BATTERY_SENSE_RESOLUTION_BITS +#define BATTERY_SENSE_RESOLUTION_BITS 12 +#endif #ifdef ARCH_ESP32 - // ESP32 needs special analog stuff - adcAttachPin(BATTERY_PIN); +// ESP32 needs special analog stuff +// configure ADC +#ifndef BAT_MEASURE_ADC_UNIT // ADC1 + adc1_config_width(width); + adc1_config_channel_atten(adc_channel, atten); +#else // ADC2 + adc2_config_channel_atten(adc_channel, atten); + // ADC2 wifi bug workaround, see + // https://github.com/espressif/arduino-esp32/issues/102 + RTC_reg_b = READ_PERI_REG(SENS_SAR_READ_CTRL2_REG); #endif + + LOG_DEBUG("ADC using channel %s\n", adc_channel_name); + // calibrate ADC + esp_adc_cal_value_t val_type = esp_adc_cal_characterize(unit, atten, width, DEFAULT_VREF, adc_characs); + // show ADC characterization base + if (val_type == ESP_ADC_CAL_VAL_EFUSE_TP) { + ESP_LOGI(TAG, "ADC characterization based on Two Point values stored in eFuse"); + } else if (val_type == ESP_ADC_CAL_VAL_EFUSE_VREF) { + ESP_LOGI(TAG, "ADC characterization based on reference voltage stored in eFuse"); + } else { + ESP_LOGI(TAG, "ADC characterization based on default reference voltage"); + } +#endif // ARCH_ESP32 + #ifdef ARCH_NRF52 #ifdef VBAT_AR_INTERNAL analogReference(VBAT_AR_INTERNAL); #else analogReference(AR_INTERNAL); // 3.6V #endif -#endif - -#ifndef BATTERY_SENSE_RESOLUTION_BITS -#define BATTERY_SENSE_RESOLUTION_BITS 10 -#endif - - // adcStart(BATTERY_PIN); + adcStart(BATTERY_PIN); analogReadResolution(BATTERY_SENSE_RESOLUTION_BITS); // Default of 12 is not very linear. Recommended to use 10 or 11 // depending on needed resolution. + +#endif // ARCH_NRF52 + batteryLevel = &analogLevel; return true; #else return false; -#endif +#endif // !HAS_PMU } bool Power::setup() @@ -302,7 +354,7 @@ void Power::readPowerStatus() { if (batteryLevel) { bool hasBattery = batteryLevel->isBatteryConnect(); - int batteryVoltageMv = 0; + uint32_t batteryVoltageMv = 0; int8_t batteryChargePercent = 0; if (hasBattery) { batteryVoltageMv = batteryLevel->getBattVoltage(); diff --git a/src/power.h b/src/power.h index 6b787d320..8c3cd92af 100644 --- a/src/power.h +++ b/src/power.h @@ -1,7 +1,8 @@ #pragma once #include "PowerStatus.h" #include "concurrency/OSThread.h" - +#include +#include /** * Per @spattinson * MIN_BAT_MILLIVOLTS seems high. Typical 18650 are different chemistry to LiPo, even for LiPos that chart seems a bit off, other @@ -14,6 +15,10 @@ #define BAT_MILLIVOLTS_FULL 4100 #define BAT_MILLIVOLTS_EMPTY 3500 +#ifdef BAT_MEASURE_ADC_UNIT +extern RTC_NOINIT_ATTR uint64_t RTC_reg_b; +#include "soc/sens_reg.h" // needed for adc pin reset +#endif class Power : private concurrency::OSThread { @@ -45,4 +50,4 @@ class Power : private concurrency::OSThread #endif }; -extern Power *power; +extern Power *power; \ No newline at end of file diff --git a/variants/tlora_v2_1_16/variant.h b/variants/tlora_v2_1_16/variant.h index 11c5921ba..42f3a0d52 100644 --- a/variants/tlora_v2_1_16/variant.h +++ b/variants/tlora_v2_1_16/variant.h @@ -3,9 +3,13 @@ #define GPS_RX_PIN 15 // per @der_bear on the forum, 36 is incorrect for this board type and 15 is a better pick #define GPS_TX_PIN 13 -#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define BATTERY_PIN 35 +#define ADC_CHANNEL ADC_GPIO35_CHANNEL +#define BATTERY_SENSE_SAMPLES 30 +#define DEFAULT_VREF 1100 + // ratio of voltage divider = 2.0 (R42=100k, R43=100k) -#define ADC_MULTIPLIER 2.11 // 2.0 + 10% for correction of display undervoltage. +#define ADC_MULTIPLIER 2 #define I2C_SDA 21 // I2C pins for this board #define I2C_SCL 22 @@ -19,4 +23,4 @@ #define LORA_DIO0 26 // a No connect on the SX1262 module #define LORA_RESET 23 #define LORA_DIO1 33 // https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436 -#define LORA_DIO2 32 // Not really used +#define LORA_DIO2 32 // Not really used \ No newline at end of file From 6113a1fb702000695a34ce70e319519760952e06 Mon Sep 17 00:00:00 2001 From: code8buster Date: Sun, 14 May 2023 19:49:08 -0400 Subject: [PATCH 02/11] Tryfix heltec v2 adc issues being on SAR2 --- src/Power.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index 1eb668f00..d4ea10b23 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -20,18 +20,19 @@ static const char *TAG = "ADCmod"; #ifdef BATTERY_PIN -#ifndef BAT_MEASURE_ADC_UNIT // ADC1 +#ifndef BAT_MEASURE_ADC_UNIT // ADC1 is default static const adc1_channel_t adc_channel = ADC_CHANNEL; -#else // make adc1 default +static const adc_unit_t unit = ADC_UNIT_1; +#else // ADC2 static const adc2_channel_t adc_channel = ADC_CHANNEL; +static const adc_unit_t unit = ADC_UNIT_2; RTC_NOINIT_ATTR uint64_t RTC_reg_b; -#include "soc/sens_reg.h" // needed for adc pin reset + #endif esp_adc_cal_characteristics_t *adc_characs = (esp_adc_cal_characteristics_t *)calloc(1, sizeof(esp_adc_cal_characteristics_t)); static const adc_atten_t atten = ADC_ATTEN_DB_11; -static const adc_unit_t unit = adc_unit_name; #endif // BATTERY_PIN #ifdef HAS_PMU @@ -269,12 +270,9 @@ bool Power::analogInit() adc1_config_channel_atten(adc_channel, atten); #else // ADC2 adc2_config_channel_atten(adc_channel, atten); - // ADC2 wifi bug workaround, see - // https://github.com/espressif/arduino-esp32/issues/102 + // ADC2 wifi bug workaround RTC_reg_b = READ_PERI_REG(SENS_SAR_READ_CTRL2_REG); #endif - - LOG_DEBUG("ADC using channel %s\n", adc_channel_name); // calibrate ADC esp_adc_cal_value_t val_type = esp_adc_cal_characterize(unit, atten, width, DEFAULT_VREF, adc_characs); // show ADC characterization base From 3219ad33ef9dee4899bbf35d59a6112914da4646 Mon Sep 17 00:00:00 2001 From: code8buster Date: Tue, 16 May 2023 01:40:42 -0400 Subject: [PATCH 03/11] Add ADC channels to esp variants, plug code back in to make sure other archs work --- src/Power.cpp | 56 +++++++++++++++++++---------- src/platform/esp32/architecture.h | 5 ++- src/power.h | 2 ++ variants/diy/dr-dev/variant.h | 4 ++- variants/diy/v1/variant.h | 7 ++-- variants/heltec_v1/variant.h | 2 ++ variants/heltec_v2.1/variant.h | 5 +-- variants/heltec_v2/variant.h | 2 ++ variants/heltec_v3/variant.h | 5 +-- variants/heltec_wsl_v3/variant.h | 3 +- variants/nano-g1-explorer/variant.h | 5 +-- variants/station-g1/variant.h | 5 +-- variants/tbeam_v07/variant.h | 1 + variants/tlora_t3s3_v1/variant.h | 1 + variants/tlora_v1_3/variant.h | 1 + variants/tlora_v2/variant.h | 3 +- variants/tlora_v2_1_16/variant.h | 3 +- variants/tlora_v2_1_18/variant.h | 1 + 18 files changed, 75 insertions(+), 36 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index d4ea10b23..14ef2e951 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -18,7 +18,7 @@ static const char *TAG = "ADCmod"; #define DELAY_FOREVER portMAX_DELAY #endif -#ifdef BATTERY_PIN +#if defined(BATTERY_PIN) && defined(ARCH_ESP32) #ifndef BAT_MEASURE_ADC_UNIT // ADC1 is default static const adc1_channel_t adc_channel = ADC_CHANNEL; @@ -28,12 +28,12 @@ static const adc2_channel_t adc_channel = ADC_CHANNEL; static const adc_unit_t unit = ADC_UNIT_2; RTC_NOINIT_ATTR uint64_t RTC_reg_b; -#endif +#endif // BAT_MEASURE_ADC_UNIT esp_adc_cal_characteristics_t *adc_characs = (esp_adc_cal_characteristics_t *)calloc(1, sizeof(esp_adc_cal_characteristics_t)); static const adc_atten_t atten = ADC_ATTEN_DB_11; -#endif // BATTERY_PIN +#endif // BATTERY_PIN && ARCH_ESP32 #ifdef HAS_PMU #include "XPowersAXP192.tpp" @@ -146,12 +146,13 @@ class AnalogBatteryLevel : public HasBatteryLevel // Set the number of samples, it has an effect of increasing sensitivity, especially in complex electromagnetic // environment. uint32_t raw = 0; +#ifdef ARCH_ESP32 #ifndef BAT_MEASURE_ADC_UNIT // ADC1 for (int i = 0; i < BATTERY_SENSE_SAMPLES; i++) { raw += adc1_get_raw(adc_channel); } #else // ADC2 - uint32_t adc_buf = 0; + int32_t adc_buf = 0; for (int i = 0; i < BATTERY_SENSE_SAMPLES; i++) { // ADC2 wifi bug workaround, see // https://github.com/espressif/arduino-esp32/issues/102 @@ -161,11 +162,24 @@ class AnalogBatteryLevel : public HasBatteryLevel raw += adc_buf; } #endif // BAT_MEASURE_ADC_UNIT +#else // !ARCH_ESP32 + for (uint32_t i = 0; i < BATTERY_SENSE_SAMPLES; i++) { + raw += analogRead(BATTERY_PIN); + } +#endif raw = raw / BATTERY_SENSE_SAMPLES; float scaled; +#ifdef ARCH_ESP32 scaled = esp_adc_cal_raw_to_voltage(raw, adc_characs); scaled *= operativeAdcMultiplier; - // LOG_DEBUG("battery gpio %d raw val=%u scaled=%u\n", BATTERY_PIN, raw, (uint32_t)(scaled)); +#else +#ifndef VBAT_RAW_TO_SCALED + scaled = 1000.0 * operativeAdcMultiplier * (AREF_VOLTAGE / 1024.0) * raw; +#else + scaled = VBAT_RAW_TO_SCALED(raw); // defined in variant.h +#endif // VBAT RAW TO SCALED +#endif // ARCH_ESP32 + // LOG_DEBUG("battery gpio %d raw val=%u scaled=%u\n", BATTERY_PIN, raw, (uint32_t)(scaled)); last_read_value = scaled; return scaled; @@ -255,16 +269,19 @@ bool Power::analogInit() LOG_DEBUG("Using analog input %d for battery level\n", BATTERY_PIN); // disable any internal pullups - pinMode(35, INPUT); -#endif // BATTERY PIN + pinMode(BATTERY_PIN, INPUT); #ifndef BATTERY_SENSE_RESOLUTION_BITS -#define BATTERY_SENSE_RESOLUTION_BITS 12 +#define BATTERY_SENSE_RESOLUTION_BITS 10 #endif -#ifdef ARCH_ESP32 -// ESP32 needs special analog stuff -// configure ADC +#ifdef ARCH_ESP32 // ESP32 needs special analog stuff + +#ifndef ADC_WIDTH // max resolution by default + static const adc_bits_width_t width = ADC_WIDTH_BIT_12; +#else + static const adc_bits_width_t width = ADC_WIDTH; +#endif #ifndef BAT_MEASURE_ADC_UNIT // ADC1 adc1_config_width(width); adc1_config_channel_atten(adc_channel, atten); @@ -291,7 +308,6 @@ bool Power::analogInit() #else analogReference(AR_INTERNAL); // 3.6V #endif - adcStart(BATTERY_PIN); analogReadResolution(BATTERY_SENSE_RESOLUTION_BITS); // Default of 12 is not very linear. Recommended to use 10 or 11 // depending on needed resolution. @@ -301,6 +317,7 @@ bool Power::analogInit() return true; #else return false; +#endif // BATTERY_PIN #endif // !HAS_PMU } @@ -415,8 +432,8 @@ void Power::readPowerStatus() #endif - // If we have a battery at all and it is less than 10% full, force deep sleep if we have more than 10 low readings in a - // row + // If we have a battery at all and it is less than 10% full, force deep sleep if we have more than 10 low readings in + // a row if (powerStatus2.getHasBattery() && !powerStatus2.getHasUSB()) { if (batteryLevel->getBattVoltage() < MIN_BAT_MILLIVOLTS) { low_voltage_counter++; @@ -494,10 +511,10 @@ int32_t Power::runOnce() * Init the power manager chip * * axp192 power - DCDC1 0.7-3.5V @ 1200mA max -> OLED // If you turn this off you'll lose comms to the axp192 because the OLED and the axp192 - share the same i2c bus, instead use ssd1306 sleep mode DCDC2 -> unused DCDC3 0.7-3.5V @ 700mA max -> ESP32 (keep this on!) LDO1 - 30mA -> charges GPS backup battery // charges the tiny J13 battery by the GPS to power the GPS ram (for a couple of days), can - not be turned off LDO2 200mA -> LORA LDO3 200mA -> GPS + DCDC1 0.7-3.5V @ 1200mA max -> OLED // If you turn this off you'll lose comms to the axp192 because the OLED and the + axp192 share the same i2c bus, instead use ssd1306 sleep mode DCDC2 -> unused DCDC3 0.7-3.5V @ 700mA max -> ESP32 (keep this + on!) LDO1 30mA -> charges GPS backup battery // charges the tiny J13 battery by the GPS to power the GPS ram (for a couple of + days), can not be turned off LDO2 200mA -> LORA LDO3 200mA -> GPS * */ bool Power::axpChipInit() @@ -624,7 +641,8 @@ bool Power::axpChipInit() // t-beam s3 core /** * gnss module power channel - * The default ALDO4 is off, you need to turn on the GNSS power first, otherwise it will be invalid during initialization + * The default ALDO4 is off, you need to turn on the GNSS power first, otherwise it will be invalid during + * initialization */ PMU->setPowerChannelVoltage(XPOWERS_ALDO4, 3300); PMU->enablePowerOutput(XPOWERS_ALDO4); diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index da2d9d905..7a1e9ba49 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -39,6 +39,9 @@ #ifndef HAS_CPU_SHUTDOWN #define HAS_CPU_SHUTDOWN 1 #endif +#ifndef DEFAULT_VREF +#define DEFAULT_VREF 1100 +#endif #if defined(HAS_AXP192) || defined(HAS_AXP2101) #define HAS_PMU @@ -132,4 +135,4 @@ #define RF95_NSS 18 #endif -#define SERIAL0_RX_GPIO 3 // Always GPIO3 on ESP32 +#define SERIAL0_RX_GPIO 3 // Always GPIO3 on ESP32 \ No newline at end of file diff --git a/src/power.h b/src/power.h index 8c3cd92af..c47e78466 100644 --- a/src/power.h +++ b/src/power.h @@ -1,8 +1,10 @@ #pragma once #include "PowerStatus.h" #include "concurrency/OSThread.h" +#ifdef ARCH_ESP32 #include #include +#endif /** * Per @spattinson * MIN_BAT_MILLIVOLTS seems high. Typical 18650 are different chemistry to LiPo, even for LiPos that chart seems a bit off, other diff --git a/variants/diy/dr-dev/variant.h b/variants/diy/dr-dev/variant.h index 122a617b6..113fe5e3f 100644 --- a/variants/diy/dr-dev/variant.h +++ b/variants/diy/dr-dev/variant.h @@ -2,6 +2,8 @@ #define HAS_SCREEN 0 #define I2C_SDA 4 #define I2C_SCL 5 +#define BATTERY_PIN 34 +#define ADC1_GPIO34_CHANNEL // GPS #undef GPS_RX_PIN @@ -67,4 +69,4 @@ #define USE_SX1262 //#define USE_SX1268 //#define USE_LLCC68 -#define SX126X_E22 +#define SX126X_E22 \ No newline at end of file diff --git a/variants/diy/v1/variant.h b/variants/diy/v1/variant.h index c47437643..a1083f9bb 100644 --- a/variants/diy/v1/variant.h +++ b/variants/diy/v1/variant.h @@ -9,8 +9,9 @@ #define GPS_TX_PIN 15 #define GPS_UBLOX -#define BUTTON_PIN 39 // The middle button GPIO on the T-Beam -#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define BUTTON_PIN 39 // The middle button GPIO on the T-Beam +#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define ADC_CHANNEL ADC1_GPIO35_CHANNEL #define ADC_MULTIPLIER 1.85 // (R1 = 470k, R2 = 680k) #define EXT_PWR_DETECT 4 // Pin to detect connected external power source for LILYGO® TTGO T-Energy T18 and other DIY boards #define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975). @@ -52,4 +53,4 @@ // Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch // (which is the default for the sx1262interface code) #define SX126X_E22 -#endif +#endif \ No newline at end of file diff --git a/variants/heltec_v1/variant.h b/variants/heltec_v1/variant.h index 948f6ff1e..d1338a28e 100644 --- a/variants/heltec_v1/variant.h +++ b/variants/heltec_v1/variant.h @@ -27,3 +27,5 @@ #define ADC_MULTIPLIER 3.2 #define BATTERY_PIN 13 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define ADC_CHANNEL ADC2_GPIO13_CHANNEL +#define BAT_MEASURE_ADC_UNIT 2 \ No newline at end of file diff --git a/variants/heltec_v2.1/variant.h b/variants/heltec_v2.1/variant.h index 39a0e677f..e7cfd5b34 100644 --- a/variants/heltec_v2.1/variant.h +++ b/variants/heltec_v2.1/variant.h @@ -29,5 +29,6 @@ #define ADC_MULTIPLIER 3.8 -#define BATTERY_PIN 37 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage -#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module. +#define BATTERY_PIN 37 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define ADC_CHANNEL ADC1_GPIO37_CHANNEL +#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module. \ No newline at end of file diff --git a/variants/heltec_v2/variant.h b/variants/heltec_v2/variant.h index 59e0c76e6..5c183818b 100644 --- a/variants/heltec_v2/variant.h +++ b/variants/heltec_v2/variant.h @@ -27,3 +27,5 @@ // ratio of voltage divider = 3.20 (R12=100k, R10=220k) #define ADC_MULTIPLIER 3.2 #define BATTERY_PIN 13 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define ADC_CHANNEL ADC2_GPIO13_CHANNEL +#define BAT_MEASURE_ADC_UNIT 2 \ No newline at end of file diff --git a/variants/heltec_v3/variant.h b/variants/heltec_v3/variant.h index a2e8bde8e..16ee6d712 100644 --- a/variants/heltec_v3/variant.h +++ b/variants/heltec_v3/variant.h @@ -8,7 +8,8 @@ #define BUTTON_PIN 0 #define BATTERY_PIN 1 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage -#define ADC_MULTIPLIER 5.22 +#define ADC_CHANNEL ADC1_GPIO1_CHANNEL +#define ADC_MULTIPLIER 4.9 #define USE_SX1262 @@ -27,4 +28,4 @@ #define SX126X_DIO1 LORA_DIO1 #define SX126X_BUSY LORA_DIO2 #define SX126X_RESET LORA_RESET -#define SX126X_E22 +#define SX126X_E22 \ No newline at end of file diff --git a/variants/heltec_wsl_v3/variant.h b/variants/heltec_wsl_v3/variant.h index 66415741b..38b38e759 100644 --- a/variants/heltec_wsl_v3/variant.h +++ b/variants/heltec_wsl_v3/variant.h @@ -9,7 +9,8 @@ #define BUTTON_PIN 0 #define BATTERY_PIN 1 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage -#define ADC_MULTIPLIER 5.22 +#define ADC_CHANNEL ADC1_GPIO1_CHANNEL +#define ADC_MULTIPLIER 4.9 #define USE_SX1262 diff --git a/variants/nano-g1-explorer/variant.h b/variants/nano-g1-explorer/variant.h index ad8957a51..fb3fc72d1 100644 --- a/variants/nano-g1-explorer/variant.h +++ b/variants/nano-g1-explorer/variant.h @@ -29,8 +29,9 @@ // code) #endif -#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define ADC_CHANNEL ADC1_GPIO35_CHANNEL #define BATTERY_SENSE_SAMPLES 15 // Set the number of samples, It has an effect of increasing sensitivity. #define ADC_MULTIPLIER 2 -#define USE_SH1107_128_64 +#define USE_SH1107_128_64 \ No newline at end of file diff --git a/variants/station-g1/variant.h b/variants/station-g1/variant.h index 4572d47a6..3439cb125 100644 --- a/variants/station-g1/variant.h +++ b/variants/station-g1/variant.h @@ -32,7 +32,8 @@ // Info:https://uniteng.com/wiki/doku.php?id=meshtastic:station#rf_design_-_lora_station_edition_g1 #endif -#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define ADC_CHANNEL ADC1_GPIO35_CHANNEL #define BATTERY_SENSE_SAMPLES 30 // Set the number of samples, It has an effect of increasing sensitivity. #define ADC_MULTIPLIER 6.45 #define BAT_FULLVOLT 12600 @@ -41,4 +42,4 @@ #define BAT_NOBATVOLT 6690 // different screen -#define USE_SH1106 +#define USE_SH1106 \ No newline at end of file diff --git a/variants/tbeam_v07/variant.h b/variants/tbeam_v07/variant.h index 2c8008688..898705ce2 100644 --- a/variants/tbeam_v07/variant.h +++ b/variants/tbeam_v07/variant.h @@ -6,6 +6,7 @@ #define BUTTON_PIN 39 #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module. +#define ADC_CHANNEL ADC1_GPIO35_CHANNEL #define USE_RF95 #define LORA_DIO0 26 // a No connect on the SX1262 module diff --git a/variants/tlora_t3s3_v1/variant.h b/variants/tlora_t3s3_v1/variant.h index 768a7c2da..313b08e6d 100644 --- a/variants/tlora_t3s3_v1/variant.h +++ b/variants/tlora_t3s3_v1/variant.h @@ -9,6 +9,7 @@ #define BATTERY_PIN 1 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage // ratio of voltage divider = 2.0 (R42=100k, R43=100k) #define ADC_MULTIPLIER 2.11 // 2.0 + 10% for correction of display undervoltage. +#define ADC_CHANNEL ADC1_GPIO1_CHANNEL #define I2C_SDA 18 // I2C pins for this board #define I2C_SCL 17 diff --git a/variants/tlora_v1_3/variant.h b/variants/tlora_v1_3/variant.h index 7e8aec0c4..50041f296 100644 --- a/variants/tlora_v1_3/variant.h +++ b/variants/tlora_v1_3/variant.h @@ -4,6 +4,7 @@ #define GPS_TX_PIN 13 // per @eugene #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define ADC_CHANNEL ADC1_GPIO35_CHANNEL #define I2C_SDA 21 // I2C pins for this board #define I2C_SCL 22 diff --git a/variants/tlora_v2/variant.h b/variants/tlora_v2/variant.h index f18503139..b9b521771 100644 --- a/variants/tlora_v2/variant.h +++ b/variants/tlora_v2/variant.h @@ -4,6 +4,7 @@ #define GPS_TX_PIN 13 // per @eugene #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define ADC_CHANNEL ADC1_GPIO35_CHANNEL #define I2C_SDA 21 // I2C pins for this board #define I2C_SCL 22 @@ -19,4 +20,4 @@ #define LORA_DIO0 26 // a No connect on the SX1262 module #define LORA_RESET 14 #define LORA_DIO1 33 // Must be manually wired: https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436 -#define LORA_DIO2 32 // Not really used +#define LORA_DIO2 32 // Not really used \ No newline at end of file diff --git a/variants/tlora_v2_1_16/variant.h b/variants/tlora_v2_1_16/variant.h index 42f3a0d52..adb5af898 100644 --- a/variants/tlora_v2_1_16/variant.h +++ b/variants/tlora_v2_1_16/variant.h @@ -4,9 +4,8 @@ #define GPS_TX_PIN 13 #define BATTERY_PIN 35 -#define ADC_CHANNEL ADC_GPIO35_CHANNEL +#define ADC_CHANNEL ADC1_GPIO35_CHANNEL #define BATTERY_SENSE_SAMPLES 30 -#define DEFAULT_VREF 1100 // ratio of voltage divider = 2.0 (R42=100k, R43=100k) #define ADC_MULTIPLIER 2 diff --git a/variants/tlora_v2_1_18/variant.h b/variants/tlora_v2_1_18/variant.h index 0262f0122..e8f0a9659 100644 --- a/variants/tlora_v2_1_18/variant.h +++ b/variants/tlora_v2_1_18/variant.h @@ -4,6 +4,7 @@ #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage // ratio of voltage divider = 2.0 (R42=100k, R43=100k) #define ADC_MULTIPLIER 2.11 // 2.0 + 10% for correction of display undervoltage. +#define ADC_CHANNEL ADC1_GPIO35_CHANNEL #define I2C_SDA 21 // I2C pins for this board #define I2C_SCL 22 From 9878ff38364938c6e14ce1c283c52e80ae54bf74 Mon Sep 17 00:00:00 2001 From: code8buster Date: Tue, 16 May 2023 02:43:00 -0400 Subject: [PATCH 04/11] Tryfix datatype errors --- src/Power.cpp | 4 ++-- variants/diy/dr-dev/variant.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index 14ef2e951..29c14ee73 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -54,7 +54,7 @@ class HasBatteryLevel /** * The raw voltage of the battery or NAN if unknown */ - virtual uint32_t getBattVoltage() { return 0; } + virtual uint16_t getBattVoltage() { return 0; } /** * return true if there is a battery installed in this unit @@ -123,7 +123,7 @@ class AnalogBatteryLevel : public HasBatteryLevel /** * The raw voltage of the batteryin millivolts or NAN if unknown */ - virtual uint32_t getBattVoltage() override + virtual uint16_t getBattVoltage() override { #ifndef ADC_MULTIPLIER diff --git a/variants/diy/dr-dev/variant.h b/variants/diy/dr-dev/variant.h index 113fe5e3f..b9c82a9c8 100644 --- a/variants/diy/dr-dev/variant.h +++ b/variants/diy/dr-dev/variant.h @@ -3,7 +3,7 @@ #define I2C_SDA 4 #define I2C_SCL 5 #define BATTERY_PIN 34 -#define ADC1_GPIO34_CHANNEL +#define ADC_CHANNEL ADC1_GPIO34_CHANNEL // GPS #undef GPS_RX_PIN From c0979e29ff539ca0ea7a8035a43dc88bdf34e5a3 Mon Sep 17 00:00:00 2001 From: code8buster Date: Tue, 16 May 2023 12:47:30 -0400 Subject: [PATCH 05/11] Fix a few platformio envs, maybe make cppcheck happy --- platformio.ini | 10 +++++----- src/Power.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/platformio.ini b/platformio.ini index f7af9631c..498a05b97 100644 --- a/platformio.ini +++ b/platformio.ini @@ -7,12 +7,12 @@ default_envs = tbeam ;default_envs = tbeam-s3-core ;default_envs = tbeam0.7 ;default_envs = heltec-v1 -;default_envs = heltec-v2.0 -;default_envs = heltec-v2.1 +;default_envs = heltec-v2_0 +;default_envs = heltec-v2_1 ;default_envs = tlora-v1 ;default_envs = tlora_v1_3 ;default_envs = tlora-v2 -;default_envs = tlora-v2-1-1.6 +;default_envs = tlora-v2-1-1_6 ;default_envs = tlora-t3s3-v1 ;default_envs = lora-relay-v1 # nrf board ;default_envs = t-echo @@ -21,7 +21,7 @@ default_envs = tbeam ;default_envs = nano-g1 ;default_envs = pca10059_diy_eink ;default_envs = meshtastic-diy-v1 -;default_envs = meshtastic-diy-v1.1 +;default_envs = meshtastic-diy-v1_1 ;default_envs = meshtastic-dr-dev ;default_envs = m5stack-coreink ;default_envs = rak4631 @@ -112,4 +112,4 @@ lib_deps = adafruit/Adafruit SHT31 Library@^2.2.0 adafruit/Adafruit PM25 AQI Sensor@^1.0.6 adafruit/Adafruit MPU6050@^2.2.4 - adafruit/Adafruit LIS3DH@^1.2.4 + adafruit/Adafruit LIS3DH@^1.2.4 \ No newline at end of file diff --git a/src/Power.cpp b/src/Power.cpp index 29c14ee73..4937e04f7 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -315,9 +315,9 @@ bool Power::analogInit() batteryLevel = &analogLevel; return true; +#endif // BATTERY_PIN #else return false; -#endif // BATTERY_PIN #endif // !HAS_PMU } From a9fed83d9ab106419d673951f40436434885328c Mon Sep 17 00:00:00 2001 From: code8buster Date: Tue, 16 May 2023 13:05:45 -0400 Subject: [PATCH 06/11] Make pull request targets happy --- src/Power.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index 4937e04f7..c3a34d620 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -263,8 +263,6 @@ bool Power::analogInit() pinMode(EXT_PWR_DETECT, INPUT); #endif -#ifndef HAS_PMU - #ifdef BATTERY_PIN LOG_DEBUG("Using analog input %d for battery level\n", BATTERY_PIN); @@ -315,10 +313,9 @@ bool Power::analogInit() batteryLevel = &analogLevel; return true; -#endif // BATTERY_PIN #else return false; -#endif // !HAS_PMU +#endif } bool Power::setup() From 1b68408f2f68030d7dff7299f8b2a69e421eefed Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 22 May 2023 07:00:20 -0500 Subject: [PATCH 07/11] Remote hardware overhaul (#2495) * Update protos * WIP * Param * Has remote hardware * Protos * Initializer * Added new admin message for node remote hardware pins * Badunkatrunk * Init and memcpy --- protobufs | 2 +- src/main.cpp | 1 + src/mesh/NodeDB.cpp | 5 + src/mesh/generated/meshtastic/admin.pb.c | 3 + src/mesh/generated/meshtastic/admin.pb.h | 32 ++++- src/mesh/generated/meshtastic/deviceonly.pb.c | 3 + src/mesh/generated/meshtastic/deviceonly.pb.h | 131 +++++++++++------- src/mesh/generated/meshtastic/localonly.pb.h | 2 +- src/mesh/generated/meshtastic/mesh.pb.h | 12 +- .../generated/meshtastic/module_config.pb.c | 4 + .../generated/meshtastic/module_config.pb.h | 72 ++++++++-- src/modules/AdminModule.cpp | 42 ++++++ src/modules/AdminModule.h | 3 + src/modules/RemoteHardwareModule.cpp | 2 +- 14 files changed, 245 insertions(+), 69 deletions(-) diff --git a/protobufs b/protobufs index 345b3bf10..6a94e6a77 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 345b3bf103237503459457ac2b74f4fedf2db102 +Subproject commit 6a94e6a77f67d26a8b065c2ea61f07376a5ed142 diff --git a/src/main.cpp b/src/main.cpp index 202dce549..19ed56662 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -670,6 +670,7 @@ extern meshtastic_DeviceMetadata getDeviceMetadata() deviceMetadata.role = config.device.role; deviceMetadata.position_flags = config.position.position_flags; deviceMetadata.hw_model = HW_VENDOR; + deviceMetadata.hasRemoteHardware = moduleConfig.remote_hardware.enabled; return deviceMetadata; } diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index c64468d05..feabd5029 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -349,6 +349,11 @@ void NodeDB::init() if (channelFileCRC != crc32Buffer(&channelFile, sizeof(channelFile))) saveWhat |= SEGMENT_CHANNELS; + if (!devicestate.node_remote_hardware_pins) { + meshtastic_NodeRemoteHardwarePin empty[12] = {meshtastic_RemoteHardwarePin_init_default}; + memcpy(devicestate.node_remote_hardware_pins, empty, sizeof(empty)); + } + saveToDisk(saveWhat); } diff --git a/src/mesh/generated/meshtastic/admin.pb.c b/src/mesh/generated/meshtastic/admin.pb.c index c897c1760..92835c89c 100644 --- a/src/mesh/generated/meshtastic/admin.pb.c +++ b/src/mesh/generated/meshtastic/admin.pb.c @@ -12,6 +12,9 @@ PB_BIND(meshtastic_AdminMessage, meshtastic_AdminMessage, 2) PB_BIND(meshtastic_HamParameters, meshtastic_HamParameters, AUTO) +PB_BIND(meshtastic_NodeRemoteHardwarePinsResponse, meshtastic_NodeRemoteHardwarePinsResponse, 2) + + diff --git a/src/mesh/generated/meshtastic/admin.pb.h b/src/mesh/generated/meshtastic/admin.pb.h index 2518f199e..8ededf207 100644 --- a/src/mesh/generated/meshtastic/admin.pb.h +++ b/src/mesh/generated/meshtastic/admin.pb.h @@ -9,6 +9,7 @@ #include "meshtastic/mesh.pb.h" #include "meshtastic/module_config.pb.h" #include "meshtastic/connection_status.pb.h" +#include "meshtastic/deviceonly.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -70,6 +71,13 @@ typedef struct _meshtastic_HamParameters { char short_name[6]; } meshtastic_HamParameters; +/* Response envelope for node_remote_hardware_pins */ +typedef struct _meshtastic_NodeRemoteHardwarePinsResponse { + /* Nodes and their respective remote hardware GPIO pins */ + pb_size_t node_remote_hardware_pins_count; + meshtastic_NodeRemoteHardwarePin node_remote_hardware_pins[12]; +} meshtastic_NodeRemoteHardwarePinsResponse; + /* This message is handled by the Admin module and is responsible for all settings/channel read/write operations. This message is used to do settings operations to both remote AND local nodes. (Prior to 1.2 these operations were done via special ToRadio operations) */ @@ -111,6 +119,10 @@ typedef struct _meshtastic_AdminMessage { meshtastic_DeviceConnectionStatus get_device_connection_status_response; /* Setup a node for licensed amateur (ham) radio operation */ meshtastic_HamParameters set_ham_mode; + /* Get the mesh's nodes with their available gpio pins for RemoteHardware module use */ + bool get_node_remote_hardware_pins_request; + /* Respond with the mesh's nodes with their available gpio pins for RemoteHardware module use */ + meshtastic_NodeRemoteHardwarePinsResponse get_node_remote_hardware_pins_response; /* Set the owner for this node */ meshtastic_User set_owner; /* Set channels (using the new API). @@ -168,17 +180,21 @@ extern "C" { + /* Initializer values for message structs */ #define meshtastic_AdminMessage_init_default {0, {0}} #define meshtastic_HamParameters_init_default {"", 0, 0, ""} +#define meshtastic_NodeRemoteHardwarePinsResponse_init_default {0, {meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default}} #define meshtastic_AdminMessage_init_zero {0, {0}} #define meshtastic_HamParameters_init_zero {"", 0, 0, ""} +#define meshtastic_NodeRemoteHardwarePinsResponse_init_zero {0, {meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero}} /* Field tags (for use in manual encoding/decoding) */ #define meshtastic_HamParameters_call_sign_tag 1 #define meshtastic_HamParameters_tx_power_tag 2 #define meshtastic_HamParameters_frequency_tag 3 #define meshtastic_HamParameters_short_name_tag 4 +#define meshtastic_NodeRemoteHardwarePinsResponse_node_remote_hardware_pins_tag 1 #define meshtastic_AdminMessage_get_channel_request_tag 1 #define meshtastic_AdminMessage_get_channel_response_tag 2 #define meshtastic_AdminMessage_get_owner_request_tag 3 @@ -196,6 +212,8 @@ extern "C" { #define meshtastic_AdminMessage_get_device_connection_status_request_tag 16 #define meshtastic_AdminMessage_get_device_connection_status_response_tag 17 #define meshtastic_AdminMessage_set_ham_mode_tag 18 +#define meshtastic_AdminMessage_get_node_remote_hardware_pins_request_tag 19 +#define meshtastic_AdminMessage_get_node_remote_hardware_pins_response_tag 20 #define meshtastic_AdminMessage_set_owner_tag 32 #define meshtastic_AdminMessage_set_channel_tag 33 #define meshtastic_AdminMessage_set_config_tag 34 @@ -230,6 +248,8 @@ X(a, STATIC, ONEOF, STRING, (payload_variant,get_ringtone_response,get_ri X(a, STATIC, ONEOF, BOOL, (payload_variant,get_device_connection_status_request,get_device_connection_status_request), 16) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,get_device_connection_status_response,get_device_connection_status_response), 17) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,set_ham_mode,set_ham_mode), 18) \ +X(a, STATIC, ONEOF, BOOL, (payload_variant,get_node_remote_hardware_pins_request,get_node_remote_hardware_pins_request), 19) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,get_node_remote_hardware_pins_response,get_node_remote_hardware_pins_response), 20) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,set_owner,set_owner), 32) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,set_channel,set_channel), 33) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,set_config,set_config), 34) \ @@ -253,6 +273,7 @@ X(a, STATIC, ONEOF, INT32, (payload_variant,nodedb_reset,nodedb_reset), #define meshtastic_AdminMessage_payload_variant_get_device_metadata_response_MSGTYPE meshtastic_DeviceMetadata #define meshtastic_AdminMessage_payload_variant_get_device_connection_status_response_MSGTYPE meshtastic_DeviceConnectionStatus #define meshtastic_AdminMessage_payload_variant_set_ham_mode_MSGTYPE meshtastic_HamParameters +#define meshtastic_AdminMessage_payload_variant_get_node_remote_hardware_pins_response_MSGTYPE meshtastic_NodeRemoteHardwarePinsResponse #define meshtastic_AdminMessage_payload_variant_set_owner_MSGTYPE meshtastic_User #define meshtastic_AdminMessage_payload_variant_set_channel_MSGTYPE meshtastic_Channel #define meshtastic_AdminMessage_payload_variant_set_config_MSGTYPE meshtastic_Config @@ -266,16 +287,25 @@ X(a, STATIC, SINGULAR, STRING, short_name, 4) #define meshtastic_HamParameters_CALLBACK NULL #define meshtastic_HamParameters_DEFAULT NULL +#define meshtastic_NodeRemoteHardwarePinsResponse_FIELDLIST(X, a) \ +X(a, STATIC, REPEATED, MESSAGE, node_remote_hardware_pins, 1) +#define meshtastic_NodeRemoteHardwarePinsResponse_CALLBACK NULL +#define meshtastic_NodeRemoteHardwarePinsResponse_DEFAULT NULL +#define meshtastic_NodeRemoteHardwarePinsResponse_node_remote_hardware_pins_MSGTYPE meshtastic_NodeRemoteHardwarePin + extern const pb_msgdesc_t meshtastic_AdminMessage_msg; extern const pb_msgdesc_t meshtastic_HamParameters_msg; +extern const pb_msgdesc_t meshtastic_NodeRemoteHardwarePinsResponse_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ #define meshtastic_AdminMessage_fields &meshtastic_AdminMessage_msg #define meshtastic_HamParameters_fields &meshtastic_HamParameters_msg +#define meshtastic_NodeRemoteHardwarePinsResponse_fields &meshtastic_NodeRemoteHardwarePinsResponse_msg /* Maximum encoded size of messages (where known) */ -#define meshtastic_AdminMessage_size 234 +#define meshtastic_AdminMessage_size 376 #define meshtastic_HamParameters_size 32 +#define meshtastic_NodeRemoteHardwarePinsResponse_size 372 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/deviceonly.pb.c b/src/mesh/generated/meshtastic/deviceonly.pb.c index f3d27d086..e741d25de 100644 --- a/src/mesh/generated/meshtastic/deviceonly.pb.c +++ b/src/mesh/generated/meshtastic/deviceonly.pb.c @@ -15,5 +15,8 @@ PB_BIND(meshtastic_ChannelFile, meshtastic_ChannelFile, 2) PB_BIND(meshtastic_OEMStore, meshtastic_OEMStore, 2) +PB_BIND(meshtastic_NodeRemoteHardwarePin, meshtastic_NodeRemoteHardwarePin, AUTO) + + diff --git a/src/mesh/generated/meshtastic/deviceonly.pb.h b/src/mesh/generated/meshtastic/deviceonly.pb.h index 3f28faae8..cf64de5d2 100644 --- a/src/mesh/generated/meshtastic/deviceonly.pb.h +++ b/src/mesh/generated/meshtastic/deviceonly.pb.h @@ -7,6 +7,7 @@ #include "meshtastic/channel.pb.h" #include "meshtastic/localonly.pb.h" #include "meshtastic/mesh.pb.h" +#include "meshtastic/module_config.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -24,6 +25,51 @@ typedef enum _meshtastic_ScreenFonts { } meshtastic_ScreenFonts; /* Struct definitions */ +/* The on-disk saved channels */ +typedef struct _meshtastic_ChannelFile { + /* The channels our node knows about */ + pb_size_t channels_count; + meshtastic_Channel channels[8]; + /* A version integer used to invalidate old save files when we make + incompatible changes This integer is set at build time and is private to + NodeDB.cpp in the device code. */ + uint32_t version; +} meshtastic_ChannelFile; + +typedef PB_BYTES_ARRAY_T(2048) meshtastic_OEMStore_oem_icon_bits_t; +typedef PB_BYTES_ARRAY_T(32) meshtastic_OEMStore_oem_aes_key_t; +/* This can be used for customizing the firmware distribution. If populated, + show a secondary bootup screen with custom logo and text for 2.5 seconds. */ +typedef struct _meshtastic_OEMStore { + /* The Logo width in Px */ + uint32_t oem_icon_width; + /* The Logo height in Px */ + uint32_t oem_icon_height; + /* The Logo in XBM bytechar format */ + meshtastic_OEMStore_oem_icon_bits_t oem_icon_bits; + /* Use this font for the OEM text. */ + meshtastic_ScreenFonts oem_font; + /* Use this font for the OEM text. */ + char oem_text[40]; + /* The default device encryption key, 16 or 32 byte */ + meshtastic_OEMStore_oem_aes_key_t oem_aes_key; + /* A Preset LocalConfig to apply during factory reset */ + bool has_oem_local_config; + meshtastic_LocalConfig oem_local_config; + /* A Preset LocalModuleConfig to apply during factory reset */ + bool has_oem_local_module_config; + meshtastic_LocalModuleConfig oem_local_module_config; +} meshtastic_OEMStore; + +/* RemoteHardwarePins associated with a node */ +typedef struct _meshtastic_NodeRemoteHardwarePin { + /* The node_num exposing the available gpio pin */ + uint32_t node_num; + /* The the available gpio pin for usage with RemoteHardware module */ + bool has_pin; + meshtastic_RemoteHardwarePin pin; +} meshtastic_NodeRemoteHardwarePin; + /* This message is never sent over the wire, but it is used for serializing DB state to flash in the device code FIXME, since we write this each time we enter deep sleep (and have infinite @@ -61,44 +107,11 @@ typedef struct _meshtastic_DeviceState { Might be null */ bool has_rx_waypoint; meshtastic_MeshPacket rx_waypoint; + /* The mesh's nodes with their available gpio pins for RemoteHardware module */ + pb_size_t node_remote_hardware_pins_count; + meshtastic_NodeRemoteHardwarePin node_remote_hardware_pins[12]; } meshtastic_DeviceState; -/* The on-disk saved channels */ -typedef struct _meshtastic_ChannelFile { - /* The channels our node knows about */ - pb_size_t channels_count; - meshtastic_Channel channels[8]; - /* A version integer used to invalidate old save files when we make - incompatible changes This integer is set at build time and is private to - NodeDB.cpp in the device code. */ - uint32_t version; -} meshtastic_ChannelFile; - -typedef PB_BYTES_ARRAY_T(2048) meshtastic_OEMStore_oem_icon_bits_t; -typedef PB_BYTES_ARRAY_T(32) meshtastic_OEMStore_oem_aes_key_t; -/* This can be used for customizing the firmware distribution. If populated, - show a secondary bootup screen with custom logo and text for 2.5 seconds. */ -typedef struct _meshtastic_OEMStore { - /* The Logo width in Px */ - uint32_t oem_icon_width; - /* The Logo height in Px */ - uint32_t oem_icon_height; - /* The Logo in XBM bytechar format */ - meshtastic_OEMStore_oem_icon_bits_t oem_icon_bits; - /* Use this font for the OEM text. */ - meshtastic_ScreenFonts oem_font; - /* Use this font for the OEM text. */ - char oem_text[40]; - /* The default device encryption key, 16 or 32 byte */ - meshtastic_OEMStore_oem_aes_key_t oem_aes_key; - /* A Preset LocalConfig to apply during factory reset */ - bool has_oem_local_config; - meshtastic_LocalConfig oem_local_config; - /* A Preset LocalModuleConfig to apply during factory reset */ - bool has_oem_local_module_config; - meshtastic_LocalModuleConfig oem_local_module_config; -} meshtastic_OEMStore; - #ifdef __cplusplus extern "C" { @@ -114,24 +127,18 @@ extern "C" { #define meshtastic_OEMStore_oem_font_ENUMTYPE meshtastic_ScreenFonts + /* Initializer values for message structs */ -#define meshtastic_DeviceState_init_default {false, meshtastic_MyNodeInfo_init_default, false, meshtastic_User_init_default, 0, {meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default}, 0, {meshtastic_MeshPacket_init_default}, false, meshtastic_MeshPacket_init_default, 0, 0, 0, false, meshtastic_MeshPacket_init_default} +#define meshtastic_DeviceState_init_default {false, meshtastic_MyNodeInfo_init_default, false, meshtastic_User_init_default, 0, {meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default}, 0, {meshtastic_MeshPacket_init_default}, false, meshtastic_MeshPacket_init_default, 0, 0, 0, false, meshtastic_MeshPacket_init_default, 0, {meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default}} #define meshtastic_ChannelFile_init_default {0, {meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default}, 0} #define meshtastic_OEMStore_init_default {0, 0, {0, {0}}, _meshtastic_ScreenFonts_MIN, "", {0, {0}}, false, meshtastic_LocalConfig_init_default, false, meshtastic_LocalModuleConfig_init_default} -#define meshtastic_DeviceState_init_zero {false, meshtastic_MyNodeInfo_init_zero, false, meshtastic_User_init_zero, 0, {meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero}, 0, {meshtastic_MeshPacket_init_zero}, false, meshtastic_MeshPacket_init_zero, 0, 0, 0, false, meshtastic_MeshPacket_init_zero} +#define meshtastic_NodeRemoteHardwarePin_init_default {0, false, meshtastic_RemoteHardwarePin_init_default} +#define meshtastic_DeviceState_init_zero {false, meshtastic_MyNodeInfo_init_zero, false, meshtastic_User_init_zero, 0, {meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero}, 0, {meshtastic_MeshPacket_init_zero}, false, meshtastic_MeshPacket_init_zero, 0, 0, 0, false, meshtastic_MeshPacket_init_zero, 0, {meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero}} #define meshtastic_ChannelFile_init_zero {0, {meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero}, 0} #define meshtastic_OEMStore_init_zero {0, 0, {0, {0}}, _meshtastic_ScreenFonts_MIN, "", {0, {0}}, false, meshtastic_LocalConfig_init_zero, false, meshtastic_LocalModuleConfig_init_zero} +#define meshtastic_NodeRemoteHardwarePin_init_zero {0, false, meshtastic_RemoteHardwarePin_init_zero} /* Field tags (for use in manual encoding/decoding) */ -#define meshtastic_DeviceState_my_node_tag 2 -#define meshtastic_DeviceState_owner_tag 3 -#define meshtastic_DeviceState_node_db_tag 4 -#define meshtastic_DeviceState_receive_queue_tag 5 -#define meshtastic_DeviceState_rx_text_message_tag 7 -#define meshtastic_DeviceState_version_tag 8 -#define meshtastic_DeviceState_no_save_tag 9 -#define meshtastic_DeviceState_did_gps_reset_tag 11 -#define meshtastic_DeviceState_rx_waypoint_tag 12 #define meshtastic_ChannelFile_channels_tag 1 #define meshtastic_ChannelFile_version_tag 2 #define meshtastic_OEMStore_oem_icon_width_tag 1 @@ -142,6 +149,18 @@ extern "C" { #define meshtastic_OEMStore_oem_aes_key_tag 6 #define meshtastic_OEMStore_oem_local_config_tag 7 #define meshtastic_OEMStore_oem_local_module_config_tag 8 +#define meshtastic_NodeRemoteHardwarePin_node_num_tag 1 +#define meshtastic_NodeRemoteHardwarePin_pin_tag 2 +#define meshtastic_DeviceState_my_node_tag 2 +#define meshtastic_DeviceState_owner_tag 3 +#define meshtastic_DeviceState_node_db_tag 4 +#define meshtastic_DeviceState_receive_queue_tag 5 +#define meshtastic_DeviceState_rx_text_message_tag 7 +#define meshtastic_DeviceState_version_tag 8 +#define meshtastic_DeviceState_no_save_tag 9 +#define meshtastic_DeviceState_did_gps_reset_tag 11 +#define meshtastic_DeviceState_rx_waypoint_tag 12 +#define meshtastic_DeviceState_node_remote_hardware_pins_tag 13 /* Struct field encoding specification for nanopb */ #define meshtastic_DeviceState_FIELDLIST(X, a) \ @@ -153,7 +172,8 @@ X(a, STATIC, OPTIONAL, MESSAGE, rx_text_message, 7) \ X(a, STATIC, SINGULAR, UINT32, version, 8) \ X(a, STATIC, SINGULAR, BOOL, no_save, 9) \ X(a, STATIC, SINGULAR, BOOL, did_gps_reset, 11) \ -X(a, STATIC, OPTIONAL, MESSAGE, rx_waypoint, 12) +X(a, STATIC, OPTIONAL, MESSAGE, rx_waypoint, 12) \ +X(a, STATIC, REPEATED, MESSAGE, node_remote_hardware_pins, 13) #define meshtastic_DeviceState_CALLBACK NULL #define meshtastic_DeviceState_DEFAULT NULL #define meshtastic_DeviceState_my_node_MSGTYPE meshtastic_MyNodeInfo @@ -162,6 +182,7 @@ X(a, STATIC, OPTIONAL, MESSAGE, rx_waypoint, 12) #define meshtastic_DeviceState_receive_queue_MSGTYPE meshtastic_MeshPacket #define meshtastic_DeviceState_rx_text_message_MSGTYPE meshtastic_MeshPacket #define meshtastic_DeviceState_rx_waypoint_MSGTYPE meshtastic_MeshPacket +#define meshtastic_DeviceState_node_remote_hardware_pins_MSGTYPE meshtastic_NodeRemoteHardwarePin #define meshtastic_ChannelFile_FIELDLIST(X, a) \ X(a, STATIC, REPEATED, MESSAGE, channels, 1) \ @@ -184,19 +205,29 @@ X(a, STATIC, OPTIONAL, MESSAGE, oem_local_module_config, 8) #define meshtastic_OEMStore_oem_local_config_MSGTYPE meshtastic_LocalConfig #define meshtastic_OEMStore_oem_local_module_config_MSGTYPE meshtastic_LocalModuleConfig +#define meshtastic_NodeRemoteHardwarePin_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, node_num, 1) \ +X(a, STATIC, OPTIONAL, MESSAGE, pin, 2) +#define meshtastic_NodeRemoteHardwarePin_CALLBACK NULL +#define meshtastic_NodeRemoteHardwarePin_DEFAULT NULL +#define meshtastic_NodeRemoteHardwarePin_pin_MSGTYPE meshtastic_RemoteHardwarePin + extern const pb_msgdesc_t meshtastic_DeviceState_msg; extern const pb_msgdesc_t meshtastic_ChannelFile_msg; extern const pb_msgdesc_t meshtastic_OEMStore_msg; +extern const pb_msgdesc_t meshtastic_NodeRemoteHardwarePin_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ #define meshtastic_DeviceState_fields &meshtastic_DeviceState_msg #define meshtastic_ChannelFile_fields &meshtastic_ChannelFile_msg #define meshtastic_OEMStore_fields &meshtastic_OEMStore_msg +#define meshtastic_NodeRemoteHardwarePin_fields &meshtastic_NodeRemoteHardwarePin_msg /* Maximum encoded size of messages (where known) */ #define meshtastic_ChannelFile_size 638 -#define meshtastic_DeviceState_size 22364 -#define meshtastic_OEMStore_size 3043 +#define meshtastic_DeviceState_size 22736 +#define meshtastic_NodeRemoteHardwarePin_size 29 +#define meshtastic_OEMStore_size 3137 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/localonly.pb.h b/src/mesh/generated/meshtastic/localonly.pb.h index 15b7b2b43..87638f32c 100644 --- a/src/mesh/generated/meshtastic/localonly.pb.h +++ b/src/mesh/generated/meshtastic/localonly.pb.h @@ -157,7 +157,7 @@ extern const pb_msgdesc_t meshtastic_LocalModuleConfig_msg; /* Maximum encoded size of messages (where known) */ #define meshtastic_LocalConfig_size 458 -#define meshtastic_LocalModuleConfig_size 439 +#define meshtastic_LocalModuleConfig_size 533 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index 984939702..98113c62b 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -719,6 +719,8 @@ typedef struct _meshtastic_DeviceMetadata { uint32_t position_flags; /* Device hardware model */ meshtastic_HardwareModel hw_model; + /* Has Remote Hardware enabled */ + bool hasRemoteHardware; } meshtastic_DeviceMetadata; /* Packets from the radio to the phone will appear on the fromRadio characteristic. @@ -855,7 +857,7 @@ extern "C" { #define meshtastic_Compressed_init_default {_meshtastic_PortNum_MIN, {0, {0}}} #define meshtastic_NeighborInfo_init_default {0, 0, 0, {meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default, meshtastic_Neighbor_init_default}} #define meshtastic_Neighbor_init_default {0, 0} -#define meshtastic_DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN} +#define meshtastic_DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN, 0} #define meshtastic_Position_init_zero {0, 0, 0, 0, _meshtastic_Position_LocSource_MIN, _meshtastic_Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_User_init_zero {"", "", "", {0}, _meshtastic_HardwareModel_MIN, 0} #define meshtastic_RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}} @@ -872,7 +874,7 @@ extern "C" { #define meshtastic_Compressed_init_zero {_meshtastic_PortNum_MIN, {0, {0}}} #define meshtastic_NeighborInfo_init_zero {0, 0, 0, {meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero, meshtastic_Neighbor_init_zero}} #define meshtastic_Neighbor_init_zero {0, 0} -#define meshtastic_DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN} +#define meshtastic_DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN, 0} /* Field tags (for use in manual encoding/decoding) */ #define meshtastic_Position_latitude_i_tag 1 @@ -987,6 +989,7 @@ extern "C" { #define meshtastic_DeviceMetadata_role_tag 7 #define meshtastic_DeviceMetadata_position_flags_tag 8 #define meshtastic_DeviceMetadata_hw_model_tag 9 +#define meshtastic_DeviceMetadata_hasRemoteHardware_tag 10 #define meshtastic_FromRadio_id_tag 1 #define meshtastic_FromRadio_packet_tag 2 #define meshtastic_FromRadio_my_info_tag 3 @@ -1210,7 +1213,8 @@ X(a, STATIC, SINGULAR, BOOL, hasBluetooth, 5) \ X(a, STATIC, SINGULAR, BOOL, hasEthernet, 6) \ X(a, STATIC, SINGULAR, UENUM, role, 7) \ X(a, STATIC, SINGULAR, UINT32, position_flags, 8) \ -X(a, STATIC, SINGULAR, UENUM, hw_model, 9) +X(a, STATIC, SINGULAR, UENUM, hw_model, 9) \ +X(a, STATIC, SINGULAR, BOOL, hasRemoteHardware, 10) #define meshtastic_DeviceMetadata_CALLBACK NULL #define meshtastic_DeviceMetadata_DEFAULT NULL @@ -1254,7 +1258,7 @@ extern const pb_msgdesc_t meshtastic_DeviceMetadata_msg; /* Maximum encoded size of messages (where known) */ #define meshtastic_Compressed_size 243 #define meshtastic_Data_size 270 -#define meshtastic_DeviceMetadata_size 44 +#define meshtastic_DeviceMetadata_size 46 #define meshtastic_FromRadio_size 330 #define meshtastic_LogRecord_size 81 #define meshtastic_MeshPacket_size 321 diff --git a/src/mesh/generated/meshtastic/module_config.pb.c b/src/mesh/generated/meshtastic/module_config.pb.c index 0878be909..123a4fedf 100644 --- a/src/mesh/generated/meshtastic/module_config.pb.c +++ b/src/mesh/generated/meshtastic/module_config.pb.c @@ -36,6 +36,10 @@ PB_BIND(meshtastic_ModuleConfig_TelemetryConfig, meshtastic_ModuleConfig_Telemet PB_BIND(meshtastic_ModuleConfig_CannedMessageConfig, meshtastic_ModuleConfig_CannedMessageConfig, AUTO) +PB_BIND(meshtastic_RemoteHardwarePin, meshtastic_RemoteHardwarePin, AUTO) + + + diff --git a/src/mesh/generated/meshtastic/module_config.pb.h b/src/mesh/generated/meshtastic/module_config.pb.h index e59d33dd0..82ac68ca2 100644 --- a/src/mesh/generated/meshtastic/module_config.pb.h +++ b/src/mesh/generated/meshtastic/module_config.pb.h @@ -10,6 +10,15 @@ #endif /* Enum definitions */ +typedef enum _meshtastic_RemoteHardwarePinType { + /* Unset/unused */ + meshtastic_RemoteHardwarePinType_UNKNOWN = 0, + /* GPIO pin can be read (if it is high / low) */ + meshtastic_RemoteHardwarePinType_DIGITAL_READ = 1, + /* GPIO pin can be written to (high / low) */ + meshtastic_RemoteHardwarePinType_DIGITAL_WRITE = 2 +} meshtastic_RemoteHardwarePinType; + /* Baudrate for codec2 voice */ typedef enum _meshtastic_ModuleConfig_AudioConfig_Audio_Baud { meshtastic_ModuleConfig_AudioConfig_Audio_Baud_CODEC2_DEFAULT = 0, @@ -103,12 +112,6 @@ typedef struct _meshtastic_ModuleConfig_MQTTConfig { char root[16]; } meshtastic_ModuleConfig_MQTTConfig; -/* RemoteHardwareModule Config */ -typedef struct _meshtastic_ModuleConfig_RemoteHardwareConfig { - /* Whether the Module is enabled */ - bool enabled; -} meshtastic_ModuleConfig_RemoteHardwareConfig; - /* Audio Config for codec2 voice */ typedef struct _meshtastic_ModuleConfig_AudioConfig { /* Whether Audio is enabled */ @@ -262,6 +265,27 @@ typedef struct _meshtastic_ModuleConfig_CannedMessageConfig { bool send_bell; } meshtastic_ModuleConfig_CannedMessageConfig; +/* A GPIO pin definition for remote hardware module */ +typedef struct _meshtastic_RemoteHardwarePin { + /* GPIO Pin number (must match Arduino) */ + uint8_t gpio_pin; + /* Name for the GPIO pin (i.e. Front gate, mailbox, etc) */ + char name[15]; + /* Type of GPIO access available to consumers on the mesh */ + meshtastic_RemoteHardwarePinType type; +} meshtastic_RemoteHardwarePin; + +/* RemoteHardwareModule Config */ +typedef struct _meshtastic_ModuleConfig_RemoteHardwareConfig { + /* Whether the Module is enabled */ + bool enabled; + /* Whether the Module allows consumers to read / write to pins not defined in available_pins */ + bool allow_undefined_pin_access; + /* Exposes the available pins to the mesh for reading and writing */ + pb_size_t available_pins_count; + meshtastic_RemoteHardwarePin available_pins[4]; +} meshtastic_ModuleConfig_RemoteHardwareConfig; + /* Module Config */ typedef struct _meshtastic_ModuleConfig { pb_size_t which_payload_variant; @@ -293,6 +317,10 @@ extern "C" { #endif /* Helper constants for enums */ +#define _meshtastic_RemoteHardwarePinType_MIN meshtastic_RemoteHardwarePinType_UNKNOWN +#define _meshtastic_RemoteHardwarePinType_MAX meshtastic_RemoteHardwarePinType_DIGITAL_WRITE +#define _meshtastic_RemoteHardwarePinType_ARRAYSIZE ((meshtastic_RemoteHardwarePinType)(meshtastic_RemoteHardwarePinType_DIGITAL_WRITE+1)) + #define _meshtastic_ModuleConfig_AudioConfig_Audio_Baud_MIN meshtastic_ModuleConfig_AudioConfig_Audio_Baud_CODEC2_DEFAULT #define _meshtastic_ModuleConfig_AudioConfig_Audio_Baud_MAX meshtastic_ModuleConfig_AudioConfig_Audio_Baud_CODEC2_700B #define _meshtastic_ModuleConfig_AudioConfig_Audio_Baud_ARRAYSIZE ((meshtastic_ModuleConfig_AudioConfig_Audio_Baud)(meshtastic_ModuleConfig_AudioConfig_Audio_Baud_CODEC2_700B+1)) @@ -325,11 +353,13 @@ extern "C" { #define meshtastic_ModuleConfig_CannedMessageConfig_inputbroker_event_ccw_ENUMTYPE meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar #define meshtastic_ModuleConfig_CannedMessageConfig_inputbroker_event_press_ENUMTYPE meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar +#define meshtastic_RemoteHardwarePin_type_ENUMTYPE meshtastic_RemoteHardwarePinType + /* Initializer values for message structs */ #define meshtastic_ModuleConfig_init_default {0, {meshtastic_ModuleConfig_MQTTConfig_init_default}} #define meshtastic_ModuleConfig_MQTTConfig_init_default {0, "", "", "", 0, 0, 0, ""} -#define meshtastic_ModuleConfig_RemoteHardwareConfig_init_default {0} +#define meshtastic_ModuleConfig_RemoteHardwareConfig_init_default {0, 0, 0, {meshtastic_RemoteHardwarePin_init_default, meshtastic_RemoteHardwarePin_init_default, meshtastic_RemoteHardwarePin_init_default, meshtastic_RemoteHardwarePin_init_default}} #define meshtastic_ModuleConfig_AudioConfig_init_default {0, 0, _meshtastic_ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0} #define meshtastic_ModuleConfig_SerialConfig_init_default {0, 0, 0, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Mode_MIN} #define meshtastic_ModuleConfig_ExternalNotificationConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} @@ -337,9 +367,10 @@ extern "C" { #define meshtastic_ModuleConfig_RangeTestConfig_init_default {0, 0, 0} #define meshtastic_ModuleConfig_TelemetryConfig_init_default {0, 0, 0, 0, 0, 0, 0} #define meshtastic_ModuleConfig_CannedMessageConfig_init_default {0, 0, 0, 0, _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0} +#define meshtastic_RemoteHardwarePin_init_default {0, "", _meshtastic_RemoteHardwarePinType_MIN} #define meshtastic_ModuleConfig_init_zero {0, {meshtastic_ModuleConfig_MQTTConfig_init_zero}} #define meshtastic_ModuleConfig_MQTTConfig_init_zero {0, "", "", "", 0, 0, 0, ""} -#define meshtastic_ModuleConfig_RemoteHardwareConfig_init_zero {0} +#define meshtastic_ModuleConfig_RemoteHardwareConfig_init_zero {0, 0, 0, {meshtastic_RemoteHardwarePin_init_zero, meshtastic_RemoteHardwarePin_init_zero, meshtastic_RemoteHardwarePin_init_zero, meshtastic_RemoteHardwarePin_init_zero}} #define meshtastic_ModuleConfig_AudioConfig_init_zero {0, 0, _meshtastic_ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0} #define meshtastic_ModuleConfig_SerialConfig_init_zero {0, 0, 0, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Mode_MIN} #define meshtastic_ModuleConfig_ExternalNotificationConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} @@ -347,6 +378,7 @@ extern "C" { #define meshtastic_ModuleConfig_RangeTestConfig_init_zero {0, 0, 0} #define meshtastic_ModuleConfig_TelemetryConfig_init_zero {0, 0, 0, 0, 0, 0, 0} #define meshtastic_ModuleConfig_CannedMessageConfig_init_zero {0, 0, 0, 0, _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0} +#define meshtastic_RemoteHardwarePin_init_zero {0, "", _meshtastic_RemoteHardwarePinType_MIN} /* Field tags (for use in manual encoding/decoding) */ #define meshtastic_ModuleConfig_MQTTConfig_enabled_tag 1 @@ -357,7 +389,6 @@ extern "C" { #define meshtastic_ModuleConfig_MQTTConfig_json_enabled_tag 6 #define meshtastic_ModuleConfig_MQTTConfig_tls_enabled_tag 7 #define meshtastic_ModuleConfig_MQTTConfig_root_tag 8 -#define meshtastic_ModuleConfig_RemoteHardwareConfig_enabled_tag 1 #define meshtastic_ModuleConfig_AudioConfig_codec2_enabled_tag 1 #define meshtastic_ModuleConfig_AudioConfig_ptt_pin_tag 2 #define meshtastic_ModuleConfig_AudioConfig_bitrate_tag 3 @@ -412,6 +443,12 @@ extern "C" { #define meshtastic_ModuleConfig_CannedMessageConfig_enabled_tag 9 #define meshtastic_ModuleConfig_CannedMessageConfig_allow_input_source_tag 10 #define meshtastic_ModuleConfig_CannedMessageConfig_send_bell_tag 11 +#define meshtastic_RemoteHardwarePin_gpio_pin_tag 1 +#define meshtastic_RemoteHardwarePin_name_tag 2 +#define meshtastic_RemoteHardwarePin_type_tag 3 +#define meshtastic_ModuleConfig_RemoteHardwareConfig_enabled_tag 1 +#define meshtastic_ModuleConfig_RemoteHardwareConfig_allow_undefined_pin_access_tag 2 +#define meshtastic_ModuleConfig_RemoteHardwareConfig_available_pins_tag 3 #define meshtastic_ModuleConfig_mqtt_tag 1 #define meshtastic_ModuleConfig_serial_tag 2 #define meshtastic_ModuleConfig_external_notification_tag 3 @@ -458,9 +495,12 @@ X(a, STATIC, SINGULAR, STRING, root, 8) #define meshtastic_ModuleConfig_MQTTConfig_DEFAULT NULL #define meshtastic_ModuleConfig_RemoteHardwareConfig_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, BOOL, enabled, 1) +X(a, STATIC, SINGULAR, BOOL, enabled, 1) \ +X(a, STATIC, SINGULAR, BOOL, allow_undefined_pin_access, 2) \ +X(a, STATIC, REPEATED, MESSAGE, available_pins, 3) #define meshtastic_ModuleConfig_RemoteHardwareConfig_CALLBACK NULL #define meshtastic_ModuleConfig_RemoteHardwareConfig_DEFAULT NULL +#define meshtastic_ModuleConfig_RemoteHardwareConfig_available_pins_MSGTYPE meshtastic_RemoteHardwarePin #define meshtastic_ModuleConfig_AudioConfig_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, BOOL, codec2_enabled, 1) \ @@ -544,6 +584,13 @@ X(a, STATIC, SINGULAR, BOOL, send_bell, 11) #define meshtastic_ModuleConfig_CannedMessageConfig_CALLBACK NULL #define meshtastic_ModuleConfig_CannedMessageConfig_DEFAULT NULL +#define meshtastic_RemoteHardwarePin_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, gpio_pin, 1) \ +X(a, STATIC, SINGULAR, STRING, name, 2) \ +X(a, STATIC, SINGULAR, UENUM, type, 3) +#define meshtastic_RemoteHardwarePin_CALLBACK NULL +#define meshtastic_RemoteHardwarePin_DEFAULT NULL + extern const pb_msgdesc_t meshtastic_ModuleConfig_msg; extern const pb_msgdesc_t meshtastic_ModuleConfig_MQTTConfig_msg; extern const pb_msgdesc_t meshtastic_ModuleConfig_RemoteHardwareConfig_msg; @@ -554,6 +601,7 @@ extern const pb_msgdesc_t meshtastic_ModuleConfig_StoreForwardConfig_msg; extern const pb_msgdesc_t meshtastic_ModuleConfig_RangeTestConfig_msg; extern const pb_msgdesc_t meshtastic_ModuleConfig_TelemetryConfig_msg; extern const pb_msgdesc_t meshtastic_ModuleConfig_CannedMessageConfig_msg; +extern const pb_msgdesc_t meshtastic_RemoteHardwarePin_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ #define meshtastic_ModuleConfig_fields &meshtastic_ModuleConfig_msg @@ -566,6 +614,7 @@ extern const pb_msgdesc_t meshtastic_ModuleConfig_CannedMessageConfig_msg; #define meshtastic_ModuleConfig_RangeTestConfig_fields &meshtastic_ModuleConfig_RangeTestConfig_msg #define meshtastic_ModuleConfig_TelemetryConfig_fields &meshtastic_ModuleConfig_TelemetryConfig_msg #define meshtastic_ModuleConfig_CannedMessageConfig_fields &meshtastic_ModuleConfig_CannedMessageConfig_msg +#define meshtastic_RemoteHardwarePin_fields &meshtastic_RemoteHardwarePin_msg /* Maximum encoded size of messages (where known) */ #define meshtastic_ModuleConfig_AudioConfig_size 19 @@ -573,11 +622,12 @@ extern const pb_msgdesc_t meshtastic_ModuleConfig_CannedMessageConfig_msg; #define meshtastic_ModuleConfig_ExternalNotificationConfig_size 40 #define meshtastic_ModuleConfig_MQTTConfig_size 220 #define meshtastic_ModuleConfig_RangeTestConfig_size 10 -#define meshtastic_ModuleConfig_RemoteHardwareConfig_size 2 +#define meshtastic_ModuleConfig_RemoteHardwareConfig_size 96 #define meshtastic_ModuleConfig_SerialConfig_size 26 #define meshtastic_ModuleConfig_StoreForwardConfig_size 22 #define meshtastic_ModuleConfig_TelemetryConfig_size 26 #define meshtastic_ModuleConfig_size 223 +#define meshtastic_RemoteHardwarePin_size 21 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index d5f887734..401e92f45 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -50,6 +50,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta // if handled == false, then let others look at this message also if they want bool handled = false; assert(r); + bool fromOthers = mp.from != 0 && mp.from != nodeDB.getNodeNum(); switch (r->which_payload_variant) { @@ -175,6 +176,14 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta handleGetDeviceConnectionStatus(mp); break; } + case meshtastic_AdminMessage_get_module_config_response_tag: { + LOG_INFO("Client is receiving a get_module_config response.\n"); + if (fromOthers && r->get_module_config_response.which_payload_variant == + meshtastic_AdminMessage_ModuleConfigType_REMOTEHARDWARE_CONFIG) { + handleGetModuleConfigResponse(mp, r); + } + break; + } #ifdef ARCH_PORTDUINO case meshtastic_AdminMessage_exit_simulator_tag: LOG_INFO("Exiting simulator\n"); @@ -205,6 +214,29 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta return handled; } +void AdminModule::handleGetModuleConfigResponse(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *r) +{ + // Skip if it's disabled or no pins are exposed + if (!r->get_module_config_response.payload_variant.remote_hardware.enabled || + !r->get_module_config_response.payload_variant.remote_hardware.available_pins) { + LOG_DEBUG("Remote hardware module disabled or no vailable_pins. Skipping...\n"); + return; + } + for (uint8_t i = 0; i < devicestate.node_remote_hardware_pins_count; i++) { + if (devicestate.node_remote_hardware_pins[i].node_num == 0 || !devicestate.node_remote_hardware_pins[i].has_pin) { + continue; + } + for (uint8_t j = 0; j < sizeof(r->get_module_config_response.payload_variant.remote_hardware.available_pins); j++) { + auto availablePin = r->get_module_config_response.payload_variant.remote_hardware.available_pins[j]; + if (i < devicestate.node_remote_hardware_pins_count) { + devicestate.node_remote_hardware_pins[i].node_num = mp.from; + devicestate.node_remote_hardware_pins[i].pin = availablePin; + } + i++; + } + } +} + /** * Setter methods */ @@ -487,6 +519,16 @@ void AdminModule::handleGetModuleConfig(const meshtastic_MeshPacket &req, const } } +void AdminModule::handleGetNodeRemoteHardwarePins(const meshtastic_MeshPacket &req) +{ + // We create the reply here + meshtastic_AdminMessage r = meshtastic_AdminMessage_init_default; + memcpy(r.get_node_remote_hardware_pins_response.node_remote_hardware_pins, devicestate.node_remote_hardware_pins, + sizeof(devicestate.node_remote_hardware_pins)); + r.which_payload_variant = meshtastic_AdminMessage_get_node_remote_hardware_pins_response_tag; + myReply = allocDataProtobuf(r); +} + void AdminModule::handleGetDeviceMetadata(const meshtastic_MeshPacket &req) { meshtastic_AdminMessage r = meshtastic_AdminMessage_init_default; diff --git a/src/modules/AdminModule.h b/src/modules/AdminModule.h index 7170e61d6..eb06e7b83 100644 --- a/src/modules/AdminModule.h +++ b/src/modules/AdminModule.h @@ -26,15 +26,18 @@ class AdminModule : public ProtobufModule bool hasOpenEditTransaction = false; void saveChanges(int saveWhat, bool shouldReboot = true); + /** * Getters */ + void handleGetModuleConfigResponse(const meshtastic_MeshPacket &req, meshtastic_AdminMessage *p); void handleGetOwner(const meshtastic_MeshPacket &req); void handleGetConfig(const meshtastic_MeshPacket &req, uint32_t configType); void handleGetModuleConfig(const meshtastic_MeshPacket &req, uint32_t configType); void handleGetChannel(const meshtastic_MeshPacket &req, uint32_t channelIndex); void handleGetDeviceMetadata(const meshtastic_MeshPacket &req); void handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &req); + void handleGetNodeRemoteHardwarePins(const meshtastic_MeshPacket &req); /** * Setters */ diff --git a/src/modules/RemoteHardwareModule.cpp b/src/modules/RemoteHardwareModule.cpp index c3232d266..3d4d735b4 100644 --- a/src/modules/RemoteHardwareModule.cpp +++ b/src/modules/RemoteHardwareModule.cpp @@ -53,7 +53,7 @@ bool RemoteHardwareModule::handleReceivedProtobuf(const meshtastic_MeshPacket &r { if (moduleConfig.remote_hardware.enabled) { auto p = *pptr; - LOG_INFO("Received RemoteHardware typ=%d\n", p.type); + LOG_INFO("Received RemoteHardware type=%d\n", p.type); switch (p.type) { case meshtastic_HardwareMessage_Type_WRITE_GPIOS: From eb916da8cee99e5723d4c83bee84696d7f9c347b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 22 May 2023 20:19:13 -0500 Subject: [PATCH 08/11] [create-pull-request] automated change (#2506) Co-authored-by: thebentern --- protobufs | 2 +- src/mesh/generated/meshtastic/admin.pb.h | 14 +++++++------- src/mesh/generated/meshtastic/config.pb.h | 8 ++++---- src/mesh/generated/meshtastic/module_config.pb.h | 2 +- src/mesh/generated/meshtastic/portnums.pb.h | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/protobufs b/protobufs index 6a94e6a77..d7327c3de 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 6a94e6a77f67d26a8b065c2ea61f07376a5ed142 +Subproject commit d7327c3de2a1dbd9ebb90864c703f97c673a4fc7 diff --git a/src/mesh/generated/meshtastic/admin.pb.h b/src/mesh/generated/meshtastic/admin.pb.h index 8ededf207..b6162b846 100644 --- a/src/mesh/generated/meshtastic/admin.pb.h +++ b/src/mesh/generated/meshtastic/admin.pb.h @@ -6,10 +6,10 @@ #include #include "meshtastic/channel.pb.h" #include "meshtastic/config.pb.h" -#include "meshtastic/mesh.pb.h" -#include "meshtastic/module_config.pb.h" #include "meshtastic/connection_status.pb.h" #include "meshtastic/deviceonly.pb.h" +#include "meshtastic/mesh.pb.h" +#include "meshtastic/module_config.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -75,7 +75,7 @@ typedef struct _meshtastic_HamParameters { typedef struct _meshtastic_NodeRemoteHardwarePinsResponse { /* Nodes and their respective remote hardware GPIO pins */ pb_size_t node_remote_hardware_pins_count; - meshtastic_NodeRemoteHardwarePin node_remote_hardware_pins[12]; + meshtastic_NodeRemoteHardwarePin node_remote_hardware_pins[16]; } meshtastic_NodeRemoteHardwarePinsResponse; /* This message is handled by the Admin module and is responsible for all settings/channel read/write operations. @@ -184,10 +184,10 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_AdminMessage_init_default {0, {0}} #define meshtastic_HamParameters_init_default {"", 0, 0, ""} -#define meshtastic_NodeRemoteHardwarePinsResponse_init_default {0, {meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default}} +#define meshtastic_NodeRemoteHardwarePinsResponse_init_default {0, {meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default, meshtastic_NodeRemoteHardwarePin_init_default}} #define meshtastic_AdminMessage_init_zero {0, {0}} #define meshtastic_HamParameters_init_zero {"", 0, 0, ""} -#define meshtastic_NodeRemoteHardwarePinsResponse_init_zero {0, {meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero}} +#define meshtastic_NodeRemoteHardwarePinsResponse_init_zero {0, {meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero, meshtastic_NodeRemoteHardwarePin_init_zero}} /* Field tags (for use in manual encoding/decoding) */ #define meshtastic_HamParameters_call_sign_tag 1 @@ -303,9 +303,9 @@ extern const pb_msgdesc_t meshtastic_NodeRemoteHardwarePinsResponse_msg; #define meshtastic_NodeRemoteHardwarePinsResponse_fields &meshtastic_NodeRemoteHardwarePinsResponse_msg /* Maximum encoded size of messages (where known) */ -#define meshtastic_AdminMessage_size 376 +#define meshtastic_AdminMessage_size 500 #define meshtastic_HamParameters_size 32 -#define meshtastic_NodeRemoteHardwarePinsResponse_size 372 +#define meshtastic_NodeRemoteHardwarePinsResponse_size 496 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/config.pb.h b/src/mesh/generated/meshtastic/config.pb.h index f858d46f8..b7c11a609 100644 --- a/src/mesh/generated/meshtastic/config.pb.h +++ b/src/mesh/generated/meshtastic/config.pb.h @@ -18,7 +18,7 @@ typedef enum _meshtastic_Config_DeviceConfig_Role { Same as a client except packets will not hop over this node, does not contribute to routing packets for mesh. */ meshtastic_Config_DeviceConfig_Role_CLIENT_MUTE = 1, /* Router device role. - Mesh packets will prefer to be routed over this node. This node will not be used by client apps. + Mesh packets will prefer to be routed over this node. This node will not be used by client apps. The wifi/ble radios and the oled screen will be put to sleep. This mode may still potentially have higher power usage due to it's preference in message rebroadcasting on the mesh. */ meshtastic_Config_DeviceConfig_Role_ROUTER = 2, @@ -293,7 +293,7 @@ typedef struct _meshtastic_Config_PowerConfig { 0 for default of 1 minute */ uint32_t wait_bluetooth_secs; /* Mesh Super Deep Sleep Timeout Seconds - While in Light Sleep if this value is exceeded we will lower into super deep sleep + While in Light Sleep if this value is exceeded we will lower into super deep sleep for sds_secs (default 1 year) or a button press 0 for default of two hours, MAXUINT for disabled */ uint32_t mesh_sds_timeout_secs; @@ -356,7 +356,7 @@ typedef struct _meshtastic_Config_DisplayConfig { /* Automatically toggles to the next page on the screen like a carousel, based the specified interval in seconds. Potentially useful for devices without user buttons. */ uint32_t auto_screen_carousel_secs; - /* If this is set, the displayed compass will always point north. if unset, the old behaviour + /* If this is set, the displayed compass will always point north. if unset, the old behaviour (top of display is heading direction) is used. */ bool compass_north_top; /* Flip screen vertically, for cases that mount the screen upside down */ @@ -419,7 +419,7 @@ typedef struct _meshtastic_Config_LoRaConfig { If using the hash algorithm the channel number will be: hash(channel_name) % NUM_CHANNELS (Where num channels depends on the regulatory region). */ uint16_t channel_num; - /* If true, duty cycle limits will be exceeded and thus you're possibly not following + /* If true, duty cycle limits will be exceeded and thus you're possibly not following the local regulations if you're not a HAM. Has no effect if the duty cycle of the used region is 100%. */ bool override_duty_cycle; diff --git a/src/mesh/generated/meshtastic/module_config.pb.h b/src/mesh/generated/meshtastic/module_config.pb.h index 82ac68ca2..be1f33e2f 100644 --- a/src/mesh/generated/meshtastic/module_config.pb.h +++ b/src/mesh/generated/meshtastic/module_config.pb.h @@ -211,7 +211,7 @@ typedef struct _meshtastic_ModuleConfig_RangeTestConfig { bool enabled; /* Send out range test messages from this node */ uint32_t sender; - /* Bool value indicating that this node should save a RangeTest.csv file. + /* Bool value indicating that this node should save a RangeTest.csv file. ESP32 Only */ bool save; } meshtastic_ModuleConfig_RangeTestConfig; diff --git a/src/mesh/generated/meshtastic/portnums.pb.h b/src/mesh/generated/meshtastic/portnums.pb.h index ccf94372e..089d7b59f 100644 --- a/src/mesh/generated/meshtastic/portnums.pb.h +++ b/src/mesh/generated/meshtastic/portnums.pb.h @@ -77,9 +77,9 @@ typedef enum _meshtastic_PortNum { Maintained by Github user a-f-G-U-C (a Meshtastic contributor) Project files at https://github.com/a-f-G-U-C/Meshtastic-ZPS */ meshtastic_PortNum_ZPS_APP = 68, - /* Used to let multiple instances of Linux native applications communicate + /* Used to let multiple instances of Linux native applications communicate as if they did using their LoRa chip. - Maintained by GitHub user GUVWAF. + Maintained by GitHub user GUVWAF. Project files at https://github.com/GUVWAF/Meshtasticator */ meshtastic_PortNum_SIMULATOR_APP = 69, /* Provides a traceroute functionality to show the route a packet towards From 4f0922ec2b4d054a33c4fe6a5ce7d6ef9365933c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 23 May 2023 16:18:14 -0500 Subject: [PATCH 09/11] Concat remote hardware pins (#2508) --- src/modules/AdminModule.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 401e92f45..28177cb63 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -521,11 +521,23 @@ void AdminModule::handleGetModuleConfig(const meshtastic_MeshPacket &req, const void AdminModule::handleGetNodeRemoteHardwarePins(const meshtastic_MeshPacket &req) { - // We create the reply here meshtastic_AdminMessage r = meshtastic_AdminMessage_init_default; - memcpy(r.get_node_remote_hardware_pins_response.node_remote_hardware_pins, devicestate.node_remote_hardware_pins, - sizeof(devicestate.node_remote_hardware_pins)); r.which_payload_variant = meshtastic_AdminMessage_get_node_remote_hardware_pins_response_tag; + for (uint8_t i = 0; i < devicestate.node_remote_hardware_pins_count; i++) { + if (devicestate.node_remote_hardware_pins[i].node_num == 0 || !devicestate.node_remote_hardware_pins[i].has_pin) { + continue; + } + r.get_node_remote_hardware_pins_response.node_remote_hardware_pins[i] = devicestate.node_remote_hardware_pins[i]; + } + for (uint8_t i = 0; i < moduleConfig.remote_hardware.available_pins_count; i++) { + if (!moduleConfig.remote_hardware.available_pins[i].gpio_pin) { + continue; + } + meshtastic_NodeRemoteHardwarePin nodePin = meshtastic_NodeRemoteHardwarePin_init_default; + nodePin.node_num = nodeDB.getNodeNum(); + nodePin.pin = moduleConfig.remote_hardware.available_pins[i]; + r.get_node_remote_hardware_pins_response.node_remote_hardware_pins[i + 12] = nodePin; + } myReply = allocDataProtobuf(r); } From 1dfa8f2d9e250bd8bd946b77bc43dbfafb62556d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 23 May 2023 23:19:36 +0200 Subject: [PATCH 10/11] RAK11310 (#2299) * POC. Board definition JSON upcoming. Generic for now * side-effect: RP2040 is building again. * WIP Pico Targets * current state of affairs * ahem * POC. Board definition JSON upcoming. Generic for now * side-effect: RP2040 is building again. * WIP Pico Targets * current state of affairs * ahem * fmt * update toolkit and fmt * Add built in LED pin * Use arduino pins * init SPI bus on right pins. * Use SPI1 and control chip select manually * Use macro define for SPI selection. This needs to be defined in the ini file since portduino needs it inside the framework source * Remove manual CS; works when not using setCS() * Remove whoopsie debug line * we are not ARDUINO_AVR_NANO_EVERY any more * fix rp2040 compilation * fix RadioLibHAL * Use new arduino-pico core * Use cortex-m0plus for BSEC2 library * Forgot RAK11310 target for BSEC2 library * That branch was merged * RAK11310 is working too --------- Co-authored-by: Ben Meadors Co-authored-by: GUVWAF --- .github/workflows/main_matrix.yml | 25 +++++++----- arch/rp2040/rp2040.ini | 5 ++- boards/wiscore_rak11300.json | 40 ++++++++++++++++++ src/SerialConsole.cpp | 2 +- src/main.cpp | 24 +++++++++-- src/mesh/RadioLibInterface.cpp | 2 +- variants/rak11310/pins_arduino.h | 68 +++++++++++++++++++++++++++++++ variants/rak11310/platformio.ini | 15 +++++++ variants/rak11310/variant.h | 55 +++++++++++++++++++++++++ variants/rpipico/platformio.ini | 6 +-- variants/rpipico/variant.h | 6 ++- variants/rpipicow/platformio.ini | 6 +-- variants/rpipicow/variant.h | 4 +- 13 files changed, 229 insertions(+), 29 deletions(-) create mode 100644 boards/wiscore_rak11300.json create mode 100644 variants/rak11310/pins_arduino.h create mode 100644 variants/rak11310/platformio.ini create mode 100644 variants/rak11310/variant.h diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 6194bfe69..bbc7fdf84 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -33,6 +33,7 @@ jobs: - board: m5stack-coreink - board: tbeam-s3-core - board: tlora-t3s3-v1 + - board: rak11310 runs-on: ubuntu-latest steps: @@ -103,16 +104,17 @@ jobs: with: board: ${{ matrix.board }} - # build-rpi2040: - # strategy: - # fail-fast: false - # max-parallel: 2 - # matrix: - # include: - # - board: pico - # uses: ./.github/workflows/build_rpi2040.yml - # with: - # board: ${{ matrix.board }} + build-rpi2040: + strategy: + fail-fast: false + max-parallel: 2 + matrix: + include: + - board: pico + - board: rak11310 + uses: ./.github/workflows/build_rpi2040.yml + with: + board: ${{ matrix.board }} build-native: runs-on: ubuntu-latest @@ -186,7 +188,8 @@ jobs: gather-artifacts: runs-on: ubuntu-latest - needs: [build-esp32, build-esp32-s3, build-nrf52, build-native] #, build-rpi2040] + needs: + [build-esp32, build-esp32-s3, build-nrf52, build-native, build-rpi2040] steps: - name: Checkout code uses: actions/checkout@v3 diff --git a/arch/rp2040/rp2040.ini b/arch/rp2040/rp2040.ini index 6f5449ae6..9d102be02 100644 --- a/arch/rp2040/rp2040.ini +++ b/arch/rp2040/rp2040.ini @@ -1,7 +1,8 @@ ; Common settings for rp2040 Processor based targets [rp2040_base] -platform = https://github.com/maxgerhardt/platform-raspberrypi.git#9f8c10e50b5acd18e7bfd32638199c655be73a5b +platform = https://github.com/maxgerhardt/platform-raspberrypi.git#0c33219f53faa035e188925ea1324f472e8b93d2 extends = arduino_base +platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#652f9f9eda0d77efeafebc7c1ff5cd45defc71bf board_build.core = earlephilhower board_build.filesystem_size = 0.5m @@ -20,4 +21,4 @@ lib_deps = ${arduino_base.lib_deps} ${environmental_base.lib_deps} jgromes/RadioLib@^6.0.0 - https://github.com/kokke/tiny-AES-c.git#f06ac37fc31dfdaca2e0d9bec83f90d5663c319b + https://github.com/kokke/tiny-AES-c.git#f06ac37fc31dfdaca2e0d9bec83f90d5663c319b \ No newline at end of file diff --git a/boards/wiscore_rak11300.json b/boards/wiscore_rak11300.json new file mode 100644 index 000000000..19beee74d --- /dev/null +++ b/boards/wiscore_rak11300.json @@ -0,0 +1,40 @@ +{ + "build": { + "arduino": { + "earlephilhower": { + "boot2_source": "boot2_w25q080_2_padded_checksum.S", + "usb_vid": "0x2E8A", + "usb_pid": "0x000A" + } + }, + "core": "earlephilhower", + "cpu": "cortex-m0plus", + "extra_flags": "-DARDUINO_GENERIC_RP2040 -DRASPBERRY_PI_PICO -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=250", + "f_cpu": "133000000L", + "hwids": [ + ["0x2E8A", "0x00C0"], + ["0x2E8A", "0x000A"] + ], + "mcu": "rp2040", + "variant": "WisBlock_RAK11300_Board" + }, + "debug": { + "jlink_device": "RP2040_M0_0", + "openocd_target": "rp2040.cfg", + "svd_path": "rp2040.svd" + }, + "frameworks": ["arduino"], + "name": "WisBlock RAK11300", + "upload": { + "maximum_ram_size": 270336, + "maximum_size": 2097152, + "require_upload_port": true, + "native_usb": true, + "use_1200bps_touch": true, + "wait_for_upload_port": false, + "protocol": "picotool", + "protocols": ["cmsis-dap", "raspberrypi-swd", "picotool", "picoprobe"] + }, + "url": "https://docs.rakwireless.com/", + "vendor": "RAKwireless" +} diff --git a/src/SerialConsole.cpp b/src/SerialConsole.cpp index 91b4e2826..e827dcf3b 100644 --- a/src/SerialConsole.cpp +++ b/src/SerialConsole.cpp @@ -31,7 +31,7 @@ SerialConsole::SerialConsole() : StreamAPI(&Port), RedirectablePrint(&Port), con // setDestination(&noopPrint); for testing, try turning off 'all' debug output and see what leaks Port.begin(SERIAL_BAUD); -#if defined(ARCH_NRF52) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) +#if defined(ARCH_NRF52) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) || defined(ARCH_RP2040) time_t timeout = millis(); while (!Port) { if ((millis() - timeout) < 5000) { diff --git a/src/main.cpp b/src/main.cpp index 19ed56662..5120cb269 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -447,7 +447,21 @@ void setup() // Init our SPI controller (must be before screen and lora) initSPI(); -#ifndef ARCH_ESP32 +#ifdef ARCH_RP2040 +#ifdef HW_SPI1_DEVICE + SPI1.setSCK(RF95_SCK); + SPI1.setTX(RF95_MOSI); + SPI1.setRX(RF95_MISO); + pinMode(RF95_NSS, OUTPUT); + digitalWrite(RF95_NSS, HIGH); + SPI1.begin(false); +#else // HW_SPI1_DEVICE + SPI.setSCK(RF95_SCK); + SPI.setTX(RF95_MOSI); + SPI.setRX(RF95_MISO); + SPI.begin(false); +#endif // HW_SPI1_DEVICE +#elif !defined(ARCH_ESP32) // ARCH_RP2040 SPI.begin(); #else // ESP32 @@ -509,9 +523,11 @@ void setup() digitalWrite(SX126X_ANT_SW, 1); #endif - // Init LockingHAL first, to use it for radio init - +#ifdef HW_SPI1_DEVICE + LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI1, spiSettings); +#else // HW_SPI1_DEVICE LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); +#endif // radio init MUST BE AFTER service.init, so we have our radio config settings (from nodedb init) @@ -718,4 +734,4 @@ void loop() mainDelay.delay(delayMsec); } // if (didWake) LOG_DEBUG("wake!\n"); -} +} \ No newline at end of file diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index bce6b8a97..a74d41090 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -406,4 +406,4 @@ void RadioLibInterface::startSend(meshtastic_MeshPacket *txp) // bits enableInterrupt(isrTxLevel0); } -} +} \ No newline at end of file diff --git a/variants/rak11310/pins_arduino.h b/variants/rak11310/pins_arduino.h new file mode 100644 index 000000000..626bed1da --- /dev/null +++ b/variants/rak11310/pins_arduino.h @@ -0,0 +1,68 @@ +#pragma once + +// Pin definitions taken from: +// https://datasheets.raspberrypi.org/pico/pico-datasheet.pdf + +static const uint8_t WB_IO1 = 6; // SLOT_A SLOT_B +static const uint8_t WB_IO2 = 22; // SLOT_A SLOT_B +static const uint8_t WB_IO3 = 7; // SLOT_C +static const uint8_t WB_IO4 = 28; // SLOT_C +static const uint8_t WB_IO5 = 9; // SLOT_D +static const uint8_t WB_IO6 = 8; // SLOT_D +static const uint8_t WB_A0 = 26; // IO_SLOT +static const uint8_t WB_A1 = 27; // IO_SLOT + +#define PIN_A0 (26u) +#define PIN_A1 (27u) +#define PIN_A2 (28u) +#define PIN_A3 (29u) + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; +static const uint8_t A3 = PIN_A3; + +// LEDs +#define PIN_LED (23u) +#define PIN_LED1 PIN_LED +#define PIN_LED2 (24u) +#define LED_BUILTIN PIN_LED + +#define ADC_RESOLUTION 12 + +// Serial +#define PIN_SERIAL1_TX (0ul) +#define PIN_SERIAL1_RX (1ul) + +#define PIN_SERIAL2_TX (4ul) +#define PIN_SERIAL2_RX (5ul) + +// SPI +#define PIN_SPI0_MISO (12u) +#define PIN_SPI0_MOSI (11u) +#define PIN_SPI0_SCK (10u) +#define PIN_SPI0_SS (13u) + +#define PIN_SPI1_MISO (16u) +#define PIN_SPI1_MOSI (19u) +#define PIN_SPI1_SCK (18u) +#define PIN_SPI1_SS (17u) + +// Wire +#define PIN_WIRE0_SDA (2u) +#define PIN_WIRE0_SCL (3u) + +#define PIN_WIRE1_SDA (20u) +#define PIN_WIRE1_SCL (21u) + +#define SERIAL_HOWMANY (3u) +#define SPI_HOWMANY (2u) +#define WIRE_HOWMANY (2u) + +static const uint8_t SS = PIN_SPI0_SS; +static const uint8_t MOSI = PIN_SPI0_MOSI; +static const uint8_t MISO = PIN_SPI0_MISO; +static const uint8_t SCK = PIN_SPI0_SCK; + +static const uint8_t SDA = PIN_WIRE0_SDA; +static const uint8_t SCL = PIN_WIRE0_SCL; \ No newline at end of file diff --git a/variants/rak11310/platformio.ini b/variants/rak11310/platformio.ini new file mode 100644 index 000000000..c4ff35d4e --- /dev/null +++ b/variants/rak11310/platformio.ini @@ -0,0 +1,15 @@ +[env:rak11310] +extends = rp2040_base +board = wiscore_rak11300 +board_level = extra +upload_protocol = picotool + +# add our variants files to the include and src paths +build_flags = ${rp2040_base.build_flags} + -DPRIVATE_HW + -Ivariants/rak11310 + -DDEBUG_RP2040_PORT=Serial + -DUSE_TINYUSB + -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m0plus" +lib_deps = + ${rp2040_base.lib_deps} \ No newline at end of file diff --git a/variants/rak11310/variant.h b/variants/rak11310/variant.h new file mode 100644 index 000000000..7bb61fc2f --- /dev/null +++ b/variants/rak11310/variant.h @@ -0,0 +1,55 @@ +// #define RADIOLIB_CUSTOM_ARDUINO 1 +// #define RADIOLIB_TONE_UNSUPPORTED 1 +// #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED 1 + +#define ARDUINO_ARCH_AVR + +#undef CBC +#define CBC 0 +#undef CTR +#define CTR 1 +#undef ECB +#define ECB 0 + +#undef GPS_SERIAL_NUM + +#define LED_CONN PIN_LED2 + +#define BUTTON_PIN 9 +#define BUTTON_NEED_PULLUP +// #define EXT_NOTIFY_OUT 4 + +#define BATTERY_PIN 26 +// ratio of voltage divider = 3.0 (R17=200k, R18=100k) +#define ADC_MULTIPLIER 3.1 // 3.0 + a bit for being optimistic + +#define USE_SX1262 + +#undef RF95_SCK +#undef RF95_MISO +#undef RF95_MOSI +#undef RF95_NSS + +// RAK BSP somehow uses SPI1 instead of SPI0 +#define HW_SPI1_DEVICE +#define RF95_SCK PIN_SPI0_SCK +#define RF95_MOSI PIN_SPI0_MOSI +#define RF95_MISO PIN_SPI0_MISO +#define RF95_NSS PIN_SPI0_SS + +#define LORA_DIO0 RADIOLIB_NC +#define LORA_RESET 14 +#define LORA_DIO1 29 +#define LORA_DIO2 15 +#define LORA_DIO3 RADIOLIB_NC + +#ifdef USE_SX1262 +#define SX126X_CS RF95_NSS +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY LORA_DIO2 +#define SX126X_RESET LORA_RESET +#define SX126X_POWER_EN 25 +#define SX126X_E22 // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3 +#endif + +#include \ No newline at end of file diff --git a/variants/rpipico/platformio.ini b/variants/rpipico/platformio.ini index a169e8a9d..c9852a4b3 100644 --- a/variants/rpipico/platformio.ini +++ b/variants/rpipico/platformio.ini @@ -8,11 +8,9 @@ upload_protocol = picotool build_flags = ${rp2040_base.build_flags} -DPRIVATE_HW -Ivariants/rpipico - -DARDUINO_AVR_NANO_EVERY - -DDEBUG_RP2040_WIRE - -DDEBUG_RP2040_SPI - -DDEBUG_RP2040_CORE -DDEBUG_RP2040_PORT=Serial -DUSE_TINYUSB + -DHW_SPI1_DEVICE + -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m0plus" lib_deps = ${rp2040_base.lib_deps} \ No newline at end of file diff --git a/variants/rpipico/variant.h b/variants/rpipico/variant.h index d620a356b..f7fc49d6c 100644 --- a/variants/rpipico/variant.h +++ b/variants/rpipico/variant.h @@ -4,8 +4,11 @@ #define ARDUINO_ARCH_AVR +#undef CBC #define CBC 0 +#undef CTR #define CTR 1 +#undef ECB #define ECB 0 #define NO_GPS 1 @@ -18,11 +21,12 @@ #define BUTTON_PIN 17 #define EXT_NOTIFY_OUT 4 +#define LED_PIN PIN_LED + #define BATTERY_PIN 26 // ratio of voltage divider = 3.0 (R17=200k, R18=100k) #define ADC_MULTIPLIER 3.1 // 3.0 + a bit for being optimistic -#define USE_RF95 #define USE_SX1262 #undef RF95_SCK diff --git a/variants/rpipicow/platformio.ini b/variants/rpipicow/platformio.ini index 6e5c32a52..a0fd626b3 100644 --- a/variants/rpipicow/platformio.ini +++ b/variants/rpipicow/platformio.ini @@ -8,11 +8,9 @@ upload_protocol = picotool build_flags = ${rp2040_base.build_flags} -DPRIVATE_HW -Ivariants/rpipicow - -DARDUINO_AVR_NANO_EVERY - -DDEBUG_RP2040_WIRE - -DDEBUG_RP2040_SPI - -DDEBUG_RP2040_CORE -DDEBUG_RP2040_PORT=Serial -DUSE_TINYUSB + -DHW_SPI1_DEVICE + -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m0plus" lib_deps = ${rp2040_base.lib_deps} \ No newline at end of file diff --git a/variants/rpipicow/variant.h b/variants/rpipicow/variant.h index d620a356b..4aa0c5a5d 100644 --- a/variants/rpipicow/variant.h +++ b/variants/rpipicow/variant.h @@ -4,8 +4,11 @@ #define ARDUINO_ARCH_AVR +#undef CBC #define CBC 0 +#undef CTR #define CTR 1 +#undef ECB #define ECB 0 #define NO_GPS 1 @@ -22,7 +25,6 @@ // ratio of voltage divider = 3.0 (R17=200k, R18=100k) #define ADC_MULTIPLIER 3.1 // 3.0 + a bit for being optimistic -#define USE_RF95 #define USE_SX1262 #undef RF95_SCK From 0261754269eb6e8cf404d51251531fb2d67d2a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 15 May 2023 17:17:14 +0200 Subject: [PATCH 11/11] Add variant an plumbing for #2468 --- src/graphics/Screen.cpp | 10 ++++---- src/graphics/Screen.h | 2 +- src/graphics/TFTDisplay.cpp | 2 +- src/graphics/images.h | 2 +- variants/picomputer-s3/pins_arduino.h | 37 +++++++++++++++++++++++++++ variants/picomputer-s3/platformio.ini | 27 +++++++++++++++++++ variants/picomputer-s3/variant.h | 24 +++++++++++++++++ 7 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 variants/picomputer-s3/pins_arduino.h create mode 100644 variants/picomputer-s3/platformio.ini create mode 100644 variants/picomputer-s3/variant.h diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 072a9d14d..9d666d986 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -101,7 +101,7 @@ static uint16_t displayWidth, displayHeight; #define SCREEN_WIDTH displayWidth #define SCREEN_HEIGHT displayHeight -#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) +#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(USE_ST7789) // The screen is bigger so use bigger fonts #define FONT_SMALL ArialMT_Plain_16 // Height: 19 #define FONT_MEDIUM ArialMT_Plain_24 // Height: 28 @@ -491,7 +491,7 @@ static void drawNodes(OLEDDisplay *display, int16_t x, int16_t y, NodeStatus *no { char usersString[20]; snprintf(usersString, sizeof(usersString), "%d/%d", nodeStatus->getNumOnline(), nodeStatus->getNumTotal()); -#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) +#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(USE_ST7789) display->drawFastImage(x, y + 3, 8, 8, imgUser); #else display->drawFastImage(x, y, 8, 8, imgUser); @@ -1487,7 +1487,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 #ifdef ARCH_ESP32 if (millis() - storeForwardModule->lastHeartbeat > (storeForwardModule->heartbeatInterval * 1200)) { // no heartbeat, overlap a bit -#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) +#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(USE_ST7789) display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 12, 8, imgQuestionL1); display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 12, 8, @@ -1497,7 +1497,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 imgQuestion); #endif } else { -#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) +#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(USE_ST7789) display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 16, 8, imgSFL1); display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 16, 8, @@ -1509,7 +1509,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 } #endif } else { -#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) +#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(USE_ST7789) display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 12, 8, imgInfoL1); display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 12, 8, diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index 992a73285..a9ddc3316 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -380,7 +380,7 @@ class Screen : public concurrency::OSThread SH1106Wire dispdev; #elif defined(USE_SSD1306) SSD1306Wire dispdev; -#elif defined(ST7735_CS) || defined(ILI9341_DRIVER) +#elif defined(ST7735_CS) || defined(ILI9341_DRIVER) || defined(USE_ST7789) TFTDisplay dispdev; #elif defined(USE_EINK) EInkDisplay dispdev; diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index 8c07a4204..ed4367d42 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -1,6 +1,6 @@ #include "configuration.h" -#if defined(ST7735_CS) || defined(ILI9341_DRIVER) +#if defined(ST7735_CS) || defined(ILI9341_DRIVER) || defined(USE_ST7789) #include "SPILock.h" #include "TFTDisplay.h" #include diff --git a/src/graphics/images.h b/src/graphics/images.h index b1818e32c..6b7c91862 100644 --- a/src/graphics/images.h +++ b/src/graphics/images.h @@ -14,7 +14,7 @@ const uint8_t imgUser[] PROGMEM = {0x3C, 0x42, 0x99, 0xA5, 0xA5, 0x99, 0x42, 0x3 const uint8_t imgPositionEmpty[] PROGMEM = {0x20, 0x30, 0x28, 0x24, 0x42, 0xFF}; const uint8_t imgPositionSolid[] PROGMEM = {0x20, 0x30, 0x38, 0x3C, 0x7E, 0xFF}; -#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) +#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(USE_ST7789) const uint8_t imgQuestionL1[] PROGMEM = {0xff, 0x01, 0x01, 0x32, 0x7b, 0x49, 0x49, 0x6f, 0x26, 0x01, 0x01, 0xff}; const uint8_t imgQuestionL2[] PROGMEM = {0x0f, 0x08, 0x08, 0x08, 0x06, 0x0f, 0x0f, 0x06, 0x08, 0x08, 0x08, 0x0f}; const uint8_t imgInfoL1[] PROGMEM = {0xff, 0x01, 0x01, 0x01, 0x1e, 0x7f, 0x1e, 0x01, 0x01, 0x01, 0x01, 0xff}; diff --git a/variants/picomputer-s3/pins_arduino.h b/variants/picomputer-s3/pins_arduino.h new file mode 100644 index 000000000..ee0e34ebf --- /dev/null +++ b/variants/picomputer-s3/pins_arduino.h @@ -0,0 +1,37 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +#define EXTERNAL_NUM_INTERRUPTS 46 +#define NUM_DIGITAL_PINS 48 +#define NUM_ANALOG_INPUTS 20 + +#define analogInputToDigitalPin(p) (((p) < 20) ? (analogChannelToDigitalPin(p)) : -1) +#define digitalPinToInterrupt(p) (((p) < 48) ? (p) : -1) +#define digitalPinHasPWM(p) (p < 46) + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +// The default Wire will be mapped to PMU and RTC +static const uint8_t SDA = 12; +static const uint8_t SCL = 14; + +// Default SPI will be mapped to Radio +static const uint8_t MISO = 39; +static const uint8_t SCK = 21; +static const uint8_t MOSI = 38; +static const uint8_t SS = 17; + +//#define SPI_MOSI (11) +//#define SPI_SCK (14) +//#define SPI_MISO (2) +//#define SPI_CS (13) + +//#define SDCARD_CS SPI_CS + +#endif /* Pins_Arduino_h */ \ No newline at end of file diff --git a/variants/picomputer-s3/platformio.ini b/variants/picomputer-s3/platformio.ini new file mode 100644 index 000000000..0cb58f23c --- /dev/null +++ b/variants/picomputer-s3/platformio.ini @@ -0,0 +1,27 @@ +[env:picomputer_s3] +extends = esp32s3_base +board = bpi_picow_esp32_s3 +board_level = extra +;OpenOCD flash method +;upload_protocol = esp-builtin +;Normal method +upload_protocol = esptool + +build_flags = + ${esp32_base.build_flags} + -D PRIVATE_HW + -I variants/picomputer-s3 + -DST7789_DRIVER + -DUSER_SETUP_LOADED + -DTFT_SDA_READ + -DTFT_MOSI=19 + -DTFT_MISO=-1 + -DTFT_SCLK=18 + -DTFT_CS=21 + -DTFT_DC=16 + -DTFT_BL=20 + -DDISABLE_ALL_LIBRARY_WARNINGS + +lib_deps = + ${esp32_base.lib_deps} + bodmer/TFT_eSPI@^2.4.76 \ No newline at end of file diff --git a/variants/picomputer-s3/variant.h b/variants/picomputer-s3/variant.h new file mode 100644 index 000000000..cbb8fe65e --- /dev/null +++ b/variants/picomputer-s3/variant.h @@ -0,0 +1,24 @@ +#define HAS_GPS 0 +#undef GPS_RX_PIN +#undef GPS_TX_PIN + +#define USE_ST7789 + +#define LED_PIN 48 // If defined we will blink this LED + +#define BUTTON_PIN 0 // If defined, this will be used for user button presses, + +#define BUTTON_NEED_PULLUP + +#define USE_RF95 // RFM95/SX127x + +#define RF95_SCK 10 +#define RF95_MISO 12 +#define RF95_MOSI 11 +#define RF95_NSS 13 +#define LORA_RESET RADIOLIB_NC + +// per SX1276_Receive_Interrupt/utilities.h +#define LORA_DIO0 28 +#define LORA_DIO1 RADIOLIB_NC +#define LORA_DIO2 RADIOLIB_NC \ No newline at end of file