Restore Keymind features after LoRa OTA merge

This commit is contained in:
mikecarper committed 2026-07-11 12:45:02 -07:00
1 parent 4c0dbe707d
commit 4f8f36354e
45 files changed
+1320 -235

No files matched your search

+15 -19
View File
@@ -55,25 +55,25 @@ bool ThinkNodeM1SensorManager::begin() {
// Check initial switch state to determine if GPS should be active
if (last_gps_switch_state == HIGH) { // Switch is HIGH when ON
start_gps();
setGpsTelemetryUserEnabled(true);
}
return true;
}
bool ThinkNodeM1SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) {
if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission?
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
}
queryGpsTelemetry(requester_permissions, telemetry);
return true;
}
void ThinkNodeM1SensorManager::loop() {
static long next_gps_update = 0;
static long last_switch_check = 0;
static unsigned long next_gps_update = 0;
static unsigned long last_switch_check = 0;
unsigned long now = millis();
loopGpsTelemetry(now);
// Check GPS switch state every second
if (millis() - last_switch_check > 1000) {
if (now - last_switch_check > 1000) {
bool current_switch_state = digitalRead(PIN_GPS_SWITCH);
// Detect switch state change
@@ -82,14 +82,14 @@ void ThinkNodeM1SensorManager::loop() {
if (current_switch_state == HIGH) { // Switch is ON
MESH_DEBUG_PRINTLN("GPS switch ON");
start_gps();
setGpsTelemetryUserEnabled(true);
} else { // Switch is OFF
MESH_DEBUG_PRINTLN("GPS switch OFF");
stop_gps();
setGpsTelemetryUserEnabled(false);
}
}
last_switch_check = millis();
last_switch_check = now;
}
if (!gps_active) {
@@ -98,14 +98,15 @@ void ThinkNodeM1SensorManager::loop() {
_location->loop();
if (millis() > next_gps_update) {
if ((long)(now - next_gps_update) >= 0) {
if (_location->isValid()) {
node_lat = ((double)_location->getLatitude())/1000000.;
node_lon = ((double)_location->getLongitude())/1000000.;
node_altitude = ((double)_location->getAltitude()) / 1000.0;
processGpsTelemetryFix(node_lat, node_lon, node_altitude, now);
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
}
next_gps_update = millis() + 1000;
next_gps_update = now + 1000;
}
}
@@ -119,20 +120,15 @@ const char* ThinkNodeM1SensorManager::getSettingName(int i) const {
const char* ThinkNodeM1SensorManager::getSettingValue(int i) const {
if (i == 0) {
return gps_active ? "1" : "0";
return isGpsTelemetryUserEnabled() ? "1" : "0";
}
return NULL;
}
bool ThinkNodeM1SensorManager::setSettingValue(const char* name, const char* value) {
if (strcmp(name, "gps") == 0) {
if (strcmp(value, "0") == 0) {
stop_gps();
} else {
start_gps();
}
setGpsTelemetryUserEnabled(strcmp(value, "0") != 0);
return true;
}
return false; // not supported
}