GPS support (experimental)
This commit is contained in:
parent
f5eb8cdc76
commit
485b4fb2f0
@ -53,8 +53,8 @@ typedef struct {
|
||||
typedef struct {
|
||||
float latitude;
|
||||
float longitude;
|
||||
float hdop;
|
||||
uint8_t satellites;
|
||||
uint16_t hdop;
|
||||
uint16_t altitude;
|
||||
} gpsStatus_t;
|
||||
extern gpsStatus_t gps_status; // struct for storing gps data
|
||||
|
@ -5,18 +5,16 @@
|
||||
// Local logging tag
|
||||
static const char TAG[] = "main";
|
||||
|
||||
// GPS read data to global struct
|
||||
// read GPS data and cast to global struct
|
||||
void gps_read(){
|
||||
gps_status.latitude = (float) gps.location.lat();
|
||||
gps_status.longitude = (float) gps.location.lng();
|
||||
gps_status.satellites = (uint8_t) gps.satellites.value();
|
||||
gps_status.hdop = (float) gps.hdop.value();
|
||||
gps_status.hdop = (uint16_t) gps.hdop.value();
|
||||
gps_status.altitude = (uint16_t) gps.altitude.meters();
|
||||
ESP_LOGI(TAG, "Lat: %f / Lon: %f", gps_status.latitude, gps_status.longitude);
|
||||
ESP_LOGI(TAG, "Sats: %d / HDOP: %f / Alti: %d", gps_status.satellites, gps_status.hdop, gps_status.altitude);
|
||||
}
|
||||
|
||||
/// GPS serial feed FreeRTos Task
|
||||
// GPS serial feed FreeRTos Task
|
||||
void gps_loop(void * pvParameters) {
|
||||
|
||||
configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check
|
||||
|
@ -138,7 +138,7 @@ void do_send(osjob_t* j){
|
||||
if (cfg.gpsmode && gps.location.isValid()) {
|
||||
gps_read();
|
||||
LMIC_setTxData2(GPSPORT, (byte*)&gps_status, sizeof(gps_status), (cfg.countermode & 0x02));
|
||||
ESP_LOGI(TAG, "HDOP=%d, SATS=%d, LAT=%d, LON=%d", gps_status.hdop, gps_status.satellites, gps_status.latitude, gps_status.longitude );
|
||||
ESP_LOGI(TAG, "HDOP=%d, SATS=%d, LAT=%f, LON=%f", gps_status.hdop, gps_status.satellites, gps_status.latitude, gps_status.longitude );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -470,6 +470,10 @@ void setup() {
|
||||
ESP_LOGI(TAG, "ESP32 SDK: %s", ESP.getSdkVersion());
|
||||
#endif
|
||||
|
||||
#ifdef HAS_GPS
|
||||
ESP_LOGI(TAG, "TinyGPS+ version %s", TinyGPSPlus::libraryVersion());
|
||||
#endif
|
||||
|
||||
// read settings from NVRAM
|
||||
loadConfig(); // includes initialize if necessary
|
||||
|
||||
@ -583,7 +587,7 @@ xTaskCreatePinnedToCore(sniffer_loop, "wifisniffer", 2048, ( void * ) 1, 1, NULL
|
||||
#ifdef HAS_GPS
|
||||
if (cfg.gpsmode) {
|
||||
ESP_LOGI(TAG, "Starting GPS task on core 0");
|
||||
xTaskCreatePinnedToCore(gps_loop, "gpsreader", 2048, ( void * ) 1, 1, NULL, 0);
|
||||
xTaskCreatePinnedToCore(gps_loop, "gpsfeed", 2048, ( void * ) 1, 1, NULL, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -262,14 +262,12 @@ void get_gps (uint8_t val) {
|
||||
#ifdef HAS_GPS
|
||||
gps_read();
|
||||
transmit((byte*)&gps_status, sizeof(gps_status));
|
||||
ESP_LOGI(TAG, "HDOP=%d, SATS=%d, LAT=%d, LON=%d", gps_status.hdop, gps_status.satellites, gps_status.latitude, gps_status.longitude );
|
||||
ESP_LOGI(TAG, "HDOP=%d, SATS=%d, LAT=%f, LON=%f", gps_status.hdop, gps_status.satellites, gps_status.latitude, gps_status.longitude );
|
||||
#else
|
||||
ESP_LOGE(TAG, "No GPS device present");
|
||||
ESP_LOGE(TAG, "GPS not present");
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
// assign previously defined functions to set of numeric remote commands
|
||||
// format: opcode, function, flag (1 = do make settings persistent / 0 = don't)
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user