1- #include < Arduino.h>
21#include " target.h"
2+
3+ #include < Arduino.h>
34#include < helpers/ArduinoHelpers.h>
5+
6+ #ifdef ENV_INCLUDE_GPS
47#include < helpers/sensors/MicroNMEALocationProvider.h>
8+ #endif
59
610T114Board board;
711
12+ #if defined(P_LORA_SCLK)
813RADIO_CLASS radio = new Module(P_LORA_NSS , P_LORA_DIO_1 , P_LORA_RESET , P_LORA_BUSY , SPI );
14+ #else
15+ RADIO_CLASS radio = new Module(P_LORA_NSS , P_LORA_DIO_1 , P_LORA_RESET , P_LORA_BUSY );
16+ #endif
917
1018WRAPPER_CLASS radio_driver (radio, board);
1119
1220VolatileRTCClock fallback_clock;
1321AutoDiscoverRTCClock rtc_clock (fallback_clock);
14- MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
15- T114SensorManager sensors = T114SensorManager(nmea);
22+
23+ #if ENV_INCLUDE_GPS
24+ #include < helpers/sensors/MicroNMEALocationProvider.h>
25+ MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
26+ EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
27+ #else
28+ EnvironmentSensorManager sensors;
29+ #endif
1630
1731#ifdef DISPLAY_CLASS
18- DISPLAY_CLASS display;
19- MomentaryButton user_btn (PIN_USER_BTN , 1000 , true );
32+ DISPLAY_CLASS display;
33+ MomentaryButton user_btn (PIN_USER_BTN , 1000 , true );
2034#endif
2135
2236bool radio_init () {
2337 rtc_clock.begin (Wire);
2438
39+ #if defined(P_LORA_SCLK)
2540 return radio.std_init (&SPI );
41+ #else
42+ return radio.std_init ();
43+ #endif
2644}
2745
2846uint32_t radio_get_rng_seed () {
@@ -42,37 +60,5 @@ void radio_set_tx_power(uint8_t dbm) {
4260
4361mesh::LocalIdentity radio_new_identity () {
4462 RadioNoiseListener rng (radio);
45- return mesh::LocalIdentity (&rng); // create new random identity
46- }
47-
48- bool T114SensorManager::begin () {
49- Serial1.begin (9600 );
50-
51- // Try to detect if GPS is physically connected to determine if we should expose the setting
52- pinMode (PIN_GPS_EN , OUTPUT );
53- digitalWrite (PIN_GPS_EN , HIGH ); // Power on GPS
54-
55- // Give GPS a moment to power up and send data
56- delay (1500 );
57-
58- // We'll consider GPS detected if we see any data on Serial1
59- gps_detected = (Serial1.available () > 0 );
60-
61- if (gps_detected) {
62- MESH_DEBUG_PRINTLN (" GPS detected" );
63- } else {
64- MESH_DEBUG_PRINTLN (" No GPS detected" );
65- }
66- digitalWrite (PIN_GPS_EN , LOW ); // Power off GPS until the setting is changed
67-
68- return EnvironmentSensorManager::begin ();
69- }
70-
71- bool T114SensorManager::querySensors (uint8_t requester_permissions, CayenneLPP& telemetry) {
72- EnvironmentSensorManager::querySensors (requester_permissions, telemetry);
73-
74- if (requester_permissions & TELEM_PERM_LOCATION ) { // does requester have permission?
75- telemetry.addGPS (TELEM_CHANNEL_SELF , node_lat, node_lon, node_altitude);
76- }
77- return true ;
63+ return mesh::LocalIdentity (&rng); // create new random identity
7864}
0 commit comments