firmware/src/power.h

105 lines
3.1 KiB
C
Raw Normal View History

#pragma once
2024-06-16 14:29:45 +00:00
#include "../variants/rak2560/RAK9154Sensor.h"
#include "PowerStatus.h"
#include "concurrency/OSThread.h"
2024-05-03 12:26:57 +00:00
#include "configuration.h"
2024-06-16 11:45:17 +00:00
#ifdef ARCH_ESP32
// "legacy adc calibration driver is deprecated, please migrate to use esp_adc/adc_cali.h and esp_adc/adc_cali_scheme.h
#include <esp_adc_cal.h>
#include <soc/adc_channel.h>
#endif
Battery level with proportional filter and lookup table (#3216) * Add battery level with lookup table now uses a lookup table to better calculate battery level of different cells * LifePo4 and PB battery table - added voltage filter removed delay from adc reading, added a software filter to smooth out voltage readings. In those applications battery would last hours to days, no sudden change should be expected so a less frequent voltage reading or a more aggressive filtering could be done. Note: to speed up convergence i initiliazied the last value to the minimum voltage, there are other and better ways to init the filter. Added LiFePO4 and PB open circuit volta battery tables, * Fixed ADC_CTRL , Checks for valid ADC readings line 230/386 For heltec v3 and heltec tracker a different approach was used with the ADC_CTRL pin, now is more uniform using the same code for the 3 boards. line 236 Check if the raw reading we are getting is Valid or not, count only the valid readings. This could lead to a division by 0 (improbable) so that's why at line 258 there is a check for that. * updated OCV values updated value to not OCV but to very low current, almost the same anyway * Added Alkaline/Nimh voltage curve Added Alkaline/Nimh voltage curve for AA/AAA and similar cells * updates variants for new capacity measurement * trunk reformatting * trunk fmt * Add LTO chemistry --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: code8buster <20384924+code8buster@users.noreply.github.com>
2024-02-16 12:09:57 +00:00
#ifndef NUM_OCV_POINTS
#define NUM_OCV_POINTS 11
#endif
#ifndef OCV_ARRAY
#ifdef CELL_TYPE_LIFEPO4
#define OCV_ARRAY 3400, 3350, 3320, 3290, 3270, 3260, 3250, 3230, 3200, 3120, 3000
#elif defined(CELL_TYPE_LEADACID)
#define OCV_ARRAY 2120, 2090, 2070, 2050, 2030, 2010, 1990, 1980, 1970, 1960, 1950
#elif defined(CELL_TYPE_ALKALINE)
#define OCV_ARRAY 1580, 1400, 1350, 1300, 1280, 1250, 1230, 1190, 1150, 1100, 1000
#elif defined(CELL_TYPE_NIMH)
#define OCV_ARRAY 1400, 1300, 1280, 1270, 1260, 1250, 1240, 1230, 1210, 1150, 1000
#elif defined(CELL_TYPE_LTO)
#define OCV_ARRAY 2700, 2560, 2540, 2520, 2500, 2460, 2420, 2400, 2380, 2320, 1500
Battery level with proportional filter and lookup table (#3216) * Add battery level with lookup table now uses a lookup table to better calculate battery level of different cells * LifePo4 and PB battery table - added voltage filter removed delay from adc reading, added a software filter to smooth out voltage readings. In those applications battery would last hours to days, no sudden change should be expected so a less frequent voltage reading or a more aggressive filtering could be done. Note: to speed up convergence i initiliazied the last value to the minimum voltage, there are other and better ways to init the filter. Added LiFePO4 and PB open circuit volta battery tables, * Fixed ADC_CTRL , Checks for valid ADC readings line 230/386 For heltec v3 and heltec tracker a different approach was used with the ADC_CTRL pin, now is more uniform using the same code for the 3 boards. line 236 Check if the raw reading we are getting is Valid or not, count only the valid readings. This could lead to a division by 0 (improbable) so that's why at line 258 there is a check for that. * updated OCV values updated value to not OCV but to very low current, almost the same anyway * Added Alkaline/Nimh voltage curve Added Alkaline/Nimh voltage curve for AA/AAA and similar cells * updates variants for new capacity measurement * trunk reformatting * trunk fmt * Add LTO chemistry --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: code8buster <20384924+code8buster@users.noreply.github.com>
2024-02-16 12:09:57 +00:00
#else // LiIon
#define OCV_ARRAY 4190, 4050, 3990, 3890, 3800, 3720, 3630, 3530, 3420, 3300, 3100
#endif
#endif
/*Note: 12V lead acid is 6 cells, most board accept only 1 cell LiIon/LiPo*/
#ifndef NUM_CELLS
#define NUM_CELLS 1
#endif
#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
#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && !defined(ARCH_PORTDUINO)
#include "modules/Telemetry/Sensor/INA219Sensor.h"
Detect charging status by measuring current flow with configured INA battery sensor (#5271) * INA219 charging detection minimal implementation: if there is a configured INA219 sensor for battery monitoring we can take the current flow across the shunt resistor to know if we are charging the battery - negative milliamps indicate charging * Update Power.cpp added comments and 2 extra defines to disable and swap detection direction * Update Power.cpp fix disabled case * move getCurrentMa() to new CurrentSensor class * INA219 charging detection minimal implementation: if there is a configured INA219 sensor for battery monitoring we can take the current flow across the shunt resistor to know if we are charging the battery - negative milliamps indicate charging * Update Power.cpp added comments and 2 extra defines to disable and swap detection direction * Update Power.cpp fix disabled case * move getCurrentMa() to new CurrentSensor class * add INA3221 charging detection * RP2040: Update core; add mDNS support (#5355) * Update arduino-pico core * RP2040: Add mDNS support * SimpleMDNS `begin` now returns a bool * Add `-g` option to `debug_build_flags` to link files for gdb * RAK11310 needs old platform as well * Change defines to specific architecture * Core version 4.2.1 is out * Add sudo to apt-get commands for Raspbian Build (#5364) Without sudo, inadequate permissions to runs the commands meant the build was failing. * Typo fix in build_raspbian.yml (#5365) s/sudp/sudo :(:(:( * Rework some things * Trunk * Separate littlefs bundle * version tags * Diag * Add littlefswebui * Bug fixed in ExternalNotificationModule (#5375) While `nagging` setExternalState wasn't written to Buzzer & Vibra so output was never toggled. Possible fix for #5348 * Cleanup static files from bad Web UI bundle on 2.5.13 release (#5376) * Cleanup static files from bad Web UI bundle on 2.5.13 release * Check existence first * Esp32 is the only one we care about * Move some actions to after `startTransmit()` (#5383) To minimize the time between channel scan and actual transmit * [create-pull-request] automated change (#5380) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Allows all 3 PKI keys to be added to userPrefs.h (#4969) and a tool. (#5368) * more userPrefs.h Added PKI Admin keys to userPrefs.h * Update userPrefs.h Allows all 3 PKI keys to be added to userPrefs.h (#4969) * Update NodeDB.cpp Trunk * Update userPrefs.h Changed wording * Create base64_to_hex.py A little tool for converting base64 PKI Keys to decoded byte that userPrefs.h can understand. * more userPrefs.h Added PKI Admin keys to userPrefs.h * Update userPrefs.h Allows all 3 PKI keys to be added to userPrefs.h (#4969) * Update NodeDB.cpp Trunk * Update userPrefs.h Changed wording * Create base64_to_hex.py A little tool for converting base64 PKI Keys to decoded byte that userPrefs.h can understand. * [create-pull-request] automated change (#5388) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * add smiley emoji (#5391) * add smiley emoji * clang-formatted * Anable trace route function on wismeshtap platform (#5389) * fix 'symbal' typo (#5395) * [create-pull-request] automated change (#5399) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * /api/v1/fromradio: add OPTIONS handler for CORS. (#5386) This avoids hitting the 404 Not Found handler, which breaks connection keep-alive, so this change fixes a big performance regression for Web Client in Chrome: https://github.com/meshtastic/firmware/issues/5385 Tested on Heltec V3. Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Make heart emoji usable (#5403) * Create a specific hw_model for WisMesh Tap (#5400) * Create a specific hw_model for WisMesh Tap * Trunk * HAS_ETHERNET * Remove it altogether * Don't need these either * Fix RTC time injection and consolidate position logic (#5396) * Fix RTC time injection and consolidate position logic * Comment out unused var warning * Backerds * Update arduino-pico core to fix sporadic hangs (#5406) * Update platform-raspberrypi also (#5407) * Update arduino-pico core to fix sporadic hangs * Update platform-raspberrypi also * --web added to device-install(.sh/.bat) (#5405) * Add --web * Update device-install.bat Forgot a "-" a few places. --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * add GPS in indicator board (#5411) * Fixed NMEA sentence issue in CalTopo as well as bug with no printing all of the nodes (#5412) * --web littlefswebui-* typo fix (#5416) * Add --web * Update device-install.bat Forgot a "-" a few places. * Typo fix. * Typo fix --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com> * Temporarily disable MDNS when MQTT is enabled (#5418) Leads to a panic * Check for OkToMqtt flag presence before uplinking to MQTT (#5413) * Check for oktomqtt flag presence before uplinking to MQTT * Move to mqtt->onSend * Temetry can respond to want-response for LocalStats variant (#5414) * Seems like the last DIY board that's not "extra" (#5420) * Cherry pick tdeck fixes (#5422) * Try-fix (workaround) T-Deck audio crash * set T-Deck audio to unused 48 (mem mclk) * swap mclk to gpio 21 * dreamcatcher: assign GPIO44 to audio mclk --------- Co-authored-by: mverch67 <manuel.verch@gmx.de> * add canned message and keyboard in indicator board (#5410) * add canned message and keyboard in indicator board * Added virtual keyboard macro and enabled for Indicator * Cleanup macros by applying USE_VIRTUAL_KEYBOARD and DISPLAY_CLOCK_FRAME --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Update build-native.sh (#5415) * Update build-native.sh Device-install.sh and device-update.sh are not used on native platform, skip copying to release directory after build and copy native-install.sh and native-run.sh instead. * Update build-native.sh Skip native-run.sh copy * Cleans up visibility in GPS.h (#5426) Signed-off-by: Christopher Hoover <ch@murgatroid.com> * Fix admin key loading from userPrefs.h (#5417) * Fix LED pinout for T-Echo board marked v1.0, date 2021-6-28 * Merge PR #420 * Fixed double and missing Default class. * Use correct format specifier and fixed typo. * Removed duplicate code. * Fix error: #if with no expression * Fix warning: extra tokens at end of #endif directive. * Fix antenna switching logic. Complementary-pin control logic is required on the rp2040-lora board. * Fix deprecated macros. * Set RP2040 in dormant mode when deep sleep is triggered. * Fix array out of bounds read. * Admin key count needs to be set otherwise the key will be zero loaded after reset. * Don't reset the admin key size when loading defaults. Preserve an existing key in config if possible. * Remove log spam when reading INA voltage sensor. * Remove static declaration for admin keys from userPrefs.h. Load hard coded admin keys in case config file has empty slots. * Removed newlines from log. --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com> * try to detect dfrobot station to tell it apart from an ublox gps. (#5393) * Remove BMA-423 and STK8X by default (#5429) * Remove BMA-423 by default * STK * Wrong macro * Helps if you include the file * [create-pull-request] automated change (#5431) Co-authored-by: caveman99 <25002+caveman99@users.noreply.github.com> * Support for the ClimateGuard RadSens Geiger-Muller tube (#5425) * fixes https://github.com/meshtastic/firmware/issues/5434 (#5435) * update libpax * fix interval init * Fix memory leaks by adding missing `free()` calls before early returns in `MQTT::onReceive` (#5439) This fix addresses memory leaks in the `MQTT::onReceive` function by ensuring that dynamically allocated resources (`e.channel_id`, `e.gateway_id` and `e.packet`) are properly freed before each early return. Previously, these resources were only freed at the end of the function, leaving them unhandled in certain exit paths. Adding the missing `free()` calls prevents memory leaks and ensures proper resource cleanup in all scenarios. * Removing 1.0 legacy boards from releases and completely removing Heltec wireless capsule from support (#5436) Co-authored-by: Tom Fifield <tom@tomfifield.net> * A second round of cleanup on GPS.h. (#5433) * Move yet more stuff out of GPS.h and into file scope. * Protect code macros from eating semicolons. * Remove unused (and unimplemented) getDOPString. * clang-format with project style file on affected files. Signed-off-by: Christopher Hoover <ch@murgatroid.com> * enable MQTT with TLS on RPi picow (#5442) Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Don't powersave on Wifi (#5443) * Don't go into light sleep with wifi enabled * Move * Trunk * Revert "Seems like the last DIY board that's not "extra" (#5420)" (#5446) This reverts commit e6fb6b115aebb12b31fb93ed9d1508a6109b2f03. * Actually gunzip all the files when building a .deb (#5449) * [create-pull-request] automated change (#5457) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Cleanup i2c scan logs and macro to save some bytes and remain consistent (#5455) * Cleanup i2c scan logs and macro to save some bytes and remain consistent * Functions are better than macros * Exclude i2c scan for STM32 * Useless log * Clean up some inline functions (#5454) * Use isWithinTimespanMs to avoid refererence to NodeDb instance inside of NodeDb (#5453) * fix cors for meshtasticd to allow use of cross origin clients (#5463) * Remove ATECC crypto chip placeholder code (#5461) * GPS.h cleanups round 3. (#5447) * GPS.h cleanups round 3. No effective behavior change. Protected members can be private so make it so. (Supporting subclasses needs a lot more work.) Moves uBloxGnssModelInfo into file scope. Moves uBloxProtocolVersion into uBloxGnssModelInfo. Moves baud rate arrays into file scope. Removes unused/ unimplemented powerStateToString. Signed-off-by: Christopher Hoover <ch@murgatroid.com> * Trunk Format. --------- Signed-off-by: Christopher Hoover <ch@murgatroid.com> Co-authored-by: Tom Fifield <tom@tomfifield.net> * Fix ukrainian fonts (#5468) * FIX: rollback to !4624 * UPDATE: new 16 and 24 UA Fonts and fixes * fix: Solve the lightsleep crash problem via disable lightsleep for indicator. (#5470) * Trunk * Warnings and log cleanup (#5472) * Don't log if keyboard not found * Signed comparison issue * [create-pull-request] automated change (#5475) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Adds libusb dev package to Raspbian build steps (#5480) * [create-pull-request] automated change (#5478) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Portduino fixes (#5479) * Set config.yaml defaults even if General is missing * Unsigned values should get %u in logging * Update arduino-pico core and remove MDNS restriction (#5483) * Update xiao_esp32 fully support L67K (#5488) L67K module hardware changed * Convert userprefs to a json file instead of header file which has to be included everywhere (#5471) * WIP * Got string quoting and macro expansion working * Need the placeholder * Cleanup * Missed a user prefs reference * Update jsonc * SimRadio: clean-up and emulate collisions (#5487) * Clean up SimRadio and don't let it use PKC * Add collision emulation for SimRadio * Add stats from SimRadio to LocalStats * Make emulating collisions optional * add nodeId to nodeinfo update log lines and removed redundant nodeinfo update log line (#5493) * Refact the macro definition of GPS initialization of GPSDEFAULTD_NOT_PRESENT and added seeeed Indicator to this sequence (#5494) Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Extend Length of Source and Destination Node IDs Logged (#5492) * show 8 chars for logging source and destination ids * extend legnth of source and destination nodes in log * Added femtofox configs (#5477) * added femtofox configs * Rename bin/config.d/femtofox_Waveshare-SX126X-XXXM_AI-Thinker-RA-01SH.yaml to bin/config.d/femtofox/femtofox_Waveshare-SX126X-XXXM_AI-Thinker-RA-01SH.yaml * moved femtofox configs to subdir * [Add] LR1110, LR1120 and LR1121 to linux native Portduino (#5496) * Update main.cpp * Update PortduinoGlue.h * Update PortduinoGlue.cpp * Update PortduinoGlue.cpp * Update PortduinoGlue.cpp * Update main.cpp * [create-pull-request] automated change (#5500) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Fix minor typos in package workflows (#5505) * Don't use channel index for encrypted packet (#5509) * Don't use channel index for encrypted packet * Remove assert in `getKey`, set invalid key length So encrypting will fail without reboot * Reset channel to 0 when unable to encrypt Such that the NAK doesn't use the failing channel hash * Always Announce MDNS meshtastic service (#5503) * refactor server api port into define * always announce MDNS meshtastic service * fix nodeDB erase loop when free mem returns invalid value (0, -1). (#5519) Co-authored-by: mverch67 <manuel.verch@gmx.de> * Add heltec capsule back * Revert "Add heltec capsule back" This reverts commit fc16d9342116235fa86cf6ac163b17125bb4b50e. * Lets try this again minus device ui * Add popular nrf52 pro micro to the builds (#5523) * Add MACAddress to config.yaml (#5506) * Add MACAddress to config.yaml * Better error handling on native, including failing to launch with blank MAC Address and real hardware. * Re-arrange Mac Address handling and add MACAddressSource * Bump portduino to remove macaddr function there --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Configure Seeed Xiao S3 RX enable pin (#5517) * Create OpenWRT_One_mikroBUS_sx1262.yaml (#5529) * tlora_v2_1_16: Unset BUTTON_PIN and BUTTON_NEED_PULLUP (#5535) Unset BUTTON_PIN and BUTTON_NEED_PULLUP as the board ships without a user button. Devices and users expecting a button on GPIO12 have to set [GPIO for user button](https://meshtastic.org/docs/configuration/radio/device/#gpio-for-user-button) to 12 (or any GPIO pin the momentary switch was connected to) to restore functionality. Signed-off-by: Andrew Yong <me@ndoo.sg> * [create-pull-request] automated change (#5530) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Fix detection for some RadSens hardware versions (#5542) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Initialize dmac array to nulls (#5538) * Initialize dmac array to nulls * Use std::cout for print before console is init. * Update OpenWRT_One_mikroBUS_sx1262.yaml (#5544) * Add portduino-buildroot variant (#5540) * Add portduino-buildroot variant * Update platform-native for platform-buildroot * portduino-buildroot: Define c standard (#5547) * Portduino: Move meshtasticd/web out of /usr/share/doc/ (#5548) * Portduino: fix transitional symlinks (#5550) * Windows Support - Trunk and Platformio (#5397) (#5518) * Add support for GPG * Add usb device support * Add trunk.io to devcontainer * Trunk things * trunk fmt * formatting * fix trivy/DS002, checkov/CKV_DOCKER_3 * hide docker extension popup * fix trivy/DS026, checkov/CKV_DOCKER_2 Co-authored-by: Kalle Lilja <15094562+ThatKalle@users.noreply.github.com> * Synch minor changes from TFT branch (#5520) * Synch minor changes from TFT branch Includes: * New nordicnrf52 minor version (10.5.0 --> 10.6.0) * Optimisations for T_DECK * preparation for MESH_TAB * add ext notification module to portduino --------- Co-authored-by: mverch67 <manuel.verch@gmx.de> * DIO3_TCXO_VOLTAGE in config.yaml can now take an exact voltage (#5558) * Support TLORA_V3.0 (#5563) - Support TLORA_V3.0. Update of the legendary 2.1_1.6.1 with solar charger, TCXO and IPEX connector. - 'extra' some short-lived EOL intermediate boards in that range. If possible use T3S3 instead of all of these! - update trunk to latest version * Create OpenWRT-One-mikroBUS-LR-IOT-CLICK.yaml (#5564) * Portduino: fix setting hwId via argument (#5565) * INA219 charging detection minimal implementation: if there is a configured INA219 sensor for battery monitoring we can take the current flow across the shunt resistor to know if we are charging the battery - negative milliamps indicate charging * Update Power.cpp added comments and 2 extra defines to disable and swap detection direction * Trunk Fixes * Add INA226 support --------- Signed-off-by: Christopher Hoover <ch@murgatroid.com> Signed-off-by: Andrew Yong <me@ndoo.sg> Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz> Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Co-authored-by: Tom Fifield <tom@tomfifield.net> Co-authored-by: Michael Gjelsø <36234524+gjelsoe@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> Co-authored-by: jcyrio <50239349+jcyrio@users.noreply.github.com> Co-authored-by: Daniel.Cao <144674500+DanielCao0@users.noreply.github.com> Co-authored-by: Catalin Patulea <cronos586@gmail.com> Co-authored-by: dylanli <dylan3000dylan@gmail.com> Co-authored-by: mverch67 <manuel.verch@gmx.de> Co-authored-by: madeofstown <33820964+madeofstown@users.noreply.github.com> Co-authored-by: Christopher Hoover <ch@murgatroid.com> Co-authored-by: Mictronics <github@mictronics.de> Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com> Co-authored-by: caveman99 <25002+caveman99@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: César de Tassis Filho <CTassisF@users.noreply.github.com> Co-authored-by: Tomas Dubec <tomas.dubec@gmail.com> Co-authored-by: Liam Cottle <liam@liamcottle.com> Co-authored-by: panaceya <panaceya@users.noreply.github.com> Co-authored-by: virgil <virgil.wang.cj@gmail.com> Co-authored-by: Robert <r@rbrt.io> Co-authored-by: noon92 <40807970+noon92@users.noreply.github.com> Co-authored-by: Mark Trevor Birss <markbirss@gmail.com> Co-authored-by: broglep <20624281+broglep@users.noreply.github.com> Co-authored-by: Matthias Granberry <matthias.granberry@gmail.com> Co-authored-by: Andrew Yong <me@ndoo.sg> Co-authored-by: Jake-B <jake-b@users.noreply.github.com> Co-authored-by: Austin <vidplace7@gmail.com> Co-authored-by: Kalle Lilja <15094562+ThatKalle@users.noreply.github.com>
2024-12-22 04:02:50 +00:00
#include "modules/Telemetry/Sensor/INA226Sensor.h"
#include "modules/Telemetry/Sensor/INA260Sensor.h"
#include "modules/Telemetry/Sensor/INA3221Sensor.h"
extern INA219Sensor ina219Sensor;
Detect charging status by measuring current flow with configured INA battery sensor (#5271) * INA219 charging detection minimal implementation: if there is a configured INA219 sensor for battery monitoring we can take the current flow across the shunt resistor to know if we are charging the battery - negative milliamps indicate charging * Update Power.cpp added comments and 2 extra defines to disable and swap detection direction * Update Power.cpp fix disabled case * move getCurrentMa() to new CurrentSensor class * INA219 charging detection minimal implementation: if there is a configured INA219 sensor for battery monitoring we can take the current flow across the shunt resistor to know if we are charging the battery - negative milliamps indicate charging * Update Power.cpp added comments and 2 extra defines to disable and swap detection direction * Update Power.cpp fix disabled case * move getCurrentMa() to new CurrentSensor class * add INA3221 charging detection * RP2040: Update core; add mDNS support (#5355) * Update arduino-pico core * RP2040: Add mDNS support * SimpleMDNS `begin` now returns a bool * Add `-g` option to `debug_build_flags` to link files for gdb * RAK11310 needs old platform as well * Change defines to specific architecture * Core version 4.2.1 is out * Add sudo to apt-get commands for Raspbian Build (#5364) Without sudo, inadequate permissions to runs the commands meant the build was failing. * Typo fix in build_raspbian.yml (#5365) s/sudp/sudo :(:(:( * Rework some things * Trunk * Separate littlefs bundle * version tags * Diag * Add littlefswebui * Bug fixed in ExternalNotificationModule (#5375) While `nagging` setExternalState wasn't written to Buzzer & Vibra so output was never toggled. Possible fix for #5348 * Cleanup static files from bad Web UI bundle on 2.5.13 release (#5376) * Cleanup static files from bad Web UI bundle on 2.5.13 release * Check existence first * Esp32 is the only one we care about * Move some actions to after `startTransmit()` (#5383) To minimize the time between channel scan and actual transmit * [create-pull-request] automated change (#5380) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Allows all 3 PKI keys to be added to userPrefs.h (#4969) and a tool. (#5368) * more userPrefs.h Added PKI Admin keys to userPrefs.h * Update userPrefs.h Allows all 3 PKI keys to be added to userPrefs.h (#4969) * Update NodeDB.cpp Trunk * Update userPrefs.h Changed wording * Create base64_to_hex.py A little tool for converting base64 PKI Keys to decoded byte that userPrefs.h can understand. * more userPrefs.h Added PKI Admin keys to userPrefs.h * Update userPrefs.h Allows all 3 PKI keys to be added to userPrefs.h (#4969) * Update NodeDB.cpp Trunk * Update userPrefs.h Changed wording * Create base64_to_hex.py A little tool for converting base64 PKI Keys to decoded byte that userPrefs.h can understand. * [create-pull-request] automated change (#5388) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * add smiley emoji (#5391) * add smiley emoji * clang-formatted * Anable trace route function on wismeshtap platform (#5389) * fix 'symbal' typo (#5395) * [create-pull-request] automated change (#5399) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * /api/v1/fromradio: add OPTIONS handler for CORS. (#5386) This avoids hitting the 404 Not Found handler, which breaks connection keep-alive, so this change fixes a big performance regression for Web Client in Chrome: https://github.com/meshtastic/firmware/issues/5385 Tested on Heltec V3. Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Make heart emoji usable (#5403) * Create a specific hw_model for WisMesh Tap (#5400) * Create a specific hw_model for WisMesh Tap * Trunk * HAS_ETHERNET * Remove it altogether * Don't need these either * Fix RTC time injection and consolidate position logic (#5396) * Fix RTC time injection and consolidate position logic * Comment out unused var warning * Backerds * Update arduino-pico core to fix sporadic hangs (#5406) * Update platform-raspberrypi also (#5407) * Update arduino-pico core to fix sporadic hangs * Update platform-raspberrypi also * --web added to device-install(.sh/.bat) (#5405) * Add --web * Update device-install.bat Forgot a "-" a few places. --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * add GPS in indicator board (#5411) * Fixed NMEA sentence issue in CalTopo as well as bug with no printing all of the nodes (#5412) * --web littlefswebui-* typo fix (#5416) * Add --web * Update device-install.bat Forgot a "-" a few places. * Typo fix. * Typo fix --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com> * Temporarily disable MDNS when MQTT is enabled (#5418) Leads to a panic * Check for OkToMqtt flag presence before uplinking to MQTT (#5413) * Check for oktomqtt flag presence before uplinking to MQTT * Move to mqtt->onSend * Temetry can respond to want-response for LocalStats variant (#5414) * Seems like the last DIY board that's not "extra" (#5420) * Cherry pick tdeck fixes (#5422) * Try-fix (workaround) T-Deck audio crash * set T-Deck audio to unused 48 (mem mclk) * swap mclk to gpio 21 * dreamcatcher: assign GPIO44 to audio mclk --------- Co-authored-by: mverch67 <manuel.verch@gmx.de> * add canned message and keyboard in indicator board (#5410) * add canned message and keyboard in indicator board * Added virtual keyboard macro and enabled for Indicator * Cleanup macros by applying USE_VIRTUAL_KEYBOARD and DISPLAY_CLOCK_FRAME --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Update build-native.sh (#5415) * Update build-native.sh Device-install.sh and device-update.sh are not used on native platform, skip copying to release directory after build and copy native-install.sh and native-run.sh instead. * Update build-native.sh Skip native-run.sh copy * Cleans up visibility in GPS.h (#5426) Signed-off-by: Christopher Hoover <ch@murgatroid.com> * Fix admin key loading from userPrefs.h (#5417) * Fix LED pinout for T-Echo board marked v1.0, date 2021-6-28 * Merge PR #420 * Fixed double and missing Default class. * Use correct format specifier and fixed typo. * Removed duplicate code. * Fix error: #if with no expression * Fix warning: extra tokens at end of #endif directive. * Fix antenna switching logic. Complementary-pin control logic is required on the rp2040-lora board. * Fix deprecated macros. * Set RP2040 in dormant mode when deep sleep is triggered. * Fix array out of bounds read. * Admin key count needs to be set otherwise the key will be zero loaded after reset. * Don't reset the admin key size when loading defaults. Preserve an existing key in config if possible. * Remove log spam when reading INA voltage sensor. * Remove static declaration for admin keys from userPrefs.h. Load hard coded admin keys in case config file has empty slots. * Removed newlines from log. --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com> * try to detect dfrobot station to tell it apart from an ublox gps. (#5393) * Remove BMA-423 and STK8X by default (#5429) * Remove BMA-423 by default * STK * Wrong macro * Helps if you include the file * [create-pull-request] automated change (#5431) Co-authored-by: caveman99 <25002+caveman99@users.noreply.github.com> * Support for the ClimateGuard RadSens Geiger-Muller tube (#5425) * fixes https://github.com/meshtastic/firmware/issues/5434 (#5435) * update libpax * fix interval init * Fix memory leaks by adding missing `free()` calls before early returns in `MQTT::onReceive` (#5439) This fix addresses memory leaks in the `MQTT::onReceive` function by ensuring that dynamically allocated resources (`e.channel_id`, `e.gateway_id` and `e.packet`) are properly freed before each early return. Previously, these resources were only freed at the end of the function, leaving them unhandled in certain exit paths. Adding the missing `free()` calls prevents memory leaks and ensures proper resource cleanup in all scenarios. * Removing 1.0 legacy boards from releases and completely removing Heltec wireless capsule from support (#5436) Co-authored-by: Tom Fifield <tom@tomfifield.net> * A second round of cleanup on GPS.h. (#5433) * Move yet more stuff out of GPS.h and into file scope. * Protect code macros from eating semicolons. * Remove unused (and unimplemented) getDOPString. * clang-format with project style file on affected files. Signed-off-by: Christopher Hoover <ch@murgatroid.com> * enable MQTT with TLS on RPi picow (#5442) Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Don't powersave on Wifi (#5443) * Don't go into light sleep with wifi enabled * Move * Trunk * Revert "Seems like the last DIY board that's not "extra" (#5420)" (#5446) This reverts commit e6fb6b115aebb12b31fb93ed9d1508a6109b2f03. * Actually gunzip all the files when building a .deb (#5449) * [create-pull-request] automated change (#5457) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Cleanup i2c scan logs and macro to save some bytes and remain consistent (#5455) * Cleanup i2c scan logs and macro to save some bytes and remain consistent * Functions are better than macros * Exclude i2c scan for STM32 * Useless log * Clean up some inline functions (#5454) * Use isWithinTimespanMs to avoid refererence to NodeDb instance inside of NodeDb (#5453) * fix cors for meshtasticd to allow use of cross origin clients (#5463) * Remove ATECC crypto chip placeholder code (#5461) * GPS.h cleanups round 3. (#5447) * GPS.h cleanups round 3. No effective behavior change. Protected members can be private so make it so. (Supporting subclasses needs a lot more work.) Moves uBloxGnssModelInfo into file scope. Moves uBloxProtocolVersion into uBloxGnssModelInfo. Moves baud rate arrays into file scope. Removes unused/ unimplemented powerStateToString. Signed-off-by: Christopher Hoover <ch@murgatroid.com> * Trunk Format. --------- Signed-off-by: Christopher Hoover <ch@murgatroid.com> Co-authored-by: Tom Fifield <tom@tomfifield.net> * Fix ukrainian fonts (#5468) * FIX: rollback to !4624 * UPDATE: new 16 and 24 UA Fonts and fixes * fix: Solve the lightsleep crash problem via disable lightsleep for indicator. (#5470) * Trunk * Warnings and log cleanup (#5472) * Don't log if keyboard not found * Signed comparison issue * [create-pull-request] automated change (#5475) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Adds libusb dev package to Raspbian build steps (#5480) * [create-pull-request] automated change (#5478) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Portduino fixes (#5479) * Set config.yaml defaults even if General is missing * Unsigned values should get %u in logging * Update arduino-pico core and remove MDNS restriction (#5483) * Update xiao_esp32 fully support L67K (#5488) L67K module hardware changed * Convert userprefs to a json file instead of header file which has to be included everywhere (#5471) * WIP * Got string quoting and macro expansion working * Need the placeholder * Cleanup * Missed a user prefs reference * Update jsonc * SimRadio: clean-up and emulate collisions (#5487) * Clean up SimRadio and don't let it use PKC * Add collision emulation for SimRadio * Add stats from SimRadio to LocalStats * Make emulating collisions optional * add nodeId to nodeinfo update log lines and removed redundant nodeinfo update log line (#5493) * Refact the macro definition of GPS initialization of GPSDEFAULTD_NOT_PRESENT and added seeeed Indicator to this sequence (#5494) Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Extend Length of Source and Destination Node IDs Logged (#5492) * show 8 chars for logging source and destination ids * extend legnth of source and destination nodes in log * Added femtofox configs (#5477) * added femtofox configs * Rename bin/config.d/femtofox_Waveshare-SX126X-XXXM_AI-Thinker-RA-01SH.yaml to bin/config.d/femtofox/femtofox_Waveshare-SX126X-XXXM_AI-Thinker-RA-01SH.yaml * moved femtofox configs to subdir * [Add] LR1110, LR1120 and LR1121 to linux native Portduino (#5496) * Update main.cpp * Update PortduinoGlue.h * Update PortduinoGlue.cpp * Update PortduinoGlue.cpp * Update PortduinoGlue.cpp * Update main.cpp * [create-pull-request] automated change (#5500) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Fix minor typos in package workflows (#5505) * Don't use channel index for encrypted packet (#5509) * Don't use channel index for encrypted packet * Remove assert in `getKey`, set invalid key length So encrypting will fail without reboot * Reset channel to 0 when unable to encrypt Such that the NAK doesn't use the failing channel hash * Always Announce MDNS meshtastic service (#5503) * refactor server api port into define * always announce MDNS meshtastic service * fix nodeDB erase loop when free mem returns invalid value (0, -1). (#5519) Co-authored-by: mverch67 <manuel.verch@gmx.de> * Add heltec capsule back * Revert "Add heltec capsule back" This reverts commit fc16d9342116235fa86cf6ac163b17125bb4b50e. * Lets try this again minus device ui * Add popular nrf52 pro micro to the builds (#5523) * Add MACAddress to config.yaml (#5506) * Add MACAddress to config.yaml * Better error handling on native, including failing to launch with blank MAC Address and real hardware. * Re-arrange Mac Address handling and add MACAddressSource * Bump portduino to remove macaddr function there --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Configure Seeed Xiao S3 RX enable pin (#5517) * Create OpenWRT_One_mikroBUS_sx1262.yaml (#5529) * tlora_v2_1_16: Unset BUTTON_PIN and BUTTON_NEED_PULLUP (#5535) Unset BUTTON_PIN and BUTTON_NEED_PULLUP as the board ships without a user button. Devices and users expecting a button on GPIO12 have to set [GPIO for user button](https://meshtastic.org/docs/configuration/radio/device/#gpio-for-user-button) to 12 (or any GPIO pin the momentary switch was connected to) to restore functionality. Signed-off-by: Andrew Yong <me@ndoo.sg> * [create-pull-request] automated change (#5530) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Fix detection for some RadSens hardware versions (#5542) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Initialize dmac array to nulls (#5538) * Initialize dmac array to nulls * Use std::cout for print before console is init. * Update OpenWRT_One_mikroBUS_sx1262.yaml (#5544) * Add portduino-buildroot variant (#5540) * Add portduino-buildroot variant * Update platform-native for platform-buildroot * portduino-buildroot: Define c standard (#5547) * Portduino: Move meshtasticd/web out of /usr/share/doc/ (#5548) * Portduino: fix transitional symlinks (#5550) * Windows Support - Trunk and Platformio (#5397) (#5518) * Add support for GPG * Add usb device support * Add trunk.io to devcontainer * Trunk things * trunk fmt * formatting * fix trivy/DS002, checkov/CKV_DOCKER_3 * hide docker extension popup * fix trivy/DS026, checkov/CKV_DOCKER_2 Co-authored-by: Kalle Lilja <15094562+ThatKalle@users.noreply.github.com> * Synch minor changes from TFT branch (#5520) * Synch minor changes from TFT branch Includes: * New nordicnrf52 minor version (10.5.0 --> 10.6.0) * Optimisations for T_DECK * preparation for MESH_TAB * add ext notification module to portduino --------- Co-authored-by: mverch67 <manuel.verch@gmx.de> * DIO3_TCXO_VOLTAGE in config.yaml can now take an exact voltage (#5558) * Support TLORA_V3.0 (#5563) - Support TLORA_V3.0. Update of the legendary 2.1_1.6.1 with solar charger, TCXO and IPEX connector. - 'extra' some short-lived EOL intermediate boards in that range. If possible use T3S3 instead of all of these! - update trunk to latest version * Create OpenWRT-One-mikroBUS-LR-IOT-CLICK.yaml (#5564) * Portduino: fix setting hwId via argument (#5565) * INA219 charging detection minimal implementation: if there is a configured INA219 sensor for battery monitoring we can take the current flow across the shunt resistor to know if we are charging the battery - negative milliamps indicate charging * Update Power.cpp added comments and 2 extra defines to disable and swap detection direction * Trunk Fixes * Add INA226 support --------- Signed-off-by: Christopher Hoover <ch@murgatroid.com> Signed-off-by: Andrew Yong <me@ndoo.sg> Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz> Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Co-authored-by: Tom Fifield <tom@tomfifield.net> Co-authored-by: Michael Gjelsø <36234524+gjelsoe@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> Co-authored-by: jcyrio <50239349+jcyrio@users.noreply.github.com> Co-authored-by: Daniel.Cao <144674500+DanielCao0@users.noreply.github.com> Co-authored-by: Catalin Patulea <cronos586@gmail.com> Co-authored-by: dylanli <dylan3000dylan@gmail.com> Co-authored-by: mverch67 <manuel.verch@gmx.de> Co-authored-by: madeofstown <33820964+madeofstown@users.noreply.github.com> Co-authored-by: Christopher Hoover <ch@murgatroid.com> Co-authored-by: Mictronics <github@mictronics.de> Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com> Co-authored-by: caveman99 <25002+caveman99@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: César de Tassis Filho <CTassisF@users.noreply.github.com> Co-authored-by: Tomas Dubec <tomas.dubec@gmail.com> Co-authored-by: Liam Cottle <liam@liamcottle.com> Co-authored-by: panaceya <panaceya@users.noreply.github.com> Co-authored-by: virgil <virgil.wang.cj@gmail.com> Co-authored-by: Robert <r@rbrt.io> Co-authored-by: noon92 <40807970+noon92@users.noreply.github.com> Co-authored-by: Mark Trevor Birss <markbirss@gmail.com> Co-authored-by: broglep <20624281+broglep@users.noreply.github.com> Co-authored-by: Matthias Granberry <matthias.granberry@gmail.com> Co-authored-by: Andrew Yong <me@ndoo.sg> Co-authored-by: Jake-B <jake-b@users.noreply.github.com> Co-authored-by: Austin <vidplace7@gmail.com> Co-authored-by: Kalle Lilja <15094562+ThatKalle@users.noreply.github.com>
2024-12-22 04:02:50 +00:00
extern INA226Sensor ina226Sensor;
extern INA260Sensor ina260Sensor;
extern INA3221Sensor ina3221Sensor;
#endif
#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
#include "modules/Telemetry/Sensor/MAX17048Sensor.h"
extern MAX17048Sensor max17048Sensor;
#endif
2024-06-16 06:24:36 +00:00
#if HAS_RAKPROT && !defined(ARCH_PORTDUINO)
2024-06-16 11:45:17 +00:00
#include "../variants/rak2560/RAK9154Sensor.h"
2024-06-16 06:24:36 +00:00
extern RAK9154Sensor rak9154Sensor;
#endif
Finish powermon/powerstress (#4230) * Turn off vscode cmake prompt - we don't use cmake on meshtastic * Add rak4631_dap variant for debugging with NanoDAP debug probe device. * The rak device can also run freertos (which is underneath nrf52 arduino) * Add semihosting support for nrf52840 devices Initial platformio.ini file only supports rak4630 Default to non TCP for the semihosting log output for now... Fixes https://github.com/meshtastic/firmware/issues/4135 * powermon WIP (for https://github.com/meshtastic/firmware/issues/4136 ) * oops - mean't to mark the _dbg variant as an 'extra' board. * powermon wip * Make serial port on wio-sdk-wm1110 board work By disabling the (inaccessible) adafruit USB * Instrument (radiolib only for now) lora for powermon per https://github.com/meshtastic/firmware/issues/4136 * powermon gps support https://github.com/meshtastic/firmware/issues/4136 * Add CPU deep and light sleep powermon states https://github.com/meshtastic/firmware/issues/4136 * Change the board/swversion bootstring so it is a new "structured" log msg. * powermon wip * add example script for getting esp S3 debugging working Not yet used but I didn't want these nasty tricks to get lost yet. * Add PowerMon reporting for screen and bluetooth pwr. * make power.powermon_enables config setting work. * update to latest protobufs * fix bogus shellcheck warning * make powermon optional (but default enabled because tiny and no runtime impact) * tell vscode, if formatting, use whatever our trunk formatter wants without this flag if the user has set some other formatter (clang) in their user level settings, it will be looking in the wrong directory for the clang options (we want the options in .trunk/clang) Note: formatOnSave is true in master, which means a bunch of our older files are non compliant and if you edit them it will generate lots of formatting related diffs. I guess I'll start letting that happen with my future commits ;-). * add PowerStress module * nrf52 arduino is built upon freertos, so let platformio debug it * don't accidentally try to Segger ICE if we are using another ICE * clean up RedirectablePrint::log so it doesn't have three very different implementations inline. * remove NoopPrint - it is no longer needed * when talking to API clients via serial, don't turn off log msgs instead encapsuate them * fix the build - would loop forever if there were no files to send * don't use Segger code if not talking to a Segger debugger * when encapsulating logs, make sure the strings always has nul terminators * nrf52 soft device will watchdog if you use ICE while BT on... so have debugger disable bluetooth. * Important to not print debug messages while writing to the toPhone scratch buffer * don't include newlines if encapsulating log records as protobufs * update to latest protobufs (needed for powermon goo) * PowerStress WIP * for #4154 and #4136 add concept of dependent gpios... Which is currently only tested with the LED but eventually will be used for shared GPIO/screen power rail enable and LED forcing (which is a sanity check in the power stress testing) * fix linter warning * Transformer is a better name for the LED input > operation > output classes * PMW led changes to work on esp32-s3 * power stress improvements * allow ble logrecords to be fetched either by NOTIFY or INDICATE ble types This allows 'lossless' log reading. If client has requested INDICATE (rather than NOTIFY) each log record emitted via log() will have to fetched by the client device before the meshtastic node can continue. * Fix serious problem with nrf52 BLE logging. When doing notifies of LogRecords it is important to use the binary write routines - writing using the 'string' write won't work. Because protobufs can contain \0 nuls inside of them which if being parsed as a string will cause only a portion of the protobuf to be sent. I noticed this because some log messages were not getting through. * fix gpio transformer stuff to work correctly with LED_INVERTED Thanks @todd-herbert for noticing this and the great stack trace. The root cause was that I had accidentially shadowed outPin in a subclass with an unneeded override. It would break on any board that had inverted LED power. fixes https://github.com/meshtastic/firmware/pull/4230#pullrequestreview-2217389099 * Support driving multiple output gpios from one input. While investigating https://github.com/meshtastic/firmware/pull/4230#pullrequestreview-2217389099 I noticed in variant.h that there are now apparently newer TBEAMs than mine that have _both_ a GPIO based power LED and the PMU based LED. Add a splitter so that we can drive two output GPIOs from one logical signal. --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
2024-08-06 17:35:54 +00:00
#ifdef HAS_PMU
#include "XPowersAXP192.tpp"
#include "XPowersAXP2101.tpp"
#include "XPowersLibInterface.hpp"
extern XPowersLibInterface *PMU;
#endif
class Power : private concurrency::OSThread
{
2024-06-16 14:29:45 +00:00
public:
Observable<const meshtastic::PowerStatus *> newStatus;
2024-06-16 14:29:45 +00:00
Power();
2024-06-16 14:29:45 +00:00
void shutdown();
void readPowerStatus();
virtual bool setup();
virtual int32_t runOnce() override;
void setStatusHandler(meshtastic::PowerStatus *handler) { statusHandler = handler; }
const uint16_t OCV[11] = {OCV_ARRAY};
2024-06-16 14:29:45 +00:00
protected:
meshtastic::PowerStatus *statusHandler;
2024-06-16 14:29:45 +00:00
/// Setup a xpowers chip axp192/axp2101, return true if found
bool axpChipInit();
/// Setup a simple ADC input based battery sensor
bool analogInit();
/// Setup a Lipo battery level sensor
bool lipoInit();
2024-06-16 14:29:45 +00:00
private:
// open circuit voltage lookup table
uint8_t low_voltage_counter;
2023-01-21 13:34:29 +00:00
#ifdef DEBUG_HEAP
2024-06-16 14:29:45 +00:00
uint32_t lastheap;
2022-12-21 12:36:38 +00:00
#endif
};
Detect charging status by measuring current flow with configured INA battery sensor (#5271) * INA219 charging detection minimal implementation: if there is a configured INA219 sensor for battery monitoring we can take the current flow across the shunt resistor to know if we are charging the battery - negative milliamps indicate charging * Update Power.cpp added comments and 2 extra defines to disable and swap detection direction * Update Power.cpp fix disabled case * move getCurrentMa() to new CurrentSensor class * INA219 charging detection minimal implementation: if there is a configured INA219 sensor for battery monitoring we can take the current flow across the shunt resistor to know if we are charging the battery - negative milliamps indicate charging * Update Power.cpp added comments and 2 extra defines to disable and swap detection direction * Update Power.cpp fix disabled case * move getCurrentMa() to new CurrentSensor class * add INA3221 charging detection * RP2040: Update core; add mDNS support (#5355) * Update arduino-pico core * RP2040: Add mDNS support * SimpleMDNS `begin` now returns a bool * Add `-g` option to `debug_build_flags` to link files for gdb * RAK11310 needs old platform as well * Change defines to specific architecture * Core version 4.2.1 is out * Add sudo to apt-get commands for Raspbian Build (#5364) Without sudo, inadequate permissions to runs the commands meant the build was failing. * Typo fix in build_raspbian.yml (#5365) s/sudp/sudo :(:(:( * Rework some things * Trunk * Separate littlefs bundle * version tags * Diag * Add littlefswebui * Bug fixed in ExternalNotificationModule (#5375) While `nagging` setExternalState wasn't written to Buzzer & Vibra so output was never toggled. Possible fix for #5348 * Cleanup static files from bad Web UI bundle on 2.5.13 release (#5376) * Cleanup static files from bad Web UI bundle on 2.5.13 release * Check existence first * Esp32 is the only one we care about * Move some actions to after `startTransmit()` (#5383) To minimize the time between channel scan and actual transmit * [create-pull-request] automated change (#5380) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Allows all 3 PKI keys to be added to userPrefs.h (#4969) and a tool. (#5368) * more userPrefs.h Added PKI Admin keys to userPrefs.h * Update userPrefs.h Allows all 3 PKI keys to be added to userPrefs.h (#4969) * Update NodeDB.cpp Trunk * Update userPrefs.h Changed wording * Create base64_to_hex.py A little tool for converting base64 PKI Keys to decoded byte that userPrefs.h can understand. * more userPrefs.h Added PKI Admin keys to userPrefs.h * Update userPrefs.h Allows all 3 PKI keys to be added to userPrefs.h (#4969) * Update NodeDB.cpp Trunk * Update userPrefs.h Changed wording * Create base64_to_hex.py A little tool for converting base64 PKI Keys to decoded byte that userPrefs.h can understand. * [create-pull-request] automated change (#5388) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * add smiley emoji (#5391) * add smiley emoji * clang-formatted * Anable trace route function on wismeshtap platform (#5389) * fix 'symbal' typo (#5395) * [create-pull-request] automated change (#5399) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * /api/v1/fromradio: add OPTIONS handler for CORS. (#5386) This avoids hitting the 404 Not Found handler, which breaks connection keep-alive, so this change fixes a big performance regression for Web Client in Chrome: https://github.com/meshtastic/firmware/issues/5385 Tested on Heltec V3. Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Make heart emoji usable (#5403) * Create a specific hw_model for WisMesh Tap (#5400) * Create a specific hw_model for WisMesh Tap * Trunk * HAS_ETHERNET * Remove it altogether * Don't need these either * Fix RTC time injection and consolidate position logic (#5396) * Fix RTC time injection and consolidate position logic * Comment out unused var warning * Backerds * Update arduino-pico core to fix sporadic hangs (#5406) * Update platform-raspberrypi also (#5407) * Update arduino-pico core to fix sporadic hangs * Update platform-raspberrypi also * --web added to device-install(.sh/.bat) (#5405) * Add --web * Update device-install.bat Forgot a "-" a few places. --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * add GPS in indicator board (#5411) * Fixed NMEA sentence issue in CalTopo as well as bug with no printing all of the nodes (#5412) * --web littlefswebui-* typo fix (#5416) * Add --web * Update device-install.bat Forgot a "-" a few places. * Typo fix. * Typo fix --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com> * Temporarily disable MDNS when MQTT is enabled (#5418) Leads to a panic * Check for OkToMqtt flag presence before uplinking to MQTT (#5413) * Check for oktomqtt flag presence before uplinking to MQTT * Move to mqtt->onSend * Temetry can respond to want-response for LocalStats variant (#5414) * Seems like the last DIY board that's not "extra" (#5420) * Cherry pick tdeck fixes (#5422) * Try-fix (workaround) T-Deck audio crash * set T-Deck audio to unused 48 (mem mclk) * swap mclk to gpio 21 * dreamcatcher: assign GPIO44 to audio mclk --------- Co-authored-by: mverch67 <manuel.verch@gmx.de> * add canned message and keyboard in indicator board (#5410) * add canned message and keyboard in indicator board * Added virtual keyboard macro and enabled for Indicator * Cleanup macros by applying USE_VIRTUAL_KEYBOARD and DISPLAY_CLOCK_FRAME --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Update build-native.sh (#5415) * Update build-native.sh Device-install.sh and device-update.sh are not used on native platform, skip copying to release directory after build and copy native-install.sh and native-run.sh instead. * Update build-native.sh Skip native-run.sh copy * Cleans up visibility in GPS.h (#5426) Signed-off-by: Christopher Hoover <ch@murgatroid.com> * Fix admin key loading from userPrefs.h (#5417) * Fix LED pinout for T-Echo board marked v1.0, date 2021-6-28 * Merge PR #420 * Fixed double and missing Default class. * Use correct format specifier and fixed typo. * Removed duplicate code. * Fix error: #if with no expression * Fix warning: extra tokens at end of #endif directive. * Fix antenna switching logic. Complementary-pin control logic is required on the rp2040-lora board. * Fix deprecated macros. * Set RP2040 in dormant mode when deep sleep is triggered. * Fix array out of bounds read. * Admin key count needs to be set otherwise the key will be zero loaded after reset. * Don't reset the admin key size when loading defaults. Preserve an existing key in config if possible. * Remove log spam when reading INA voltage sensor. * Remove static declaration for admin keys from userPrefs.h. Load hard coded admin keys in case config file has empty slots. * Removed newlines from log. --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com> * try to detect dfrobot station to tell it apart from an ublox gps. (#5393) * Remove BMA-423 and STK8X by default (#5429) * Remove BMA-423 by default * STK * Wrong macro * Helps if you include the file * [create-pull-request] automated change (#5431) Co-authored-by: caveman99 <25002+caveman99@users.noreply.github.com> * Support for the ClimateGuard RadSens Geiger-Muller tube (#5425) * fixes https://github.com/meshtastic/firmware/issues/5434 (#5435) * update libpax * fix interval init * Fix memory leaks by adding missing `free()` calls before early returns in `MQTT::onReceive` (#5439) This fix addresses memory leaks in the `MQTT::onReceive` function by ensuring that dynamically allocated resources (`e.channel_id`, `e.gateway_id` and `e.packet`) are properly freed before each early return. Previously, these resources were only freed at the end of the function, leaving them unhandled in certain exit paths. Adding the missing `free()` calls prevents memory leaks and ensures proper resource cleanup in all scenarios. * Removing 1.0 legacy boards from releases and completely removing Heltec wireless capsule from support (#5436) Co-authored-by: Tom Fifield <tom@tomfifield.net> * A second round of cleanup on GPS.h. (#5433) * Move yet more stuff out of GPS.h and into file scope. * Protect code macros from eating semicolons. * Remove unused (and unimplemented) getDOPString. * clang-format with project style file on affected files. Signed-off-by: Christopher Hoover <ch@murgatroid.com> * enable MQTT with TLS on RPi picow (#5442) Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Don't powersave on Wifi (#5443) * Don't go into light sleep with wifi enabled * Move * Trunk * Revert "Seems like the last DIY board that's not "extra" (#5420)" (#5446) This reverts commit e6fb6b115aebb12b31fb93ed9d1508a6109b2f03. * Actually gunzip all the files when building a .deb (#5449) * [create-pull-request] automated change (#5457) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Cleanup i2c scan logs and macro to save some bytes and remain consistent (#5455) * Cleanup i2c scan logs and macro to save some bytes and remain consistent * Functions are better than macros * Exclude i2c scan for STM32 * Useless log * Clean up some inline functions (#5454) * Use isWithinTimespanMs to avoid refererence to NodeDb instance inside of NodeDb (#5453) * fix cors for meshtasticd to allow use of cross origin clients (#5463) * Remove ATECC crypto chip placeholder code (#5461) * GPS.h cleanups round 3. (#5447) * GPS.h cleanups round 3. No effective behavior change. Protected members can be private so make it so. (Supporting subclasses needs a lot more work.) Moves uBloxGnssModelInfo into file scope. Moves uBloxProtocolVersion into uBloxGnssModelInfo. Moves baud rate arrays into file scope. Removes unused/ unimplemented powerStateToString. Signed-off-by: Christopher Hoover <ch@murgatroid.com> * Trunk Format. --------- Signed-off-by: Christopher Hoover <ch@murgatroid.com> Co-authored-by: Tom Fifield <tom@tomfifield.net> * Fix ukrainian fonts (#5468) * FIX: rollback to !4624 * UPDATE: new 16 and 24 UA Fonts and fixes * fix: Solve the lightsleep crash problem via disable lightsleep for indicator. (#5470) * Trunk * Warnings and log cleanup (#5472) * Don't log if keyboard not found * Signed comparison issue * [create-pull-request] automated change (#5475) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Adds libusb dev package to Raspbian build steps (#5480) * [create-pull-request] automated change (#5478) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Portduino fixes (#5479) * Set config.yaml defaults even if General is missing * Unsigned values should get %u in logging * Update arduino-pico core and remove MDNS restriction (#5483) * Update xiao_esp32 fully support L67K (#5488) L67K module hardware changed * Convert userprefs to a json file instead of header file which has to be included everywhere (#5471) * WIP * Got string quoting and macro expansion working * Need the placeholder * Cleanup * Missed a user prefs reference * Update jsonc * SimRadio: clean-up and emulate collisions (#5487) * Clean up SimRadio and don't let it use PKC * Add collision emulation for SimRadio * Add stats from SimRadio to LocalStats * Make emulating collisions optional * add nodeId to nodeinfo update log lines and removed redundant nodeinfo update log line (#5493) * Refact the macro definition of GPS initialization of GPSDEFAULTD_NOT_PRESENT and added seeeed Indicator to this sequence (#5494) Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Extend Length of Source and Destination Node IDs Logged (#5492) * show 8 chars for logging source and destination ids * extend legnth of source and destination nodes in log * Added femtofox configs (#5477) * added femtofox configs * Rename bin/config.d/femtofox_Waveshare-SX126X-XXXM_AI-Thinker-RA-01SH.yaml to bin/config.d/femtofox/femtofox_Waveshare-SX126X-XXXM_AI-Thinker-RA-01SH.yaml * moved femtofox configs to subdir * [Add] LR1110, LR1120 and LR1121 to linux native Portduino (#5496) * Update main.cpp * Update PortduinoGlue.h * Update PortduinoGlue.cpp * Update PortduinoGlue.cpp * Update PortduinoGlue.cpp * Update main.cpp * [create-pull-request] automated change (#5500) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Fix minor typos in package workflows (#5505) * Don't use channel index for encrypted packet (#5509) * Don't use channel index for encrypted packet * Remove assert in `getKey`, set invalid key length So encrypting will fail without reboot * Reset channel to 0 when unable to encrypt Such that the NAK doesn't use the failing channel hash * Always Announce MDNS meshtastic service (#5503) * refactor server api port into define * always announce MDNS meshtastic service * fix nodeDB erase loop when free mem returns invalid value (0, -1). (#5519) Co-authored-by: mverch67 <manuel.verch@gmx.de> * Add heltec capsule back * Revert "Add heltec capsule back" This reverts commit fc16d9342116235fa86cf6ac163b17125bb4b50e. * Lets try this again minus device ui * Add popular nrf52 pro micro to the builds (#5523) * Add MACAddress to config.yaml (#5506) * Add MACAddress to config.yaml * Better error handling on native, including failing to launch with blank MAC Address and real hardware. * Re-arrange Mac Address handling and add MACAddressSource * Bump portduino to remove macaddr function there --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> * Configure Seeed Xiao S3 RX enable pin (#5517) * Create OpenWRT_One_mikroBUS_sx1262.yaml (#5529) * tlora_v2_1_16: Unset BUTTON_PIN and BUTTON_NEED_PULLUP (#5535) Unset BUTTON_PIN and BUTTON_NEED_PULLUP as the board ships without a user button. Devices and users expecting a button on GPIO12 have to set [GPIO for user button](https://meshtastic.org/docs/configuration/radio/device/#gpio-for-user-button) to 12 (or any GPIO pin the momentary switch was connected to) to restore functionality. Signed-off-by: Andrew Yong <me@ndoo.sg> * [create-pull-request] automated change (#5530) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Fix detection for some RadSens hardware versions (#5542) Co-authored-by: Jake-B <jake-b@users.noreply.github.com> * Initialize dmac array to nulls (#5538) * Initialize dmac array to nulls * Use std::cout for print before console is init. * Update OpenWRT_One_mikroBUS_sx1262.yaml (#5544) * Add portduino-buildroot variant (#5540) * Add portduino-buildroot variant * Update platform-native for platform-buildroot * portduino-buildroot: Define c standard (#5547) * Portduino: Move meshtasticd/web out of /usr/share/doc/ (#5548) * Portduino: fix transitional symlinks (#5550) * Windows Support - Trunk and Platformio (#5397) (#5518) * Add support for GPG * Add usb device support * Add trunk.io to devcontainer * Trunk things * trunk fmt * formatting * fix trivy/DS002, checkov/CKV_DOCKER_3 * hide docker extension popup * fix trivy/DS026, checkov/CKV_DOCKER_2 Co-authored-by: Kalle Lilja <15094562+ThatKalle@users.noreply.github.com> * Synch minor changes from TFT branch (#5520) * Synch minor changes from TFT branch Includes: * New nordicnrf52 minor version (10.5.0 --> 10.6.0) * Optimisations for T_DECK * preparation for MESH_TAB * add ext notification module to portduino --------- Co-authored-by: mverch67 <manuel.verch@gmx.de> * DIO3_TCXO_VOLTAGE in config.yaml can now take an exact voltage (#5558) * Support TLORA_V3.0 (#5563) - Support TLORA_V3.0. Update of the legendary 2.1_1.6.1 with solar charger, TCXO and IPEX connector. - 'extra' some short-lived EOL intermediate boards in that range. If possible use T3S3 instead of all of these! - update trunk to latest version * Create OpenWRT-One-mikroBUS-LR-IOT-CLICK.yaml (#5564) * Portduino: fix setting hwId via argument (#5565) * INA219 charging detection minimal implementation: if there is a configured INA219 sensor for battery monitoring we can take the current flow across the shunt resistor to know if we are charging the battery - negative milliamps indicate charging * Update Power.cpp added comments and 2 extra defines to disable and swap detection direction * Trunk Fixes * Add INA226 support --------- Signed-off-by: Christopher Hoover <ch@murgatroid.com> Signed-off-by: Andrew Yong <me@ndoo.sg> Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz> Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Co-authored-by: Tom Fifield <tom@tomfifield.net> Co-authored-by: Michael Gjelsø <36234524+gjelsoe@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> Co-authored-by: jcyrio <50239349+jcyrio@users.noreply.github.com> Co-authored-by: Daniel.Cao <144674500+DanielCao0@users.noreply.github.com> Co-authored-by: Catalin Patulea <cronos586@gmail.com> Co-authored-by: dylanli <dylan3000dylan@gmail.com> Co-authored-by: mverch67 <manuel.verch@gmx.de> Co-authored-by: madeofstown <33820964+madeofstown@users.noreply.github.com> Co-authored-by: Christopher Hoover <ch@murgatroid.com> Co-authored-by: Mictronics <github@mictronics.de> Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com> Co-authored-by: caveman99 <25002+caveman99@users.noreply.github.com> Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com> Co-authored-by: César de Tassis Filho <CTassisF@users.noreply.github.com> Co-authored-by: Tomas Dubec <tomas.dubec@gmail.com> Co-authored-by: Liam Cottle <liam@liamcottle.com> Co-authored-by: panaceya <panaceya@users.noreply.github.com> Co-authored-by: virgil <virgil.wang.cj@gmail.com> Co-authored-by: Robert <r@rbrt.io> Co-authored-by: noon92 <40807970+noon92@users.noreply.github.com> Co-authored-by: Mark Trevor Birss <markbirss@gmail.com> Co-authored-by: broglep <20624281+broglep@users.noreply.github.com> Co-authored-by: Matthias Granberry <matthias.granberry@gmail.com> Co-authored-by: Andrew Yong <me@ndoo.sg> Co-authored-by: Jake-B <jake-b@users.noreply.github.com> Co-authored-by: Austin <vidplace7@gmail.com> Co-authored-by: Kalle Lilja <15094562+ThatKalle@users.noreply.github.com>
2024-12-22 04:02:50 +00:00
extern Power *power;