|
@@ -865,14 +865,9 @@ static void ui_handle_fare_input(struct mg_connection *nc, struct http_message *
|
|
|
ret = mg_get_http_var(&(hm->body), "rule", s_rule, _SLEN);
|
|
ret = mg_get_http_var(&(hm->body), "rule", s_rule, _SLEN);
|
|
|
if (ret<=0) { mg_http_send_error(nc, 404, NULL); return; }
|
|
if (ret<=0) { mg_http_send_error(nc, 404, NULL); return; }
|
|
|
|
|
|
|
|
- printf("got rule '%s'\n", s_rule);
|
|
|
|
|
-
|
|
|
|
|
ret = mg_get_http_var(&(hm->body), "param", s_param, _SLEN);
|
|
ret = mg_get_http_var(&(hm->body), "param", s_param, _SLEN);
|
|
|
- //if (ret<=0) { mg_http_send_error(nc, 404, NULL); return; }
|
|
|
|
|
if (ret<=0) { s_param[0] = '\0'; }
|
|
if (ret<=0) { s_param[0] = '\0'; }
|
|
|
|
|
|
|
|
- printf("got param '%s'\n", s_param);
|
|
|
|
|
-
|
|
|
|
|
if (hub_fd >= 0) {
|
|
if (hub_fd >= 0) {
|
|
|
strncpy(dr.rulename, s_rule, DRIVER_RULECALL_LEN - 1);
|
|
strncpy(dr.rulename, s_rule, DRIVER_RULECALL_LEN - 1);
|
|
|
strncpy(dr.ruleparam, s_param, DRIVER_RULECALL_LEN - 1);
|
|
strncpy(dr.ruleparam, s_param, DRIVER_RULECALL_LEN - 1);
|
|
@@ -950,7 +945,7 @@ static void ui_handle_dim(struct mg_connection *nc, struct http_message *hm) {
|
|
|
|
|
|
|
|
// assuming we're running as root for now
|
|
// assuming we're running as root for now
|
|
|
//
|
|
//
|
|
|
- ret = system("su - pi -c \"/usr/bin/xset -display :0 dpms force off\"");
|
|
|
|
|
|
|
+ ret = system("su - pi -c \"/usr/bin/xset -display :0 dpms force off\" &");
|
|
|
|
|
|
|
|
if (ret!=0) {
|
|
if (ret!=0) {
|
|
|
mg_printf(nc, "HTTP/1.1 200 OK\r\nContent-Length: %lu\r\n\r\n%s",
|
|
mg_printf(nc, "HTTP/1.1 200 OK\r\nContent-Length: %lu\r\n\r\n%s",
|
|
@@ -978,7 +973,7 @@ static void ui_handle_volume(struct mg_connection *nc, struct http_message *hm)
|
|
|
// assuming we're running as root for now
|
|
// assuming we're running as root for now
|
|
|
//
|
|
//
|
|
|
f_vol = atof(s_volume);
|
|
f_vol = atof(s_volume);
|
|
|
- snprintf(_cmd, 1023, "/home/bus/bin/volumeset %04f", f_vol);
|
|
|
|
|
|
|
+ snprintf(_cmd, 1023, "/home/bus/bin/volumeset %04f &", f_vol);
|
|
|
ret = system(_cmd);
|
|
ret = system(_cmd);
|
|
|
|
|
|
|
|
if (ret!=0) {
|
|
if (ret!=0) {
|
|
@@ -1031,10 +1026,10 @@ static void ui_handle_interfaceupdown(struct mg_connection *nc, struct http_mess
|
|
|
// Bring eth0 interface up or down.
|
|
// Bring eth0 interface up or down.
|
|
|
//
|
|
//
|
|
|
if (_iface_updown==1) {
|
|
if (_iface_updown==1) {
|
|
|
- ret = system("/sbin/ip link set eth0 up");
|
|
|
|
|
|
|
+ ret = system("/sbin/ip link set eth0 up &");
|
|
|
}
|
|
}
|
|
|
else if (_iface_updown==0) {
|
|
else if (_iface_updown==0) {
|
|
|
- ret = system("/sbin/ip link set eth0 down");
|
|
|
|
|
|
|
+ ret = system("/sbin/ip link set eth0 down &");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (ret!=0) {
|
|
if (ret!=0) {
|
|
@@ -1089,6 +1084,27 @@ static void ui_handle_interfaceinfo(struct mg_connection *nc, struct http_messag
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+// run 'say' custom script for voice text to speech
|
|
|
|
|
+//
|
|
|
|
|
+static void ui_handle_say(struct mg_connection *nc, struct http_message *hm) {
|
|
|
|
|
+ int ret;
|
|
|
|
|
+ //char msg_fail[] = "fail say";
|
|
|
|
|
+ char msg_ok[] = "ok say";
|
|
|
|
|
+
|
|
|
|
|
+ char s_message[_SLEN];
|
|
|
|
|
+ char buf[4*_SLEN];
|
|
|
|
|
+
|
|
|
|
|
+ ret = mg_get_http_var(&(hm->body), "message", s_message, _SLEN);
|
|
|
|
|
+ if (ret<=0) { mg_http_send_error(nc, 404, NULL); return; }
|
|
|
|
|
+
|
|
|
|
|
+ snprintf(buf, 4*_SLEN-1, "/home/bus/bin/say \"%s\" &", s_message);
|
|
|
|
|
+ system(buf);
|
|
|
|
|
+
|
|
|
|
|
+ mg_printf(nc, "HTTP/1.1 200 OK\r\nContent-Length: %lu\r\n\r\n%s",
|
|
|
|
|
+ (unsigned long)strlen(msg_ok), msg_ok);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//-----
|
|
//-----
|
|
|
//-----
|
|
//-----
|
|
|
//-----
|
|
//-----
|
|
@@ -1150,6 +1166,10 @@ static void api_handle_req(struct mg_connection *nc, struct http_message *hm) {
|
|
|
ui_handle_interfaceinfo(nc, hm);
|
|
ui_handle_interfaceinfo(nc, hm);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ else if (strncmp(s_action, "say", strlen("say")+1)==0) {
|
|
|
|
|
+ ui_handle_say(nc, hm);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
else {
|
|
else {
|
|
|
mg_http_send_error(nc, 404, NULL);
|
|
mg_http_send_error(nc, 404, NULL);
|
|
|
}
|
|
}
|
|
@@ -1383,6 +1403,8 @@ int main(int argc, char **argv) {
|
|
|
update_driver_status = 0;
|
|
update_driver_status = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ check_paddle_request();
|
|
|
|
|
+
|
|
|
//If we have to redraw the UI
|
|
//If we have to redraw the UI
|
|
|
//if(redraw_flag && !calibration)
|
|
//if(redraw_flag && !calibration)
|
|
|
//
|
|
//
|