4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2009 Develer S.r.l. (http://www.develer.com/)
34 * \author Daniele Basile <asterix@develer.com>
36 * $WIZ$ module_name = "nmea"
37 * $WIZ$ module_configuration = "bertos/cfg/cfg_nmea.h"
38 * $WIZ$ module_depends = "kfile", "nmeap01"
44 #include "cfg/cfg_nmea.h"
46 #include <net/nmeap/inc/nmeap.h>
48 #include <kern/kfile.h>
53 * Implemented NMEA parser strings.
55 #define NMEA_GPGGA 1 // GGA MESSAGE ID
56 #define NMEA_GPRMC 2 // RMC MESSAGE ID
57 #define NMEA_GPVTG 3 // VTG MESSAGE ID
58 #define NMEA_GPGSV 4 // GSV MESSAGE ID
60 // Standart type to rappresent fiels.
61 typedef int32_t udegree_t; // Micro degrees
62 typedef int32_t mdegree_t; // Milli degrees
63 typedef int16_t degree_t; // Degrees
67 * Global Positioning System Fix Data.
68 * Extracted data from a GGA message
70 * Note: time member contains the seconds elapsed from 00:00:00 1/1/1970,
71 * because from nmea sentence we read only the time of UTC position, we
72 * have not any reference of date (day, month and year) so time is referred to
73 * the start of unix time.
75 typedef struct NmeaGga
77 udegree_t latitude; /* Latitude (micro degree) */
78 udegree_t longitude; /* Longitude (micro degree) */
79 int32_t altitude; /* Altitude (Meter) */
80 time_t time; /* UTC of position (Unix time) */
81 uint16_t satellites; /* Satellites are in view */
82 uint16_t quality; /* Fix Quality: 0 = Invalid; 1 = GPS fix; 2 = DGPS fix; */
83 uint16_t hdop; /* Relative accuracy of horizontal position (hdop * 10) */
84 int16_t geoid; /* Height of geoid above WGS84 ellipsoid (Meter) */
88 * Recommended minimum specific GPS/Transit data.
89 * Extracted data from an RMC message
91 * Note: RMC sentences contain also date stamp so, time contains real seconds elapsed
92 * from 0:00:00 1/1/1970.
94 typedef struct NmeaRmc
96 time_t time; /* UTC of position (Unix time) */
97 char warn; /* Navigation receiver warning A = OK, V = warning */
98 udegree_t latitude; /* Latitude (micro degree) */
99 udegree_t longitude; /* Longitude (micro degree) */
100 uint16_t speed; /* Speed over ground (knots) */
101 degree_t course; /* Track made good in degrees True (degree) */
102 degree_t mag_var; /* Magnetic variation degrees (degree) */
106 * Extracted data from an vtg message
108 typedef struct NmeaVtg
110 degree_t track_good; /* True track made good (degree) */
111 uint16_t knot_speed; /* Speed over ground (knots) */
112 uint16_t km_speed; /* Speed over ground in kilometers/hour */
116 * Extracted data from an gsv message
120 uint16_t sv_prn; /* SV PRN number */
121 degree_t elevation; /* Elevation in degrees, 90 maximum */
122 degree_t azimut; /* Azimuth, degrees from true north, 000 to 359 */
123 uint16_t snr; /* SNR, 00-99 dB (null when not tracking) */
126 typedef struct NmeaGsv
128 uint16_t tot_message; /* Total number of messages of this type in this cycle */
129 uint16_t message_num; /* Message number */
130 uint16_t tot_svv; /* Total number of SVs in view */
131 struct SvInfo info[4]; /* Stanrd gsv nmea report up to 4 sv info */
134 void nmea_poll(nmeap_context_t *context, KFile *channel);
136 int nmea_gpgsv(nmeap_context_t *context, nmeap_sentence_t *sentence);
137 int nmea_gpvtg(nmeap_context_t *context, nmeap_sentence_t *sentence);
138 int nmea_gprmc(nmeap_context_t *context, nmeap_sentence_t *sentence);
139 int nmea_gpgga(nmeap_context_t *context, nmeap_sentence_t *sentence);
141 // Example of callout
142 void gpgga_callout(nmeap_context_t *context, void *data, void *user_data);
143 void gprmc_callout(nmeap_context_t *context, void *data, void *user_data);
144 void gpgsv_callout(nmeap_context_t *context, void *data, void *user_data);
145 void gpvtg_callout(nmeap_context_t *context, void *data, void *user_data);
147 int nmea_testSetup(void);
148 int nmea_testTearDown(void);
149 int nmea_testRun(void);
151 #endif /* NET_NMEA_H */