mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Merge pull request #820 from fdlamotte/gps_reset_fix
ESM: delegate gps management to LocationProvider
This commit is contained in:
commit
e5de6e6600
2 changed files with 38 additions and 58 deletions
|
|
@ -437,21 +437,8 @@ void EnvironmentSensorManager::initBasicGPS() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Try to detect if GPS is physically connected to determine if we should expose the setting
|
// Try to detect if GPS is physically connected to determine if we should expose the setting
|
||||||
#ifdef PIN_GPS_EN
|
_location->begin();
|
||||||
pinMode(PIN_GPS_EN, OUTPUT);
|
_location->reset();
|
||||||
#ifdef PIN_GPS_EN_ACTIVE
|
|
||||||
digitalWrite(PIN_GPS_EN, PIN_GPS_EN_ACTIVE); // Power on GPS
|
|
||||||
#else
|
|
||||||
digitalWrite(PIN_GPS_EN, HIGH); // Power on GPS
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PIN_GPS_RESET
|
|
||||||
pinMode(PIN_GPS_RESET, OUTPUT);
|
|
||||||
digitalWrite(PIN_GPS_RESET, PIN_GPS_RESET_ACTIVE); // assert for 10ms
|
|
||||||
delay(10);
|
|
||||||
digitalWrite(PIN_GPS_RESET, !PIN_GPS_RESET_ACTIVE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PIN_GPS_EN
|
#ifndef PIN_GPS_EN
|
||||||
MESH_DEBUG_PRINTLN("No GPS wake/reset pin found for this board. Continuing on...");
|
MESH_DEBUG_PRINTLN("No GPS wake/reset pin found for this board. Continuing on...");
|
||||||
|
|
@ -472,16 +459,12 @@ void EnvironmentSensorManager::initBasicGPS() {
|
||||||
} else {
|
} else {
|
||||||
MESH_DEBUG_PRINTLN("No GPS detected");
|
MESH_DEBUG_PRINTLN("No GPS detected");
|
||||||
}
|
}
|
||||||
#ifdef PIN_GPS_EN
|
_location->stop();
|
||||||
#ifdef PIN_GPS_EN_ACTIVE
|
|
||||||
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE);
|
|
||||||
#else
|
|
||||||
digitalWrite(PIN_GPS_EN, LOW); // Power off GPS until the setting is changed
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
gps_active = false; //Set GPS visibility off until setting is changed
|
gps_active = false; //Set GPS visibility off until setting is changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gps code for rak might be moved to MicroNMEALoactionProvider
|
||||||
|
// or make a new location provider ...
|
||||||
#ifdef RAK_WISBLOCK_GPS
|
#ifdef RAK_WISBLOCK_GPS
|
||||||
void EnvironmentSensorManager::rakGPSInit(){
|
void EnvironmentSensorManager::rakGPSInit(){
|
||||||
|
|
||||||
|
|
@ -561,27 +544,13 @@ void EnvironmentSensorManager::start_gps() {
|
||||||
digitalWrite(gpsResetPin, HIGH);
|
digitalWrite(gpsResetPin, HIGH);
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
#ifdef PIN_GPS_EN
|
|
||||||
pinMode(PIN_GPS_EN, OUTPUT);
|
|
||||||
#ifdef PIN_GPS_EN_ACTIVE
|
|
||||||
digitalWrite(PIN_GPS_EN, PIN_GPS_EN_ACTIVE);
|
|
||||||
#else
|
|
||||||
digitalWrite(PIN_GPS_EN, HIGH);
|
|
||||||
#endif
|
|
||||||
#ifndef PIN_GPS_RESET
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PIN_GPS_RESET
|
_location->begin();
|
||||||
pinMode(PIN_GPS_RESET, OUTPUT);
|
_location->reset();
|
||||||
digitalWrite(PIN_GPS_RESET, PIN_GPS_RESET_ACTIVE); // assert for 10ms
|
|
||||||
delay(10);
|
|
||||||
digitalWrite(PIN_GPS_RESET, !PIN_GPS_RESET_ACTIVE);
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#ifndef PIN_GPS_RESET
|
||||||
MESH_DEBUG_PRINTLN("Start GPS is N/A on this board. Actual GPS state unchanged");
|
MESH_DEBUG_PRINTLN("Start GPS is N/A on this board. Actual GPS state unchanged");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnvironmentSensorManager::stop_gps() {
|
void EnvironmentSensorManager::stop_gps() {
|
||||||
|
|
@ -591,17 +560,12 @@ void EnvironmentSensorManager::stop_gps() {
|
||||||
digitalWrite(gpsResetPin, LOW);
|
digitalWrite(gpsResetPin, LOW);
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
#ifdef PIN_GPS_EN
|
|
||||||
pinMode(PIN_GPS_EN, OUTPUT);
|
|
||||||
#ifdef PIN_GPS_EN_ACTIVE
|
|
||||||
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE);
|
|
||||||
#else
|
|
||||||
digitalWrite(PIN_GPS_EN, LOW);
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
_location->stop();
|
||||||
|
|
||||||
|
#ifndef PIN_GPS_EN
|
||||||
MESH_DEBUG_PRINTLN("Stop GPS is N/A on this board. Actual GPS state unchanged");
|
MESH_DEBUG_PRINTLN("Stop GPS is N/A on this board. Actual GPS state unchanged");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnvironmentSensorManager::loop() {
|
void EnvironmentSensorManager::loop() {
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,31 @@
|
||||||
#include <RTClib.h>
|
#include <RTClib.h>
|
||||||
|
|
||||||
#ifndef GPS_EN
|
#ifndef GPS_EN
|
||||||
#define GPS_EN (-1)
|
#ifdef PIN_GPS_EN
|
||||||
|
#define GPS_EN PIN_GPS_EN
|
||||||
|
#else
|
||||||
|
#define GPS_EN (-1)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PIN_GPS_EN_ACTIVE
|
||||||
|
#define PIN_GPS_EN_ACTIVE HIGH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef GPS_RESET
|
#ifndef GPS_RESET
|
||||||
#define GPS_RESET (-1)
|
#ifdef PIN_GPS_RESET
|
||||||
|
#define GPS_RESET PIN_GPS_RESET
|
||||||
|
#else
|
||||||
|
#define GPS_RESET (-1)
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef GPS_RESET_FORCE
|
#ifndef GPS_RESET_FORCE
|
||||||
#define GPS_RESET_FORCE LOW
|
#ifdef PIN_GPS_RESET_ACTIVE
|
||||||
|
#define GPS_RESET_FORCE PIN_GPS_RESET_ACTIVE
|
||||||
|
#else
|
||||||
|
#define GPS_RESET_FORCE LOW
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class MicroNMEALocationProvider : public LocationProvider {
|
class MicroNMEALocationProvider : public LocationProvider {
|
||||||
|
|
@ -40,25 +56,25 @@ public :
|
||||||
}
|
}
|
||||||
|
|
||||||
void begin() override {
|
void begin() override {
|
||||||
|
if (_pin_en != -1) {
|
||||||
|
digitalWrite(_pin_en, PIN_GPS_EN_ACTIVE);
|
||||||
|
}
|
||||||
if (_pin_reset != -1) {
|
if (_pin_reset != -1) {
|
||||||
digitalWrite(_pin_reset, !GPS_RESET_FORCE);
|
digitalWrite(_pin_reset, !GPS_RESET_FORCE);
|
||||||
}
|
}
|
||||||
if (_pin_en != -1) {
|
|
||||||
digitalWrite(_pin_en, HIGH);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset() override {
|
void reset() override {
|
||||||
if (_pin_reset != -1) {
|
if (_pin_reset != -1) {
|
||||||
digitalWrite(_pin_reset, GPS_RESET_FORCE);
|
digitalWrite(_pin_reset, GPS_RESET_FORCE);
|
||||||
delay(100);
|
delay(10);
|
||||||
digitalWrite(_pin_reset, !GPS_RESET_FORCE);
|
digitalWrite(_pin_reset, !GPS_RESET_FORCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void stop() override {
|
void stop() override {
|
||||||
if (_pin_en != -1) {
|
if (_pin_en != -1) {
|
||||||
digitalWrite(_pin_en, LOW);
|
digitalWrite(_pin_en, !PIN_GPS_EN_ACTIVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,4 +123,4 @@ public :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue