Compare commits

...

30 Commits

Author SHA1 Message Date
Michael Gjelsø
305888452c
Merge a76e18a9d0 into cc5d00e211 2025-07-28 23:56:34 +02:00
Ben Meadors
cc5d00e211
Core portnums rebroadcast mode whitelist instead of blacklist (#7487)
Some checks are pending
CI / build-rp2040 (push) Blocked by required conditions
CI / build-rp2350 (push) Blocked by required conditions
CI / build-stm32 (push) Blocked by required conditions
CI / build-debian-src (push) Waiting to run
CI / package-pio-deps-native-tft (push) Waiting to run
CI / test-native (push) Waiting to run
CI / docker-deb-amd64 (push) Waiting to run
CI / docker-deb-amd64-tft (push) Waiting to run
CI / docker-alp-amd64 (push) Waiting to run
CI / docker-alp-amd64-tft (push) Waiting to run
CI / docker-deb-arm64 (push) Waiting to run
CI / docker-deb-armv7 (push) Waiting to run
CI / gather-artifacts (esp32) (push) Blocked by required conditions
CI / gather-artifacts (esp32c3) (push) Blocked by required conditions
CI / gather-artifacts (esp32c6) (push) Blocked by required conditions
CI / gather-artifacts (esp32s3) (push) Blocked by required conditions
CI / gather-artifacts (nrf52840) (push) Blocked by required conditions
CI / gather-artifacts (rp2040) (push) Blocked by required conditions
CI / gather-artifacts (rp2350) (push) Blocked by required conditions
CI / gather-artifacts (stm32) (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / release-firmware (esp32) (push) Blocked by required conditions
CI / release-firmware (esp32c3) (push) Blocked by required conditions
CI / release-firmware (esp32c6) (push) Blocked by required conditions
CI / release-firmware (esp32s3) (push) Blocked by required conditions
CI / release-firmware (nrf52840) (push) Blocked by required conditions
CI / release-firmware (rp2040) (push) Blocked by required conditions
CI / release-firmware (rp2350) (push) Blocked by required conditions
CI / release-firmware (stm32) (push) Blocked by required conditions
CI / publish-firmware (push) Blocked by required conditions
2025-07-28 12:37:37 -05:00
Ben Meadors
1a8ab2aadc
NodeDB count on MyNodeInfo for client progress reporting (#7489) 2025-07-28 12:23:59 -05:00
Thomas Göttgens
608fdc6f52
Santa may be checking his list twice, but we only need this in the platformio.ini (#7490) 2025-07-28 09:47:46 -05:00
Michael Gjelsø
a76e18a9d0
Merge branch 'master' into use_detected_ina_addr 2025-07-17 12:25:20 +02:00
Michael Gjelsø
dc8b7a2b63
Merge branch 'master' into use_detected_ina_addr 2025-07-07 15:42:18 +02:00
Michael Gjelsø
d3fe19eca6
Merge branch 'master' into use_detected_ina_addr 2025-07-03 17:42:08 +02:00
Tom Fifield
6f93f81fbe
Merge branch 'master' into use_detected_ina_addr 2025-07-02 11:31:55 +10:00
Michael Gjelsø
a23ba533ac
Merge branch 'master' into use_detected_ina_addr 2025-06-27 20:30:29 +02:00
Michael Gjelsø
6e89d6bcb7
Merge branch 'meshtastic:master' into use_detected_ina_addr 2025-05-18 18:30:33 +02:00
michael
aca5249fd1 Trunk formating 2025-05-18 18:26:58 +02:00
Michael Gjelsø
fc8594a8d3
Merge branch 'master' into use_detected_ina_addr 2025-05-14 19:02:01 +02:00
Michael Gjelsø
39e42f64e9
Merge branch 'master' into use_detected_ina_addr 2025-05-13 20:40:20 +02:00
Tom Fifield
624fccb865
Merge branch 'master' into use_detected_ina_addr 2025-05-13 08:40:19 +10:00
Michael Gjelsø
4e527ff487
Merge branch 'master' into use_detected_ina_addr 2025-04-17 16:09:03 +02:00
Michael Gjelsø
d8ef6d5592
Merge branch 'master' into use_detected_ina_addr 2025-04-17 12:41:05 +02:00
Michael Gjelsø
0b325faf17
Merge branch 'master' into use_detected_ina_addr 2025-04-17 11:13:13 +02:00
Michael Gjelsø
c58bf5070b
Merge branch 'meshtastic:master' into use_detected_ina_addr 2025-03-31 18:00:56 +02:00
gjelsoe
07f955518a Use ScanI2C
Re-wrote some to use ScanI2C
2025-03-31 15:37:53 +02:00
Michael Gjelsø
bd19402411
Merge branch 'meshtastic:master' into use_detected_ina_addr 2025-03-06 16:56:17 +01:00
gjelsoe
bde3a88f41 Merge branch 'use_detected_ina_addr' of https://github.com/gjelsoe/firmware into use_detected_ina_addr 2025-03-02 14:59:06 +01:00
Michael Gjelsø
323e977961
Merge branch 'master' into use_detected_ina_addr 2025-03-01 14:06:16 +01:00
michael
57cf9ddd0a Trunk.... 2025-02-27 16:08:44 +01:00
gjelsoe
3df87d9fab Merge branch 'use_detected_ina_addr' of https://github.com/gjelsoe/firmware into use_detected_ina_addr 2025-02-27 15:24:55 +01:00
gjelsoe
81176de5a7 Update Power.cpp
Take two
2025-02-27 13:54:54 +08:00
gjelsoe
fc289198c9 Update Power.cpp
First stab at using I2C detected INA addr.
2025-02-27 13:54:54 +08:00
Michael Gjelsø
6e89ba98fd
Merge branch 'meshtastic:master' into use_detected_ina_addr 2025-02-17 16:28:21 +01:00
Michael Gjelsø
61912b0dd9
Merge branch 'meshtastic:master' into use_detected_ina_addr 2025-02-16 15:26:05 +01:00
gjelsoe
8b2a6c3b78 Update Power.cpp
Take two
2025-02-15 23:40:27 +01:00
gjelsoe
89e0857c73 Update Power.cpp
First stab at using I2C detected INA addr.
2025-02-15 19:18:25 +01:00
8 changed files with 142 additions and 47 deletions

View File

@ -82,6 +82,8 @@ static const uint8_t ext_chrg_detect_value = EXT_CHRG_DETECT_VALUE;
#endif
#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
#include "main.h";
uint8_t INA_ADDR_LOCAL;
#if __has_include(<Adafruit_INA219.h>)
INA219Sensor ina219Sensor;
#else
@ -474,7 +476,8 @@ class AnalogBatteryLevel : public HasBatteryLevel
if (hasINA()) {
// get current flow from INA sensor - negative value means power flowing into the battery
// default assuming BATTERY+ <--> INA_VIN+ <--> SHUNT RESISTOR <--> INA_VIN- <--> LOAD
LOG_DEBUG("Using INA on I2C addr 0x%x for charging detection", config.power.device_battery_ina_address);
// LOG_DEBUG("Using INA on I2C addr 0x%x for charging detection", config.power.device_battery_ina_address);
LOG_DEBUG("Using INA on I2C addr 0x%x for charging detection", INA_ADDR_LOCAL);
#if defined(INA_CHARGING_DETECTION_INVERT)
return getINACurrent() > 0;
#else
@ -517,61 +520,131 @@ class AnalogBatteryLevel : public HasBatteryLevel
#endif
#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
/*
Read Voltage from INA using autodetect of addr first else use addr in config.power.device_battery_ina_address
*/
uint16_t getINAVoltage()
{
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first == config.power.device_battery_ina_address) {
return ina219Sensor.getBusVoltageMv();
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA226].first ==
config.power.device_battery_ina_address) {
return ina226Sensor.getBusVoltageMv();
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA260].first ==
config.power.device_battery_ina_address) {
return ina260Sensor.getBusVoltageMv();
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA3221].first ==
config.power.device_battery_ina_address) {
return ina3221Sensor.getBusVoltageMv();
if (!config.power.device_battery_ina_address) {
if (ina_found.type != ScanI2C::DeviceType::NONE) {
switch (ina_found.type) {
case ScanI2C::DeviceType::INA219:
return ina219Sensor.getBusVoltageMv();
break;
case ScanI2C::DeviceType::INA226:
return ina226Sensor.getBusVoltageMv();
break;
case ScanI2C::DeviceType::INA260:
return ina260Sensor.getBusVoltageMv();
break;
case ScanI2C::DeviceType::INA3221:
return ina3221Sensor.getBusVoltageMv();
break;
}
}
} else if (config.power.device_battery_ina_address) {
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first == config.power.device_battery_ina_address) {
return ina219Sensor.getBusVoltageMv();
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA226].first ==
config.power.device_battery_ina_address) {
return ina226Sensor.getBusVoltageMv();
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA260].first ==
config.power.device_battery_ina_address) {
return ina260Sensor.getBusVoltageMv();
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA3221].first ==
config.power.device_battery_ina_address) {
return ina3221Sensor.getBusVoltageMv();
}
}
return 0;
}
/*
Read Current from INA using autodetect of addr first else use addr in config.power.device_battery_ina_address
*/
int16_t getINACurrent()
{
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first == config.power.device_battery_ina_address) {
return ina219Sensor.getCurrentMa();
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA226].first ==
config.power.device_battery_ina_address) {
return ina226Sensor.getCurrentMa();
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA3221].first ==
config.power.device_battery_ina_address) {
return ina3221Sensor.getCurrentMa();
if (!config.power.device_battery_ina_address) {
if (ina_found.type != ScanI2C::DeviceType::NONE) {
switch (ina_found.type) {
case ScanI2C::DeviceType::INA219:
return ina219Sensor.getCurrentMa();
case ScanI2C::DeviceType::INA226:
return ina226Sensor.getCurrentMa();
case ScanI2C::DeviceType::INA3221:
return ina3221Sensor.getCurrentMa();
}
}
} else if (config.power.device_battery_ina_address) {
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first == config.power.device_battery_ina_address) {
return ina219Sensor.getCurrentMa();
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA226].first ==
config.power.device_battery_ina_address) {
return ina226Sensor.getCurrentMa();
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA3221].first ==
config.power.device_battery_ina_address) {
return ina3221Sensor.getCurrentMa();
}
}
return 0;
}
bool hasINA()
/*
Use autodetect of addr first else use addr in config.power.device_battery_ina_address
Store INA addr in local variable for later use.
*/
{
if (!config.power.device_battery_ina_address) {
return false;
}
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first == config.power.device_battery_ina_address) {
if (!ina219Sensor.isInitialized())
return ina219Sensor.runOnce() > 0;
return ina219Sensor.isRunning();
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA226].first ==
config.power.device_battery_ina_address) {
if (!ina226Sensor.isInitialized())
return ina226Sensor.runOnce() > 0;
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA260].first ==
config.power.device_battery_ina_address) {
if (!ina260Sensor.isInitialized())
return ina260Sensor.runOnce() > 0;
return ina260Sensor.isRunning();
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA3221].first ==
config.power.device_battery_ina_address) {
if (!ina3221Sensor.isInitialized())
return ina3221Sensor.runOnce() > 0;
return ina3221Sensor.isRunning();
if (ina_found.type != ScanI2C::DeviceType::NONE) {
INA_ADDR_LOCAL = ina_found.address.address;
switch (ina_found.type) {
case ScanI2C::DeviceType::INA219:
if (!ina219Sensor.isInitialized())
return ina219Sensor.runOnce() > 0;
return ina219Sensor.isRunning();
case ScanI2C::DeviceType::INA226:
if (!ina226Sensor.isInitialized())
return ina226Sensor.runOnce() > 0;
return ina226Sensor.isRunning();
case ScanI2C::DeviceType::INA260:
if (!ina260Sensor.isInitialized())
return ina260Sensor.runOnce() > 0;
return ina260Sensor.isRunning();
case ScanI2C::DeviceType::INA3221:
if (!ina3221Sensor.isInitialized())
return ina3221Sensor.runOnce() > 0;
return ina3221Sensor.isRunning();
}
}
} else if (config.power.device_battery_ina_address) {
INA_ADDR_LOCAL = config.power.device_battery_ina_address;
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first == config.power.device_battery_ina_address) {
if (!ina219Sensor.isInitialized())
return ina219Sensor.runOnce() > 0;
return ina219Sensor.isRunning();
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA226].first ==
config.power.device_battery_ina_address) {
if (!ina226Sensor.isInitialized())
return ina226Sensor.runOnce() > 0;
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA260].first ==
config.power.device_battery_ina_address) {
if (!ina260Sensor.isInitialized())
return ina260Sensor.runOnce() > 0;
return ina260Sensor.isRunning();
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA3221].first ==
config.power.device_battery_ina_address) {
if (!ina3221Sensor.isInitialized())
return ina3221Sensor.runOnce() > 0;
return ina3221Sensor.isRunning();
}
}
INA_ADDR_LOCAL = 0;
return false;
}
#endif

View File

@ -41,6 +41,12 @@ ScanI2C::FoundDevice ScanI2C::firstAccelerometer() const
return firstOfOrNONE(9, types);
}
ScanI2C::FoundDevice ScanI2C::firstINA() const
{
ScanI2C::DeviceType types[] = {INA219, INA226, INA260, INA3221};
return firstOfOrNONE(4, types);
}
ScanI2C::FoundDevice ScanI2C::firstAQI() const
{
ScanI2C::DeviceType types[] = {PMSA0031, SCD4X};

View File

@ -132,6 +132,8 @@ class ScanI2C
FoundDevice firstAccelerometer() const;
FoundDevice firstINA() const;
FoundDevice firstAQI() const;
FoundDevice firstRGBLED() const;

View File

@ -194,9 +194,15 @@ ScanI2C::DeviceAddress rtc_found = ScanI2C::ADDRESS_NONE;
ScanI2C::DeviceAddress accelerometer_found = ScanI2C::ADDRESS_NONE;
// The I2C address of the RGB LED (if found)
ScanI2C::FoundDevice rgb_found = ScanI2C::FoundDevice(ScanI2C::DeviceType::NONE, ScanI2C::ADDRESS_NONE);
// The I2C address of the INA Module (if found)
ScanI2C::FoundDevice ina_found = ScanI2C::FoundDevice(ScanI2C::DeviceType::NONE, ScanI2C::ADDRESS_NONE);
ScanI2C::DeviceAddress ina_Address = ScanI2C::ADDRESS_NONE;
/// The I2C address of our Air Quality Indicator (if found)
ScanI2C::DeviceAddress aqi_found = ScanI2C::ADDRESS_NONE;
#ifdef T_WATCH_S3
Adafruit_DRV2605 drv;
#endif
@ -653,6 +659,12 @@ void setup()
LOG_DEBUG("acc_info = %i", acc_info.type);
#endif
#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && !defined(ARCH_PORTDUINO)
auto ina_Info = i2cScanner->firstINA();
// ina_Address = ina_Info.type != ScanI2C::DeviceType::NONE ? ina_Info.address : ina_Address;
LOG_DEBUG("ina_info = %i", ina_Info.type);
#endif
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BME_680, meshtastic_TelemetrySensorType_BME680);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BME_280, meshtastic_TelemetrySensorType_BME280);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BMP_280, meshtastic_TelemetrySensorType_BMP280);

View File

@ -35,6 +35,8 @@ extern bool kb_found;
extern ScanI2C::DeviceAddress rtc_found;
extern ScanI2C::DeviceAddress accelerometer_found;
extern ScanI2C::FoundDevice rgb_found;
// extern ScanI2C::DeviceAddress ina_Address;
extern ScanI2C::FoundDevice ina_found;
extern ScanI2C::DeviceAddress aqi_found;
extern bool eink_found;

View File

@ -205,6 +205,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
// app not to send locations on our behalf.
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_my_info_tag;
strncpy(myNodeInfo.pio_env, optstr(APP_ENV), sizeof(myNodeInfo.pio_env));
myNodeInfo.nodedb_count = static_cast<uint16_t>(nodeDB->getNumMeshNodes());
fromRadioScratch.my_info = myNodeInfo;
state = STATE_SEND_UIDATA;

View File

@ -651,11 +651,12 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
shouldIgnoreNonstandardPorts = true;
#endif
if (shouldIgnoreNonstandardPorts && p->which_payload_variant == meshtastic_MeshPacket_decoded_tag &&
IS_ONE_OF(p->decoded.portnum, meshtastic_PortNum_ATAK_FORWARDER, meshtastic_PortNum_ATAK_PLUGIN,
meshtastic_PortNum_PAXCOUNTER_APP, meshtastic_PortNum_IP_TUNNEL_APP, meshtastic_PortNum_AUDIO_APP,
meshtastic_PortNum_PRIVATE_APP, meshtastic_PortNum_DETECTION_SENSOR_APP, meshtastic_PortNum_RANGE_TEST_APP,
meshtastic_PortNum_REMOTE_HARDWARE_APP)) {
LOG_DEBUG("Ignore packet on blacklisted portnum for CORE_PORTNUMS_ONLY");
!IS_ONE_OF(p->decoded.portnum, meshtastic_PortNum_TEXT_MESSAGE_APP, meshtastic_PortNum_TEXT_MESSAGE_COMPRESSED_APP,
meshtastic_PortNum_POSITION_APP, meshtastic_PortNum_NODEINFO_APP, meshtastic_PortNum_ROUTING_APP,
meshtastic_PortNum_TELEMETRY_APP, meshtastic_PortNum_ADMIN_APP, meshtastic_PortNum_ALERT_APP,
meshtastic_PortNum_KEY_VERIFICATION_APP, meshtastic_PortNum_WAYPOINT_APP,
meshtastic_PortNum_STORE_FORWARD_APP, meshtastic_PortNum_TRACEROUTE_APP)) {
LOG_DEBUG("Ignore packet on non-standard portnum for CORE_PORTNUMS_ONLY");
cancelSending(p->from, p->id);
skipHandle = true;
}

View File

@ -19,8 +19,6 @@
#ifndef _VARIANT_GAT562_MESH_TRIAL_TRACKER_
#define _VARIANT_GAT562_MESH_TRIAL_TRACKER_
#define GAT562_MESH_TRIAL_TRACKER
// led pin 2 (blue), see https://github.com/meshtastic/firmware/blob/master/src/mesh/NodeDB.cpp#L723
#define RAK4630