2 * Copyright (C) 2005 Alfredo Pironti
4 * This software is distributed under a BSD-style license. See the
5 * file "COPYING" in the top-level directory of the disribution for details.
10 #include "gpsd_config.h"
13 gpsmm::gpsmm() : gps_data(0) { gps_data = NULL; }
15 struct gps_data_t* gpsmm::open(void) {
16 return open("localhost",DEFAULT_GPSD_PORT);
19 struct gps_data_t* gpsmm::open(const char *host, const char *port) {
20 gps_data=gps_open(host,port);
21 if (gps_data==NULL) { //connection not opened
24 else { //connection succesfully opened
25 to_user= new struct gps_data_t;
26 return backup(); //we return the backup of our internal structure
30 struct gps_data_t* gpsmm::stream(int flags) {
31 if (gps_stream(gps_data,flags, NULL)==-1) {
39 struct gps_data_t* gpsmm::send(const char *request) {
40 if (gps_send(gps_data,request)==-1) {
48 struct gps_data_t* gpsmm::poll(void) {
49 if (gps_poll(gps_data)<0) {
50 // we return null if there was a read() error or connection is cloed by gpsd
58 int gpsmm::close(void) {
59 return gps_close(gps_data);
62 bool gpsmm::waiting(void) {
63 return gps_waiting(gps_data);
66 void gpsmm::clear_fix(void) {
67 gps_clear_fix(&(gps_data->fix));
70 void gpsmm::enable_debug(int level, FILE *fp) {
71 #ifdef CLIENTDEBUG_ENABLE
72 gps_enable_debug(level, fp);
73 #endif /* CLIENTDEBUG_ENABLE */