Version 0.3.35 Added nodes database net_ssid field.

Mon, 15 Jun 2020 20:26:46 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 15 Jun 2020 20:26:46 +0200
changeset 703
faeede125639
parent 702
f0896a6f9b64
child 704
62a1d2baec75

Version 0.3.35 Added nodes database net_ssid field.

bmsd/bms.h file | annotate | diff | comparison | revisions
bmsd/mysql.c file | annotate | diff | comparison | revisions
bmsd/nodes.c file | annotate | diff | comparison | revisions
config.status file | annotate | diff | comparison | revisions
configure file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
www/js/mon_node.js file | annotate | diff | comparison | revisions
--- a/bmsd/bms.h	Sat Jun 13 13:50:57 2020 +0200
+++ b/bmsd/bms.h	Mon Jun 15 20:26:46 2020 +0200
@@ -108,6 +108,7 @@
     char			*net_ifname;		///< Interface name
     int				net_rssi;		///< RSSI value if wireless.
     int				interval;		///< Update interval
+    char			*net_ssid;		///< WiFi SSID
 } sys_node_list;
 
 
--- a/bmsd/mysql.c	Sat Jun 13 13:50:57 2020 +0200
+++ b/bmsd/mysql.c	Mon Jun 15 20:26:46 2020 +0200
@@ -118,6 +118,7 @@
 		node->net_ifname    = xstrcpy(row[19]);
 		node->net_rssi      = atoi(row[20]);
 		node->interval      = atoi(row[21]);
+		node->net_ssid	    = xstrcpy(row[22]);
 
 		if (nodes == NULL) {
 		    nodes = node;
@@ -454,6 +455,8 @@
 	    free(tmpn->net_address);
 	if (tmpn->net_ifname)
 	    free(tmpn->net_ifname);
+	if (tmpn->net_ssid)
+	    free(tmpn->net_ssid);
 	free(tmpn);
     }
 }
@@ -516,11 +519,11 @@
 	"INSERT INTO  mon_nodes SET uuid='%s', node='%s', online='%d', group_id='%s', " \
         "hardwaremake='%s', hardwaremodel='%s', os='%s', os_version='%s', firmware='%s', firstseen='%s', lastseen='%s', " \
 	"temperature='%.3f', humidity='%.3f', barometer='%.3f', gps_latitude='%.8f', gps_longitude='%.8f', gps_altitude='%.8f', " \
-	"net_address='%s', net_ifname='%s', net_rssi='%d', up_interval='%d'",
+	"net_address='%s', net_ifname='%s', net_rssi='%d', up_interval='%d', net_ssid='%s'",
 	node->uuid, node->node, node->online ?1:0, node->group_id, 
 	node->hardwaremake, node->hardwaremodel, node->os, node->os_version, node->firmware, first, last,
 	node->temperature, node->humidity, node->barometer, node->gps_latitude, node->gps_longitude, node->gps_altitude,
-	node->net_address, node->net_ifname, node->net_rssi, node->interval);
+	node->net_address, node->net_ifname, node->net_rssi, node->interval, node->net_ssid);
 
     if (bms_mysql_query(query) == 0) {
 	syslog(LOG_NOTICE,  "MySQL: insert new node %s", node->node);
@@ -543,10 +546,10 @@
     snprintf(query, 1023,
 	"UPDATE mon_nodes SET online='%d', hardwaremake='%s', hardwaremodel='%s', os='%s', os_version='%s', firmware='%s', lastseen='%s', " \
 	"temperature='%.3f', humidity='%.3f', barometer='%.3f', gps_latitude='%.8f', gps_longitude='%.8f', gps_altitude='%.8f', " \
-	"net_address='%s', net_ifname='%s', net_rssi='%d', up_interval='%d' WHERE uuid='%s'",
+	"net_address='%s', net_ifname='%s', net_rssi='%d', up_interval='%d', net_ssid='%s' WHERE uuid='%s'",
 	node->online ? 1:0, node->hardwaremake, node->hardwaremodel, node->os, node->os_version, node->firmware, last,
 	node->temperature, node->humidity, node->barometer, node->gps_latitude, node->gps_longitude, node->gps_altitude, 
-	node->net_address, node->net_ifname, node->net_rssi, node->interval, node->uuid);
+	node->net_address, node->net_ifname, node->net_rssi, node->interval, node->net_ssid, node->uuid);
 
     bms_mysql_query(query);
     free(query);
--- a/bmsd/nodes.c	Sat Jun 13 13:50:57 2020 +0200
+++ b/bmsd/nodes.c	Mon Jun 15 20:26:46 2020 +0200
@@ -82,7 +82,7 @@
     	node->firstseen = node->lastseen = time(NULL);
     	node->temperature = node->humidity = node->barometer = 0.0;
     	node->gps_latitude = node->gps_longitude = node->gps_altitude = 0.0;
-	node->net_address = node->net_ifname = NULL;
+	node->net_address = node->net_ifname = node->net_ssid = NULL;
 	node->net_rssi = 0;
 	node->interval = 300;
     }
@@ -171,6 +171,11 @@
 		    free(node->net_ifname);
 		node->net_ifname = xstrcpy((char *)json_object_get_string(val));
 	    }
+	    if (json_object_object_get_ex(metric2, "ssid", &val)) {
+                if (node->net_ssid)
+                    free(node->net_ssid);
+                node->net_ssid = xstrcpy((char *)json_object_get_string(val));
+            }
 	    if (json_object_object_get_ex(metric2, "rssi", &val)) {
 		node->net_rssi = json_object_get_int(val);
 	    }
@@ -233,6 +238,11 @@
     msg = xstrcat(msg, (char *)"\",\"net_address\":\"");
     msg = xstrcat(msg, node->net_address);
     msg = xstrcat(msg, (char *)"\"");
+    if (node->net_ssid) {
+	msg = xstrcat(msg, (char *)",\"net_ssid\":\"");
+	msg = xstrcat(msg, node->net_ssid);
+	msg = xstrcat(msg, (char *)"\"");
+    }
     if (node->net_rssi != 0) {
     	msg = xstrcat(msg, (char *)",\"net_rssi\":");
     	snprintf(buf, 64, "%d", node->net_rssi);
@@ -278,7 +288,7 @@
     	printf("THB       %.2f  %.2f  %.2f\n", node->temperature, node->humidity, node->barometer);
     	printf("GPS       %.5f  %.5f  %.5f\n", node->gps_latitude, node->gps_longitude, node->gps_altitude);
 	printf("net       %s:%s\n", node->net_ifname, node->net_address);
-	printf("rssi      %d\n", node->net_rssi);
+	printf("ssid rssi %s %d\n", node->net_ssid, node->net_rssi);
 	printf("interval  %d\n", node->interval);
     }
 }
--- a/config.status	Sat Jun 13 13:50:57 2020 +0200
+++ b/config.status	Mon Jun 15 20:26:46 2020 +0200
@@ -621,7 +621,7 @@
 S["CC"]="gcc"
 S["CYEARS"]="2016-2020"
 S["COPYRIGHT"]="Copyright (C) 2016-2020 Michiel Broek, All Rights Reserved"
-S["VERSION"]="0.3.34"
+S["VERSION"]="0.3.35"
 S["PACKAGE"]="bms"
 S["SUBDIRS"]="bmsd doc script tools www"
 S["target_alias"]=""
@@ -710,7 +710,7 @@
 D["PACKAGE_STRING"]=" \"\""
 D["PACKAGE_BUGREPORT"]=" \"\""
 D["PACKAGE_URL"]=" \"\""
-D["VERSION"]=" \"0.3.34\""
+D["VERSION"]=" \"0.3.35\""
 D["COPYRIGHT"]=" \"Copyright (C) 2016-2020 Michiel Broek, All Rights Reserved\""
 D["STDC_HEADERS"]=" 1"
 D["HAVE_SYS_TYPES_H"]=" 1"
--- a/configure	Sat Jun 13 13:50:57 2020 +0200
+++ b/configure	Mon Jun 15 20:26:46 2020 +0200
@@ -2043,7 +2043,7 @@
 
 
 PACKAGE="bms"
-VERSION="0.3.34"
+VERSION="0.3.35"
 COPYRIGHT="Copyright (C) 2016-2020 Michiel Broek, All Rights Reserved"
 CYEARS="2016-2020"
 
--- a/configure.ac	Sat Jun 13 13:50:57 2020 +0200
+++ b/configure.ac	Mon Jun 15 20:26:46 2020 +0200
@@ -8,7 +8,7 @@
 dnl General settings
 dnl After changeing the version number, run autoconf!
 PACKAGE="bms"
-VERSION="0.3.34"
+VERSION="0.3.35"
 COPYRIGHT="Copyright (C) 2016-2020 Michiel Broek, All Rights Reserved"
 CYEARS="2016-2020"
 AC_SUBST(PACKAGE)
--- a/www/js/mon_node.js	Sat Jun 13 13:50:57 2020 +0200
+++ b/www/js/mon_node.js	Mon Jun 15 20:26:46 2020 +0200
@@ -48,6 +48,7 @@
    { name: 'gps_altitude', type: 'float' },
    { name: 'net_address', type: 'string' },
    { name: 'net_ifname', type: 'string' },
+   { name: 'net_ssid', type: 'string' },
    { name: 'net_rssi', type: 'int' },
    { name: 'up_interval', type: 'int' }
   ],
@@ -87,6 +88,8 @@
    if ((record.gps_latitude != 0) && (record.gps_longitude != 0))
     html += '<tr><td>GPS</td><td>' + record.gps_latitude + ' ' + record.gps_longitude + ' ' + record.gps_altitude + '</td></tr>';
    html += '<tr><td>Netwerk</td><td>' + record.net_ifname + ' ' + record.net_address + '</td></tr>';
+   if (record.net_ssid)
+    html += '<tr><td>WiFi SSID</td><td>' + record.net_ssid + '</td></tr>';
    if (record.net_rssi < 0)
     html += '<tr><td>WiFi signaal</td><td>' + record.net_rssi + '</td></tr>';
    html += '<tr><td>Update interval</td><td>' + record.up_interval + ' sec.</td></tr>';
@@ -123,6 +126,8 @@
      record.humidity = obj.humidity;
     record.net_ifname = obj.net_ifname;
     record.net_address = obj.net_address;
+    if (obj.net_ssid)
+     record.net_ssid = obj.net_ssid;
     if (obj.net_rssi)
      record.net_rssi = obj.net_rssi;
    }

mercurial