|
|
@@ -351,12 +351,12 @@ int update_gps(char *in)
|
|
|
// Require at least MIN_SATS_FOR_TIME satellites to accept a new system clock value from the GPS unit.
|
|
|
// This is to keep a crummy GPS fix from generating a bogus or unstable system time.
|
|
|
|
|
|
- if(my_gps_stat.num_sats >= MIN_SATS_FOR_TIME)
|
|
|
+ if(my_gps_stat.num_sats >= MIN_SATS_FOR_TIME)
|
|
|
{
|
|
|
// Pass the time field (f1) and the date field (f9) in to the routine that sets the system clock if needed.
|
|
|
// (this routine also stores the utc timestamp derived from the GPS date and time fields so it can be passed to
|
|
|
// other modules that may have a need for this information).
|
|
|
- handle_gps_time(f1,f9);
|
|
|
+ handle_gps_time(f1,f9);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -666,38 +666,92 @@ static void process_ws_message(struct websocket_message *ws_msg) {
|
|
|
printf("\n");
|
|
|
}
|
|
|
|
|
|
+#define MAX_PKGS (16)
|
|
|
|
|
|
//
|
|
|
// ui wants status information
|
|
|
//
|
|
|
static void ui_handle_status_input(struct mg_connection *nc, struct http_message *hm) {
|
|
|
- char buf[_SLEN];
|
|
|
- //char msg[][_SLEN] = { "fail error", "ok .", };
|
|
|
-
|
|
|
- //DEBUG sample message
|
|
|
- snprintf(buf, _SLEN, "ok msg=status\nroute=%s|trip=%s|stop=%s|gps=%i|tunnel=%i|date=%s|eqiupno=%s|nmsg=%s|last_token=%s|config=%s|firmware=%s|imei=%s|imsi=%s|eth0=%s",
|
|
|
- "9900", "1", "0",
|
|
|
- 1, 1,
|
|
|
- "2019-08-13 09;23:00",
|
|
|
- "9999", "0",
|
|
|
- "",
|
|
|
- "20190730v403 2019-11-05 02:36:43",
|
|
|
- "1.11 2019-07-30 16:33:08",
|
|
|
- "356136074279052",
|
|
|
- "310260877138191",
|
|
|
- "00:80:66:10:E8:8A");
|
|
|
+ int i, npkgs, npkgnet=0;
|
|
|
+ char buf[4*_SLEN],
|
|
|
+ pkgnetline[_SLEN],
|
|
|
+ _str[_SLEN];
|
|
|
+ char date_str[32];
|
|
|
+ time_t t;
|
|
|
+ struct tm tm, pkgtime;
|
|
|
+ FILE *fp;
|
|
|
+ package_signature pkgs[MAX_PKGS];
|
|
|
+
|
|
|
+ t = time(NULL);
|
|
|
+ localtime_r(&t, &tm);
|
|
|
+ strftime(date_str, 32, "%Y-%m-%d", &tm);
|
|
|
+
|
|
|
+ pkgnetline[0] = '\0';
|
|
|
+ npkgs = find_packages(pkgs,MAX_PKGS);
|
|
|
+ for (i=0; i<npkgs; i++) {
|
|
|
+ localtime_r(&pkgs[i].installed, &pkgtime);
|
|
|
+ snprintf(_str, _SLEN, "pkg%i=%s %s %02d/%02d/%02d %02d:%02d:%02d",
|
|
|
+ i,
|
|
|
+ pkgs[i].pkgname, pkgs[i].pkgver,
|
|
|
+ pkgtime.tm_mon + 1, pkgtime.tm_mday, pkgtime.tm_year + 1900,
|
|
|
+ pkgtime.tm_hour, pkgtime.tm_min, pkgtime.tm_sec);
|
|
|
+ //if (npkgnet>0) { strncat(pkgnetline, "|", _SLEN); }
|
|
|
+ strncat(pkgnetline, "|", _SLEN);
|
|
|
+ strncat(pkgnetline, _str, _SLEN);
|
|
|
+ npkgnet++;
|
|
|
+ }
|
|
|
|
|
|
- /*
|
|
|
- printf(">> status:\nbuf(%i):\n%s\n", (int)strlen(buf), buf);
|
|
|
+ fp = fopen("/tmp/net_ids", "rb");
|
|
|
+ if (fp) {
|
|
|
+ i=0;
|
|
|
+ while (fgets(_str, _SLEN, fp)) {
|
|
|
+ strip_crlf(_str);
|
|
|
+ strncat(pkgnetline, "|", _SLEN);
|
|
|
+ strncat(pkgnetline, _str, _SLEN);
|
|
|
+ npkgnet++;
|
|
|
+ }
|
|
|
+ fclose(fp);
|
|
|
+ }
|
|
|
|
|
|
- //snprintf(buf, _SLEN, "ok xxx=foo bar;yyy=baz qux;...");
|
|
|
|
|
|
- printf(">> status\n");
|
|
|
- */
|
|
|
+ snprintf(buf, 4*_SLEN, "ok msg=status\n"
|
|
|
+ "equipno=%d|"
|
|
|
+
|
|
|
+ "route=%d|"
|
|
|
+ "trip=%d|"
|
|
|
+ "stop=%d|"
|
|
|
+
|
|
|
+ "gps=%i|"
|
|
|
+ "tunnel=%i|"
|
|
|
+ "gprs=%i|"
|
|
|
+
|
|
|
+ "date=%s|"
|
|
|
+ "nmsg=%d|"
|
|
|
+ "last_token=%d"
|
|
|
+
|
|
|
+ "%s",
|
|
|
+
|
|
|
+ get_equip_num(),
|
|
|
+
|
|
|
+ stop_stat.route,
|
|
|
+ stop_stat.trip,
|
|
|
+ stop_stat.stop,
|
|
|
+
|
|
|
+ gps_stat.gps_good,
|
|
|
+ tunnel_is_up(),
|
|
|
+ gprs_is_up(),
|
|
|
+
|
|
|
+ date_str,
|
|
|
+ bill_stat.unsynced_messages,
|
|
|
+ token_diag_serial % 100,
|
|
|
+
|
|
|
+ pkgnetline);
|
|
|
+
|
|
|
+ //DEBUG
|
|
|
+ printf("%s\n", buf);
|
|
|
|
|
|
mg_printf(nc, "HTTP/1.1 200 OK\r\nContent-Length: %lu\r\n\r\n%s",
|
|
|
(unsigned long)strlen(buf), buf);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1020,7 +1074,7 @@ int main(int argc, char **argv) {
|
|
|
|
|
|
// Make an initial attempt to get in touch with the interprocess communication hub (it may not be up yet depending on the start order)
|
|
|
//
|
|
|
- maintain_ipc_hub_connect(argv[0]);
|
|
|
+ maintain_ipc_hub_connect(argv[0]);
|
|
|
|
|
|
// Register our defualt system message processing callbacks
|
|
|
//
|
|
|
@@ -1163,7 +1217,7 @@ int main(int argc, char **argv) {
|
|
|
|
|
|
//Redraw the menu reflecting any changes from the last touchscreen input
|
|
|
//or other stimulus
|
|
|
- //draw_menu(mt);
|
|
|
+ //draw_menu(mt);
|
|
|
//
|
|
|
|
|
|
#ifdef TOUCHSCREEN_QUIET
|
|
|
@@ -1391,7 +1445,7 @@ int main(int argc, char **argv) {
|
|
|
//send them all to the log server
|
|
|
//
|
|
|
format_log_message(&outgoing_msg, trav[1], "DIU Reports: %s", trav + 3);
|
|
|
- send_message(hub_fd, &outgoing_msg);
|
|
|
+ send_message(hub_fd, &outgoing_msg);
|
|
|
|
|
|
//but in the case of errors, send them to the driver too
|
|
|
if(trav[1] == '!') {
|