-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIFI-14065: Add more fields to ubus command for GPS to send location …
…info to AFC server Signed-off-by: Tanya Singh <tanya_singh@accton.com>
- Loading branch information
1 parent
aedbf97
commit bef7983
Showing
5 changed files
with
153 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env ucode | ||
'use strict'; | ||
let fs = require("fs"); | ||
let ubus = require('ubus').connect(); | ||
|
||
let gps_info = ubus.call('gps', 'info'); | ||
let latitude = gps_info.latitude ?? 0; | ||
let longitude = gps_info.longitude ?? 0; | ||
|
||
// afc-location.json file content | ||
let afc_location = {}; | ||
afc_location.location_type = "ellipse"; | ||
afc_location.location = longitude + ":" + latitude ; | ||
afc_location.height = gps_info.elevation ?? 0; | ||
afc_location.height_type = "AMSL"; | ||
afc_location.major_axis = gps_info.major_axis ?? 0; | ||
afc_location.minor_axis = gps_info.minor_axis ?? 0; | ||
afc_location.orientation = gps_info.major_orientation ?? 0; | ||
afc_location.vertical_tolerance = gps_info.vdop ?? 0; | ||
|
||
let afc_location_json = fs.open("/etc/ucentral/afc-location.json", "w"); | ||
afc_location_json.write(afc_location); | ||
afc_location_json.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
From 68f93efdb492ae6fc62855766383fd7184823454 Mon Sep 17 00:00:00 2001 | ||
From: Tanya Singh <tanya.singh@4ipnet.com> | ||
Date: Wed, 11 Sep 2024 18:46:59 +0800 | ||
Subject: [PATCH] Add AFC related fields to 'ubus call gps info' command | ||
|
||
--- | ||
.../001-ubus-gps-add-gst-gsa.patch | 94 +++++++++++++++++++ | ||
1 file changed, 94 insertions(+) | ||
create mode 100644 package/utils/ugps/patches/001-ubus-gps-add-gst-gsa.patch | ||
|
||
diff --git a/package/utils/ugps/patches/001-ubus-gps-add-gst-gsa.patch b/package/utils/ugps/patches/001-ubus-gps-add-gst-gsa.patch | ||
new file mode 100644 | ||
index 0000000000..dbb2769e40 | ||
--- /dev/null | ||
+++ b/package/utils/ugps/patches/001-ubus-gps-add-gst-gsa.patch | ||
@@ -0,0 +1,94 @@ | ||
+--- ugps-2021-07-19-a8171a07.orig/nmea.h 2024-09-11 18:38:04.960719689 +0800 | ||
++++ ugps-2021-07-19-a8171a07/nmea.h 2024-09-11 18:39:21.029376727 +0800 | ||
+@@ -23,7 +23,7 @@ | ||
+ | ||
+ #include <libubox/ustream.h> | ||
+ | ||
+-extern char longitude[33], latitude[33], course[17], speed[17], elevation[17]; | ||
++extern char longitude[33], latitude[33], course[17], speed[17], elevation[17], major_axis[17], minor_axis[17], major_orientation[17], vdop[17]; | ||
+ extern int nmea_open(char *dev, struct ustream_fd *s, speed_t speed); | ||
+ extern void gps_timestamp(void); | ||
+ extern unsigned int adjust_clock; | ||
+@@ -33,5 +33,7 @@ | ||
+ #define GPS_FIELD_COG (1<<2) | ||
+ #define GPS_FIELD_SPD (1<<3) | ||
+ #define GPS_FIELD_ALT (1<<4) | ||
+- | ||
++#define GPS_FIELD_MAJ (1<<5) | ||
++#define GPS_FIELD_MIN (1<<6) | ||
++#define GPS_FIELD_VDOP (1<<7) | ||
+ #endif | ||
+--- ugps-2021-07-19-a8171a07.orig/nmea.c 2024-09-11 18:38:13.452792960 +0800 | ||
++++ ugps-2021-07-19-a8171a07/nmea.c 2024-09-11 18:40:00.425717593 +0800 | ||
+@@ -52,7 +52,7 @@ | ||
+ } nmea_params[MAX_NMEA_PARAM]; | ||
+ | ||
+ static int nmea_bad_time; | ||
+-char longitude[33] = { 0 }, latitude[33] = { 0 }, course[17] = { 0 }, speed[17] = { 0 }, elevation[17] = { 0 }; | ||
++char longitude[33] = { 0 }, latitude[33] = { 0 }, course[17] = { 0 }, speed[17] = { 0 }, elevation[17] = { 0 }, major_axis[17] = { 0 }, minor_axis[17] = { 0 }, major_orientation[17] = { 0 }, vdop[17] = { 0 }; | ||
+ int gps_valid = 0; | ||
+ char gps_fields = 0; | ||
+ | ||
+@@ -239,6 +239,30 @@ | ||
+ DEBUG(4, "speed: %s\n", speed); | ||
+ } | ||
+ | ||
++static void | ||
++nmea_gst_cb(void) | ||
++{ | ||
++ if (!gps_valid) | ||
++ return; | ||
++ strncpy(major_axis, nmea_params[3].str, sizeof(major_axis)); | ||
++ strncpy(minor_axis, nmea_params[4].str, sizeof(minor_axis)); | ||
++ strncpy(major_orientation, nmea_params[5].str, sizeof(major_orientation)); | ||
++ gps_fields |= GPS_FIELD_MAJ | GPS_FIELD_MIN; | ||
++ DEBUG(4, "major_axis: %s\n", major_axis); | ||
++ DEBUG(4, "minor_axis: %s\n", minor_axis); | ||
++ DEBUG(4, "major_orientation: %s\n", major_orientation); | ||
++} | ||
++ | ||
++static void | ||
++nmea_gsa_cb(void) | ||
++{ | ||
++ if (!gps_valid) | ||
++ return; | ||
++ strncpy(vdop, nmea_params[17].str, sizeof(vdop)); | ||
++ gps_fields |= GPS_FIELD_VDOP; | ||
++ DEBUG(4, "vdop: %s\n", vdop); | ||
++} | ||
++ | ||
+ static struct nmea_msg { | ||
+ char *msg; | ||
+ int cnt; | ||
+@@ -268,6 +292,14 @@ | ||
+ .msg = "ZDA", | ||
+ .cnt = 5, | ||
+ .handler = nmea_zda_cb, | ||
++ }, { | ||
++ .msg = "GST", | ||
++ .cnt = 8, | ||
++ .handler = nmea_gst_cb, | ||
++ }, { | ||
++ .msg = "GSA", | ||
++ .cnt = 18, | ||
++ .handler = nmea_gsa_cb, | ||
+ }, | ||
+ }; | ||
+ | ||
+--- ugps-2021-07-19-a8171a07.orig/main.c 2024-09-11 18:38:23.620880720 +0800 | ||
++++ ugps-2021-07-19-a8171a07/main.c 2024-09-11 18:40:24.681927642 +0800 | ||
+@@ -66,6 +66,14 @@ | ||
+ blobmsg_add_string(&b, "course", course); | ||
+ if (gps_fields & GPS_FIELD_SPD) | ||
+ blobmsg_add_string(&b, "speed", speed); | ||
++ if (gps_fields & GPS_FIELD_MAJ) { | ||
++ blobmsg_add_string(&b, "major_axis", major_axis); | ||
++ blobmsg_add_string(&b, "major_orientation", major_orientation); | ||
++ } | ||
++ if (gps_fields & GPS_FIELD_MIN) | ||
++ blobmsg_add_string(&b, "minor_axis", minor_axis); | ||
++ if (gps_fields & GPS_FIELD_VDOP) | ||
++ blobmsg_add_string(&b, "vdop", vdop); | ||
+ } | ||
+ ubus_send_reply(ctx, req, b.head); | ||
+ | ||
-- | ||
2.34.1 | ||
|