BeRTOS
|
00001 00041 #ifndef NET_NMEA_H 00042 #define NET_NMEA_H 00043 00044 #include "cfg/cfg_nmea.h" 00045 00046 #include <net/nmeap/inc/nmeap.h> 00047 00048 #include <io/kfile.h> 00049 00050 #include <time.h> 00051 00052 /* 00053 * Implemented NMEA parser strings. 00054 */ 00055 #define NMEA_GPGGA 1 // GGA MESSAGE ID 00056 #define NMEA_GPRMC 2 // RMC MESSAGE ID 00057 #define NMEA_GPVTG 3 // VTG MESSAGE ID 00058 #define NMEA_GPGSV 4 // GSV MESSAGE ID 00059 00060 // Standart type to rappresent fiels. 00061 typedef int32_t udegree_t; // Micro degrees 00062 typedef int32_t mdegree_t; // Milli degrees 00063 typedef int16_t degree_t; // Degrees 00064 00065 00075 typedef struct NmeaGga 00076 { 00077 udegree_t latitude; /* Latitude (micro degree) */ 00078 udegree_t longitude; /* Longitude (micro degree) */ 00079 int32_t altitude; /* Altitude (Meter) */ 00080 time_t time; /* UTC of position (Unix time) */ 00081 uint16_t satellites; /* Satellites are in view */ 00082 uint16_t quality; /* Fix Quality: 0 = Invalid; 1 = GPS fix; 2 = DGPS fix; */ 00083 uint16_t hdop; /* Relative accuracy of horizontal position (hdop * 10) */ 00084 int16_t geoid; /* Height of geoid above WGS84 ellipsoid (Meter) */ 00085 } NmeaGga; 00086 00094 typedef struct NmeaRmc 00095 { 00096 time_t time; /* UTC of position (Unix time) */ 00097 char warn; /* Navigation receiver warning A = OK, V = warning */ 00098 udegree_t latitude; /* Latitude (micro degree) */ 00099 udegree_t longitude; /* Longitude (micro degree) */ 00100 uint16_t speed; /* Speed over ground (knots) */ 00101 degree_t course; /* Track made good in degrees True (degree) */ 00102 degree_t mag_var; /* Magnetic variation degrees (degree) */ 00103 } NmeaRmc; 00104 00108 typedef struct NmeaVtg 00109 { 00110 degree_t track_good; /* True track made good (degree) */ 00111 uint16_t knot_speed; /* Speed over ground (knots) */ 00112 uint16_t km_speed; /* Speed over ground in kilometers/hour */ 00113 } NmeaVtg; 00114 00118 struct SvInfo 00119 { 00120 uint16_t sv_prn; /* SV PRN number */ 00121 degree_t elevation; /* Elevation in degrees, 90 maximum */ 00122 degree_t azimut; /* Azimuth, degrees from true north, 000 to 359 */ 00123 uint16_t snr; /* SNR, 00-99 dB (null when not tracking) */ 00124 }; 00125 00126 typedef struct NmeaGsv 00127 { 00128 uint16_t tot_message; /* Total number of messages of this type in this cycle */ 00129 uint16_t message_num; /* Message number */ 00130 uint16_t tot_svv; /* Total number of SVs in view */ 00131 struct SvInfo info[4]; /* Stanrd gsv nmea report up to 4 sv info */ 00132 } NmeaGsv; 00133 00134 void nmea_poll(nmeap_context_t *context, KFile *channel); 00135 00136 int nmea_gpgsv(nmeap_context_t *context, nmeap_sentence_t *sentence); 00137 int nmea_gpvtg(nmeap_context_t *context, nmeap_sentence_t *sentence); 00138 int nmea_gprmc(nmeap_context_t *context, nmeap_sentence_t *sentence); 00139 int nmea_gpgga(nmeap_context_t *context, nmeap_sentence_t *sentence); 00140 00141 // Example of callout 00142 void gpgga_callout(nmeap_context_t *context, void *data, void *user_data); 00143 void gprmc_callout(nmeap_context_t *context, void *data, void *user_data); 00144 void gpgsv_callout(nmeap_context_t *context, void *data, void *user_data); 00145 void gpvtg_callout(nmeap_context_t *context, void *data, void *user_data); 00146 00147 int nmea_testSetup(void); 00148 int nmea_testTearDown(void); 00149 int nmea_testRun(void); 00150 00151 #endif /* NET_NMEA_H */