Teseo Location demo for GPSProvider using ST GNSS driver.
Dependencies: GPS_Provider X_NUCLEO_GNSS1A1
Getting Started with X-NUCLEO-GNSS1A1
This example demonstrates how to use the X-NUCLEO-GNSS1A1 component with one of the STM32 Nucleo-64 platforms and how real time GNSS data received by the Teseo-LIV3F device can be displayed through a serial connection and a serial terminal on a PC. Furthermore the user can run commands enabling three advanced features:
- Geofencing
- Odometer
- Data Logging
Setup
Once the antenna has been connected to the SMA female connector of the X-NUCLEO-GNSS1A1 plugged on top of the STM32 Nucleo, a serial connection should be set up between the STM32 Nucleo and the PC with the following parameters:
- baud rate: 115200
- data: 8 bit
- parity: none
- stop: 1bit
- flow control: none
- New-line (Tx/Rx): CR
Serial connection parameters
The user can select among different options to:
- get in a human readable format information related to the acquired GNSS position (or the satellites in view, the active satellites, and so on)
- enable feature (geofencing, odometer, data logging)
- configure a geofence circle
- require geofence status
- start/stop feature (odometer, data logging)
Application menu
Revision 4:b67349d44157, committed 2021-01-14
- Comitter:
- apalmieri
- Date:
- Thu Jan 14 09:33:08 2021 +0000
- Parent:
- 3:df74e7673460
- Commit message:
- Get TeseoLocation program aligned with mbed-os-6.6.0
Changed in this revision
--- a/X_NUCLEO_GNSS1A1.lib Thu Feb 14 11:38:36 2019 +0000 +++ b/X_NUCLEO_GNSS1A1.lib Thu Jan 14 09:33:08 2021 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/teams/ST/code/X_NUCLEO_GNSS1A1/#9d0addf682f0 +https://os.mbed.com/teams/ST/code/X_NUCLEO_GNSS1A1/#1fe1ba1f0013
--- a/mbed-os.lib Thu Feb 14 11:38:36 2019 +0000 +++ b/mbed-os.lib Thu Jan 14 09:33:08 2021 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#ecb3c8c837162c73537bd0f3592c6e2a42994045 +https://github.com/ARMmbed/mbed-os/#84d991342a41011fc417aab62c0f5a8832f1d18f
--- a/source/main.cpp Thu Feb 14 11:38:36 2019 +0000 +++ b/source/main.cpp Thu Jan 14 09:33:08 2021 +0000 @@ -89,8 +89,8 @@ static int sAppCmd = APP_CMD_IDLE; static eGeofenceId geofenceId; -Serial serialDebug(DEBUG_TX_PIN, DEBUG_RX_PIN); -#define TESEO_APP_LOG_INFO(...) serialDebug.printf(__VA_ARGS__) +static BufferedSerial serialDebug(DEBUG_TX_PIN, DEBUG_RX_PIN, 115200); +#define TESEO_APP_LOG_INFO(...) printf(__VA_ARGS__) #define WARNING_NOT_RUN_MSG TESEO_APP_LOG_INFO("GNSS is not running. Please, type 'start' to make it runnable.\r\n"); #define WARNING_ALREADY_RUN_MSG TESEO_APP_LOG_INFO("GNSS is already running.\r\n"); @@ -99,6 +99,11 @@ static bool gnssRunning = false; static int level = 1; +FileHandle *mbed::mbed_override_console(int fd) +{ + return &serialDebug; +} + void locationHandler(const GPSProvider::LocationUpdateParams_t *params) { @@ -126,15 +131,16 @@ { static char cmd[32] = {0}; char ch; + char nl = '\n'; while(true) { while (!serialDebug.readable()) { - Thread::yield(); // Allow other threads to run + ThisThread::yield(); // Allow other threads to run } - ch = serialDebug.getc(); - serialDebug.putc(ch); + serialDebug.read(&ch, 1); + serialDebug.write((const void *)&ch, 1); if (ch == '\r') { - serialDebug.putc('\n'); + serialDebug.write((const void *)&nl, 1); if (strlen(cmd) > 0) { _AppCmdProcess(cmd); memset(cmd, 0, sizeof(cmd)); @@ -317,25 +323,22 @@ } else { TESEO_APP_LOG_INFO("get device info.\r\n"); if(gnss.haveDeviceInfo()) { - TESEO_APP_LOG_INFO(gnss.getDeviceInfo()); + TESEO_APP_LOG_INFO("%s", gnss.getDeviceInfo()); } TESEO_APP_LOG_INFO("\r\n"); } break; } - Thread::yield(); // Allow other threads to run + ThisThread::yield(); // Allow other threads to run } } int main() { Thread consoleThread; Thread cmdThread; - - consoleThread.set_priority(osPriorityIdle); - cmdThread.set_priority(osPriorityIdle); - serialDebug.format(8, Serial::None, 1); - serialDebug.baud(115200); + TESEO_APP_LOG_INFO("Starting GNSS...\r\n"); + consoleThread.start(_ConsoleRxHandler); gnss.reset(); @@ -344,9 +347,9 @@ _AppShowCmd(); cmdThread.start(_ExecAppCmd); - + while(1) { - Thread::yield(); + ThisThread::yield(); } } @@ -361,28 +364,28 @@ sprintf(msg,"Latitude:\t\t[ %.0f' %d'' ]\n\r", (lastLocation.lat - ((int)lastLocation.lat % 100)) / 100, ((int)lastLocation.lat % 100)); - TESEO_APP_LOG_INFO(msg); + TESEO_APP_LOG_INFO("%s", msg); sprintf(msg,"Longitude:\t\t[ %.0f' %d'' ]\n\r", (lastLocation.lon - ((int)lastLocation.lon % 100)) / 100, ((int)lastLocation.lon % 100)); - TESEO_APP_LOG_INFO(msg); + TESEO_APP_LOG_INFO("%s", msg); sprintf(msg,"Altitude:\t\t[ %.2f ]\n\r", lastLocation.altitude); - TESEO_APP_LOG_INFO(msg); + TESEO_APP_LOG_INFO("%s", msg); sprintf(msg,"Satellites locked:\t[ %d ]\n\r", lastLocation.numGPSSVs); - TESEO_APP_LOG_INFO(msg); + TESEO_APP_LOG_INFO("%s", msg); sprintf(msg, "UTC:\t\t\t[ %d ]\n\r", (int)lastLocation.utcTime); - TESEO_APP_LOG_INFO(msg); + TESEO_APP_LOG_INFO("%s", msg); } else { sprintf(msg, "Last position wasn't valid.\n\n\r"); - TESEO_APP_LOG_INFO(msg); + TESEO_APP_LOG_INFO("%s", msg); } }