Demo

Dependents:   A_TeseoLocationNEW A_TeseoLocation

Committer:
apalmieri
Date:
Fri Nov 09 17:06:11 2018 +0000
Revision:
0:a77f1f1f8318
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
apalmieri 0:a77f1f1f8318 1 /**
apalmieri 0:a77f1f1f8318 2 *******************************************************************************
apalmieri 0:a77f1f1f8318 3 * @file NMEAParser.c
apalmieri 0:a77f1f1f8318 4 * @author AST / Central Lab
apalmieri 0:a77f1f1f8318 5 * @version V1.0.0
apalmieri 0:a77f1f1f8318 6 * @date 18-May-2017
apalmieri 0:a77f1f1f8318 7 * @brief NMEA sentence parser
apalmieri 0:a77f1f1f8318 8 *
apalmieri 0:a77f1f1f8318 9 *******************************************************************************
apalmieri 0:a77f1f1f8318 10 * @attention
apalmieri 0:a77f1f1f8318 11 *
apalmieri 0:a77f1f1f8318 12 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
apalmieri 0:a77f1f1f8318 13 *
apalmieri 0:a77f1f1f8318 14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
apalmieri 0:a77f1f1f8318 15 * You may not use this file except in compliance with the License.
apalmieri 0:a77f1f1f8318 16 * You may obtain a copy of the License at:
apalmieri 0:a77f1f1f8318 17 *
apalmieri 0:a77f1f1f8318 18 * http://www.st.com/software_license_agreement_liberty_v2
apalmieri 0:a77f1f1f8318 19 *
apalmieri 0:a77f1f1f8318 20 * Redistribution and use in source and binary forms, with or without modification,
apalmieri 0:a77f1f1f8318 21 * are permitted provided that the following conditions are met:
apalmieri 0:a77f1f1f8318 22 * 1. Redistributions of source code must retain the above copyright notice,
apalmieri 0:a77f1f1f8318 23 * this list of conditions and the following disclaimer.
apalmieri 0:a77f1f1f8318 24 * 2. Redistributions in binary form must reproduce the above copyright notice,
apalmieri 0:a77f1f1f8318 25 * this list of conditions and the following disclaimer in the documentation
apalmieri 0:a77f1f1f8318 26 * and/or other materials provided with the distribution.
apalmieri 0:a77f1f1f8318 27 * 3. Neither the name of STMicroelectronics nor the names of its contributors
apalmieri 0:a77f1f1f8318 28 * may be used to endorse or promote products derived from this software
apalmieri 0:a77f1f1f8318 29 * without specific prior written permission.
apalmieri 0:a77f1f1f8318 30 *
apalmieri 0:a77f1f1f8318 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
apalmieri 0:a77f1f1f8318 32 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
apalmieri 0:a77f1f1f8318 33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
apalmieri 0:a77f1f1f8318 34 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
apalmieri 0:a77f1f1f8318 35 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
apalmieri 0:a77f1f1f8318 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
apalmieri 0:a77f1f1f8318 37 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
apalmieri 0:a77f1f1f8318 38 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
apalmieri 0:a77f1f1f8318 39 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
apalmieri 0:a77f1f1f8318 40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
apalmieri 0:a77f1f1f8318 41 *
apalmieri 0:a77f1f1f8318 42 ********************************************************************************
apalmieri 0:a77f1f1f8318 43 */
apalmieri 0:a77f1f1f8318 44
apalmieri 0:a77f1f1f8318 45 #include "string.h"
apalmieri 0:a77f1f1f8318 46 #include "NMEAParser.h"
apalmieri 0:a77f1f1f8318 47 #include "NMEAUtils.h"
apalmieri 0:a77f1f1f8318 48
apalmieri 0:a77f1f1f8318 49 /** @defgroup Middlewares
apalmieri 0:a77f1f1f8318 50 * @brief Contains all platform independent modules (eg. NMEA Sentence Parser, ...).
apalmieri 0:a77f1f1f8318 51 * @{
apalmieri 0:a77f1f1f8318 52 */
apalmieri 0:a77f1f1f8318 53
apalmieri 0:a77f1f1f8318 54 /** @defgroup ST
apalmieri 0:a77f1f1f8318 55 * @{
apalmieri 0:a77f1f1f8318 56 */
apalmieri 0:a77f1f1f8318 57
apalmieri 0:a77f1f1f8318 58 /** @defgroup LIB_NMEA
apalmieri 0:a77f1f1f8318 59 * @{
apalmieri 0:a77f1f1f8318 60 */
apalmieri 0:a77f1f1f8318 61
apalmieri 0:a77f1f1f8318 62 /** @defgroup NMEA_PARSER
apalmieri 0:a77f1f1f8318 63 * @{
apalmieri 0:a77f1f1f8318 64 */
apalmieri 0:a77f1f1f8318 65
apalmieri 0:a77f1f1f8318 66 /** @addtogroup NMEA_PARSER_PUBLIC_FUNCTIONS
apalmieri 0:a77f1f1f8318 67 * @{
apalmieri 0:a77f1f1f8318 68 */
apalmieri 0:a77f1f1f8318 69 /**
apalmieri 0:a77f1f1f8318 70 * @brief Function that makes the parsing of the $GPGGA NMEA string with all Global Positioning System Fixed data.
apalmieri 0:a77f1f1f8318 71 * @param gpgga_data Pointer to GPGGA_Infos struct
apalmieri 0:a77f1f1f8318 72 * @param NMEA NMEA string read by the Gps expansion
apalmieri 0:a77f1f1f8318 73 * @retval ParseStatus_Typedef PARSE_SUCC if the parsing process goes ok, PARSE_FAIL if it doesn't
apalmieri 0:a77f1f1f8318 74 */
apalmieri 0:a77f1f1f8318 75 ParseStatus_Typedef parse_gpgga(GPGGA_Infos *gpgga_data, uint8_t *NMEA)
apalmieri 0:a77f1f1f8318 76 {
apalmieri 0:a77f1f1f8318 77 uint8_t app[MAX_MSG_LEN][MAX_MSG_LEN];
apalmieri 0:a77f1f1f8318 78 uint8_t valid_msg = 0;
apalmieri 0:a77f1f1f8318 79
apalmieri 0:a77f1f1f8318 80 ParseStatus_Typedef status = PARSE_FAIL;
apalmieri 0:a77f1f1f8318 81
apalmieri 0:a77f1f1f8318 82 if(NMEA == NULL)
apalmieri 0:a77f1f1f8318 83 return status;
apalmieri 0:a77f1f1f8318 84
apalmieri 0:a77f1f1f8318 85 /* clear the app[][] buffer */
apalmieri 0:a77f1f1f8318 86 for (uint8_t i=0; i<MAX_MSG_LEN; i++) {
apalmieri 0:a77f1f1f8318 87 memset(app[i], 0, MAX_MSG_LEN);
apalmieri 0:a77f1f1f8318 88 }
apalmieri 0:a77f1f1f8318 89
apalmieri 0:a77f1f1f8318 90 for(unsigned i = 0, j = 0, k = 0; NMEA[i] != '\n' && i < strlen((char *)NMEA) - 1; i++)
apalmieri 0:a77f1f1f8318 91 {
apalmieri 0:a77f1f1f8318 92 if ((NMEA[i] == ',') || (NMEA[i] == '*')) {
apalmieri 0:a77f1f1f8318 93 app[j][k] = '\0';
apalmieri 0:a77f1f1f8318 94
apalmieri 0:a77f1f1f8318 95 if (strcmp((char *)app[0], "$GPGGA") == 0) {
apalmieri 0:a77f1f1f8318 96 j++;
apalmieri 0:a77f1f1f8318 97 k = 0;
apalmieri 0:a77f1f1f8318 98 valid_msg = 1;
apalmieri 0:a77f1f1f8318 99 continue;
apalmieri 0:a77f1f1f8318 100 }
apalmieri 0:a77f1f1f8318 101 else {
apalmieri 0:a77f1f1f8318 102 while(NMEA[i++] != '\n');
apalmieri 0:a77f1f1f8318 103 j = k = 0;
apalmieri 0:a77f1f1f8318 104 }
apalmieri 0:a77f1f1f8318 105 }
apalmieri 0:a77f1f1f8318 106 app[j][k++] = NMEA[i];
apalmieri 0:a77f1f1f8318 107 }
apalmieri 0:a77f1f1f8318 108
apalmieri 0:a77f1f1f8318 109 if (valid_msg == 1) {
apalmieri 0:a77f1f1f8318 110 unsigned int valid;
apalmieri 0:a77f1f1f8318 111 sscanf ((char *)app[6], "%u", &valid);
apalmieri 0:a77f1f1f8318 112 gpgga_data->valid = (GPS_ValidTypedef)valid;
apalmieri 0:a77f1f1f8318 113 if (gpgga_data->valid == VALID) {
apalmieri 0:a77f1f1f8318 114 scan_utc ((char *)app[1], &gpgga_data->utc);
apalmieri 0:a77f1f1f8318 115 sscanf ((char *)app[2], "%lf", &gpgga_data->xyz.lat);
apalmieri 0:a77f1f1f8318 116 sscanf ((char *)app[3], "%c", &gpgga_data->xyz.ns);
apalmieri 0:a77f1f1f8318 117 sscanf ((char *)app[4], "%lf", &gpgga_data->xyz.lon);
apalmieri 0:a77f1f1f8318 118 sscanf ((char *)app[5], "%c", &gpgga_data->xyz.ew);
apalmieri 0:a77f1f1f8318 119 sscanf ((char *)app[7], "%d", &gpgga_data->sats);
apalmieri 0:a77f1f1f8318 120 sscanf ((char *)app[8], "%f", &gpgga_data->acc);
apalmieri 0:a77f1f1f8318 121 sscanf ((char *)app[9], "%f", &gpgga_data->xyz.alt);
apalmieri 0:a77f1f1f8318 122 sscanf ((char *)app[10], "%c", &gpgga_data->xyz.mis);
apalmieri 0:a77f1f1f8318 123 sscanf ((char *)app[11], "%d", &gpgga_data->geoid.height);
apalmieri 0:a77f1f1f8318 124 sscanf ((char *)app[12], "%c", &gpgga_data->geoid.mis);
apalmieri 0:a77f1f1f8318 125 sscanf ((char *)app[13], "%d", &gpgga_data->update);
apalmieri 0:a77f1f1f8318 126 sscanf ((char *)app[14], "%x", &gpgga_data->checksum);
apalmieri 0:a77f1f1f8318 127
apalmieri 0:a77f1f1f8318 128 valid_msg = 0;
apalmieri 0:a77f1f1f8318 129 status = PARSE_SUCC;
apalmieri 0:a77f1f1f8318 130 }
apalmieri 0:a77f1f1f8318 131 }
apalmieri 0:a77f1f1f8318 132 return status;
apalmieri 0:a77f1f1f8318 133 }
apalmieri 0:a77f1f1f8318 134
apalmieri 0:a77f1f1f8318 135 /**
apalmieri 0:a77f1f1f8318 136 * @brief Function that makes the parsing of the string read by the Gps expansion, capturing the right parameters from it.
apalmieri 0:a77f1f1f8318 137 * @param gns_data Pointer to GNS_Infos struct
apalmieri 0:a77f1f1f8318 138 * @param NMEA NMEA string read by the Gps expansion
apalmieri 0:a77f1f1f8318 139 * @retval ParseStatus_Typedef PARSE_SUCC if the parsing process goes ok, PARSE_FAIL if it doesn't
apalmieri 0:a77f1f1f8318 140 */
apalmieri 0:a77f1f1f8318 141 ParseStatus_Typedef parse_gnsmsg (GNS_Infos *gns_data, uint8_t *NMEA)
apalmieri 0:a77f1f1f8318 142 {
apalmieri 0:a77f1f1f8318 143 uint8_t app[MAX_MSG_LEN][MAX_MSG_LEN];
apalmieri 0:a77f1f1f8318 144 uint8_t valid_msg = 0;
apalmieri 0:a77f1f1f8318 145
apalmieri 0:a77f1f1f8318 146 ParseStatus_Typedef status = PARSE_FAIL;
apalmieri 0:a77f1f1f8318 147
apalmieri 0:a77f1f1f8318 148 if(NMEA == NULL)
apalmieri 0:a77f1f1f8318 149 return status;
apalmieri 0:a77f1f1f8318 150
apalmieri 0:a77f1f1f8318 151 /* clear the app[][] buffer */
apalmieri 0:a77f1f1f8318 152 for (uint8_t i=0; i<MAX_MSG_LEN; i++) {
apalmieri 0:a77f1f1f8318 153 memset(app[i], 0, MAX_MSG_LEN);
apalmieri 0:a77f1f1f8318 154 }
apalmieri 0:a77f1f1f8318 155
apalmieri 0:a77f1f1f8318 156 for (unsigned i = 0, j = 0, k = 0; NMEA[i] != '\n' && i < strlen((char *)NMEA) - 1; i++)
apalmieri 0:a77f1f1f8318 157 {
apalmieri 0:a77f1f1f8318 158 if ((NMEA[i] == ',') || (NMEA[i] == '*')) {
apalmieri 0:a77f1f1f8318 159 app[j][k] = '\0';
apalmieri 0:a77f1f1f8318 160
apalmieri 0:a77f1f1f8318 161 if ((strcmp((char *)app[0], "$GPGNS") == 0) ||
apalmieri 0:a77f1f1f8318 162 (strcmp((char *)app[0], "$GLGNS") == 0) ||
apalmieri 0:a77f1f1f8318 163 (strcmp((char *)app[0], "$GAGNS") == 0) ||
apalmieri 0:a77f1f1f8318 164 (strcmp((char *)app[0], "$BDGNS") == 0) ||
apalmieri 0:a77f1f1f8318 165 (strcmp((char *)app[0], "$QZGNS") == 0) ||
apalmieri 0:a77f1f1f8318 166 (strcmp((char *)app[0], "$GNGNS") == 0))
apalmieri 0:a77f1f1f8318 167 {
apalmieri 0:a77f1f1f8318 168 j++;
apalmieri 0:a77f1f1f8318 169 k = 0;
apalmieri 0:a77f1f1f8318 170 valid_msg = 1;
apalmieri 0:a77f1f1f8318 171 continue;
apalmieri 0:a77f1f1f8318 172 }
apalmieri 0:a77f1f1f8318 173 else {
apalmieri 0:a77f1f1f8318 174 while (NMEA[i++] != '\n');
apalmieri 0:a77f1f1f8318 175 j = k = 0;
apalmieri 0:a77f1f1f8318 176 }
apalmieri 0:a77f1f1f8318 177 }
apalmieri 0:a77f1f1f8318 178 app[j][k++] = NMEA[i];
apalmieri 0:a77f1f1f8318 179 }
apalmieri 0:a77f1f1f8318 180
apalmieri 0:a77f1f1f8318 181 if (valid_msg == 1) {
apalmieri 0:a77f1f1f8318 182 sscanf ((char *)app[0], "%s", gns_data->constellation);
apalmieri 0:a77f1f1f8318 183 scan_utc ((char *)app[1], &gns_data->utc);
apalmieri 0:a77f1f1f8318 184 sscanf ((char *)app[2], "%lf", &gns_data->xyz.lat);
apalmieri 0:a77f1f1f8318 185 sscanf ((char *)app[3], "%c", &gns_data->xyz.ns);
apalmieri 0:a77f1f1f8318 186 sscanf ((char *)app[4], "%lf", &gns_data->xyz.lon);
apalmieri 0:a77f1f1f8318 187 sscanf ((char *)app[5], "%c", &gns_data->xyz.ew);
apalmieri 0:a77f1f1f8318 188 sscanf ((char *)app[6], "%c", &gns_data->gps_mode);
apalmieri 0:a77f1f1f8318 189 sscanf ((char *)app[7], "%c", &gns_data->glonass_mode);
apalmieri 0:a77f1f1f8318 190 sscanf ((char *)app[8], "%d", &gns_data->sats);
apalmieri 0:a77f1f1f8318 191 sscanf ((char *)app[9], "%f", &gns_data->hdop);
apalmieri 0:a77f1f1f8318 192 sscanf ((char *)app[10], "%f", &gns_data->xyz.alt);
apalmieri 0:a77f1f1f8318 193 sscanf ((char *)app[11], "%f", &gns_data->geo_sep);
apalmieri 0:a77f1f1f8318 194 sscanf ((char *)app[12], "%c", &gns_data->dgnss_age);
apalmieri 0:a77f1f1f8318 195 sscanf ((char *)app[13], "%c", &gns_data->dgnss_ref);
apalmieri 0:a77f1f1f8318 196 sscanf ((char *)app[14], "%x", &gns_data->checksum);
apalmieri 0:a77f1f1f8318 197
apalmieri 0:a77f1f1f8318 198 valid_msg = 0;
apalmieri 0:a77f1f1f8318 199 status = PARSE_SUCC;
apalmieri 0:a77f1f1f8318 200 }
apalmieri 0:a77f1f1f8318 201
apalmieri 0:a77f1f1f8318 202 return status;
apalmieri 0:a77f1f1f8318 203 }
apalmieri 0:a77f1f1f8318 204
apalmieri 0:a77f1f1f8318 205 /**
apalmieri 0:a77f1f1f8318 206 * @brief Function that makes the parsing of the $GPGST NMEA string with GPS Pseudorange Noise Statistics.
apalmieri 0:a77f1f1f8318 207 * @param GPGST_Infos Pointer to a GPGST_Infos struct
apalmieri 0:a77f1f1f8318 208 * @param NMEA NMEA string read by the Gps expansion.
apalmieri 0:a77f1f1f8318 209 * @retval ParseStatus_Typedef PARSE_SUCC if the parsing process goes ok, PARSE_FAIL if it doesn't
apalmieri 0:a77f1f1f8318 210 */
apalmieri 0:a77f1f1f8318 211 ParseStatus_Typedef parse_gpgst (GPGST_Infos *gpgst_data, uint8_t *NMEA)
apalmieri 0:a77f1f1f8318 212 {
apalmieri 0:a77f1f1f8318 213 uint8_t app[MAX_MSG_LEN][MAX_MSG_LEN];
apalmieri 0:a77f1f1f8318 214 uint8_t valid_msg = 0;
apalmieri 0:a77f1f1f8318 215
apalmieri 0:a77f1f1f8318 216 ParseStatus_Typedef status = PARSE_FAIL;
apalmieri 0:a77f1f1f8318 217
apalmieri 0:a77f1f1f8318 218 if(NMEA == NULL)
apalmieri 0:a77f1f1f8318 219 return status;
apalmieri 0:a77f1f1f8318 220
apalmieri 0:a77f1f1f8318 221 /* clear the app[][] buffer */
apalmieri 0:a77f1f1f8318 222 for (uint8_t i=0; i<MAX_MSG_LEN; i++) {
apalmieri 0:a77f1f1f8318 223 memset(app[i], 0, MAX_MSG_LEN);
apalmieri 0:a77f1f1f8318 224 }
apalmieri 0:a77f1f1f8318 225
apalmieri 0:a77f1f1f8318 226 for (unsigned i = 0, j = 0, k = 0; NMEA[i] != '\n' && i < strlen((char *)NMEA) - 1; i++)
apalmieri 0:a77f1f1f8318 227 {
apalmieri 0:a77f1f1f8318 228 if ((NMEA[i] == ',') || (NMEA[i] == '*')) {
apalmieri 0:a77f1f1f8318 229 app[j][k] = '\0';
apalmieri 0:a77f1f1f8318 230
apalmieri 0:a77f1f1f8318 231 if (strcmp((char *)app[0], "$GPGST") == 0)
apalmieri 0:a77f1f1f8318 232 {
apalmieri 0:a77f1f1f8318 233 j++;
apalmieri 0:a77f1f1f8318 234 k = 0;
apalmieri 0:a77f1f1f8318 235 valid_msg = 1;
apalmieri 0:a77f1f1f8318 236 continue;
apalmieri 0:a77f1f1f8318 237 }
apalmieri 0:a77f1f1f8318 238 else {
apalmieri 0:a77f1f1f8318 239 while (NMEA[i++] != '\n');
apalmieri 0:a77f1f1f8318 240 j = k = 0;
apalmieri 0:a77f1f1f8318 241 }
apalmieri 0:a77f1f1f8318 242 }
apalmieri 0:a77f1f1f8318 243 app[j][k++] = NMEA[i];
apalmieri 0:a77f1f1f8318 244 }
apalmieri 0:a77f1f1f8318 245
apalmieri 0:a77f1f1f8318 246 if (valid_msg == 1) {
apalmieri 0:a77f1f1f8318 247 scan_utc ((char *)app[1], &gpgst_data->utc);
apalmieri 0:a77f1f1f8318 248 sscanf ((char *)app[2], "%f", &gpgst_data->EHPE);
apalmieri 0:a77f1f1f8318 249 sscanf ((char *)app[3], "%f", &gpgst_data->semi_major_dev);
apalmieri 0:a77f1f1f8318 250 sscanf ((char *)app[4], "%f", &gpgst_data->semi_minor_dev);
apalmieri 0:a77f1f1f8318 251 sscanf ((char *)app[5], "%f", &gpgst_data->semi_major_angle);
apalmieri 0:a77f1f1f8318 252 sscanf ((char *)app[6], "%f", &gpgst_data->lat_err_dev);
apalmieri 0:a77f1f1f8318 253 sscanf ((char *)app[7], "%f", &gpgst_data->lon_err_dev);
apalmieri 0:a77f1f1f8318 254 sscanf ((char *)app[8], "%f", &gpgst_data->alt_err_dev);
apalmieri 0:a77f1f1f8318 255 sscanf ((char *)app[9], "%x", &gpgst_data->checksum);
apalmieri 0:a77f1f1f8318 256
apalmieri 0:a77f1f1f8318 257 valid_msg = 0;
apalmieri 0:a77f1f1f8318 258 status = PARSE_SUCC;
apalmieri 0:a77f1f1f8318 259 }
apalmieri 0:a77f1f1f8318 260
apalmieri 0:a77f1f1f8318 261 return status;
apalmieri 0:a77f1f1f8318 262 }
apalmieri 0:a77f1f1f8318 263
apalmieri 0:a77f1f1f8318 264 /**
apalmieri 0:a77f1f1f8318 265 * @brief Function that makes the parsing of the $GPRMC NMEA string with Recommended Minimum Specific GPS/Transit data.
apalmieri 0:a77f1f1f8318 266 * @param GPRMC_Infos Pointer to a GPRMC_Infos struct
apalmieri 0:a77f1f1f8318 267 * @param NMEA NMEA string read by the Gps expansion.
apalmieri 0:a77f1f1f8318 268 * @retval ParseStatus_Typedef PARSE_SUCC if the parsing process goes ok, PARSE_FAIL if it doesn't
apalmieri 0:a77f1f1f8318 269 */
apalmieri 0:a77f1f1f8318 270 ParseStatus_Typedef parse_gprmc (GPRMC_Infos *gprmc_data, uint8_t *NMEA)
apalmieri 0:a77f1f1f8318 271 {
apalmieri 0:a77f1f1f8318 272 uint8_t app[MAX_MSG_LEN][MAX_MSG_LEN];
apalmieri 0:a77f1f1f8318 273 uint8_t valid_msg = 0;
apalmieri 0:a77f1f1f8318 274
apalmieri 0:a77f1f1f8318 275 ParseStatus_Typedef status = PARSE_FAIL;
apalmieri 0:a77f1f1f8318 276
apalmieri 0:a77f1f1f8318 277 if(NMEA == NULL)
apalmieri 0:a77f1f1f8318 278 return status;
apalmieri 0:a77f1f1f8318 279
apalmieri 0:a77f1f1f8318 280 /* clear the app[][] buffer */
apalmieri 0:a77f1f1f8318 281 for (uint8_t i=0; i<MAX_MSG_LEN; i++) {
apalmieri 0:a77f1f1f8318 282 memset(app[i], 0, MAX_MSG_LEN);
apalmieri 0:a77f1f1f8318 283 }
apalmieri 0:a77f1f1f8318 284
apalmieri 0:a77f1f1f8318 285 for (unsigned i = 0, j = 0, k = 0; NMEA[i] != '\n' && i < strlen((char *)NMEA) - 1; i++)
apalmieri 0:a77f1f1f8318 286 {
apalmieri 0:a77f1f1f8318 287 if ((NMEA[i] == ',') || (NMEA[i] == '*')) {
apalmieri 0:a77f1f1f8318 288 app[j][k] = '\0';
apalmieri 0:a77f1f1f8318 289
apalmieri 0:a77f1f1f8318 290 if (strcmp((char *)app[0], "$GPRMC") == 0)
apalmieri 0:a77f1f1f8318 291 {
apalmieri 0:a77f1f1f8318 292 j++;
apalmieri 0:a77f1f1f8318 293 k = 0;
apalmieri 0:a77f1f1f8318 294 valid_msg = 1;
apalmieri 0:a77f1f1f8318 295 continue;
apalmieri 0:a77f1f1f8318 296 }
apalmieri 0:a77f1f1f8318 297 else {
apalmieri 0:a77f1f1f8318 298 while (NMEA[i++] != '\n');
apalmieri 0:a77f1f1f8318 299 j = k = 0;
apalmieri 0:a77f1f1f8318 300 }
apalmieri 0:a77f1f1f8318 301 }
apalmieri 0:a77f1f1f8318 302 app[j][k++] = NMEA[i];
apalmieri 0:a77f1f1f8318 303 }
apalmieri 0:a77f1f1f8318 304
apalmieri 0:a77f1f1f8318 305 if (valid_msg == 1) {
apalmieri 0:a77f1f1f8318 306 scan_utc ((char *)app[1], &gprmc_data->utc);
apalmieri 0:a77f1f1f8318 307 sscanf ((char *)app[2], "%c", &gprmc_data->status);
apalmieri 0:a77f1f1f8318 308 sscanf ((char *)app[3], "%lf", &gprmc_data->xyz.lat);
apalmieri 0:a77f1f1f8318 309 sscanf ((char *)app[4], "%c", &gprmc_data->xyz.ns);
apalmieri 0:a77f1f1f8318 310 sscanf ((char *)app[5], "%lf", &gprmc_data->xyz.lon);
apalmieri 0:a77f1f1f8318 311 sscanf ((char *)app[6], "%c", &gprmc_data->xyz.ew);
apalmieri 0:a77f1f1f8318 312 sscanf ((char *)app[7], "%f", &gprmc_data->speed);
apalmieri 0:a77f1f1f8318 313 sscanf ((char *)app[8], "%f", &gprmc_data->trackgood);
apalmieri 0:a77f1f1f8318 314 sscanf ((char *)app[9], "%d", &gprmc_data->date);
apalmieri 0:a77f1f1f8318 315 sscanf ((char *)app[10], "%f", &gprmc_data->mag_var);
apalmieri 0:a77f1f1f8318 316 sscanf ((char *)app[11], "%c", &gprmc_data->mag_var_dir);
apalmieri 0:a77f1f1f8318 317 /* WARNING: from received msg, it seems there is another data (app[12]) before the checksum */
apalmieri 0:a77f1f1f8318 318 sscanf ((char *)app[13], "%x", &gprmc_data->checksum);
apalmieri 0:a77f1f1f8318 319
apalmieri 0:a77f1f1f8318 320 valid_msg = 0;
apalmieri 0:a77f1f1f8318 321 status = PARSE_SUCC;
apalmieri 0:a77f1f1f8318 322 }
apalmieri 0:a77f1f1f8318 323
apalmieri 0:a77f1f1f8318 324 return status;
apalmieri 0:a77f1f1f8318 325 }
apalmieri 0:a77f1f1f8318 326
apalmieri 0:a77f1f1f8318 327 /**
apalmieri 0:a77f1f1f8318 328 * @brief Function that makes the parsing of the string read by the Gps expansion, capturing the right parameters from it.
apalmieri 0:a77f1f1f8318 329 * @param GSA_Infos Pointer to a GSA_Infos struct
apalmieri 0:a77f1f1f8318 330 * @param NMEA NMEA string read by the Gps expansion.
apalmieri 0:a77f1f1f8318 331 * @retval ParseStatus_Typedef PARSE_SUCC if the parsing process goes ok, PARSE_FAIL if it doesn't
apalmieri 0:a77f1f1f8318 332 */
apalmieri 0:a77f1f1f8318 333 ParseStatus_Typedef parse_gsamsg (GSA_Infos *gsa_data, uint8_t *NMEA)
apalmieri 0:a77f1f1f8318 334 {
apalmieri 0:a77f1f1f8318 335 uint8_t app[MAX_MSG_LEN][MAX_MSG_LEN];
apalmieri 0:a77f1f1f8318 336 uint8_t valid_msg = 0;
apalmieri 0:a77f1f1f8318 337
apalmieri 0:a77f1f1f8318 338 ParseStatus_Typedef status = PARSE_FAIL;
apalmieri 0:a77f1f1f8318 339
apalmieri 0:a77f1f1f8318 340 if(NMEA == NULL)
apalmieri 0:a77f1f1f8318 341 return status;
apalmieri 0:a77f1f1f8318 342
apalmieri 0:a77f1f1f8318 343 /* clear the app[][] buffer */
apalmieri 0:a77f1f1f8318 344 for (uint8_t i=0; i<19; i++) {
apalmieri 0:a77f1f1f8318 345 memset(app[i], 0, 19);
apalmieri 0:a77f1f1f8318 346 }
apalmieri 0:a77f1f1f8318 347
apalmieri 0:a77f1f1f8318 348 for (unsigned i = 0, j = 0, k = 0; NMEA[i] != '\n' && i < strlen((char *)NMEA) - 1; i++)
apalmieri 0:a77f1f1f8318 349 {
apalmieri 0:a77f1f1f8318 350 if ((NMEA[i] == ',') || (NMEA[i] == '*')) {
apalmieri 0:a77f1f1f8318 351 app[j][k] = '\0';
apalmieri 0:a77f1f1f8318 352
apalmieri 0:a77f1f1f8318 353 if ((strcmp((char *)app[0], "$GPGSA") == 0) ||
apalmieri 0:a77f1f1f8318 354 (strcmp((char *)app[0], "$GLGSA") == 0) ||
apalmieri 0:a77f1f1f8318 355 (strcmp((char *)app[0], "$GAGSA") == 0) ||
apalmieri 0:a77f1f1f8318 356 (strcmp((char *)app[0], "$BDGSA") == 0) ||
apalmieri 0:a77f1f1f8318 357 (strcmp((char *)app[0], "$GNGSA") == 0))
apalmieri 0:a77f1f1f8318 358 {
apalmieri 0:a77f1f1f8318 359 j++;
apalmieri 0:a77f1f1f8318 360 k = 0;
apalmieri 0:a77f1f1f8318 361 valid_msg = 1;
apalmieri 0:a77f1f1f8318 362 continue;
apalmieri 0:a77f1f1f8318 363 }
apalmieri 0:a77f1f1f8318 364 else {
apalmieri 0:a77f1f1f8318 365 while (NMEA[i++] != '\n');
apalmieri 0:a77f1f1f8318 366 j = k = 0;
apalmieri 0:a77f1f1f8318 367 }
apalmieri 0:a77f1f1f8318 368 }
apalmieri 0:a77f1f1f8318 369 app[j][k++] = NMEA[i];
apalmieri 0:a77f1f1f8318 370 }
apalmieri 0:a77f1f1f8318 371
apalmieri 0:a77f1f1f8318 372 if (valid_msg == 1) {
apalmieri 0:a77f1f1f8318 373 sscanf ((char *)app[0], "%s", gsa_data->constellation);
apalmieri 0:a77f1f1f8318 374 sscanf ((char *)app[1], "%c", &gsa_data->operating_mode);
apalmieri 0:a77f1f1f8318 375 sscanf ((char *)app[2], "%d", &gsa_data->current_mode);
apalmieri 0:a77f1f1f8318 376 for (uint8_t i=0; i<MAX_SAT_NUM; i++) {
apalmieri 0:a77f1f1f8318 377 sscanf ((char *)app[3+i], "%d", &gsa_data->sat_prn[i]);
apalmieri 0:a77f1f1f8318 378 }
apalmieri 0:a77f1f1f8318 379 sscanf ((char *)app[15], "%f", &gsa_data->pdop);
apalmieri 0:a77f1f1f8318 380 sscanf ((char *)app[16], "%f", &gsa_data->hdop);
apalmieri 0:a77f1f1f8318 381 sscanf ((char *)app[17], "%f", &gsa_data->vdop);
apalmieri 0:a77f1f1f8318 382 sscanf ((char *)app[18], "%x", &gsa_data->checksum);
apalmieri 0:a77f1f1f8318 383
apalmieri 0:a77f1f1f8318 384 valid_msg = 0;
apalmieri 0:a77f1f1f8318 385 status = PARSE_SUCC;
apalmieri 0:a77f1f1f8318 386 }
apalmieri 0:a77f1f1f8318 387
apalmieri 0:a77f1f1f8318 388 return status;
apalmieri 0:a77f1f1f8318 389 }
apalmieri 0:a77f1f1f8318 390
apalmieri 0:a77f1f1f8318 391 /**
apalmieri 0:a77f1f1f8318 392 * @brief Function that makes the parsing of the string read by the Gps expansion, capturing the right parameters from it.
apalmieri 0:a77f1f1f8318 393 * @param GSV_Infos Pointer to a GSV_Infos struct
apalmieri 0:a77f1f1f8318 394 * @param NMEA NMEA string read by the Gps expansion.
apalmieri 0:a77f1f1f8318 395 * @retval ParseStatus_Typedef PARSE_SUCC if the parsing process goes ok, PARSE_FAIL if it doesn't
apalmieri 0:a77f1f1f8318 396 */
apalmieri 0:a77f1f1f8318 397 ParseStatus_Typedef parse_gsvmsg(GSV_Infos *gsv_data, uint8_t *NMEA)
apalmieri 0:a77f1f1f8318 398 {
apalmieri 0:a77f1f1f8318 399 uint8_t app[32][16];
apalmieri 0:a77f1f1f8318 400 uint8_t app_idx;
apalmieri 0:a77f1f1f8318 401 uint8_t gsv_idx = 0;
apalmieri 0:a77f1f1f8318 402 int msg_amount = 1;
apalmieri 0:a77f1f1f8318 403 int curr_msg;
apalmieri 0:a77f1f1f8318 404 uint8_t right_msg = 0;
apalmieri 0:a77f1f1f8318 405 uint8_t valid_gsv_msg = 0;
apalmieri 0:a77f1f1f8318 406 unsigned i, j, k;
apalmieri 0:a77f1f1f8318 407 unsigned l = 0;
apalmieri 0:a77f1f1f8318 408
apalmieri 0:a77f1f1f8318 409 ParseStatus_Typedef status = PARSE_FAIL;
apalmieri 0:a77f1f1f8318 410
apalmieri 0:a77f1f1f8318 411 if(NMEA == NULL)
apalmieri 0:a77f1f1f8318 412 return status;
apalmieri 0:a77f1f1f8318 413
apalmieri 0:a77f1f1f8318 414 while (right_msg < msg_amount)
apalmieri 0:a77f1f1f8318 415 {
apalmieri 0:a77f1f1f8318 416 /* clear the app[][] buffer */
apalmieri 0:a77f1f1f8318 417 for (uint8_t pos=0; pos<32; pos++) {
apalmieri 0:a77f1f1f8318 418 memset(app[pos], 0, 16);
apalmieri 0:a77f1f1f8318 419 }
apalmieri 0:a77f1f1f8318 420
apalmieri 0:a77f1f1f8318 421 for (i = l, j = 0, k = 0; NMEA[i] != '\n' && i < strlen((char *)NMEA) - 1; i++)
apalmieri 0:a77f1f1f8318 422 {
apalmieri 0:a77f1f1f8318 423 if (NMEA[i] == ',') {
apalmieri 0:a77f1f1f8318 424 app[j][k] = '\0';
apalmieri 0:a77f1f1f8318 425
apalmieri 0:a77f1f1f8318 426 if ((strcmp((char *)app[0], "$GPGSV") == 0) ||
apalmieri 0:a77f1f1f8318 427 (strcmp((char *)app[0], "$GLGSV") == 0) ||
apalmieri 0:a77f1f1f8318 428 (strcmp((char *)app[0], "$GAGSV") == 0) ||
apalmieri 0:a77f1f1f8318 429 (strcmp((char *)app[0], "$BDGSV") == 0) ||
apalmieri 0:a77f1f1f8318 430 (strcmp((char *)app[0], "$QZGSV") == 0) ||
apalmieri 0:a77f1f1f8318 431 (strcmp((char *)app[0], "$GNGSV") == 0))
apalmieri 0:a77f1f1f8318 432 {
apalmieri 0:a77f1f1f8318 433 j++;
apalmieri 0:a77f1f1f8318 434 k = 0;
apalmieri 0:a77f1f1f8318 435 valid_gsv_msg = 1;
apalmieri 0:a77f1f1f8318 436 continue;
apalmieri 0:a77f1f1f8318 437 }
apalmieri 0:a77f1f1f8318 438 else {
apalmieri 0:a77f1f1f8318 439 while (NMEA[i++] != '\n');
apalmieri 0:a77f1f1f8318 440 j = k = 0;
apalmieri 0:a77f1f1f8318 441 }
apalmieri 0:a77f1f1f8318 442 }
apalmieri 0:a77f1f1f8318 443 if ((NMEA[i] == '*') && (k!=0)) {
apalmieri 0:a77f1f1f8318 444 j++;
apalmieri 0:a77f1f1f8318 445 k=0;
apalmieri 0:a77f1f1f8318 446 }
apalmieri 0:a77f1f1f8318 447 app[j][k++] = NMEA[i];
apalmieri 0:a77f1f1f8318 448 }
apalmieri 0:a77f1f1f8318 449
apalmieri 0:a77f1f1f8318 450 l = i;
apalmieri 0:a77f1f1f8318 451
apalmieri 0:a77f1f1f8318 452 if (valid_gsv_msg == 1) {
apalmieri 0:a77f1f1f8318 453 valid_gsv_msg = 0;
apalmieri 0:a77f1f1f8318 454 sscanf((char *)app[1], "%d", &msg_amount);
apalmieri 0:a77f1f1f8318 455 sscanf((char *)app[2], "%d", &curr_msg);
apalmieri 0:a77f1f1f8318 456 if (curr_msg == right_msg+1) {
apalmieri 0:a77f1f1f8318 457 valid_gsv_msg = 1;
apalmieri 0:a77f1f1f8318 458 right_msg++;
apalmieri 0:a77f1f1f8318 459 }
apalmieri 0:a77f1f1f8318 460 }
apalmieri 0:a77f1f1f8318 461 else {
apalmieri 0:a77f1f1f8318 462 right_msg = msg_amount;
apalmieri 0:a77f1f1f8318 463 }
apalmieri 0:a77f1f1f8318 464
apalmieri 0:a77f1f1f8318 465 if (valid_gsv_msg == 1) {
apalmieri 0:a77f1f1f8318 466 sscanf((char *)app[0], "%s", gsv_data->constellation);
apalmieri 0:a77f1f1f8318 467 sscanf((char *)app[1], "%d", &gsv_data->amount);
apalmieri 0:a77f1f1f8318 468 sscanf((char *)app[2], "%d", &gsv_data->number);
apalmieri 0:a77f1f1f8318 469 sscanf((char *)app[3], "%d", &gsv_data->tot_sats);
apalmieri 0:a77f1f1f8318 470 app_idx = 4;
apalmieri 0:a77f1f1f8318 471 while (app[app_idx][0] != '*') {
apalmieri 0:a77f1f1f8318 472 sscanf((char *)app[app_idx++], "%d", &gsv_data->gsv_sat_i[gsv_idx].prn);
apalmieri 0:a77f1f1f8318 473 sscanf((char *)app[app_idx++], "%d", &gsv_data->gsv_sat_i[gsv_idx].elev);
apalmieri 0:a77f1f1f8318 474 sscanf((char *)app[app_idx++], "%d", &gsv_data->gsv_sat_i[gsv_idx].azim);
apalmieri 0:a77f1f1f8318 475 if (app[app_idx][0] != '*') {
apalmieri 0:a77f1f1f8318 476 sscanf((char *)app[app_idx++], "%d", &gsv_data->gsv_sat_i[gsv_idx].cn0);
apalmieri 0:a77f1f1f8318 477 }
apalmieri 0:a77f1f1f8318 478 else {
apalmieri 0:a77f1f1f8318 479 sscanf("", "%d", &gsv_data->gsv_sat_i[gsv_idx].cn0);
apalmieri 0:a77f1f1f8318 480 }
apalmieri 0:a77f1f1f8318 481 gsv_idx++;
apalmieri 0:a77f1f1f8318 482 }
apalmieri 0:a77f1f1f8318 483
apalmieri 0:a77f1f1f8318 484 valid_gsv_msg = 0;
apalmieri 0:a77f1f1f8318 485
apalmieri 0:a77f1f1f8318 486 status = PARSE_SUCC;
apalmieri 0:a77f1f1f8318 487 }
apalmieri 0:a77f1f1f8318 488 }
apalmieri 0:a77f1f1f8318 489
apalmieri 0:a77f1f1f8318 490 return status;
apalmieri 0:a77f1f1f8318 491 }
apalmieri 0:a77f1f1f8318 492
apalmieri 0:a77f1f1f8318 493 /**
apalmieri 0:a77f1f1f8318 494 * @brief
apalmieri 0:a77f1f1f8318 495 * @param Geofence_Infos Pointer to a Geofence_Infos struct
apalmieri 0:a77f1f1f8318 496 * @param NMEA NMEA string read by the Gps expansion.
apalmieri 0:a77f1f1f8318 497 * @retval ParseStatus_Typedef PARSE_SUCC if the parsing process goes ok, PARSE_FAIL if it doesn't
apalmieri 0:a77f1f1f8318 498 */
apalmieri 0:a77f1f1f8318 499 ParseStatus_Typedef parse_pstmgeofence(Geofence_Infos *geofence_data, uint8_t *NMEA)
apalmieri 0:a77f1f1f8318 500 {
apalmieri 0:a77f1f1f8318 501 uint8_t app[MAX_MSG_LEN][MAX_MSG_LEN];
apalmieri 0:a77f1f1f8318 502 uint8_t valid_msg = 0;
apalmieri 0:a77f1f1f8318 503
apalmieri 0:a77f1f1f8318 504 ParseStatus_Typedef status = PARSE_FAIL;
apalmieri 0:a77f1f1f8318 505
apalmieri 0:a77f1f1f8318 506 if(NMEA == NULL)
apalmieri 0:a77f1f1f8318 507 return status;
apalmieri 0:a77f1f1f8318 508
apalmieri 0:a77f1f1f8318 509 /* clear the app[][] buffer */
apalmieri 0:a77f1f1f8318 510 for (uint8_t i=0; i<MAX_MSG_LEN; i++) {
apalmieri 0:a77f1f1f8318 511 memset(app[i], 0, MAX_MSG_LEN);
apalmieri 0:a77f1f1f8318 512 }
apalmieri 0:a77f1f1f8318 513
apalmieri 0:a77f1f1f8318 514 for(unsigned i = 0, j = 0, k = 0; NMEA[i] != '\n' && i < strlen((char *)NMEA) - 1; i++)
apalmieri 0:a77f1f1f8318 515 {
apalmieri 0:a77f1f1f8318 516 if ((NMEA[i] == ',') || (NMEA[i] == '*')) {
apalmieri 0:a77f1f1f8318 517 app[j][k] = '\0';
apalmieri 0:a77f1f1f8318 518
apalmieri 0:a77f1f1f8318 519 if ((strcmp((char *)app[0], "$PSTMCFGGEOFENCEOK") == 0) ||
apalmieri 0:a77f1f1f8318 520 (strcmp((char *)app[0], "$PSTMCFGGEOFENCEERROR") == 0) ||
apalmieri 0:a77f1f1f8318 521 (strcmp((char *)app[0], "$PSTMGEOFENCECFGOK") == 0) ||
apalmieri 0:a77f1f1f8318 522 (strcmp((char *)app[0], "$PSTMGEOFENCECFGERROR") == 0) ||
apalmieri 0:a77f1f1f8318 523 (strcmp((char *)app[0], "$PSTMGEOFENCESTATUS") == 0) ||
apalmieri 0:a77f1f1f8318 524 (strcmp((char *)app[0], "$PSTMGEOFENCE") == 0) ||
apalmieri 0:a77f1f1f8318 525 (strcmp((char *)app[0], "$PSTMGEOFENCEREQERROR") == 0)) {
apalmieri 0:a77f1f1f8318 526 j++;
apalmieri 0:a77f1f1f8318 527 k = 0;
apalmieri 0:a77f1f1f8318 528 valid_msg = 1;
apalmieri 0:a77f1f1f8318 529 continue;
apalmieri 0:a77f1f1f8318 530 }
apalmieri 0:a77f1f1f8318 531 else {
apalmieri 0:a77f1f1f8318 532 while(NMEA[i++] != '\n');
apalmieri 0:a77f1f1f8318 533 j = k = 0;
apalmieri 0:a77f1f1f8318 534 }
apalmieri 0:a77f1f1f8318 535 }
apalmieri 0:a77f1f1f8318 536 app[j][k++] = NMEA[i];
apalmieri 0:a77f1f1f8318 537 }
apalmieri 0:a77f1f1f8318 538
apalmieri 0:a77f1f1f8318 539 if (valid_msg == 1) {
apalmieri 0:a77f1f1f8318 540 /* Enabling */
apalmieri 0:a77f1f1f8318 541 if (strcmp((char *)app[0], "$PSTMCFGGEOFENCEOK") == 0) {
apalmieri 0:a77f1f1f8318 542 geofence_data->op = GNSS_FEATURE_EN_MSG;
apalmieri 0:a77f1f1f8318 543 geofence_data->result = 0;
apalmieri 0:a77f1f1f8318 544 }
apalmieri 0:a77f1f1f8318 545 if (strcmp((char *)app[0], "$PSTMCFGGEOFENCEERROR") == 0) {
apalmieri 0:a77f1f1f8318 546 geofence_data->op = GNSS_FEATURE_EN_MSG;
apalmieri 0:a77f1f1f8318 547 geofence_data->result = 1;
apalmieri 0:a77f1f1f8318 548 }
apalmieri 0:a77f1f1f8318 549 /* Configuring */
apalmieri 0:a77f1f1f8318 550 if (strcmp((char *)app[0], "$PSTMGEOFENCECFGOK") == 0) {
apalmieri 0:a77f1f1f8318 551 geofence_data->op = GNSS_GEOFENCE_CFG_MSG;
apalmieri 0:a77f1f1f8318 552 geofence_data->result = 0;
apalmieri 0:a77f1f1f8318 553 }
apalmieri 0:a77f1f1f8318 554 if (strcmp((char *)app[0], "$PSTMGEOFENCECFGERROR") == 0) {
apalmieri 0:a77f1f1f8318 555 geofence_data->op = GNSS_GEOFENCE_STATUS_MSG;
apalmieri 0:a77f1f1f8318 556 geofence_data->result = 1;
apalmieri 0:a77f1f1f8318 557 }
apalmieri 0:a77f1f1f8318 558 /* Querying Status */
apalmieri 0:a77f1f1f8318 559 if (strcmp((char *)app[0], "$PSTMGEOFENCESTATUS") == 0) {
apalmieri 0:a77f1f1f8318 560 geofence_data->op = GNSS_GEOFENCE_STATUS_MSG;
apalmieri 0:a77f1f1f8318 561 geofence_data->result = 0;
apalmieri 0:a77f1f1f8318 562 sscanf((char *)app[1], "%02d%02d%02d", &geofence_data->timestamp.hh,&geofence_data->timestamp.mm,&geofence_data->timestamp.ss);
apalmieri 0:a77f1f1f8318 563 sscanf((char *)app[2], "%04d%02d%02d", &geofence_data->timestamp.year,&geofence_data->timestamp.month,&geofence_data->timestamp.day);
apalmieri 0:a77f1f1f8318 564 for(uint8_t i = 0; i<MAX_GEOFENCES_NUM; i++) {
apalmieri 0:a77f1f1f8318 565 sscanf((char *)app[3+i], "%d", &geofence_data->status[i]);
apalmieri 0:a77f1f1f8318 566 }
apalmieri 0:a77f1f1f8318 567 }
apalmieri 0:a77f1f1f8318 568 /* Alarm Msg */
apalmieri 0:a77f1f1f8318 569 if (strcmp((char *)app[0], "$PSTMGEOFENCE") == 0) {
apalmieri 0:a77f1f1f8318 570 geofence_data->op = GNSS_GEOFENCE_ALARM_MSG;
apalmieri 0:a77f1f1f8318 571 geofence_data->result = 0;
apalmieri 0:a77f1f1f8318 572 sscanf((char *)app[1], "%02d%02d%02d", &geofence_data->timestamp.hh,&geofence_data->timestamp.mm,&geofence_data->timestamp.ss);
apalmieri 0:a77f1f1f8318 573 sscanf((char *)app[2], "%04d%02d%02d", &geofence_data->timestamp.year,&geofence_data->timestamp.month,&geofence_data->timestamp.day);
apalmieri 0:a77f1f1f8318 574 sscanf((char *)app[3], "%d", &geofence_data->idAlarm);
apalmieri 0:a77f1f1f8318 575 sscanf((char *)app[9], "%d", &geofence_data->status[geofence_data->idAlarm]);
apalmieri 0:a77f1f1f8318 576 }
apalmieri 0:a77f1f1f8318 577
apalmieri 0:a77f1f1f8318 578 valid_msg = 0;
apalmieri 0:a77f1f1f8318 579 status = PARSE_SUCC;
apalmieri 0:a77f1f1f8318 580 }
apalmieri 0:a77f1f1f8318 581 return status;
apalmieri 0:a77f1f1f8318 582 }
apalmieri 0:a77f1f1f8318 583
apalmieri 0:a77f1f1f8318 584 /**
apalmieri 0:a77f1f1f8318 585 * @brief
apalmieri 0:a77f1f1f8318 586 * @param Odometer_Infos Pointer to a Odometer_Infos struct
apalmieri 0:a77f1f1f8318 587 * @param NMEA NMEA string read by the Gps expansion.
apalmieri 0:a77f1f1f8318 588 * @retval ParseStatus_Typedef PARSE_SUCC if the parsing process goes ok, PARSE_FAIL if it doesn't
apalmieri 0:a77f1f1f8318 589 */
apalmieri 0:a77f1f1f8318 590 ParseStatus_Typedef parse_pstmodo(Odometer_Infos *odo_data, uint8_t *NMEA)
apalmieri 0:a77f1f1f8318 591 {
apalmieri 0:a77f1f1f8318 592 uint8_t app[MAX_MSG_LEN][MAX_MSG_LEN];
apalmieri 0:a77f1f1f8318 593 uint8_t valid_msg = 0;
apalmieri 0:a77f1f1f8318 594
apalmieri 0:a77f1f1f8318 595 ParseStatus_Typedef status = PARSE_FAIL;
apalmieri 0:a77f1f1f8318 596
apalmieri 0:a77f1f1f8318 597 if(NMEA == NULL)
apalmieri 0:a77f1f1f8318 598 return status;
apalmieri 0:a77f1f1f8318 599
apalmieri 0:a77f1f1f8318 600 /* clear the app[][] buffer */
apalmieri 0:a77f1f1f8318 601 for (uint8_t i=0; i<MAX_MSG_LEN; i++) {
apalmieri 0:a77f1f1f8318 602 memset(app[i], 0, MAX_MSG_LEN);
apalmieri 0:a77f1f1f8318 603 }
apalmieri 0:a77f1f1f8318 604
apalmieri 0:a77f1f1f8318 605 for(unsigned i = 0, j = 0, k = 0; NMEA[i] != '\n' && i < strlen((char *)NMEA) - 1; i++)
apalmieri 0:a77f1f1f8318 606 {
apalmieri 0:a77f1f1f8318 607 if ((NMEA[i] == ',') || (NMEA[i] == '*')) {
apalmieri 0:a77f1f1f8318 608 app[j][k] = '\0';
apalmieri 0:a77f1f1f8318 609
apalmieri 0:a77f1f1f8318 610 if ((strcmp((char *)app[0], "$PSTMCFGODOOK") == 0) ||
apalmieri 0:a77f1f1f8318 611 (strcmp((char *)app[0], "$PSTMCFGODOERROR") == 0) ||
apalmieri 0:a77f1f1f8318 612 (strcmp((char *)app[0], "$PSTMODOSTARTOK") == 0) ||
apalmieri 0:a77f1f1f8318 613 (strcmp((char *)app[0], "$PSTMODOSTARTERROR") == 0) ||
apalmieri 0:a77f1f1f8318 614 (strcmp((char *)app[0], "$PSTMODOSTOPOK") == 0) ||
apalmieri 0:a77f1f1f8318 615 (strcmp((char *)app[0], "$PSTMODOSTOPERROR") == 0)) {
apalmieri 0:a77f1f1f8318 616 j++;
apalmieri 0:a77f1f1f8318 617 k = 0;
apalmieri 0:a77f1f1f8318 618 valid_msg = 1;
apalmieri 0:a77f1f1f8318 619 continue;
apalmieri 0:a77f1f1f8318 620 }
apalmieri 0:a77f1f1f8318 621 else {
apalmieri 0:a77f1f1f8318 622 while(NMEA[i++] != '\n');
apalmieri 0:a77f1f1f8318 623 j = k = 0;
apalmieri 0:a77f1f1f8318 624 }
apalmieri 0:a77f1f1f8318 625 }
apalmieri 0:a77f1f1f8318 626 app[j][k++] = NMEA[i];
apalmieri 0:a77f1f1f8318 627 }
apalmieri 0:a77f1f1f8318 628
apalmieri 0:a77f1f1f8318 629 if (valid_msg == 1) {
apalmieri 0:a77f1f1f8318 630 /* Enabling */
apalmieri 0:a77f1f1f8318 631 if (strcmp((char *)app[0], "$PSTMCFGODOOK") == 0) {
apalmieri 0:a77f1f1f8318 632 odo_data->op = GNSS_FEATURE_EN_MSG;
apalmieri 0:a77f1f1f8318 633 odo_data->result = 0;
apalmieri 0:a77f1f1f8318 634 }
apalmieri 0:a77f1f1f8318 635 if (strcmp((char *)app[0], "$PSTMCFGODOERROR") == 0) {
apalmieri 0:a77f1f1f8318 636 odo_data->op = GNSS_FEATURE_EN_MSG;
apalmieri 0:a77f1f1f8318 637 odo_data->result = 1;
apalmieri 0:a77f1f1f8318 638 }
apalmieri 0:a77f1f1f8318 639
apalmieri 0:a77f1f1f8318 640 /* Start */
apalmieri 0:a77f1f1f8318 641 if (strcmp((char *)app[0], "$PSTMODOSTARTOK") == 0) {
apalmieri 0:a77f1f1f8318 642 odo_data->op = GNSS_ODO_START_MSG;
apalmieri 0:a77f1f1f8318 643 odo_data->result = 0;
apalmieri 0:a77f1f1f8318 644 }
apalmieri 0:a77f1f1f8318 645 if (strcmp((char *)app[0], "$PSTMODOSTARTERROR") == 0) {
apalmieri 0:a77f1f1f8318 646 odo_data->op = GNSS_ODO_START_MSG;
apalmieri 0:a77f1f1f8318 647 odo_data->result = 1;
apalmieri 0:a77f1f1f8318 648 }
apalmieri 0:a77f1f1f8318 649
apalmieri 0:a77f1f1f8318 650 /* Stop */
apalmieri 0:a77f1f1f8318 651 if (strcmp((char *)app[0], "$PSTMODOSTOPOK") == 0) {
apalmieri 0:a77f1f1f8318 652 odo_data->op = GNSS_ODO_STOP_MSG;
apalmieri 0:a77f1f1f8318 653 odo_data->result = 0;
apalmieri 0:a77f1f1f8318 654 }
apalmieri 0:a77f1f1f8318 655 if (strcmp((char *)app[0], "$PSTMODOSTOPERROR") == 0) {
apalmieri 0:a77f1f1f8318 656 odo_data->op = GNSS_ODO_STOP_MSG;
apalmieri 0:a77f1f1f8318 657 odo_data->result = 1;
apalmieri 0:a77f1f1f8318 658 }
apalmieri 0:a77f1f1f8318 659
apalmieri 0:a77f1f1f8318 660 valid_msg = 0;
apalmieri 0:a77f1f1f8318 661 status = PARSE_SUCC;
apalmieri 0:a77f1f1f8318 662 }
apalmieri 0:a77f1f1f8318 663 return status;
apalmieri 0:a77f1f1f8318 664 }
apalmieri 0:a77f1f1f8318 665
apalmieri 0:a77f1f1f8318 666 /**
apalmieri 0:a77f1f1f8318 667 * @brief
apalmieri 0:a77f1f1f8318 668 * @param Datalog_Infos Pointer to a Datalog_Infos struct
apalmieri 0:a77f1f1f8318 669 * @param NMEA NMEA string read by the Gps expansion.
apalmieri 0:a77f1f1f8318 670 * @retval ParseStatus_Typedef PARSE_SUCC if the parsing process goes ok, PARSE_FAIL if it doesn't
apalmieri 0:a77f1f1f8318 671 */
apalmieri 0:a77f1f1f8318 672 ParseStatus_Typedef parse_pstmdatalog(Datalog_Infos *datalog_data, uint8_t *NMEA)
apalmieri 0:a77f1f1f8318 673 {
apalmieri 0:a77f1f1f8318 674 uint8_t app[MAX_MSG_LEN][MAX_MSG_LEN];
apalmieri 0:a77f1f1f8318 675 uint8_t valid_msg = 0;
apalmieri 0:a77f1f1f8318 676
apalmieri 0:a77f1f1f8318 677 ParseStatus_Typedef status = PARSE_FAIL;
apalmieri 0:a77f1f1f8318 678
apalmieri 0:a77f1f1f8318 679 if(NMEA == NULL)
apalmieri 0:a77f1f1f8318 680 return status;
apalmieri 0:a77f1f1f8318 681
apalmieri 0:a77f1f1f8318 682 /* clear the app[][] buffer */
apalmieri 0:a77f1f1f8318 683 for (uint8_t i=0; i<MAX_MSG_LEN; i++) {
apalmieri 0:a77f1f1f8318 684 memset(app[i], 0, MAX_MSG_LEN);
apalmieri 0:a77f1f1f8318 685 }
apalmieri 0:a77f1f1f8318 686
apalmieri 0:a77f1f1f8318 687 for(unsigned i = 0, j = 0, k = 0; NMEA[i] != '\n' && i < strlen((char *)NMEA) - 1; i++)
apalmieri 0:a77f1f1f8318 688 {
apalmieri 0:a77f1f1f8318 689 if ((NMEA[i] == ',') || (NMEA[i] == '*')) {
apalmieri 0:a77f1f1f8318 690 app[j][k] = '\0';
apalmieri 0:a77f1f1f8318 691
apalmieri 0:a77f1f1f8318 692 if ((strcmp((char *)app[0], "$PSTMCFGLOGOK") == 0) ||
apalmieri 0:a77f1f1f8318 693 (strcmp((char *)app[0], "$PSTMCFGLOGERROR") == 0) ||
apalmieri 0:a77f1f1f8318 694 (strcmp((char *)app[0], "$PSTMLOGCREATEOK") == 0) ||
apalmieri 0:a77f1f1f8318 695 (strcmp((char *)app[0], "$PSTMLOGCREATEERROR") == 0) ||
apalmieri 0:a77f1f1f8318 696 (strcmp((char *)app[0], "$PSTMLOGSTARTOK") == 0) ||
apalmieri 0:a77f1f1f8318 697 (strcmp((char *)app[0], "$PSTMLOGSTARTERROR") == 0) ||
apalmieri 0:a77f1f1f8318 698 (strcmp((char *)app[0], "$PSTMLOGSTOPOK") == 0) ||
apalmieri 0:a77f1f1f8318 699 (strcmp((char *)app[0], "$PSTMLOGSTOPERROR") == 0) ||
apalmieri 0:a77f1f1f8318 700 (strcmp((char *)app[0], "$PSTMLOGERASEOK") == 0) ||
apalmieri 0:a77f1f1f8318 701 (strcmp((char *)app[0], "$PSTMLOGERASEERROR") == 0)) {
apalmieri 0:a77f1f1f8318 702 j++;
apalmieri 0:a77f1f1f8318 703 k = 0;
apalmieri 0:a77f1f1f8318 704 valid_msg = 1;
apalmieri 0:a77f1f1f8318 705 continue;
apalmieri 0:a77f1f1f8318 706 }
apalmieri 0:a77f1f1f8318 707 else {
apalmieri 0:a77f1f1f8318 708 while(NMEA[i++] != '\n');
apalmieri 0:a77f1f1f8318 709 j = k = 0;
apalmieri 0:a77f1f1f8318 710 }
apalmieri 0:a77f1f1f8318 711 }
apalmieri 0:a77f1f1f8318 712 app[j][k++] = NMEA[i];
apalmieri 0:a77f1f1f8318 713 }
apalmieri 0:a77f1f1f8318 714
apalmieri 0:a77f1f1f8318 715 if (valid_msg == 1) {
apalmieri 0:a77f1f1f8318 716 /* Enabling */
apalmieri 0:a77f1f1f8318 717 if (strcmp((char *)app[0], "$PSTMCFGLOGOK") == 0) {
apalmieri 0:a77f1f1f8318 718 datalog_data->op = GNSS_FEATURE_EN_MSG;
apalmieri 0:a77f1f1f8318 719 datalog_data->result = 0;
apalmieri 0:a77f1f1f8318 720 }
apalmieri 0:a77f1f1f8318 721 if (strcmp((char *)app[0], "$PSTMCFGLOGERROR") == 0) {
apalmieri 0:a77f1f1f8318 722 datalog_data->op = GNSS_FEATURE_EN_MSG;
apalmieri 0:a77f1f1f8318 723 datalog_data->result = 1;
apalmieri 0:a77f1f1f8318 724 }
apalmieri 0:a77f1f1f8318 725 /* Configuring */
apalmieri 0:a77f1f1f8318 726 if (strcmp((char *)app[0], "$PSTMLOGCREATEOK") == 0) {
apalmieri 0:a77f1f1f8318 727 datalog_data->op = GNSS_DATALOG_CFG_MSG;
apalmieri 0:a77f1f1f8318 728 datalog_data->result = 0;
apalmieri 0:a77f1f1f8318 729 }
apalmieri 0:a77f1f1f8318 730 if (strcmp((char *)app[0], "$PSTMLOGCREATEERROR") == 0) {
apalmieri 0:a77f1f1f8318 731 datalog_data->op = GNSS_DATALOG_CFG_MSG;
apalmieri 0:a77f1f1f8318 732 datalog_data->result = 1;
apalmieri 0:a77f1f1f8318 733 }
apalmieri 0:a77f1f1f8318 734 /* Start */
apalmieri 0:a77f1f1f8318 735 if (strcmp((char *)app[0], "$PSTMLOGSTARTOK") == 0) {
apalmieri 0:a77f1f1f8318 736 datalog_data->op = GNSS_DATALOG_START_MSG;
apalmieri 0:a77f1f1f8318 737 datalog_data->result = 0;
apalmieri 0:a77f1f1f8318 738 }
apalmieri 0:a77f1f1f8318 739 if (strcmp((char *)app[0], "$PSTMLOGSTARTERROR") == 0) {
apalmieri 0:a77f1f1f8318 740 datalog_data->op = GNSS_DATALOG_START_MSG;
apalmieri 0:a77f1f1f8318 741 datalog_data->result = 1;
apalmieri 0:a77f1f1f8318 742 }
apalmieri 0:a77f1f1f8318 743 /* Stop */
apalmieri 0:a77f1f1f8318 744 if (strcmp((char *)app[0], "$PSTMLOGSTOPOK") == 0) {
apalmieri 0:a77f1f1f8318 745 datalog_data->op = GNSS_DATALOG_STOP_MSG;
apalmieri 0:a77f1f1f8318 746 datalog_data->result = 0;
apalmieri 0:a77f1f1f8318 747 }
apalmieri 0:a77f1f1f8318 748 if (strcmp((char *)app[0], "$PSTMLOGSTOPERROR") == 0) {
apalmieri 0:a77f1f1f8318 749 datalog_data->op = GNSS_DATALOG_STOP_MSG;
apalmieri 0:a77f1f1f8318 750 datalog_data->result = 1;
apalmieri 0:a77f1f1f8318 751 }
apalmieri 0:a77f1f1f8318 752 /* Erase */
apalmieri 0:a77f1f1f8318 753 if (strcmp((char *)app[0], "$PSTMLOGERASEOK") == 0) {
apalmieri 0:a77f1f1f8318 754 datalog_data->op = GNSS_DATALOG_ERASE_MSG;
apalmieri 0:a77f1f1f8318 755 datalog_data->result = 0;
apalmieri 0:a77f1f1f8318 756 }
apalmieri 0:a77f1f1f8318 757 if (strcmp((char *)app[0], "$PSTMLOGERASEERROR") == 0) {
apalmieri 0:a77f1f1f8318 758 datalog_data->op = GNSS_DATALOG_ERASE_MSG;
apalmieri 0:a77f1f1f8318 759 datalog_data->result = 1;
apalmieri 0:a77f1f1f8318 760 }
apalmieri 0:a77f1f1f8318 761
apalmieri 0:a77f1f1f8318 762 valid_msg = 0;
apalmieri 0:a77f1f1f8318 763 status = PARSE_SUCC;
apalmieri 0:a77f1f1f8318 764 }
apalmieri 0:a77f1f1f8318 765 return status;
apalmieri 0:a77f1f1f8318 766 }
apalmieri 0:a77f1f1f8318 767
apalmieri 0:a77f1f1f8318 768 /**
apalmieri 0:a77f1f1f8318 769 * @brief
apalmieri 0:a77f1f1f8318 770 * @param Ack_Info Ack from Teseo
apalmieri 0:a77f1f1f8318 771 * @param NMEA NMEA string read by the Gps expansion.
apalmieri 0:a77f1f1f8318 772 * @retval ParseStatus_Typedef PARSE_SUCC if the parsing process goes ok, PARSE_FAIL if it doesn't
apalmieri 0:a77f1f1f8318 773 */
apalmieri 0:a77f1f1f8318 774 ParseStatus_Typedef parse_pstmsgl(Ack_Info *ack, uint8_t *NMEA)
apalmieri 0:a77f1f1f8318 775 {
apalmieri 0:a77f1f1f8318 776 uint8_t app[MAX_MSG_LEN][MAX_MSG_LEN];
apalmieri 0:a77f1f1f8318 777 uint8_t valid_msg = 0;
apalmieri 0:a77f1f1f8318 778
apalmieri 0:a77f1f1f8318 779 ParseStatus_Typedef status = PARSE_FAIL;
apalmieri 0:a77f1f1f8318 780
apalmieri 0:a77f1f1f8318 781 if(NMEA == NULL)
apalmieri 0:a77f1f1f8318 782 return status;
apalmieri 0:a77f1f1f8318 783
apalmieri 0:a77f1f1f8318 784 /* clear the app[][] buffer */
apalmieri 0:a77f1f1f8318 785 for (uint8_t i=0; i<MAX_MSG_LEN; i++) {
apalmieri 0:a77f1f1f8318 786 memset(app[i], 0, MAX_MSG_LEN);
apalmieri 0:a77f1f1f8318 787 }
apalmieri 0:a77f1f1f8318 788
apalmieri 0:a77f1f1f8318 789 for(unsigned i = 0, j = 0, k = 0; NMEA[i] != '\n' && i < strlen((char *)NMEA) - 1; i++)
apalmieri 0:a77f1f1f8318 790 {
apalmieri 0:a77f1f1f8318 791 if ((NMEA[i] == ',') || (NMEA[i] == '*')) {
apalmieri 0:a77f1f1f8318 792 app[j][k] = '\0';
apalmieri 0:a77f1f1f8318 793
apalmieri 0:a77f1f1f8318 794 if ((strcmp((char *)app[0], "$PSTMCFGMSGLOK") == 0) ||
apalmieri 0:a77f1f1f8318 795 (strcmp((char *)app[0], "$PSTMCFGMSGLERROR") == 0)) {
apalmieri 0:a77f1f1f8318 796 j++;
apalmieri 0:a77f1f1f8318 797 k = 0;
apalmieri 0:a77f1f1f8318 798 valid_msg = 1;
apalmieri 0:a77f1f1f8318 799 continue;
apalmieri 0:a77f1f1f8318 800 }
apalmieri 0:a77f1f1f8318 801 else {
apalmieri 0:a77f1f1f8318 802 while(NMEA[i++] != '\n');
apalmieri 0:a77f1f1f8318 803 j = k = 0;
apalmieri 0:a77f1f1f8318 804 }
apalmieri 0:a77f1f1f8318 805 }
apalmieri 0:a77f1f1f8318 806 app[j][k++] = NMEA[i];
apalmieri 0:a77f1f1f8318 807 }
apalmieri 0:a77f1f1f8318 808
apalmieri 0:a77f1f1f8318 809 if (valid_msg == 1) {
apalmieri 0:a77f1f1f8318 810 /* Enabling */
apalmieri 0:a77f1f1f8318 811 if (strcmp((char *)app[0], "$PSTMCFGMSGLOK") == 0) {
apalmieri 0:a77f1f1f8318 812 *ack = 0;
apalmieri 0:a77f1f1f8318 813 }
apalmieri 0:a77f1f1f8318 814 if (strcmp((char *)app[0], "$PSTMCFGMSGLERROR") == 0) {
apalmieri 0:a77f1f1f8318 815 *ack = 1;
apalmieri 0:a77f1f1f8318 816 }
apalmieri 0:a77f1f1f8318 817
apalmieri 0:a77f1f1f8318 818 valid_msg = 0;
apalmieri 0:a77f1f1f8318 819 status = PARSE_SUCC;
apalmieri 0:a77f1f1f8318 820 }
apalmieri 0:a77f1f1f8318 821 return status;
apalmieri 0:a77f1f1f8318 822 }
apalmieri 0:a77f1f1f8318 823
apalmieri 0:a77f1f1f8318 824 /**
apalmieri 0:a77f1f1f8318 825 * @brief
apalmieri 0:a77f1f1f8318 826 * @param Ack_Info Ack from Teseo
apalmieri 0:a77f1f1f8318 827 * @param NMEA NMEA string read by the Gps expansion.
apalmieri 0:a77f1f1f8318 828 * @retval ParseStatus_Typedef PARSE_SUCC if the parsing process goes ok, PARSE_FAIL if it doesn't
apalmieri 0:a77f1f1f8318 829 */
apalmieri 0:a77f1f1f8318 830 ParseStatus_Typedef parse_pstmsavepar(Ack_Info *ack, uint8_t *NMEA)
apalmieri 0:a77f1f1f8318 831 {
apalmieri 0:a77f1f1f8318 832 uint8_t app[MAX_MSG_LEN][MAX_MSG_LEN];
apalmieri 0:a77f1f1f8318 833 uint8_t valid_msg = 0;
apalmieri 0:a77f1f1f8318 834
apalmieri 0:a77f1f1f8318 835 ParseStatus_Typedef status = PARSE_FAIL;
apalmieri 0:a77f1f1f8318 836
apalmieri 0:a77f1f1f8318 837 if(NMEA == NULL)
apalmieri 0:a77f1f1f8318 838 return status;
apalmieri 0:a77f1f1f8318 839
apalmieri 0:a77f1f1f8318 840 /* clear the app[][] buffer */
apalmieri 0:a77f1f1f8318 841 for (uint8_t i=0; i<MAX_MSG_LEN; i++) {
apalmieri 0:a77f1f1f8318 842 memset(app[i], 0, MAX_MSG_LEN);
apalmieri 0:a77f1f1f8318 843 }
apalmieri 0:a77f1f1f8318 844
apalmieri 0:a77f1f1f8318 845 for(unsigned i = 0, j = 0, k = 0; NMEA[i] != '\n' && i < strlen((char *)NMEA) - 1; i++)
apalmieri 0:a77f1f1f8318 846 {
apalmieri 0:a77f1f1f8318 847 if ((NMEA[i] == ',') || (NMEA[i] == '*')) {
apalmieri 0:a77f1f1f8318 848 app[j][k] = '\0';
apalmieri 0:a77f1f1f8318 849
apalmieri 0:a77f1f1f8318 850 if ((strcmp((char *)app[0], "$PSTMSAVEPAROK") == 0) ||
apalmieri 0:a77f1f1f8318 851 (strcmp((char *)app[0], "$PSTMSAVEPARERROR") == 0)) {
apalmieri 0:a77f1f1f8318 852 j++;
apalmieri 0:a77f1f1f8318 853 k = 0;
apalmieri 0:a77f1f1f8318 854 valid_msg = 1;
apalmieri 0:a77f1f1f8318 855 continue;
apalmieri 0:a77f1f1f8318 856 }
apalmieri 0:a77f1f1f8318 857 else {
apalmieri 0:a77f1f1f8318 858 while(NMEA[i++] != '\n');
apalmieri 0:a77f1f1f8318 859 j = k = 0;
apalmieri 0:a77f1f1f8318 860 }
apalmieri 0:a77f1f1f8318 861 }
apalmieri 0:a77f1f1f8318 862 app[j][k++] = NMEA[i];
apalmieri 0:a77f1f1f8318 863 }
apalmieri 0:a77f1f1f8318 864
apalmieri 0:a77f1f1f8318 865 if (valid_msg == 1) {
apalmieri 0:a77f1f1f8318 866 /* Enabling */
apalmieri 0:a77f1f1f8318 867 if (strcmp((char *)app[0], "$PSTMSAVEPAROK") == 0) {
apalmieri 0:a77f1f1f8318 868 *ack = 0;
apalmieri 0:a77f1f1f8318 869 }
apalmieri 0:a77f1f1f8318 870 if (strcmp((char *)app[0], "$PSTMSAVEPARERROR") == 0) {
apalmieri 0:a77f1f1f8318 871 *ack = 1;
apalmieri 0:a77f1f1f8318 872 }
apalmieri 0:a77f1f1f8318 873
apalmieri 0:a77f1f1f8318 874 valid_msg = 0;
apalmieri 0:a77f1f1f8318 875 status = PARSE_SUCC;
apalmieri 0:a77f1f1f8318 876 }
apalmieri 0:a77f1f1f8318 877 return status;
apalmieri 0:a77f1f1f8318 878 }
apalmieri 0:a77f1f1f8318 879
apalmieri 0:a77f1f1f8318 880 /**
apalmieri 0:a77f1f1f8318 881 * @brief This function makes a copy of the datas stored into gps_t into the 'info' param
apalmieri 0:a77f1f1f8318 882 * @param info Instance of a GPGGA_Infos object where there are the infos to be copied
apalmieri 0:a77f1f1f8318 883 * @param gps_t Instance of a GPGGA_Infos object pointer where the infos stored into gps_t have to be copied
apalmieri 0:a77f1f1f8318 884 * @retval None
apalmieri 0:a77f1f1f8318 885 */
apalmieri 0:a77f1f1f8318 886 void copy_data(GPGGA_Infos *info, GPGGA_Infos gps_t){
apalmieri 0:a77f1f1f8318 887 info->acc = gps_t.acc;
apalmieri 0:a77f1f1f8318 888 info->geoid.height = gps_t.geoid.height;
apalmieri 0:a77f1f1f8318 889 info->geoid.mis = gps_t.geoid.mis;
apalmieri 0:a77f1f1f8318 890 info->sats = gps_t.sats;
apalmieri 0:a77f1f1f8318 891 info->update = gps_t.update;
apalmieri 0:a77f1f1f8318 892 info->utc.hh = gps_t.utc.hh;
apalmieri 0:a77f1f1f8318 893 info->utc.mm = gps_t.utc.mm;
apalmieri 0:a77f1f1f8318 894 info->utc.ss = gps_t.utc.ss;
apalmieri 0:a77f1f1f8318 895 info->utc.utc = gps_t.utc.utc;
apalmieri 0:a77f1f1f8318 896 info->valid = gps_t.valid;
apalmieri 0:a77f1f1f8318 897 info->xyz.alt = gps_t.xyz.alt;
apalmieri 0:a77f1f1f8318 898 info->xyz.lat = gps_t.xyz.lat;
apalmieri 0:a77f1f1f8318 899 info->xyz.lon = gps_t.xyz.lon;
apalmieri 0:a77f1f1f8318 900 info->xyz.ew = gps_t.xyz.ew;
apalmieri 0:a77f1f1f8318 901 info->xyz.ns = gps_t.xyz.ns;
apalmieri 0:a77f1f1f8318 902 info->xyz.mis = gps_t.xyz.mis;
apalmieri 0:a77f1f1f8318 903 info->checksum = gps_t.checksum;
apalmieri 0:a77f1f1f8318 904 }
apalmieri 0:a77f1f1f8318 905 /**
apalmieri 0:a77f1f1f8318 906 * @}
apalmieri 0:a77f1f1f8318 907 */
apalmieri 0:a77f1f1f8318 908
apalmieri 0:a77f1f1f8318 909 /**
apalmieri 0:a77f1f1f8318 910 * @}
apalmieri 0:a77f1f1f8318 911 */
apalmieri 0:a77f1f1f8318 912
apalmieri 0:a77f1f1f8318 913 /**
apalmieri 0:a77f1f1f8318 914 * @}
apalmieri 0:a77f1f1f8318 915 */
apalmieri 0:a77f1f1f8318 916
apalmieri 0:a77f1f1f8318 917 /**
apalmieri 0:a77f1f1f8318 918 * @}
apalmieri 0:a77f1f1f8318 919 */
apalmieri 0:a77f1f1f8318 920
apalmieri 0:a77f1f1f8318 921 /**
apalmieri 0:a77f1f1f8318 922 * @}
apalmieri 0:a77f1f1f8318 923 */