Restore Keymind features after LoRa OTA merge
This commit is contained in:
1 parent
4c0dbe707d
commit
4f8f36354e
45 files changed
+1320
-235
No files matched your search
@@ -689,9 +689,9 @@ bool EnvironmentSensorManager::begin() {
|
||||
bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) {
|
||||
next_available_channel = TELEM_CHANNEL_SELF + 1;
|
||||
|
||||
if (requester_permissions & TELEM_PERM_LOCATION && gps_active) {
|
||||
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
|
||||
}
|
||||
#if ENV_INCLUDE_GPS
|
||||
queryGpsTelemetry(requester_permissions, telemetry);
|
||||
#endif
|
||||
|
||||
if (requester_permissions & TELEM_PERM_ENVIRONMENT) {
|
||||
for (int i = 0; i < _active_sensor_count; i++) {
|
||||
@@ -726,7 +726,7 @@ const char* EnvironmentSensorManager::getSettingValue(int i) const {
|
||||
int settings = 0;
|
||||
#if ENV_INCLUDE_GPS
|
||||
if (gps_detected && i == settings++) {
|
||||
return gps_active ? "1" : "0";
|
||||
return isGpsTelemetryUserEnabled() ? "1" : "0";
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
@@ -735,11 +735,7 @@ const char* EnvironmentSensorManager::getSettingValue(int i) const {
|
||||
bool EnvironmentSensorManager::setSettingValue(const char* name, const char* value) {
|
||||
#if ENV_INCLUDE_GPS
|
||||
if (gps_detected && strcmp(name, "gps") == 0) {
|
||||
if (strcmp(value, "0") == 0) {
|
||||
stop_gps();
|
||||
} else {
|
||||
start_gps();
|
||||
}
|
||||
setGpsTelemetryUserEnabled(strcmp(value, "0") != 0);
|
||||
return true;
|
||||
}
|
||||
if (strcmp(name, "gps_interval") == 0) {
|
||||
@@ -784,6 +780,7 @@ void EnvironmentSensorManager::initBasicGPS() {
|
||||
MESH_DEBUG_PRINTLN("GPS detected");
|
||||
#ifdef PERSISTANT_GPS
|
||||
gps_active = true;
|
||||
setGpsTelemetryUserEnabled(true);
|
||||
return;
|
||||
#endif
|
||||
} else {
|
||||
@@ -876,6 +873,7 @@ bool EnvironmentSensorManager::gpsIsAwake(uint8_t ioPin){
|
||||
#endif
|
||||
|
||||
void EnvironmentSensorManager::start_gps() {
|
||||
if (gps_active) return;
|
||||
gps_active = true;
|
||||
#ifdef RAK_WISBLOCK_GPS
|
||||
pinMode(gpsResetPin, OUTPUT);
|
||||
@@ -911,32 +909,43 @@ void EnvironmentSensorManager::stop_gps() {
|
||||
void EnvironmentSensorManager::loop() {
|
||||
|
||||
#if ENV_INCLUDE_GPS
|
||||
static long next_gps_update = 0;
|
||||
static unsigned long next_gps_update = 0;
|
||||
unsigned long now = millis();
|
||||
loopGpsTelemetry(now);
|
||||
|
||||
if (gps_active) {
|
||||
_location->loop();
|
||||
}
|
||||
if (millis() > next_gps_update) {
|
||||
if ((long)(now - next_gps_update) >= 0) {
|
||||
|
||||
if(gps_active){
|
||||
#ifdef RAK_WISBLOCK_GPS
|
||||
if ((i2cGPSFlag || serialGPSFlag) && _location->isValid()) {
|
||||
node_lat = ((double)_location->getLatitude())/1000000.;
|
||||
node_lon = ((double)_location->getLongitude())/1000000.;
|
||||
float gps_lat = ((float)_location->getLatitude()) / 1000000.0f;
|
||||
float gps_lon = ((float)_location->getLongitude()) / 1000000.0f;
|
||||
float gps_altitude = ((float)_location->getAltitude()) / 1000.0f;
|
||||
node_lat = gps_lat;
|
||||
node_lon = gps_lon;
|
||||
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
|
||||
node_altitude = ((double)_location->getAltitude()) / 1000.0;
|
||||
node_altitude = gps_altitude;
|
||||
MESH_DEBUG_PRINTLN("lat %f lon %f alt %f", node_lat, node_lon, node_altitude);
|
||||
processGpsTelemetryFix(gps_lat, gps_lon, gps_altitude, now);
|
||||
}
|
||||
#else
|
||||
if (_location->isValid()) {
|
||||
node_lat = ((double)_location->getLatitude())/1000000.;
|
||||
node_lon = ((double)_location->getLongitude())/1000000.;
|
||||
float gps_lat = ((float)_location->getLatitude()) / 1000000.0f;
|
||||
float gps_lon = ((float)_location->getLongitude()) / 1000000.0f;
|
||||
float gps_altitude = ((float)_location->getAltitude()) / 1000.0f;
|
||||
node_lat = gps_lat;
|
||||
node_lon = gps_lon;
|
||||
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
|
||||
node_altitude = ((double)_location->getAltitude()) / 1000.0;
|
||||
node_altitude = gps_altitude;
|
||||
MESH_DEBUG_PRINTLN("lat %f lon %f alt %f", node_lat, node_lon, node_altitude);
|
||||
processGpsTelemetryFix(gps_lat, gps_lon, gps_altitude, now);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
next_gps_update = millis() + (gps_update_interval_sec * 1000);
|
||||
next_gps_update = now + (gps_update_interval_sec * 1000);
|
||||
}
|
||||
#endif
|
||||
#if ENV_INCLUDE_BME680_BSEC
|
||||
|
||||
Reference in new issue
Block a user