libfap  1.4
fap.h
Go to the documentation of this file.
1 /* $Id: fap.h 226 2014-11-23 12:33:36Z oh2gve $
2  *
3  * Copyright 2005-2012 Tapio Sokura
4  * Copyright 2007-2012 Heikki Hannikainen
5  *
6  * Perl-to-C modifications
7  * Copyright 2009-2014 Tapio Aaltonen
8  *
9  * This file is part of libfap.
10  *
11  * Libfap is free software; you can redistribute it and/or modify it under the
12  * terms of either:
13  *
14  * a) the GNU General Public License as published by the Free Software
15  * Foundation; either version 1, or (at your option) any later
16  * version, or
17  *
18  * b) the "Artistic License".
19  *
20  * Both licenses can be found in the licenses directory of this source code
21  * package.
22  *
23  * APRS is a registered trademark of APRS Software and Bob Bruninga, WB4APR.
24 */
25 
41 #ifndef FAP_H
42 #define FAP_H
43 
44 
45 #include <time.h>
46 
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 
53 
55 typedef enum
56 {
57  fapPACKET_NO,
58  fapPACKET_SHORT,
59  fapPACKET_NOBODY,
60 
61  fapSRCCALL_NOAX25,
62  fapSRCCALL_BADCHARS,
63 
64  fapDSTPATH_TOOMANY,
65  fapDSTCALL_NONE,
66  fapDSTCALL_NOAX25,
67 
68  fapDIGICALL_NOAX25,
69  fapDIGICALL_BADCHARS,
70 
71  fapTIMESTAMP_INV_LOC,
72  fapTIMESTAMP_INV_OBJ,
73  fapTIMESTAMP_INV_STA,
74  fapTIMESTAMP_INV_GPGGA,
75  fapTIMESTAMP_INV_GPGLL,
76 
77  fapPACKET_INVALID,
78 
79  fapNMEA_INV_CVAL,
80  fapNMEA_LARGE_EW,
81  fapNMEA_LARGE_NS,
82  fapNMEA_INV_SIGN,
83  fapNMEA_INV_CKSUM,
84 
85  fapGPRMC_FEWFIELDS,
86  fapGPRMC_NOFIX,
87  fapGPRMC_INV_TIME,
88  fapGPRMC_INV_DATE,
89  fapGPRMC_DATE_OUT,
90 
91  fapGPGGA_FEWFIELDS,
92  fapGPGGA_NOFIX,
93 
94  fapGPGLL_FEWFIELDS,
95  fapGPGLL_NOFIX,
96 
97  fapNMEA_UNSUPP,
98 
99  fapOBJ_SHORT,
100  fapOBJ_INV,
101  fapOBJ_DEC_ERR,
102 
103  fapITEM_SHORT,
104  fapITEM_INV,
105  fapITEM_DEC_ERR,
106 
107  fapLOC_SHORT,
108  fapLOC_INV,
109  fapLOC_LARGE,
110  fapLOC_AMB_INV,
111 
112  fapMICE_SHORT,
113  fapMICE_INV,
114  fapMICE_INV_INFO,
115  fapMICE_AMB_LARGE,
116  fapMICE_AMB_INV,
117  fapMICE_AMB_ODD,
118 
119  fapCOMP_INV,
120  fapCOMP_SHORT,
121 
122  fapMSG_INV,
123 
124  fapWX_UNSUPP,
125  fapUSER_UNSUPP,
126 
127  fapDX_INV_SRC,
128  fapDX_INF_FREQ,
129  fapDX_NO_DX,
130 
131  fapTLM_INV,
132  fapTLM_LARGE,
133  fapTLM_UNSUPP,
134 
135  fapEXP_UNSUPP,
136  fapSYM_INV_TABLE,
137 
138  fapNOT_IMPLEMENTED,
139  fapNMEA_NOFIELDS,
140 
141  fapNO_APRS
143 
144 
146 typedef enum
147 {
148  fapLOCATION,
149  fapOBJECT,
150  fapITEM,
151  fapMICE,
152  fapNMEA,
153 
154  fapWX,
155  fapMESSAGE,
156  fapCAPABILITIES,
157  fapSTATUS,
158  fapTELEMETRY,
159  fapTELEMETRY_MESSAGE,
160  fapDX_SPOT,
161 
162  fapEXPERIMENTAL
164 
165 
167 typedef enum
168 {
169  fapPOS_COMPRESSED,
170  fapPOS_UNCOMPRESSED,
171  fapPOS_MICE,
172  fapPOS_NMEA
174 
175 
177 typedef struct
178 {
180  double* wind_gust;
182  unsigned int* wind_dir;
184  double* wind_speed;
185 
187  double* temp;
189  double* temp_in;
190 
192  double* rain_1h;
194  double* rain_24h;
196  double* rain_midnight;
197 
199  unsigned int* humidity;
201  unsigned int* humidity_in;
202 
204  double* pressure;
206  unsigned int* luminosity;
207 
209  double* snow_24h;
210 
212  char* soft;
214 
215 
216 
218 typedef struct
219 {
221  unsigned int* seq;
223  double* val1;
225  double* val2;
227  double* val3;
229  double* val4;
231  double* val5;
232 
234  char bits[8];
236 
237 
238 
240 typedef struct
241 {
246 
248  char* orig_packet;
250  unsigned int orig_packet_len;
251 
253  char* header;
255  char* body;
257  unsigned int body_len;
263  char** path;
265  unsigned int path_len;
266 
268  double* latitude;
270  double* longitude;
274  double* pos_resolution;
276  unsigned int* pos_ambiguity;
279 
281  double* altitude;
283  unsigned int* course;
285  double* speed;
286 
291 
293  short* messaging;
295  char* destination;
297  char* message;
299  char* message_ack;
303  char* message_id;
305 
311  char* comment;
313  unsigned int comment_len;
314 
318  short* alive;
319 
323  unsigned int* radio_range;
325  char* phg;
327  time_t* timestamp;
332 
335 
338 
340  char* messagebits;
342  char* status;
344  unsigned int status_len;
346  char** capabilities;
348  unsigned int capabilities_len;
349 
350 } fap_packet_t;
351 
352 
353 
354 
356 
375 fap_packet_t* fap_parseaprs(char const* input, unsigned int const input_len, short const is_ax25);
376 
377 
379 
383 void fap_explain_error(fap_error_code_t const error, char* buffer);
384 
386 
390 void fap_mice_mbits_to_message(char const* bits, char* buffer);
391 
393 
399 double fap_distance(double lon0, double lat0, double lon1, double lat1);
400 
401 
403 
408 double fap_direction(double lon0, double lat0, double lon1, double lat1);
409 
410 
412 
417 int fap_count_digihops(fap_packet_t const* packet);
418 
419 
421 
431 char* fap_check_ax25_call(char const* input, short const add_ssid0);
432 
433 
435 
450 int fap_kiss_to_tnc2(char const* kissframe, unsigned int kissframe_len,
451  char* tnc2frame, unsigned int* tnc2frame_len, unsigned int* tnc_id);
452 
453 
455 
466 int fap_tnc2_to_kiss(char const* tnc2frame, unsigned int tnc2frame_len, unsigned int const tnc_id,
467  char* kissframe, unsigned int* kissframe_len);
468 
469 
470 
471 /* Implementation-specific functions. */
472 
474 
477 int fap_ax25_to_tnc2(char const* ax25frame, unsigned int ax25frame_len,
478  char* tnc2frame, unsigned int* tnc2frame_len);
479 
481 
484 int fap_tnc2_to_ax25(char const* tnc2frame, unsigned int tnc2frame_len,
485  char* ax25frame, unsigned int* ax25frame_len);
486 
487 
489 
493 void fap_free(fap_packet_t* packet);
494 
495 
496 
498 
502 void fap_init();
503 
504 
505 
507 
511 void fap_cleanup();
512 
513 
514 #ifdef __cplusplus
515 }
516 #endif
517 
518 #endif // FAP_H