mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-30 18:07:52 +00:00
afc: Add more fields to ubus command for GPS to send location info to AFC server
Fixes: WIFI-14065 Signed-off-by: Tanya Singh <tanya_singh@accton.com>
This commit is contained in:
committed by
John Crispin
parent
18f357a06b
commit
ecff108ac9
@@ -601,6 +601,7 @@ define Package/afcd/install
|
||||
$(INSTALL_DIR) $(1)/usr/share/hostap $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/afcd.init $(1)/etc/init.d/afcd
|
||||
$(INSTALL_DATA) ./files/afcd.uc $(1)/usr/share/hostap/
|
||||
$(INSTALL_DATA) ./files/afc_location.uc $(1)/usr/share/hostap/
|
||||
endef
|
||||
|
||||
define Install/hostapd
|
||||
|
||||
23
feeds/ipq807x_v5.4/hostapd/files/afc_location.uc
Normal file
23
feeds/ipq807x_v5.4/hostapd/files/afc_location.uc
Normal file
@@ -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();
|
||||
@@ -4,6 +4,7 @@ START=19
|
||||
|
||||
USE_PROCD=1
|
||||
NAME=afcd
|
||||
PROG=/usr/bin/ucode
|
||||
|
||||
add_afc() {
|
||||
config_get_bool disabled "$1" disabled 0
|
||||
@@ -14,15 +15,26 @@ add_afc() {
|
||||
[ -n "$url" ] || return
|
||||
|
||||
procd_open_instance afcd
|
||||
procd_set_param command /usr/bin/ucode /usr/share/hostap/afcd.uc -u "$url"
|
||||
procd_set_param command "$PROG" /usr/share/hostap/afcd.uc -u "$url"
|
||||
[ -n "$cert" ] && procd_append_param command -c "$cert"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
_afc_location() {
|
||||
# create afc-location.json
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG" /usr/share/hostap/afc_location.uc
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load wireless
|
||||
config_foreach add_afc afc-server
|
||||
|
||||
local gps_disabled=$(uci get gps.@gps[-1].disabled)
|
||||
[ "$gps_disabled" -eq 0 ] && _afc_location
|
||||
}
|
||||
|
||||
service_triggers()
|
||||
|
||||
@@ -14,6 +14,8 @@ gps_enable() {
|
||||
echo 1 > /sys/class/gpio/gps_reset/value
|
||||
sleep 1
|
||||
echo 0 > /sys/class/gpio/gps_reset/value
|
||||
# enable PAIR message to include Packet Type: 062 with GST (8 = NMEA_SEN_GST )
|
||||
echo "\$PAIR062,8,1*37" > /dev/ttyMSM1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
113
patches/0076-ubus-gps-afc-info.patch
Normal file
113
patches/0076-ubus-gps-afc-info.patch
Normal file
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user