@@ -437,21 +437,8 @@ void EnvironmentSensorManager::initBasicGPS() {
437437 #endif
438438
439439 // Try to detect if GPS is physically connected to determine if we should expose the setting
440- #ifdef PIN_GPS_EN
441- pinMode (PIN_GPS_EN, OUTPUT);
442- #ifdef PIN_GPS_EN_ACTIVE
443- digitalWrite (PIN_GPS_EN, PIN_GPS_EN_ACTIVE); // Power on GPS
444- #else
445- digitalWrite (PIN_GPS_EN, HIGH); // Power on GPS
446- #endif
447- #endif
448-
449- #ifdef PIN_GPS_RESET
450- pinMode (PIN_GPS_RESET, OUTPUT);
451- digitalWrite (PIN_GPS_RESET, PIN_GPS_RESET_ACTIVE); // assert for 10ms
452- delay (10 );
453- digitalWrite (PIN_GPS_RESET, !PIN_GPS_RESET_ACTIVE);
454- #endif
440+ _location->begin ();
441+ _location->reset ();
455442
456443 #ifndef PIN_GPS_EN
457444 MESH_DEBUG_PRINTLN (" No GPS wake/reset pin found for this board. Continuing on..." );
@@ -472,16 +459,12 @@ void EnvironmentSensorManager::initBasicGPS() {
472459 } else {
473460 MESH_DEBUG_PRINTLN (" No GPS detected" );
474461 }
475- #ifdef PIN_GPS_EN
476- #ifdef PIN_GPS_EN_ACTIVE
477- digitalWrite (PIN_GPS_EN, !PIN_GPS_EN_ACTIVE);
478- #else
479- digitalWrite (PIN_GPS_EN, LOW); // Power off GPS until the setting is changed
480- #endif
481- #endif
462+ _location->stop ();
482463 gps_active = false ; // Set GPS visibility off until setting is changed
483464}
484465
466+ // gps code for rak might be moved to MicroNMEALoactionProvider
467+ // or make a new location provider ...
485468#ifdef RAK_WISBLOCK_GPS
486469void EnvironmentSensorManager::rakGPSInit (){
487470
@@ -561,27 +544,13 @@ void EnvironmentSensorManager::start_gps() {
561544 digitalWrite (gpsResetPin, HIGH);
562545 return ;
563546 #endif
564- #ifdef PIN_GPS_EN
565- pinMode (PIN_GPS_EN, OUTPUT);
566- #ifdef PIN_GPS_EN_ACTIVE
567- digitalWrite (PIN_GPS_EN, PIN_GPS_EN_ACTIVE);
568- #else
569- digitalWrite (PIN_GPS_EN, HIGH);
570- #endif
571- #ifndef PIN_GPS_RESET
572- return ;
573- #endif
574- #endif
575547
576- #ifdef PIN_GPS_RESET
577- pinMode (PIN_GPS_RESET, OUTPUT);
578- digitalWrite (PIN_GPS_RESET, PIN_GPS_RESET_ACTIVE); // assert for 10ms
579- delay (10 );
580- digitalWrite (PIN_GPS_RESET, !PIN_GPS_RESET_ACTIVE);
581- return ;
582- #endif
548+ _location->begin ();
549+ _location->reset ();
583550
551+ #ifndef PIN_GPS_RESET
584552 MESH_DEBUG_PRINTLN (" Start GPS is N/A on this board. Actual GPS state unchanged" );
553+ #endif
585554}
586555
587556void EnvironmentSensorManager::stop_gps () {
@@ -591,17 +560,12 @@ void EnvironmentSensorManager::stop_gps() {
591560 digitalWrite (gpsResetPin, LOW);
592561 return ;
593562 #endif
594- #ifdef PIN_GPS_EN
595- pinMode (PIN_GPS_EN, OUTPUT);
596- #ifdef PIN_GPS_EN_ACTIVE
597- digitalWrite (PIN_GPS_EN, !PIN_GPS_EN_ACTIVE);
598- #else
599- digitalWrite (PIN_GPS_EN, LOW);
600- #endif
601- return ;
602- #endif
603563
564+ _location->stop ();
565+
566+ #ifndef PIN_GPS_EN
604567 MESH_DEBUG_PRINTLN (" Stop GPS is N/A on this board. Actual GPS state unchanged" );
568+ #endif
605569}
606570
607571void EnvironmentSensorManager::loop () {
0 commit comments