summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gps.h3
-rw-r--r--json.h4
-rw-r--r--libgps_json.c20
3 files changed, 18 insertions, 9 deletions
diff --git a/gps.h b/gps.h
index 681b0dcf..4c3a7b13 100644
--- a/gps.h
+++ b/gps.h
@@ -777,6 +777,9 @@ struct ais_t
struct device_t {
char path[GPS_PATH_MAX];
+ char driver[64];
+ char subtype[64];
+ double activated;
};
struct compass_t {
diff --git a/json.h b/json.h
index 8910e3b1..9aa983aa 100644
--- a/json.h
+++ b/json.h
@@ -43,8 +43,8 @@ struct json_attr_t {
} dflt;
};
-#define JSON_ATTR_MAX 31 /* max charss in JSON attribute name */
-#define JSON_VAL_MAX 63 /* max charss in JSON value part */
+#define JSON_ATTR_MAX 31 /* max chars in JSON attribute name */
+#define JSON_VAL_MAX 63 /* max chars in JSON value part */
int json_read_object(const char *, const struct json_attr_t *, int, const char **end);
int json_read_array(const char *, const struct json_array_t *, const char **);
diff --git a/libgps_json.c b/libgps_json.c
index faf660c7..de620ca0 100644
--- a/libgps_json.c
+++ b/libgps_json.c
@@ -141,14 +141,18 @@ static int json_sky_read(const char *buf,
}
static int json_device_read(const char *buf,
- struct gps_data_t *gpsdata, const char **endptr)
+ struct device_t *dev, const char **endptr)
{
const struct json_attr_t json_attrs_device[] = {
{"class", check, .dflt.check = "DEVICE"},
- {"path", string, .addr.string.ptr = gpsdata->devices.list[0].path,
- .addr.string.len = GPS_PATH_MAX},
- {"activated", real, .addr.real = &gpsdata->devices.time},
- // type (list), driver, subtype
+ {"path", string, .addr.string.ptr = dev->path,
+ .addr.string.len = sizeof(dev->path)},
+ {"activated", real, .addr.real = &dev->activated},
+ // type (list)
+ {"driver", string, .addr.string.ptr = dev->driver,
+ .addr.string.len = sizeof(dev->driver)},
+ {"subtype", string, .addr.string.ptr = dev->subtype,
+ .addr.string.len = sizeof(dev->subtype)},
{NULL},
};
int status;
@@ -157,7 +161,6 @@ static int json_device_read(const char *buf,
if (status != 0)
return status;
- gpsdata->set |= DEVICE_SET;
return 0;
}
@@ -200,7 +203,10 @@ int libgps_json_unpack(const char *buf, struct gps_data_t *gpsdata)
} else if (strstr(buf, "\"class\":\"SKY\"") != 0) {
return json_sky_read(buf, gpsdata, NULL);
} else if (strstr(buf, "\"class\":\"DEVICE\"") != 0) {
- return json_device_read(buf, gpsdata, NULL);
+ int status = json_device_read(buf, &gpsdata->devices.list[0], NULL);
+ if (status == 0)
+ gpsdata->set |= DEVICE_SET;
+ return status;
} else
return -1;
}