Files
meshcore-tth/src/helpers/sensors/EnvironmentSensorManager.h
T
tthandClaude Opus 5.5 36de0d92cd Merge remote-tracking branch 'origin/dev' into main
77 upstream commitů (8.–23. 9. 2026): MyMesh::Listener místo UITask,
Board::handleCommand + board.loop() hook, agc.reset.interval, validace
`set af`, CMD_SEND_CHANNEL_DATA gate, DC-DC na LR1110/LR1121, nové desky.

Konflikty:
- simple_repeater/main.cpp: náš BLE vstup konzole + upstream oprava
  plného bufferu (\r na size-2, NUL na konci)
- platformio.ini: zůstává ${nrf52_fw.pkg} (pin je shodný s upstreamem)
- TxtDataHelpers.cpp: upstream verze (ltoa + include api/itoa.h) místo
  našeho sprintf — řeší totéž STM32 selhání
- EnvironmentSensorManager.h: obě metody

Postaveno: SenseCap_Solar_repeater_ble, SenseCap_hreb_rpt,
SenseCap_ples_rpt, Xiao_x1_rpt, Xiao_x2_cmp, T1000E_cmp_cz. Neflashováno.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 18:35:35 +02:00

65 lines
2.1 KiB
C++

#pragma once
#include <Mesh.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/LocationProvider.h>
class EnvironmentSensorManager : public SensorManager {
protected:
static const int MAX_ACTIVE_SENSORS = 16;
// Query function pointer + sub-channel index (for multi-channel sensors like INA3221).
// Sub-channel is 0 for all single-output sensors.
struct ActiveSensor {
void (*query)(uint8_t channel, uint8_t sub_channel, CayenneLPP& telemetry);
uint8_t sub_channel;
};
ActiveSensor _active_sensors[MAX_ACTIVE_SENSORS];
int _active_sensor_count = 0;
uint8_t next_available_channel = TELEM_CHANNEL_SELF + 1;
bool gps_detected = false;
bool gps_active = false;
uint32_t gps_update_interval_sec = 1;
#if ENV_INCLUDE_GPS
// Duty-cycle state. `gps_duty` is the mode; `gps_active` stays the truth
// about the receiver being powered, so everything that already reads it
// (telemetry, settings) keeps working unchanged.
bool gps_duty = false;
uint32_t gps_wake_at = 0; // millis of the next sync attempt
uint32_t gps_awake_until = 0; // millis the current attempt gives up at
LocationProvider* _location;
void start_gps();
void stop_gps();
void gpsDutyLoop();
void initBasicGPS();
#ifdef RAK_BOARD
void rakGPSInit();
bool gpsIsAwake(uint8_t ioPin);
#endif
#endif
public:
#if ENV_INCLUDE_GPS
EnvironmentSensorManager(LocationProvider &location): _location(&location){};
LocationProvider* getLocationProvider() { return _location; }
void requestLocationRefresh() override;
bool isGPSDetected() const override { return gps_detected; }
#else
EnvironmentSensorManager(){};
#endif
bool begin() override;
bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) override;
#if ENV_INCLUDE_GPS || defined(ENV_INCLUDE_BME680_BSEC)
void loop() override;
#endif
int getNumSettings() const override;
const char* getSettingName(int i) const override;
const char* getSettingValue(int i) const override;
bool setSettingValue(const char* name, const char* value) override;
int scanI2C(char* dest, size_t max_len) override;
};