mirror of
https://github.com/meshtastic/firmware.git
synced 2026-02-05 08:31:56 +00:00
Compare commits
9 Commits
develop
...
udp-cleanu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
857c16faa2 | ||
|
|
3aa0cbd26a | ||
|
|
17ccd6f921 | ||
|
|
b008c7a170 | ||
|
|
a08e7f07ff | ||
|
|
c8a9cdc148 | ||
|
|
644fa5b54e | ||
|
|
e9d4485bb5 | ||
|
|
004179c045 |
@@ -156,16 +156,8 @@ IF %BPS_RESET% EQU 1 (
|
|||||||
SET "PROGNAME=!FILENAME:.factory.bin=!"
|
SET "PROGNAME=!FILENAME:.factory.bin=!"
|
||||||
CALL :LOG_MESSAGE DEBUG "Computed PROGNAME: !PROGNAME!"
|
CALL :LOG_MESSAGE DEBUG "Computed PROGNAME: !PROGNAME!"
|
||||||
|
|
||||||
IF "__!MCU!__" == "__esp32s3__" (
|
@REM Determine OTA filename based on MCU type (unified OTA format)
|
||||||
@REM We are working with ESP32-S3
|
SET "OTA_FILENAME=mt-!MCU!-ota.bin"
|
||||||
SET "OTA_FILENAME=bleota-s3.bin"
|
|
||||||
) ELSE IF "__!MCU!__" == "__esp32c3__" (
|
|
||||||
@REM We are working with ESP32-C3
|
|
||||||
SET "OTA_FILENAME=bleota-c3.bin"
|
|
||||||
) ELSE (
|
|
||||||
@REM Everything else
|
|
||||||
SET "OTA_FILENAME=bleota.bin"
|
|
||||||
)
|
|
||||||
CALL :LOG_MESSAGE DEBUG "Set OTA_FILENAME to: !OTA_FILENAME!"
|
CALL :LOG_MESSAGE DEBUG "Set OTA_FILENAME to: !OTA_FILENAME!"
|
||||||
|
|
||||||
@REM Set SPIFFS filename with "littlefs-" prefix.
|
@REM Set SPIFFS filename with "littlefs-" prefix.
|
||||||
|
|||||||
@@ -131,14 +131,8 @@ if [[ -f "$FILENAME" && "$FILENAME" == *.factory.bin ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Determine OTA filename based on MCU type
|
# Determine OTA filename based on MCU type (unified OTA format)
|
||||||
if [ "$MCU" == "esp32s3" ]; then
|
OTAFILE="mt-${MCU}-ota.bin"
|
||||||
OTAFILE=bleota-s3.bin
|
|
||||||
elif [ "$MCU" == "esp32c3" ]; then
|
|
||||||
OTAFILE=bleota-c3.bin
|
|
||||||
else
|
|
||||||
OTAFILE=bleota.bin
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set SPIFFS filename with "littlefs-" prefix.
|
# Set SPIFFS filename with "littlefs-" prefix.
|
||||||
SPIFFSFILE="littlefs-${PROGNAME/firmware-/}.bin"
|
SPIFFSFILE="littlefs-${PROGNAME/firmware-/}.bin"
|
||||||
|
|||||||
@@ -72,11 +72,13 @@ RTCSetResult readFromRTC()
|
|||||||
#elif defined(PCF8563_RTC) || defined(PCF85063_RTC)
|
#elif defined(PCF8563_RTC) || defined(PCF85063_RTC)
|
||||||
#if defined(PCF8563_RTC)
|
#if defined(PCF8563_RTC)
|
||||||
if (rtc_found.address == PCF8563_RTC) {
|
if (rtc_found.address == PCF8563_RTC) {
|
||||||
|
SensorPCF8563 rtc;
|
||||||
#elif defined(PCF85063_RTC)
|
#elif defined(PCF85063_RTC)
|
||||||
if (rtc_found.address == PCF85063_RTC) {
|
if (rtc_found.address == PCF85063_RTC) {
|
||||||
|
SensorPCF85063 rtc;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
uint32_t now = millis();
|
uint32_t now = millis();
|
||||||
SensorRtcHelper rtc;
|
|
||||||
|
|
||||||
#if WIRE_INTERFACES_COUNT == 2
|
#if WIRE_INTERFACES_COUNT == 2
|
||||||
rtc.begin(rtc_found.port == ScanI2C::I2CPort::WIRE1 ? Wire1 : Wire);
|
rtc.begin(rtc_found.port == ScanI2C::I2CPort::WIRE1 ? Wire1 : Wire);
|
||||||
@@ -240,10 +242,12 @@ RTCSetResult perhapsSetRTC(RTCQuality q, const struct timeval *tv, bool forceUpd
|
|||||||
#elif defined(PCF8563_RTC) || defined(PCF85063_RTC)
|
#elif defined(PCF8563_RTC) || defined(PCF85063_RTC)
|
||||||
#if defined(PCF8563_RTC)
|
#if defined(PCF8563_RTC)
|
||||||
if (rtc_found.address == PCF8563_RTC) {
|
if (rtc_found.address == PCF8563_RTC) {
|
||||||
|
SensorPCF8563 rtc;
|
||||||
#elif defined(PCF85063_RTC)
|
#elif defined(PCF85063_RTC)
|
||||||
if (rtc_found.address == PCF85063_RTC) {
|
if (rtc_found.address == PCF85063_RTC) {
|
||||||
|
SensorPCF85063 rtc;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
SensorRtcHelper rtc;
|
|
||||||
|
|
||||||
#if WIRE_INTERFACES_COUNT == 2
|
#if WIRE_INTERFACES_COUNT == 2
|
||||||
rtc.begin(rtc_found.port == ScanI2C::I2CPort::WIRE1 ? Wire1 : Wire);
|
rtc.begin(rtc_found.port == ScanI2C::I2CPort::WIRE1 ? Wire1 : Wire);
|
||||||
|
|||||||
@@ -1498,6 +1498,7 @@ void menuHandler::nodeNameLengthMenu()
|
|||||||
|
|
||||||
config.display.use_long_node_name = option.value;
|
config.display.use_long_node_name = option.value;
|
||||||
saveUIConfig();
|
saveUIConfig();
|
||||||
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
LOG_INFO("Setting names to %s", option.value ? "long" : "short");
|
LOG_INFO("Setting names to %s", option.value ? "long" : "short");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2213,8 +2213,8 @@ bool NodeDB::restorePreferences(meshtastic_AdminMessage_BackupLocation location,
|
|||||||
} else if (location == meshtastic_AdminMessage_BackupLocation_SD) {
|
} else if (location == meshtastic_AdminMessage_BackupLocation_SD) {
|
||||||
// TODO: After more mainline SD card support
|
// TODO: After more mainline SD card support
|
||||||
}
|
}
|
||||||
return success;
|
|
||||||
#endif
|
#endif
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Record an error that should be reported via analytics
|
/// Record an error that should be reported via analytics
|
||||||
|
|||||||
@@ -22,10 +22,14 @@
|
|||||||
class UdpMulticastHandler final
|
class UdpMulticastHandler final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UdpMulticastHandler() { udpIpAddress = IPAddress(224, 0, 0, 69); }
|
UdpMulticastHandler() : isRunning(false) { udpIpAddress = IPAddress(224, 0, 0, 69); }
|
||||||
|
|
||||||
void start()
|
void start()
|
||||||
{
|
{
|
||||||
|
if (isRunning) {
|
||||||
|
LOG_DEBUG("UDP multicast already running");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (udp.listenMulticast(udpIpAddress, UDP_MULTICAST_DEFAUL_PORT, 64)) {
|
if (udp.listenMulticast(udpIpAddress, UDP_MULTICAST_DEFAUL_PORT, 64)) {
|
||||||
#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO)
|
#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO)
|
||||||
LOG_DEBUG("UDP Listening on IP: %u.%u.%u.%u:%u", udpIpAddress[0], udpIpAddress[1], udpIpAddress[2], udpIpAddress[3],
|
LOG_DEBUG("UDP Listening on IP: %u.%u.%u.%u:%u", udpIpAddress[0], udpIpAddress[1], udpIpAddress[2], udpIpAddress[3],
|
||||||
@@ -34,13 +38,29 @@ class UdpMulticastHandler final
|
|||||||
LOG_DEBUG("UDP Listening on IP: %s", WiFi.localIP().toString().c_str());
|
LOG_DEBUG("UDP Listening on IP: %s", WiFi.localIP().toString().c_str());
|
||||||
#endif
|
#endif
|
||||||
udp.onPacket([this](AsyncUDPPacket packet) { onReceive(packet); });
|
udp.onPacket([this](AsyncUDPPacket packet) { onReceive(packet); });
|
||||||
|
isRunning = true;
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG("Failed to listen on UDP");
|
LOG_DEBUG("Failed to listen on UDP");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stop()
|
||||||
|
{
|
||||||
|
if (!isRunning) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOG_DEBUG("Stopping UDP multicast");
|
||||||
|
#if defined(ARCH_ESP32) || defined(ARCH_NRF52)
|
||||||
|
udp.close();
|
||||||
|
#endif
|
||||||
|
isRunning = false;
|
||||||
|
}
|
||||||
|
|
||||||
void onReceive(AsyncUDPPacket packet)
|
void onReceive(AsyncUDPPacket packet)
|
||||||
{
|
{
|
||||||
|
if (!isRunning) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
size_t packetLength = packet.length();
|
size_t packetLength = packet.length();
|
||||||
#if defined(ARCH_NRF52)
|
#if defined(ARCH_NRF52)
|
||||||
IPAddress ip = packet.remoteIP();
|
IPAddress ip = packet.remoteIP();
|
||||||
@@ -67,7 +87,7 @@ class UdpMulticastHandler final
|
|||||||
|
|
||||||
bool onSend(const meshtastic_MeshPacket *mp)
|
bool onSend(const meshtastic_MeshPacket *mp)
|
||||||
{
|
{
|
||||||
if (!mp || !udp) {
|
if (!isRunning || !mp || !udp) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#if defined(ARCH_NRF52)
|
#if defined(ARCH_NRF52)
|
||||||
@@ -92,5 +112,6 @@ class UdpMulticastHandler final
|
|||||||
private:
|
private:
|
||||||
IPAddress udpIpAddress;
|
IPAddress udpIpAddress;
|
||||||
AsyncUDP udp;
|
AsyncUDP udp;
|
||||||
|
bool isRunning;
|
||||||
};
|
};
|
||||||
#endif // HAS_UDP_MULTICAST
|
#endif // HAS_UDP_MULTICAST
|
||||||
@@ -391,6 +391,11 @@ static void WiFiEvent(WiFiEvent_t event)
|
|||||||
LOG_INFO("Disconnected from WiFi access point");
|
LOG_INFO("Disconnected from WiFi access point");
|
||||||
#ifdef WIFI_LED
|
#ifdef WIFI_LED
|
||||||
digitalWrite(WIFI_LED, LOW);
|
digitalWrite(WIFI_LED, LOW);
|
||||||
|
#endif
|
||||||
|
#if HAS_UDP_MULTICAST
|
||||||
|
if (udpHandler) {
|
||||||
|
udpHandler->stop();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!isReconnecting) {
|
if (!isReconnecting) {
|
||||||
WiFi.disconnect(false, true);
|
WiFi.disconnect(false, true);
|
||||||
@@ -417,6 +422,11 @@ static void WiFiEvent(WiFiEvent_t event)
|
|||||||
break;
|
break;
|
||||||
case ARDUINO_EVENT_WIFI_STA_LOST_IP:
|
case ARDUINO_EVENT_WIFI_STA_LOST_IP:
|
||||||
LOG_INFO("Lost IP address and IP address is reset to 0");
|
LOG_INFO("Lost IP address and IP address is reset to 0");
|
||||||
|
#if HAS_UDP_MULTICAST
|
||||||
|
if (udpHandler) {
|
||||||
|
udpHandler->stop();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (!isReconnecting) {
|
if (!isReconnecting) {
|
||||||
WiFi.disconnect(false, true);
|
WiFi.disconnect(false, true);
|
||||||
syslog.disable();
|
syslog.disable();
|
||||||
|
|||||||
@@ -24,6 +24,11 @@
|
|||||||
#include <nvs.h>
|
#include <nvs.h>
|
||||||
#include <nvs_flash.h>
|
#include <nvs_flash.h>
|
||||||
|
|
||||||
|
// Weak empty variant shutdown prep function.
|
||||||
|
// May be redefined by variant files.
|
||||||
|
void variant_shutdown() __attribute__((weak));
|
||||||
|
void variant_shutdown() {}
|
||||||
|
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !MESHTASTIC_EXCLUDE_BLUETOOTH
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !MESHTASTIC_EXCLUDE_BLUETOOTH
|
||||||
void setBluetoothEnable(bool enable)
|
void setBluetoothEnable(bool enable)
|
||||||
{
|
{
|
||||||
@@ -249,6 +254,7 @@ void cpuDeepSleep(uint32_t msecToWake)
|
|||||||
|
|
||||||
#endif // #end ESP32S3_WAKE_TYPE
|
#endif // #end ESP32S3_WAKE_TYPE
|
||||||
#endif
|
#endif
|
||||||
|
variant_shutdown();
|
||||||
|
|
||||||
// We want RTC peripherals to stay on
|
// We want RTC peripherals to stay on
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||||
|
|||||||
@@ -36,6 +36,13 @@ bool AsyncUDP::writeTo(const uint8_t *data, size_t len, IPAddress ip, uint16_t p
|
|||||||
return udp.endPacket();
|
return udp.endPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AsyncUDP::close()
|
||||||
|
{
|
||||||
|
udp.stop();
|
||||||
|
localPort = 0;
|
||||||
|
_onPacket = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// AsyncUDPPacket
|
// AsyncUDPPacket
|
||||||
AsyncUDPPacket::AsyncUDPPacket(EthernetUDP &source) : _udp(source), _remoteIP(source.remoteIP()), _remotePort(source.remotePort())
|
AsyncUDPPacket::AsyncUDPPacket(EthernetUDP &source) : _udp(source), _remoteIP(source.remoteIP()), _remotePort(source.remotePort())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class AsyncUDP : public Print, private concurrency::OSThread
|
|||||||
|
|
||||||
bool listenMulticast(IPAddress multicastIP, uint16_t port, uint8_t ttl = 64);
|
bool listenMulticast(IPAddress multicastIP, uint16_t port, uint8_t ttl = 64);
|
||||||
bool writeTo(const uint8_t *data, size_t len, IPAddress ip, uint16_t port);
|
bool writeTo(const uint8_t *data, size_t len, IPAddress ip, uint16_t port);
|
||||||
|
void close();
|
||||||
|
|
||||||
size_t write(uint8_t b) override;
|
size_t write(uint8_t b) override;
|
||||||
size_t write(const uint8_t *data, size_t len) override;
|
size_t write(const uint8_t *data, size_t len) override;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
uint16_t getVDDVoltage();
|
uint16_t getVDDVoltage();
|
||||||
|
|
||||||
// Weak empty variant initialization function.
|
// Weak empty variant shutdown prep function.
|
||||||
// May be redefined by variant files.
|
// May be redefined by variant files.
|
||||||
void variant_shutdown() __attribute__((weak));
|
void variant_shutdown() __attribute__((weak));
|
||||||
void variant_shutdown() {}
|
void variant_shutdown() {}
|
||||||
|
|||||||
@@ -34,3 +34,5 @@ lib_deps = ${esp32s3_base.lib_deps}
|
|||||||
https://github.com/meshtastic/GxEPD2/archive/a05c11c02862624266b61599b0d6ba93e33c6f24.zip
|
https://github.com/meshtastic/GxEPD2/archive/a05c11c02862624266b61599b0d6ba93e33c6f24.zip
|
||||||
# renovate: datasource=custom.pio depName=PCA9557-arduino packageName=maxpromer/library/PCA9557-arduino
|
# renovate: datasource=custom.pio depName=PCA9557-arduino packageName=maxpromer/library/PCA9557-arduino
|
||||||
maxpromer/PCA9557-arduino@1.0.0
|
maxpromer/PCA9557-arduino@1.0.0
|
||||||
|
# renovate: datasource=custom.pio depName=SensorLib packageName=lewisxhe/library/SensorLib
|
||||||
|
lewisxhe/SensorLib@0.3.4
|
||||||
@@ -1,12 +1,17 @@
|
|||||||
#include "variant.h"
|
#include "variant.h"
|
||||||
#include <PCA9557.h>
|
#include <PCA9557.h>
|
||||||
|
|
||||||
PCA9557 io(0x18, &Wire);
|
PCA9557 io(0x18, &Wire1);
|
||||||
|
|
||||||
void earlyInitVariant()
|
void earlyInitVariant()
|
||||||
{
|
{
|
||||||
Wire.begin(48, 47);
|
Wire1.begin(48, 47);
|
||||||
io.pinMode(PCA_PIN_EINK_EN, OUTPUT);
|
io.pinMode(PCA_PIN_EINK_EN, OUTPUT);
|
||||||
io.pinMode(PCA_PIN_POWER_EN, OUTPUT);
|
io.pinMode(PCA_PIN_POWER_EN, OUTPUT);
|
||||||
io.digitalWrite(PCA_PIN_POWER_EN, HIGH);
|
io.digitalWrite(PCA_PIN_POWER_EN, HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void variant_shutdown()
|
||||||
|
{
|
||||||
|
io.digitalWrite(PCA_PIN_POWER_EN, LOW);
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,6 +30,9 @@
|
|||||||
#define I2C_SCL 1
|
#define I2C_SCL 1
|
||||||
#define I2C_SDA 2
|
#define I2C_SDA 2
|
||||||
|
|
||||||
|
// PCF8563 RTC Module
|
||||||
|
#define PCF8563_RTC 0x51
|
||||||
|
|
||||||
// GPS pins
|
// GPS pins
|
||||||
#define GPS_SWITH 10
|
#define GPS_SWITH 10
|
||||||
#define HAS_GPS 1
|
#define HAS_GPS 1
|
||||||
|
|||||||
@@ -24,5 +24,5 @@ lib_deps =
|
|||||||
${nrf52840_base.lib_deps}
|
${nrf52840_base.lib_deps}
|
||||||
# renovate: datasource=custom.pio depName=nRF52_PWM packageName=khoih-prog/library/nRF52_PWM
|
# renovate: datasource=custom.pio depName=nRF52_PWM packageName=khoih-prog/library/nRF52_PWM
|
||||||
khoih-prog/nRF52_PWM@1.0.1
|
khoih-prog/nRF52_PWM@1.0.1
|
||||||
; # renovate: datasource=custom.pio depName=SensorLib packageName=lewisxhe/library/SensorLib
|
# renovate: datasource=custom.pio depName=SensorLib packageName=lewisxhe/library/SensorLib
|
||||||
lewisxhe/SensorLib@0.3.4
|
lewisxhe/SensorLib@0.3.4
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ extern "C" {
|
|||||||
|
|
||||||
// PCF8563 RTC Module
|
// PCF8563 RTC Module
|
||||||
#define PCF8563_RTC 0x51
|
#define PCF8563_RTC 0x51
|
||||||
#define HAS_RTC 1
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,5 +21,5 @@ build_flags = ${nrf52840_base.build_flags}
|
|||||||
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/ELECROW-ThinkNode-M6>
|
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/ELECROW-ThinkNode-M6>
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${nrf52840_base.lib_deps}
|
${nrf52840_base.lib_deps}
|
||||||
; # renovate: datasource=custom.pio depName=SensorLib packageName=lewisxhe/library/SensorLib
|
# renovate: datasource=custom.pio depName=SensorLib packageName=lewisxhe/library/SensorLib
|
||||||
lewisxhe/SensorLib@0.3.4
|
lewisxhe/SensorLib@0.3.4
|
||||||
|
|||||||
@@ -121,7 +121,6 @@ static const uint8_t A0 = PIN_A0;
|
|||||||
|
|
||||||
// PCF8563 RTC Module
|
// PCF8563 RTC Module
|
||||||
#define PCF8563_RTC 0x51
|
#define PCF8563_RTC 0x51
|
||||||
#define HAS_RTC 1
|
|
||||||
|
|
||||||
// SPI
|
// SPI
|
||||||
#define SPI_INTERFACES_COUNT 1
|
#define SPI_INTERFACES_COUNT 1
|
||||||
|
|||||||
@@ -132,9 +132,6 @@ static const uint8_t A0 = PIN_A0;
|
|||||||
|
|
||||||
#define HAS_DRV2605 1
|
#define HAS_DRV2605 1
|
||||||
|
|
||||||
// Battery / ADC already defined above
|
|
||||||
#define HAS_RTC 1
|
|
||||||
|
|
||||||
#define SERIAL_PRINT_PORT 0
|
#define SERIAL_PRINT_PORT 0
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Reference in New Issue
Block a user