From: Felix Fietkau Date: Sun, 17 Feb 2013 21:36:48 +0000 (+0100) Subject: show type in the --get-signal-info command X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1803bd8512f72b6bb61b8c462e68fcfabc319f62;p=oweals%2Fuqmi.git show type in the --get-signal-info command --- diff --git a/commands-nas.c b/commands-nas.c index 09624c4..e4d7ce6 100644 --- a/commands-nas.c +++ b/commands-nas.c @@ -62,25 +62,31 @@ cmd_nas_get_signal_info_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_parse_nas_get_signal_info_response(msg, &res); if (res.set.cdma_signal_strength) { + blobmsg_add_string(&status, "type", "cdma"); blobmsg_add_u32(&status, "rssi", (int32_t) res.data.cdma_signal_strength.rssi); blobmsg_add_u32(&status, "ecio", (int32_t) res.data.cdma_signal_strength.ecio); } if (res.set.hdr_signal_strength) { + blobmsg_add_string(&status, "type", "hdr"); blobmsg_add_u32(&status, "rssi", (int32_t) res.data.hdr_signal_strength.rssi); blobmsg_add_u32(&status, "ecio", (int32_t) res.data.hdr_signal_strength.ecio); blobmsg_add_u32(&status, "io", res.data.hdr_signal_strength.io); } - if (res.set.gsm_signal_strength) + if (res.set.gsm_signal_strength) { + blobmsg_add_string(&status, "type", "gsm"); blobmsg_add_u32(&status, "signal", (int32_t) res.data.gsm_signal_strength); + } if (res.set.wcdma_signal_strength) { + blobmsg_add_string(&status, "type", "wcdma"); blobmsg_add_u32(&status, "rssi", (int32_t) res.data.wcdma_signal_strength.rssi); blobmsg_add_u32(&status, "ecio", (int32_t) res.data.wcdma_signal_strength.ecio); } if (res.set.lte_signal_strength) { + blobmsg_add_string(&status, "type", "lte"); blobmsg_add_u32(&status, "rssi", (int32_t) res.data.lte_signal_strength.rssi); blobmsg_add_u32(&status, "rsrq", (int32_t) res.data.lte_signal_strength.rsrq); blobmsg_add_u32(&status, "rsrp", (int32_t) res.data.lte_signal_strength.rsrp); diff --git a/dev.c b/dev.c index 21e30ea..b00ee8d 100644 --- a/dev.c +++ b/dev.c @@ -7,6 +7,8 @@ #include "qmi-errors.h" #include "qmi-errors.c" +bool cancel_all_requests = false; + #define __qmi_service(_n) [__##_n] = _n static const uint8_t qmi_services[__QMI_SERVICE_LAST] = { __qmi_services @@ -55,10 +57,14 @@ static void __qmi_request_complete(struct qmi_dev *qmi, struct qmi_request *req, req->pending = false; list_del(&req->list); - tlv_buf = qmi_msg_get_tlv_buf(msg, &tlv_len); - req->ret = qmi_check_message_status(tlv_buf, tlv_len); - if (req->ret) - msg = NULL; + if (msg) { + tlv_buf = qmi_msg_get_tlv_buf(msg, &tlv_len); + req->ret = qmi_check_message_status(tlv_buf, tlv_len); + if (req->ret) + msg = NULL; + } else { + req->ret = QMI_ERROR_CANCELLED; + } if (req->cb && (msg || !req->no_error_cb)) req->cb(qmi, req, msg); @@ -174,6 +180,10 @@ int qmi_request_wait(struct qmi_dev *qmi, struct qmi_request *req) cancelled = uloop_cancelled; uloop_cancelled = false; uloop_run(); + + if (cancel_all_requests) + qmi_request_cancel(qmi, req); + uloop_cancelled = cancelled; } diff --git a/main.c b/main.c index 7bfaba8..cde1f8d 100644 --- a/main.c +++ b/main.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "uqmi.h" #include "commands.h" @@ -55,11 +56,21 @@ static void keep_client_id(struct qmi_dev *qmi, const char *optarg) qmi_service_get_client_id(qmi, svc); } +static void handle_exit_signal(int signal) +{ + cancel_all_requests = true; + uloop_end(); +} + int main(int argc, char **argv) { static struct qmi_dev dev; int ch; + uloop_init(); + signal(SIGINT, handle_exit_signal); + signal(SIGTERM, handle_exit_signal); + while ((ch = getopt_long(argc, argv, "d:k:", uqmi_getopt, NULL)) != -1) { int cmd_opt = CMD_OPT(ch); diff --git a/qmi-message.h b/qmi-message.h index 35838b3..02cd881 100644 --- a/qmi-message.h +++ b/qmi-message.h @@ -73,6 +73,7 @@ enum { QMI_ERROR_NO_DATA = -1, QMI_ERROR_INVALID_DATA = -2, + QMI_ERROR_CANCELLED = -3, }; #define QMI_BUFFER_LEN 2048 diff --git a/uqmi.h b/uqmi.h index 213dbc5..842fb9b 100644 --- a/uqmi.h +++ b/uqmi.h @@ -1,8 +1,11 @@ #ifndef __UQMI_H #define __UQMI_H +#include + #include #include + #include "qmi-message.h" #ifdef DEBUG_PACKET @@ -76,6 +79,7 @@ struct qmi_request { int ret; }; +extern bool cancel_all_requests; int qmi_device_open(struct qmi_dev *qmi, const char *path); void qmi_device_close(struct qmi_dev *qmi);