ST / X_NUCLEO_GNSS1A1

Dependents:   TeseoLocation

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers createTeseoGNSS.cpp Source File

createTeseoGNSS.cpp

Go to the documentation of this file.
00001 /**
00002  ******************************************************************************
00003  * @file    createTeseoGNSS.cpp
00004  * @author  AST/CL
00005  * @version V1.1.0
00006  * @date    May, 2017
00007  * @brief   .
00008  ******************************************************************************
00009  * @attention
00010  *
00011  * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
00012  *
00013  * Redistribution and use in source and binary forms, with or without modification,
00014  * are permitted provided that the following conditions are met:
00015  *   1. Redistributions of source code must retain the above copyright notice,
00016  *      this list of conditions and the following disclaimer.
00017  *   2. Redistributions in binary form must reproduce the above copyright notice,
00018  *      this list of conditions and the following disclaimer in the documentation
00019  *      and/or other materials provided with the distribution.
00020  *   3. Neither the name of STMicroelectronics nor the names of its contributors
00021  *      may be used to endorse or promote products derived from this software
00022  *      without specific prior written permission.
00023  *
00024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00025  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00026  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00027  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00028  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00029  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00030  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00032  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00033  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034  *
00035  ******************************************************************************
00036  */
00037 
00038 #include "mbed.h"
00039 #include "Teseo.h"
00040 #include "GPSProviderImplBase.h"
00041 
00042 #include "TeseoConfig.h"
00043 
00044 static void _AppOutputCallback(uint32_t msgId, uint32_t msgType, tTeseoData *pData);
00045 static void _AppEventCallback(eTeseoLocEventType event, uint32_t data);
00046 static char msg[256];
00047 
00048 static const char *geofenceCirclePosition[] = {
00049   "Unknown",
00050   "Outside",
00051   "Boundary",
00052   "Inside"
00053 };
00054 
00055 #define TESEO_GNSS_LOG(...) printf(__VA_ARGS__)
00056 
00057 GPSProviderImplBase *
00058 createGPSProviderInstance(void)
00059 {
00060     static Teseo gnss(TESEO_PIN_RESET,
00061                       TESEO_PIN_WAKEUP,
00062                       TESEO_PIN_PPS,
00063                       TESEO_PIN_TX,
00064                       TESEO_PIN_RX);
00065 
00066     /* Register output callback and event callback functions */
00067     gnss.TeseoLocRegOutput(_AppOutputCallback, _AppEventCallback);
00068 
00069     return &gnss;
00070 }
00071 
00072 /** 
00073  * @brief  This function prints on the console the info about Fix data for single or combined satellite navigation system
00074  * @param  pData
00075  * @retval None
00076  */
00077 static void
00078 GetGNSMsgInfos(tTeseoData *pData)
00079 {
00080 //  char msg[256];
00081   
00082   TESEO_GNSS_LOG("\r\n");
00083   
00084   sprintf(msg, "Constellation:\t\t[ %s ]\t",
00085           pData->gns_data.constellation);
00086   TESEO_GNSS_LOG("%s", msg);
00087   
00088   if (strcmp(pData->gns_data.constellation, "$GPGSV") == 0) {
00089     TESEO_GNSS_LOG("-- only GPS constellation is enabled\n\r");  
00090   }
00091   else if (strcmp(pData->gns_data.constellation, "$GLGSV") == 0) {
00092     TESEO_GNSS_LOG("-- only GLONASS constellation is enabled\n\r");
00093   }
00094   else if (strcmp(pData->gns_data.constellation, "$GAGSV") == 0) {
00095     TESEO_GNSS_LOG("-- only GALILEO constellation is enabled\n\r");
00096   }
00097   else if (strcmp(pData->gns_data.constellation, "$BDGSV") == 0) {
00098     TESEO_GNSS_LOG("-- only BEIDOU constellation is enabled\n\r");    
00099   }
00100   else if (strcmp(pData->gns_data.constellation, "$QZGSV") == 0) {
00101     TESEO_GNSS_LOG("-- only QZSS constellation is enabled\n\r");
00102   }
00103   else if (strcmp(pData->gns_data.constellation, "$GNGSV") == 0) {
00104     TESEO_GNSS_LOG("-- message to report all satellites for all enabled constellations\n\r");   
00105   }
00106   
00107   sprintf(msg, "UTC:\t\t\t[ %02d:%02d:%02d ]\n\r",
00108           pData->gns_data.utc.hh, 
00109           pData->gns_data.utc.mm, 
00110           pData->gns_data.utc.ss);
00111   TESEO_GNSS_LOG("%s", msg);
00112   
00113   sprintf(msg,"Latitude:\t\t[ %.0f' %d'' %c ]\n\r",
00114           (pData->gns_data.xyz.lat - ((int)pData->gns_data.xyz.lat % 100)) / 100, 
00115           ((int)pData->gns_data.xyz.lat % 100), 
00116           pData->gns_data.xyz.ns);          
00117   TESEO_GNSS_LOG("%s", msg);
00118   
00119   sprintf(msg,"Longitude:\t\t[ %.0f' %d'' %c ]\n\r",
00120           (pData->gns_data.xyz.lon - ((int)pData->gns_data.xyz.lon % 100)) / 100, 
00121           ((int)pData->gns_data.xyz.lon % 100),
00122           pData->gns_data.xyz.ew);
00123   TESEO_GNSS_LOG("%s", msg);
00124   
00125   sprintf(msg,"Satellites locked:\t[ %d ]\n\r",
00126           pData->gns_data.sats);
00127   TESEO_GNSS_LOG("%s", msg);
00128   
00129   sprintf(msg,"HDOP:\t\t\t[ %.01f ]\n\r",
00130           pData->gns_data.hdop);
00131   TESEO_GNSS_LOG("%s", msg);
00132   
00133   sprintf(msg,"Altitude:\t\t[ %.01f ]\n\r",
00134           pData->gns_data.xyz.alt);
00135   TESEO_GNSS_LOG("%s", msg);
00136   
00137   sprintf(msg,"Geoid infos:\t\t[ %.01f ]\n\r",
00138           pData->gns_data.geo_sep);
00139   TESEO_GNSS_LOG("%s", msg);
00140   
00141   //  sprintf(msg,"ID - Checksum:\t\t[ *%x ]\n\r",
00142   //          (pData->gns_data.checksum);
00143   //  TESEO_GNSS_LOG("%s", msg);
00144   
00145   TESEO_GNSS_LOG("\n\n\r");
00146   
00147   return;
00148 }
00149 
00150 /** 
00151  * @brief  This function prints on the console the info about GPS Pseudorange Noise Statistics
00152  * @param  pData
00153  * @retval None
00154  */
00155 static void
00156 GetGPGSTInfos(tTeseoData *pData)
00157 {
00158 //  char msg[256];
00159   
00160   TESEO_GNSS_LOG("\r\n");
00161     
00162   sprintf(msg, "UTC:\t\t\t[ %02d:%02d:%02d ]\n\r",
00163           pData->gpgst_data.utc.hh, 
00164           pData->gpgst_data.utc.mm, 
00165           pData->gpgst_data.utc.ss);
00166   TESEO_GNSS_LOG("%s", msg);
00167     
00168   sprintf(msg,"EHPE:\t\t[ %.01f ]\n\r",
00169           pData->gpgst_data.EHPE);
00170   TESEO_GNSS_LOG("%s", msg);
00171     
00172   sprintf(msg,"Semi-major Dev:\t\t[ %.01f ]\n\r",
00173           pData->gpgst_data.semi_major_dev);
00174   TESEO_GNSS_LOG("%s", msg);
00175     
00176   sprintf(msg,"Semi-minor Dev:\t\t[ %.01f ]\n\r",
00177           pData->gpgst_data.semi_minor_dev);
00178   TESEO_GNSS_LOG("%s", msg);
00179   
00180   sprintf(msg,"Semi-maior Angle:\t\t[ %.01f ]\n\r",
00181           pData->gpgst_data.semi_major_angle);
00182   TESEO_GNSS_LOG("%s", msg);
00183       
00184   sprintf(msg,"Lat Err Dev:\t\t[ %.01f ]\n\r",
00185           pData->gpgst_data.lat_err_dev);
00186   TESEO_GNSS_LOG("%s", msg);
00187   
00188   sprintf(msg,"Lon Err Dev:\t\t[ %.01f ]\n\r",
00189           pData->gpgst_data.lon_err_dev);
00190   TESEO_GNSS_LOG("%s", msg);
00191   
00192   sprintf(msg,"Alt Err Dev:\t\t[ %.01f ]\n\r",
00193           pData->gpgst_data.alt_err_dev);
00194   TESEO_GNSS_LOG("%s", msg);
00195     
00196 //  sprintf(msg,"ID - Checksum:\t\t[ *%x ]\n\r",
00197 //          pData->gpgst_data.checksum);
00198 //  TESEO_GNSS_LOG("%s", msg);
00199     
00200   TESEO_GNSS_LOG("\n\n\r");
00201 
00202   return;
00203 }
00204 
00205 /** 
00206  * @brief  This function prints on the console the info about Recommended Minimum Specific GPS/Transit data got by the most recent reception process
00207  * @param  pData
00208  * @retval None
00209  */
00210 static void
00211 GetGPRMCInfos(tTeseoData *pData)
00212 {
00213 //  char msg[256];
00214   
00215   TESEO_GNSS_LOG("\r\n");
00216     
00217   sprintf(msg, "UTC:\t\t\t\t[ %02d:%02d:%02d ]\n\r",
00218           pData->gprmc_data.utc.hh, 
00219           pData->gprmc_data.utc.mm, 
00220           pData->gprmc_data.utc.ss);
00221   TESEO_GNSS_LOG("%s", msg);
00222     
00223   sprintf(msg,"Status:\t\t\t\t[ %c ]\t\t",
00224           pData->gprmc_data.status);
00225   TESEO_GNSS_LOG("%s", msg);
00226   if (pData->gprmc_data.status == 'A') {
00227     TESEO_GNSS_LOG("-- Valid (reported in 2D and 3D fix conditions)\n\r");
00228   }
00229   else if (pData->gprmc_data.status == 'V') {
00230     TESEO_GNSS_LOG("-- Warning (reported in NO FIX conditions)\n\r");
00231   }
00232   else {
00233     TESEO_GNSS_LOG("-- Unknown status\n\r");
00234   }
00235     
00236   sprintf(msg,"Latitude:\t\t\t[ %.0f' %02d'' %c ]\n\r",
00237           ((pData->gprmc_data.xyz.lat - ((int)pData->gprmc_data.xyz.lat % 100))) / 100, 
00238           ((int)pData->gprmc_data.xyz.lat % 100), 
00239           pData->gprmc_data.xyz.ns);          
00240   TESEO_GNSS_LOG("%s", msg);
00241   
00242   sprintf(msg,"Longitude:\t\t\t[ %.0f' %02d'' %c ]\n\r",
00243           ((pData->gprmc_data.xyz.lon - ((int)pData->gprmc_data.xyz.lon % 100))) / 100, 
00244           ((int)pData->gprmc_data.xyz.lon % 100),
00245           pData->gprmc_data.xyz.ew);
00246   TESEO_GNSS_LOG("%s", msg);
00247     
00248   sprintf(msg,"Speed over ground (knots):\t[ %.01f ]\n\r",
00249           pData->gprmc_data.speed);
00250   TESEO_GNSS_LOG("%s", msg);
00251   
00252   sprintf(msg,"Trackgood:\t\t\t[ %.01f ]\n\r",
00253           pData->gprmc_data.trackgood);
00254   TESEO_GNSS_LOG("%s", msg);
00255   
00256   sprintf(msg,"Date (ddmmyy):\t\t\t[ %d ]\n\r",
00257           pData->gprmc_data.date);
00258   TESEO_GNSS_LOG("%s", msg);
00259     
00260   sprintf(msg,"Magnetic Variation:\t\t[ %.01f ]\n\r",
00261           pData->gprmc_data.mag_var);
00262   TESEO_GNSS_LOG("%s", msg);
00263   
00264   if (pData->gprmc_data.mag_var_dir != 'E' &&
00265       pData->gprmc_data.mag_var_dir != 'W') {
00266     sprintf(msg,"Magnetic Var. Direction:\t[ - ]\n\r");
00267   }
00268   else {
00269     sprintf(msg,"Magnetic Var. Direction:\t[ %c ]\n\r",
00270           pData->gprmc_data.mag_var_dir);
00271   }
00272   TESEO_GNSS_LOG("%s", msg);
00273   
00274 //  sprintf(msg,"Checksum:\t\t[ *%x ]\n\r",
00275 //          pData->gprmc_data.checksum);
00276 //  TESEO_GNSS_LOG("%s", msg);
00277     
00278   TESEO_GNSS_LOG("\n\n\r");
00279 
00280   return;
00281 }
00282 
00283 /** 
00284  * @brief  This function prints on the console the info about GNSS satellites got by the most recent reception process
00285  * @param  pData
00286  * @retval None
00287  */
00288 static void
00289 GetGSAMsgInfos(tTeseoData *pData)
00290 {
00291 //  char msg[256];
00292   
00293   TESEO_GNSS_LOG("\r\n");
00294   
00295   sprintf(msg, "Constellation:\t\t[ %s ]\t",
00296           pData->gsa_data.constellation);
00297   TESEO_GNSS_LOG("%s", msg);
00298   
00299   if (strcmp(pData->gsa_data.constellation, "$GPGSA") == 0) {
00300     TESEO_GNSS_LOG("-- only GPS constellation is enabled\n\r");    
00301   }
00302   else if (strcmp(pData->gsa_data.constellation, "$GLGSA") == 0) {
00303     TESEO_GNSS_LOG("-- only GLONASS constellation is enabled\n\r");
00304   }
00305   else if (strcmp(pData->gsa_data.constellation, "$GAGSA") == 0) {
00306     TESEO_GNSS_LOG("-- only GALILEO constellation is enabled\n\r");
00307   }
00308   else if (strcmp(pData->gsa_data.constellation, "$BDGSA") == 0) {
00309     TESEO_GNSS_LOG("-- only BEIDOU constellation is enabled\n\r");
00310   }
00311   else if (strcmp(pData->gsa_data.constellation, "$GNGSA") == 0) {
00312     TESEO_GNSS_LOG("-- more than one constellation is enabled\n\r");   
00313   }
00314   
00315   sprintf(msg, "Operating Mode:\t\t[ %c ]\t\t",
00316           pData->gsa_data.operating_mode);
00317   TESEO_GNSS_LOG("%s", msg);
00318   if (pData->gsa_data.operating_mode == 'A') {
00319     TESEO_GNSS_LOG("-- Auto (2D/3D)\n\r");
00320   }
00321   else if (pData->gsa_data.operating_mode == 'M') {
00322     TESEO_GNSS_LOG("-- Manual\n\r");
00323   }
00324   
00325   sprintf(msg,"Current Mode:\t\t[ %d ]\t\t",
00326           pData->gsa_data.current_mode);          
00327   TESEO_GNSS_LOG("%s", msg);
00328   if (pData->gsa_data.current_mode == 1) {
00329     TESEO_GNSS_LOG("-- no fix available\n\r");
00330   }
00331   else if (pData->gsa_data.current_mode == 2) {
00332     TESEO_GNSS_LOG("-- 2D\n\r");
00333   }
00334   else if (pData->gsa_data.current_mode == 3) {
00335     TESEO_GNSS_LOG("-- 3D\n\r");
00336   }
00337   
00338   for (uint8_t i=0; i<12; i++) {  
00339     sprintf(msg,"SatPRN%02d:\t\t[ %d ]\n\r", i+1,
00340             pData->gsa_data.sat_prn[i]);
00341     TESEO_GNSS_LOG("%s", msg);
00342   }
00343   
00344   sprintf(msg,"PDOP:\t\t\t[ %.01f ]\n\r",
00345           pData->gsa_data.pdop);
00346   TESEO_GNSS_LOG("%s", msg);
00347   
00348   sprintf(msg,"HDOP:\t\t\t[ %.01f ]\n\r",
00349           pData->gsa_data.hdop);
00350   TESEO_GNSS_LOG("%s", msg);
00351   
00352   sprintf(msg,"VDOP:\t\t\t[ %.01f ]\n\r",
00353           pData->gsa_data.vdop);
00354   TESEO_GNSS_LOG("%s", msg);
00355   
00356 //  sprintf(msg,"ID - Checksum:\t\t[ *%x ]\n\r",
00357 //          pData->gsa_data.checksum);
00358 //  TESEO_GNSS_LOG("%s", msg);
00359   
00360   TESEO_GNSS_LOG("\n\n\r");
00361   
00362 }
00363             
00364 /** 
00365  * @brief  This function prints on the console the info about GNSS satellites got by the most recent reception process
00366  * @param  pData
00367  * @retval None
00368  */
00369 static void
00370 GetGSVMsgInfos(tTeseoData *pData)
00371 {
00372   uint8_t i;
00373   uint8_t tot_sats = pData->gsv_data.tot_sats;
00374 //  char msg[256];
00375   
00376   char degree_sym = 248;
00377   
00378   TESEO_GNSS_LOG("\r\n");
00379   
00380   sprintf(msg, "Constellation:\t\t[ %s ]\t",
00381           pData->gsv_data.constellation);
00382   TESEO_GNSS_LOG("%s", msg);
00383   
00384   if (strcmp(pData->gsv_data.constellation, "$GPGSV") == 0) {
00385     TESEO_GNSS_LOG("-- message to report all GPS satellites\n\r");    
00386   }
00387   else if (strcmp(pData->gsv_data.constellation, "$GLGSV") == 0) {
00388     TESEO_GNSS_LOG("-- message to report all GLONASS satellites\n\r");
00389   }
00390   else if (strcmp(pData->gsv_data.constellation, "$GAGSV") == 0) {
00391     TESEO_GNSS_LOG("-- message to report all GALILEO satellites\n\r");
00392   }
00393   else if (strcmp(pData->gsv_data.constellation, "$BDGSV") == 0) {
00394     TESEO_GNSS_LOG("-- message to report all BEIDOU satellites\n\r");
00395   }
00396   else if (strcmp(pData->gsv_data.constellation, "$QZGSV") == 0) {
00397     TESEO_GNSS_LOG("-- message to report all QZSS satellites\n\r");
00398   }
00399   else if (strcmp(pData->gsv_data.constellation, "$GNGSV") == 0) {
00400     TESEO_GNSS_LOG("-- message to report all satellites for all enabled constellations\n\r");   
00401   }
00402   
00403   /* debug */
00404 //  sprintf(msg,"Tot Messages:\t\t[ %d ]\n\r",
00405 //          ((tTeseoData *)(handle->pData))->gsv_data.amount);
00406 //  TESEO_GNSS_LOG("%s", msg);
00407 //  
00408 //  sprintf(msg,"Message Num:\t\t[ %d ]\n\r",
00409 //          ((tTeseoData *)(handle->pData))->gsv_data.number);
00410 //  TESEO_GNSS_LOG("%s", msg);
00411   
00412   sprintf(msg,"Num of Satellites:\t[ %d ]\n\r", tot_sats);
00413   TESEO_GNSS_LOG("%s", msg);
00414   
00415   TESEO_GNSS_LOG("\n\r");
00416   
00417   for (i=0; i<tot_sats; i++) {
00418     sprintf(msg,"Sat%02dPRN:\t\t[ %03d ]\n\r", i+1, 
00419             pData->gsv_data.gsv_sat_i[i].prn);
00420     TESEO_GNSS_LOG("%s", msg);
00421     
00422     sprintf(msg,"Sat%02dElev (%c):\t\t[ %03d ]\n\r", i+1, degree_sym,
00423             pData->gsv_data.gsv_sat_i[i].elev);
00424     TESEO_GNSS_LOG("%s", msg);
00425     
00426     sprintf(msg,"Sat%02dAzim (%c):\t\t[ %03d ]\n\r", i+1, degree_sym,
00427             pData->gsv_data.gsv_sat_i[i].azim);
00428     TESEO_GNSS_LOG("%s", msg);
00429     
00430     sprintf(msg,"Sat%02dCN0 (dB):\t\t[ %03d ]\n\r", i+1, 
00431             pData->gsv_data.gsv_sat_i[i].cn0);
00432     TESEO_GNSS_LOG("%s", msg);  
00433     
00434     TESEO_GNSS_LOG("\n\r");
00435   }
00436   
00437   TESEO_GNSS_LOG("\r\n");
00438   
00439 }
00440 
00441 /** 
00442  * @brief  This function prints on the console the info Geofence
00443  * @param  pData
00444  * @retval None
00445  */
00446 static void
00447 GetGeofenceInfos(tTeseoData *pData)
00448 {
00449 //  char msg[256];
00450   
00451   TESEO_GNSS_LOG("\r\n");
00452 
00453   if(pData->geofence_data.op == GNSS_FEATURE_EN_MSG) {
00454     sprintf(msg, "Geofence Enabling:\t\t[ %s ]\t",
00455             pData->geofence_data.result ? "ERROR" : "OK");
00456     TESEO_GNSS_LOG("%s", msg);
00457   }
00458   if(pData->geofence_data.op == GNSS_GEOFENCE_CFG_MSG) {
00459     sprintf(msg, "Geofence Configuration:\t\t[ %s ]\t",
00460           pData->geofence_data.result ? "ERROR" : "OK");
00461     TESEO_GNSS_LOG("%s", msg);
00462   }
00463   if(pData->geofence_data.op == GNSS_GEOFENCE_STATUS_MSG) {
00464     sprintf(msg, "Geofence Status:\t\t[ %s ]\t",
00465           pData->geofence_data.result ? "ERROR" : "OK");
00466     TESEO_GNSS_LOG("%s", msg);
00467     if(pData->geofence_data.result == 0) {
00468       TESEO_GNSS_LOG("\r\n");
00469       sprintf(msg, "Time/Date:\t\t%02d:%02d:%02d %02d/%02d/%04d\n",
00470           pData->geofence_data.timestamp.hh,
00471           pData->geofence_data.timestamp.mm,
00472           pData->geofence_data.timestamp.ss,
00473           pData->geofence_data.timestamp.day,
00474           pData->geofence_data.timestamp.month,
00475           pData->geofence_data.timestamp.year);
00476       TESEO_GNSS_LOG("%s", msg);
00477       
00478       for(uint8_t i = 0; i<MAX_GEOFENCES_NUM; i++) {
00479         sprintf(msg, "Position circle[%d]:\t%s\n",
00480           i, geofenceCirclePosition[pData->geofence_data.status[i]]);
00481         TESEO_GNSS_LOG("%s", msg);
00482       }
00483     }
00484   }
00485   if(pData->geofence_data.op == GNSS_GEOFENCE_ALARM_MSG) {
00486     sprintf(msg, "Geofence Alarm:\t\t[ %s ]\t",
00487           pData->geofence_data.result ? "ERROR" : "OK");
00488     TESEO_GNSS_LOG("%s", msg);
00489     if(pData->geofence_data.result == 0) {
00490       TESEO_GNSS_LOG("\r\n");
00491       sprintf(msg, "Time:\t\t%02d:%02d:%02d\n",
00492           pData->geofence_data.timestamp.hh,
00493           pData->geofence_data.timestamp.mm,
00494           pData->geofence_data.timestamp.ss);
00495       TESEO_GNSS_LOG("%s", msg);
00496       int i = pData->geofence_data.idAlarm;
00497       sprintf(msg, "Position circle[%d]:\t%s\n",
00498               i, geofenceCirclePosition[pData->geofence_data.status[i]]);
00499       TESEO_GNSS_LOG("%s", msg);
00500     }
00501   }  
00502   TESEO_GNSS_LOG("\r\n");
00503   
00504 }
00505 
00506 /** 
00507  * @brief  This function prints on the console the info about Odometer
00508  * @param  pData
00509  * @retval None
00510  */
00511 static void
00512 GetOdometerInfos(tTeseoData *pData)
00513 {
00514 //  char msg[256];
00515   
00516   TESEO_GNSS_LOG("\r\n");
00517   
00518   if(pData->odo_data.op == GNSS_FEATURE_EN_MSG) {
00519     sprintf(msg, "Odometer Enabling:\t\t[ %s ]\t",
00520             pData->odo_data.result ? "ERROR" : "OK");
00521     TESEO_GNSS_LOG("%s", msg);
00522   }
00523   if((pData->odo_data.op == GNSS_ODO_START_MSG) ||
00524      (pData->odo_data.op == GNSS_ODO_STOP_MSG)) {
00525     sprintf(msg, "Odometer Operation:\t\t[ %s ]\t",
00526           pData->odo_data.result ? "ERROR" : "OK");
00527     TESEO_GNSS_LOG("%s", msg);
00528   }  
00529   TESEO_GNSS_LOG("\r\n");
00530   
00531 }
00532 
00533 /** 
00534  * @brief  This function prints on the console the info about Datalog
00535  * @param  pData
00536  * @retval None
00537  */
00538 static void
00539 GetDatalogInfos(tTeseoData *pData)
00540 {
00541 //  char msg[256];
00542   
00543   TESEO_GNSS_LOG("\r\n");
00544   
00545   if(pData->datalog_data.op == GNSS_FEATURE_EN_MSG) {
00546     sprintf(msg, "Datalog Enabling:\t\t[ %s ]\t",
00547             pData->datalog_data.result ? "ERROR" : "OK");
00548     TESEO_GNSS_LOG("%s", msg);
00549   }
00550   if(pData->datalog_data.op == GNSS_DATALOG_CFG_MSG) {
00551     sprintf(msg, "Datalog Configuring:\t\t[ %s ]\t",
00552             pData->datalog_data.result ? "ERROR" : "OK");
00553     TESEO_GNSS_LOG("%s", msg);
00554   }
00555   if(pData->datalog_data.op == GNSS_DATALOG_START_MSG) {
00556     sprintf(msg, "Datalog Start:\t\t[ %s ]\t",
00557             pData->datalog_data.result ? "ERROR" : "OK");
00558     TESEO_GNSS_LOG("%s", msg);
00559   }
00560   if(pData->datalog_data.op == GNSS_DATALOG_STOP_MSG) {
00561     sprintf(msg, "Datalog Stop:\t\t[ %s ]\t",
00562             pData->datalog_data.result ? "ERROR" : "OK");
00563     TESEO_GNSS_LOG("%s", msg);
00564   }
00565   if(pData->datalog_data.op == GNSS_DATALOG_ERASE_MSG) {
00566     sprintf(msg, "Datalog Erase:\t\t[ %s ]\t",
00567             pData->datalog_data.result ? "ERROR" : "OK");
00568     TESEO_GNSS_LOG("%s", msg);
00569   }
00570   TESEO_GNSS_LOG("\r\n");
00571   
00572 }
00573 
00574 /** 
00575  * @brief  This function prints on the console the ack about Message List cfg
00576  * @param  pData
00577  * @retval None
00578  */
00579 static void
00580 GetMsgListAck(tTeseoData *pData)
00581 {
00582 //  char msg[256];
00583   
00584   TESEO_GNSS_LOG("\r\n");
00585   
00586   sprintf(msg, "Msg List config:\t\t[ %s ]\t",
00587           pData->ack ? "ERROR" : "OK");
00588   TESEO_GNSS_LOG("%s", msg);
00589     
00590   TESEO_GNSS_LOG("\r\n");
00591 }
00592 
00593 /** 
00594  * @brief  This function prints on the console the ack about Message List cfg
00595  * @param  pData
00596  * @retval None
00597  */
00598 static void
00599 GetAck(tTeseoData *pData)
00600 {
00601 //  char msg[256];
00602   
00603   TESEO_GNSS_LOG("\r\n");
00604   
00605   sprintf(msg, "Params configuration:\t\t[ %s ]\t",
00606           pData->ack ? "ERROR" : "OK");
00607   TESEO_GNSS_LOG("%s", msg);
00608     
00609   TESEO_GNSS_LOG("\r\n");
00610 }
00611 
00612 void
00613 _AppOutputCallback(uint32_t msgId, uint32_t msgType, tTeseoData *pData)
00614 {
00615   switch (msgId) {
00616   case LOC_OUTPUT_LOCATION: {
00617     // Output last location
00618     TESEO_GNSS_LOG("Loc: lat=%lf, lon=%lf, alt=%f\r\n", pData->gpgga_data.xyz.lat, pData->gpgga_data.xyz.lon, pData->gpgga_data.xyz.alt);
00619     break;
00620   }
00621   case LOC_OUTPUT_NMEA: {
00622     //return;
00623     Teseo::eMsg msg = (Teseo::eMsg)msgType;
00624     switch(msg) {
00625     case Teseo::GNS:
00626       // GET Fix data for single or combined Satellite navigation system
00627       GetGNSMsgInfos(pData);
00628       break;
00629       
00630     case Teseo::GPGST:
00631       // GET GPS Pseudorange Noise Statistics
00632       GetGPGSTInfos(pData);
00633       break;
00634       
00635     case Teseo::GPRMC:
00636       // GET Recommended Minimum Specific GPS/Transit data
00637       GetGPRMCInfos(pData);
00638       break;
00639       
00640     case Teseo::GSA:
00641       // GET GPS DOP and Active Satellites
00642       GetGSAMsgInfos(pData);
00643       break;
00644       
00645     case Teseo::GSV:
00646       // GET GPS Satellites in View
00647       GetGSVMsgInfos(pData);
00648       break;
00649       
00650     default:
00651       break;
00652     }
00653     break;
00654   }
00655   case LOC_OUTPUT_PSTM: {
00656     Teseo::ePSTMsg msg = (Teseo::ePSTMsg)msgType;
00657     switch(msg) {
00658     case Teseo::PSTMGEOFENCE:
00659       // GET Geofence info
00660       GetGeofenceInfos(pData);
00661       break;
00662     case Teseo::PSTMODO:
00663       // GET Geofence info
00664       GetOdometerInfos(pData);
00665       break;
00666     case Teseo::PSTMDATALOG:
00667       // GET Datalog info
00668       GetDatalogInfos(pData);
00669       break;
00670     case Teseo::PSTMSGL:
00671       // GET Message List ack
00672       GetMsgListAck(pData);
00673       break;
00674     case Teseo::PSTMSAVEPAR:
00675       // GET SAVE PAR ack
00676       GetAck(pData);
00677       break;
00678     default:
00679       break;
00680     }
00681     break;
00682   }
00683   
00684   default:
00685     break;
00686   }
00687 }
00688 
00689 
00690 void
00691 _AppEventCallback(eTeseoLocEventType event, uint32_t data)
00692 {
00693     switch (event) {
00694         case TESEO_LOC_EVENT_START_RESULT:
00695             if (data != 0) {
00696                 TESEO_GNSS_LOG("start failed.\r\n");
00697             } else {
00698                 TESEO_GNSS_LOG("start OK.\r\n");
00699             }
00700             break;
00701         case TESEO_LOC_EVENT_STOP_RESULT:
00702             if (data != 0) {
00703                 TESEO_GNSS_LOG("stop failed.\r\n");
00704             } else {
00705                 TESEO_GNSS_LOG("stop OK.\r\n");
00706             }
00707             break;
00708         default:
00709             break;
00710     }
00711 }