@@ -45,26 +45,12 @@ mesh::LocalIdentity radio_new_identity() {
4545 return mesh::LocalIdentity (&rng); // create new random identity
4646}
4747
48- void T114SensorManager::start_gps () {
49- if (!gps_active) {
50- gps_active = true ;
51- _location->begin ();
52- }
53- }
54-
55- void T114SensorManager::stop_gps () {
56- if (gps_active) {
57- gps_active = false ;
58- _location->stop ();
59- }
60- }
61-
6248bool T114SensorManager::begin () {
6349 Serial1.begin (9600 );
6450
6551 // Try to detect if GPS is physically connected to determine if we should expose the setting
66- pinMode (GPS_EN , OUTPUT );
67- digitalWrite (GPS_EN , HIGH ); // Power on GPS
52+ pinMode (PIN_GPS_EN , OUTPUT );
53+ digitalWrite (PIN_GPS_EN , HIGH ); // Power on GPS
6854
6955 // Give GPS a moment to power up and send data
7056 delay (1500 );
@@ -77,57 +63,16 @@ bool T114SensorManager::begin() {
7763 } else {
7864 MESH_DEBUG_PRINTLN (" No GPS detected" );
7965 }
80- digitalWrite (GPS_EN , LOW ); // Power off GPS until the setting is changed
66+ digitalWrite (PIN_GPS_EN , LOW ); // Power off GPS until the setting is changed
8167
82- return true ;
68+ return EnvironmentSensorManager::begin () ;
8369}
8470
8571bool T114SensorManager::querySensors (uint8_t requester_permissions, CayenneLPP& telemetry) {
72+ EnvironmentSensorManager::querySensors (requester_permissions, telemetry);
73+
8674 if (requester_permissions & TELEM_PERM_LOCATION ) { // does requester have permission?
8775 telemetry.addGPS (TELEM_CHANNEL_SELF , node_lat, node_lon, node_altitude);
8876 }
8977 return true ;
9078}
91-
92- void T114SensorManager::loop () {
93- static long next_gps_update = 0 ;
94-
95- _location->loop ();
96-
97- if (millis () > next_gps_update) {
98- if (_location->isValid ()) {
99- node_lat = ((double )_location->getLatitude ())/1000000 .;
100- node_lon = ((double )_location->getLongitude ())/1000000 .;
101- node_altitude = ((double )_location->getAltitude ()) / 1000.0 ;
102- MESH_DEBUG_PRINTLN (" lat %f lon %f" , node_lat, node_lon);
103- }
104- next_gps_update = millis () + 1000 ;
105- }
106- }
107-
108- int T114SensorManager::getNumSettings () const {
109- return gps_detected ? 1 : 0 ; // only show GPS setting if GPS is detected
110- }
111-
112- const char * T114SensorManager::getSettingName (int i) const {
113- return (gps_detected && i == 0 ) ? " gps" : NULL ;
114- }
115-
116- const char * T114SensorManager::getSettingValue (int i) const {
117- if (gps_detected && i == 0 ) {
118- return gps_active ? " 1" : " 0" ;
119- }
120- return NULL ;
121- }
122-
123- bool T114SensorManager::setSettingValue (const char * name, const char * value) {
124- if (gps_detected && strcmp (name, " gps" ) == 0 ) {
125- if (strcmp (value, " 0" ) == 0 ) {
126- stop_gps ();
127- } else {
128- start_gps ();
129- }
130- return true ;
131- }
132- return false ; // not supported
133- }
0 commit comments