mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-29 13:12:04 +00:00
Compare commits
8 Commits
status-mes
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8af9e7fbdc | ||
|
|
1f7ed6888a | ||
|
|
31bf51b3f2 | ||
|
|
334a4f04cd | ||
|
|
415686dd06 | ||
|
|
b2f2f6b305 | ||
|
|
df400850c1 | ||
|
|
6ab2f02dbc |
@@ -170,7 +170,7 @@ template <typename T> bool LR11x0Interface<T>::reconfigure()
|
||||
if (err != RADIOLIB_ERR_NONE)
|
||||
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
|
||||
|
||||
err = lora.setCodingRate(cr);
|
||||
err = lora.setCodingRate(cr, cr != 7); // use long interleaving except if CR is 4/7 which doesn't support it
|
||||
if (err != RADIOLIB_ERR_NONE)
|
||||
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ template <typename T> bool SX128xInterface<T>::reconfigure()
|
||||
if (err != RADIOLIB_ERR_NONE)
|
||||
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
|
||||
|
||||
err = lora.setCodingRate(cr);
|
||||
err = lora.setCodingRate(cr, cr != 7); // use long interleaving except if CR is 4/7 which doesn't support it
|
||||
if (err != RADIOLIB_ERR_NONE)
|
||||
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "configuration.h"
|
||||
#if !MESHTASTIC_EXCLUDE_INPUTBROKER
|
||||
#include "buzz/BuzzerFeedbackThread.h"
|
||||
#include "modules/StatusLEDModule.h"
|
||||
#include "modules/SystemCommandsModule.h"
|
||||
#endif
|
||||
#if !MESHTASTIC_EXCLUDE_PKI
|
||||
@@ -90,6 +91,9 @@
|
||||
#include "modules/DropzoneModule.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAS_HARDWARE_WATCHDOG)
|
||||
#include "watchdog/watchdogThread.h"
|
||||
#endif
|
||||
/**
|
||||
* Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else)
|
||||
*/
|
||||
@@ -228,6 +232,9 @@ void setupModules()
|
||||
#if !MESHTASTIC_EXCLUDE_RANGETEST && !MESHTASTIC_EXCLUDE_GPS
|
||||
if (moduleConfig.has_range_test && moduleConfig.range_test.enabled)
|
||||
new RangeTestModule();
|
||||
#endif
|
||||
#if defined(HAS_HARDWARE_WATCHDOG)
|
||||
watchdogThread = new WatchdogThread();
|
||||
#endif
|
||||
// NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra
|
||||
// acks
|
||||
|
||||
@@ -26,7 +26,7 @@ bool RAK12035Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
|
||||
sensor.get_sensor_version(&data);
|
||||
if (data != 0) {
|
||||
LOG_INFO("Init sensor: %s", sensorName);
|
||||
LOG_INFO("RAK12035Sensor Init Succeed \nSensor1 Firmware version: %i, Sensor Name: %s", data, sensorName);
|
||||
LOG_INFO("RAK12035Sensor Init Succeed \nSensor Firmware version: %i, Sensor Name: %s", data, sensorName);
|
||||
status = true;
|
||||
sensor.sensor_sleep();
|
||||
RESTORE_3V3_POWER();
|
||||
@@ -49,33 +49,39 @@ void RAK12035Sensor::setup()
|
||||
// TODO:: Check for and run calibration check for up to 2 additional sensors if present.
|
||||
uint16_t zero_val = 0;
|
||||
uint16_t hundred_val = 0;
|
||||
uint16_t default_zero_val = 550;
|
||||
uint16_t default_hundred_val = 420;
|
||||
const uint16_t default_zero_val = 510;
|
||||
const uint16_t default_hundred_val = 390;
|
||||
|
||||
sensor.sensor_on();
|
||||
sensor.begin();
|
||||
delay(200);
|
||||
sensor.get_dry_cal(&zero_val);
|
||||
delay(200);
|
||||
sensor.get_wet_cal(&hundred_val);
|
||||
delay(200);
|
||||
if (zero_val == 0 || zero_val <= hundred_val) {
|
||||
LOG_INFO("Dry calibration value is %d", zero_val);
|
||||
LOG_INFO("Wet calibration value is %d", hundred_val);
|
||||
LOG_INFO("This does not make sense. You can recalibrate this sensor using the calibration sketch included here: "
|
||||
"https://github.com/RAKWireless/RAK12035_SoilMoisture.");
|
||||
LOG_INFO("For now, setting default calibration value for Dry Calibration: %d", default_zero_val);
|
||||
|
||||
bool calibrationReset = false;
|
||||
|
||||
if (zero_val == 0) {
|
||||
LOG_INFO("Dry calibration not set, using default: %d", default_zero_val);
|
||||
sensor.set_dry_cal(default_zero_val);
|
||||
sensor.get_dry_cal(&zero_val);
|
||||
LOG_INFO("Dry calibration reset complete. New value is %d", zero_val);
|
||||
delay(200);
|
||||
zero_val = default_zero_val;
|
||||
calibrationReset = true;
|
||||
}
|
||||
if (hundred_val == 0 || hundred_val >= zero_val) {
|
||||
LOG_INFO("Dry calibration value is %d", zero_val);
|
||||
LOG_INFO("Wet calibration value is %d", hundred_val);
|
||||
LOG_INFO("This does not make sense. You can recalibrate this sensor using the calibration sketch included here: "
|
||||
"https://github.com/RAKWireless/RAK12035_SoilMoisture.");
|
||||
LOG_INFO("For now, setting default calibration value for Wet Calibration: %d", default_hundred_val);
|
||||
LOG_INFO("Wet calibration not set, using default: %d", default_hundred_val);
|
||||
sensor.set_wet_cal(default_hundred_val);
|
||||
sensor.get_wet_cal(&hundred_val);
|
||||
LOG_INFO("Wet calibration reset complete. New value is %d", hundred_val);
|
||||
delay(200);
|
||||
hundred_val = default_hundred_val;
|
||||
calibrationReset = true;
|
||||
}
|
||||
if (calibrationReset) {
|
||||
LOG_INFO("Default calibration values applied. Consider running the calibration sketch for better accuracy: "
|
||||
"https://github.com/RAKWireless/RAK12035_SoilMoisture");
|
||||
}
|
||||
|
||||
LOG_INFO("Dry calibration value: %d, Wet calibration value: %d", zero_val, hundred_val);
|
||||
sensor.sensor_sleep();
|
||||
RESTORE_3V3_POWER();
|
||||
delay(200);
|
||||
|
||||
37
src/watchdog/watchdogThread.cpp
Normal file
37
src/watchdog/watchdogThread.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "watchdogThread.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#ifdef HAS_HARDWARE_WATCHDOG
|
||||
WatchdogThread *watchdogThread;
|
||||
|
||||
WatchdogThread::WatchdogThread() : OSThread("Watchdog")
|
||||
{
|
||||
setup();
|
||||
}
|
||||
|
||||
void WatchdogThread::feedDog(void)
|
||||
{
|
||||
digitalWrite(HARDWARE_WATCHDOG_DONE, HIGH);
|
||||
delay(1);
|
||||
digitalWrite(HARDWARE_WATCHDOG_DONE, LOW);
|
||||
}
|
||||
|
||||
int32_t WatchdogThread::runOnce()
|
||||
{
|
||||
LOG_DEBUG("Feeding hardware watchdog");
|
||||
feedDog();
|
||||
return HARDWARE_WATCHDOG_TIMEOUT_MS;
|
||||
}
|
||||
|
||||
bool WatchdogThread::setup()
|
||||
{
|
||||
LOG_DEBUG("init hardware watchdog");
|
||||
pinMode(HARDWARE_WATCHDOG_WAKE, INPUT);
|
||||
pinMode(HARDWARE_WATCHDOG_DONE, OUTPUT);
|
||||
delay(1);
|
||||
digitalWrite(HARDWARE_WATCHDOG_DONE, LOW);
|
||||
delay(1);
|
||||
feedDog();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
17
src/watchdog/watchdogThread.h
Normal file
17
src/watchdog/watchdogThread.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "concurrency/OSThread.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef HAS_HARDWARE_WATCHDOG
|
||||
class WatchdogThread : private concurrency::OSThread
|
||||
{
|
||||
public:
|
||||
WatchdogThread();
|
||||
void feedDog(void);
|
||||
virtual bool setup();
|
||||
virtual int32_t runOnce() override;
|
||||
};
|
||||
|
||||
extern WatchdogThread *watchdogThread;
|
||||
#endif
|
||||
@@ -8,6 +8,7 @@ build_flags =
|
||||
-I variants/esp32/chatter2
|
||||
-DMESHTASTIC_EXCLUDE_WEBSERVER=1
|
||||
-DMESHTASTIC_EXCLUDE_PAXCOUNTER=1
|
||||
-ULED_BUILTIN
|
||||
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
|
||||
@@ -14,3 +14,4 @@ build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-D DIY_V1
|
||||
-I variants/esp32/diy/hydra
|
||||
-ULED_BUILTIN
|
||||
|
||||
@@ -17,3 +17,4 @@ build_flags =
|
||||
-D DIY_V1
|
||||
-D EBYTE_E22
|
||||
-I variants/esp32/diy/v1
|
||||
-ULED_BUILTIN
|
||||
|
||||
@@ -14,3 +14,4 @@ build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-D NANO_G1_EXPLORER
|
||||
-I variants/esp32/nano-g1-explorer
|
||||
-ULED_BUILTIN
|
||||
|
||||
@@ -14,3 +14,4 @@ build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-D NANO_G1
|
||||
-I variants/esp32/nano-g1
|
||||
-ULED_BUILTIN
|
||||
|
||||
@@ -9,6 +9,7 @@ build_flags =
|
||||
-DHAS_STK8XXX=1
|
||||
-O2
|
||||
-I variants/esp32/radiomaster_900_bandit
|
||||
-ULED_BUILTIN
|
||||
board_build.f_cpu = 240000000L
|
||||
upload_protocol = esptool
|
||||
lib_deps =
|
||||
|
||||
@@ -13,5 +13,6 @@ build_flags =
|
||||
-DCONFIG_DISABLE_HAL_LOCKS=1
|
||||
-O2
|
||||
-I variants/esp32/radiomaster_900_bandit_nano
|
||||
-ULED_BUILTIN
|
||||
board_build.f_cpu = 240000000L
|
||||
upload_protocol = esptool
|
||||
|
||||
@@ -16,5 +16,6 @@ build_flags =
|
||||
-DCONFIG_DISABLE_HAL_LOCKS=1
|
||||
-O2
|
||||
-I variants/esp32/radiomaster_900_bandit_nano
|
||||
-ULED_BUILTIN
|
||||
board_build.f_cpu = 240000000L
|
||||
upload_protocol = esptool
|
||||
|
||||
@@ -14,3 +14,4 @@ build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-D STATION_G1
|
||||
-I variants/esp32/station-g1
|
||||
-ULED_BUILTIN
|
||||
|
||||
@@ -12,7 +12,7 @@ extends = esp32_base
|
||||
board = ttgo-lora32-v21
|
||||
board_check = true
|
||||
build_flags =
|
||||
${esp32_base.build_flags} -D TLORA_V2_1_16 -I variants/esp32/tlora_v2_1_16
|
||||
${esp32_base.build_flags} -D TLORA_V2_1_16 -I variants/esp32/tlora_v2_1_16 -ULED_BUILTIN
|
||||
upload_speed = 115200
|
||||
|
||||
[env:sugarcube]
|
||||
|
||||
@@ -7,3 +7,4 @@ build_flags =
|
||||
-I variants/esp32/tlora_v2_1_16
|
||||
-D LORA_TCXO_GPIO=12
|
||||
-D BUTTON_PIN=0
|
||||
-ULED_BUILTIN
|
||||
@@ -6,4 +6,5 @@ board_build.partitions = default_8MB.csv
|
||||
build_flags =
|
||||
${esp32s3_base.build_flags} -I variants/esp32s3/heltec_capsule_sensor_v3
|
||||
-D HELTEC_CAPSULE_SENSOR_V3
|
||||
-ULED_BUILTIN
|
||||
;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output
|
||||
|
||||
@@ -7,6 +7,7 @@ build_flags =
|
||||
${esp32s3_base.build_flags}
|
||||
-I variants/esp32s3/heltec_sensor_hub
|
||||
-D HELTEC_SENSOR_HUB
|
||||
-ULED_BUILTIN
|
||||
|
||||
lib_deps = ${esp32s3_base.lib_deps}
|
||||
# renovate: datasource=custom.pio depName=NeoPixel packageName=adafruit/library/Adafruit NeoPixel
|
||||
|
||||
@@ -17,3 +17,4 @@ build_flags =
|
||||
${esp32s3_base.build_flags}
|
||||
-D HELTEC_WSL_V3
|
||||
-I variants/esp32s3/heltec_wsl_v3
|
||||
-ULED_BUILTIN
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use
|
||||
|
||||
// Button A (44), B (43), R (12), U (13), L (11), D (18)
|
||||
#define BUTTON_PIN 44 // If defined, this will be used for user button presses
|
||||
#define BUTTON_PIN 43 // If defined, this will be used for user button presses
|
||||
#define BUTTON_NEED_PULLUP
|
||||
|
||||
#define USE_RF95
|
||||
@@ -20,8 +20,19 @@
|
||||
#define LORA_MISO 7
|
||||
#define LORA_MOSI 8
|
||||
#define LORA_CS 9
|
||||
#define LORA_DIO0 16 // a No connect on the SX1262 module
|
||||
#define LORA_DIO0 16
|
||||
#define LORA_RESET 4
|
||||
|
||||
#define LORA_DIO1 RADIOLIB_NC
|
||||
#define LORA_DIO2 RADIOLIB_NC
|
||||
|
||||
// jk, its not really a trackball but we're gonna pretend!
|
||||
#define HAS_TRACKBALL 1
|
||||
#define TB_UP 13
|
||||
#define TB_DOWN 18
|
||||
#define TB_LEFT 11
|
||||
#define TB_RIGHT 12
|
||||
#define TB_PRESS 44 // BUTTON_PIN
|
||||
#define TB_DIRECTION FALLING
|
||||
|
||||
#define ENABLE_AMBIENTLIGHTING
|
||||
|
||||
@@ -39,15 +39,15 @@ extern "C" {
|
||||
#define NUM_ANALOG_INPUTS (1)
|
||||
#define NUM_ANALOG_OUTPUTS (0)
|
||||
|
||||
#define PIN_LED1 (0 + 4) // green (confirmed on 1.0 board)
|
||||
#define PIN_LED1 (32 + 15) // green (confirmed on 1.0 board)
|
||||
#define LED_BLUE PIN_LED1 // fake for bluefruit library
|
||||
#define LED_GREEN PIN_LED1
|
||||
#define LED_STATE_ON 0 // State when LED is lit
|
||||
|
||||
#define HAS_NEOPIXEL // Enable the use of neopixels
|
||||
#define NEOPIXEL_COUNT 1 // How many neopixels are connected
|
||||
#define NEOPIXEL_DATA (32 + 15) // gpio pin used to send data to the neopixels
|
||||
#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use
|
||||
// #define HAS_NEOPIXEL // Enable the use of neopixels
|
||||
// #define NEOPIXEL_COUNT 1 // How many neopixels are connected
|
||||
// #define NEOPIXEL_DATA (32 + 15) // gpio pin used to send data to the neopixels
|
||||
// #define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use
|
||||
|
||||
/*
|
||||
* Buttons
|
||||
@@ -59,8 +59,8 @@ extern "C" {
|
||||
/*
|
||||
No longer populated on PCB
|
||||
*/
|
||||
#define PIN_SERIAL2_RX (0 + 9)
|
||||
#define PIN_SERIAL2_TX (0 + 10)
|
||||
#define PIN_SERIAL2_RX (-1)
|
||||
#define PIN_SERIAL2_TX (-1)
|
||||
|
||||
/*
|
||||
* I2C
|
||||
@@ -137,6 +137,12 @@ No longer populated on PCB
|
||||
// To debug via the segger JLINK console rather than the CDC-ACM serial device
|
||||
// #define USE_SEGGER
|
||||
|
||||
// Hardware watchdog
|
||||
#define HAS_HARDWARE_WATCHDOG
|
||||
#define HARDWARE_WATCHDOG_DONE (0 + 9)
|
||||
#define HARDWARE_WATCHDOG_WAKE (0 + 10)
|
||||
#define HARDWARE_WATCHDOG_TIMEOUT_MS (6 * 60 * 1000) // 6 minute watchdog
|
||||
|
||||
#define BQ4050_SDA_PIN (32 + 1) // I2C data line pin
|
||||
#define BQ4050_SCL_PIN (32 + 0) // I2C clock line pin
|
||||
#define BQ4050_EMERGENCY_SHUTDOWN_PIN (32 + 3) // Emergency shutdown pin
|
||||
|
||||
21
variants/stm32/milesight_gs301/platformio.ini
Normal file
21
variants/stm32/milesight_gs301/platformio.ini
Normal file
@@ -0,0 +1,21 @@
|
||||
; Milesight GS301 Bathroom Odor Detector
|
||||
; https://www.milesight.com/iot/product/lorawan-sensor/gs301
|
||||
[env:milesight_gs301]
|
||||
extends = stm32_base
|
||||
board = wiscore_rak3172 ; Convenient choice as the same USART is used for programming/debug
|
||||
board_level = extra
|
||||
board_upload.maximum_size = 233472 ; reserve the last 28KB for filesystem
|
||||
build_flags =
|
||||
${stm32_base.build_flags}
|
||||
-Ivariants/stm32/milesight_gs301
|
||||
-DPRIVATE_HW
|
||||
-DMESHTASTIC_EXCLUDE_GPS=1
|
||||
-DMESHTASTIC_EXCLUDE_I2C=1 # Analog ADuCM355 (unsupported) so no point building support for I2C in
|
||||
-DMESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR=1
|
||||
-DMESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR=1
|
||||
build_unflags =
|
||||
-DDEBUG_MUTE # We have space for debug output until sensor support is added
|
||||
lib_deps =
|
||||
${stm32_base.lib_deps}
|
||||
|
||||
upload_port = stlink
|
||||
7
variants/stm32/milesight_gs301/rfswitch.h
Normal file
7
variants/stm32/milesight_gs301/rfswitch.h
Normal file
@@ -0,0 +1,7 @@
|
||||
// Seems to use the same RF switch pins as RAK3172… getting Tx/Rx SNR +11dB with a nearby node
|
||||
// PB8, PC13
|
||||
|
||||
static const RADIOLIB_PIN_TYPE rfswitch_pins[5] = {PB8, PC13, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC};
|
||||
|
||||
static const Module::RfSwitchMode_t rfswitch_table[4] = {
|
||||
{STM32WLx::MODE_IDLE, {LOW, LOW}}, {STM32WLx::MODE_RX, {HIGH, LOW}}, {STM32WLx::MODE_TX_HP, {LOW, HIGH}}, END_OF_MODE_TABLE};
|
||||
41
variants/stm32/milesight_gs301/variant.h
Normal file
41
variants/stm32/milesight_gs301/variant.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef _VARIANT_MILESIGHT_GS301_
|
||||
#define _VARIANT_MILESIGHT_GS301_
|
||||
|
||||
#define USE_STM32WLx
|
||||
|
||||
// I/O
|
||||
#define LED_STATE_ON 1
|
||||
#define PIN_LED1 PA0 // Green LED
|
||||
#define LED_PIN PIN_LED1
|
||||
#define PIN_LED2 PA0 // Red LED
|
||||
#define USER_LED PIN_LED2
|
||||
#define BUTTON_PIN PC13
|
||||
#define BUTTON_ACTIVE_LOW true
|
||||
#define BUTTON_ACTIVE_PULLUP false
|
||||
#define PIN_BUZZER PA6
|
||||
|
||||
// EC Sense DGM10 Double Gas Module
|
||||
// Analog ADuCM355 (unsupported); SHTC3 is connected to ADuCM355 and not directly accessible
|
||||
#define PIN_WIRE_SDA PB7
|
||||
#define PIN_WIRE_SCL PB8
|
||||
// Commented out to keep sensor powered down due to lack of support
|
||||
/*
|
||||
#define VEXT_ENABLE PB12 // TI TPS61291DRV VSEL - set LOW before ENable for Vout = 3.3V
|
||||
#define VEXT_ON_VALUE LOW
|
||||
#define SENSOR_POWER_CTRL_PIN PB2 // TI TPS61291DRV EN pin
|
||||
#define SENSOR_POWER_ON HIGH
|
||||
#define HAS_SENSOR 1
|
||||
*/
|
||||
|
||||
#define ENABLE_HWSERIAL1
|
||||
#define PIN_SERIAL1_RX NC
|
||||
#define PIN_SERIAL1_TX PB6
|
||||
|
||||
// LoRa
|
||||
#define SX126X_DIO3_TCXO_VOLTAGE 3.0
|
||||
|
||||
// Required to avoid Serial1 conflicts due to board definition here:
|
||||
// https://github.com/stm32duino/Arduino_Core_STM32/blob/main/variants/STM32WLxx/WL54CCU_WL55CCU_WLE4C(8-B-C)U_WLE5C(8-B-C)U/variant_RAK3172_MODULE.h
|
||||
#define RAK3172
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user