Fix autoconnect
[project/uqmi.git] / commands-wds.c
index 3b27bfd..91cf15c 100644 (file)
@@ -28,7 +28,7 @@ cmd_wds_set_auth_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qm
                return QMI_CMD_DONE;
        }
 
-       blobmsg_add_string(&status, "error", "Invalid auth mode (valid: pap, chap, both, none)");
+       uqmi_add_error("Invalid auth mode (valid: pap, chap, both, none)");
        return QMI_CMD_EXIT;
 }
 
@@ -48,6 +48,14 @@ cmd_wds_set_password_prepare(struct qmi_dev *qmi, struct qmi_request *req, struc
        return QMI_CMD_DONE;
 }
 
+#define cmd_wds_set_autoconnect_cb no_cb
+static enum qmi_cmd_result
+cmd_wds_set_autoconnect_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+       qmi_set(&wds_sn_req, enable_autoconnect, true);
+       return QMI_CMD_DONE;
+}
+
 static void
 cmd_wds_start_network_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg)
 {
@@ -55,7 +63,7 @@ cmd_wds_start_network_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qm
 
        qmi_parse_wds_start_network_response(msg, &res);
        if (res.set.packet_data_handle)
-               blobmsg_add_u32(&status, "handle", res.data.packet_data_handle);
+               blobmsg_add_u32(&status, NULL, res.data.packet_data_handle);
 }
 
 static enum qmi_cmd_result
@@ -65,3 +73,40 @@ cmd_wds_start_network_prepare(struct qmi_dev *qmi, struct qmi_request *req, stru
        qmi_set_wds_start_network_request(msg, &wds_sn_req);
        return QMI_CMD_REQUEST;
 }
+
+static void
+cmd_wds_get_packet_service_status_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg)
+{
+       struct qmi_wds_get_packet_service_status_response res;
+       const char *data_status[] = {
+               [QMI_WDS_CONNECTION_STATUS_UNKNOWN] = "unknown",
+               [QMI_WDS_CONNECTION_STATUS_DISCONNECTED] = "disconnected",
+               [QMI_WDS_CONNECTION_STATUS_CONNECTED] = "connected",
+               [QMI_WDS_CONNECTION_STATUS_SUSPENDED] = "suspended",
+               [QMI_WDS_CONNECTION_STATUS_AUTHENTICATING] = "authenticating",
+       };
+       int s = 0;
+
+       qmi_parse_wds_get_packet_service_status_response(msg, &res);
+       if (res.set.connection_status &&
+           res.data.connection_status >= 0 &&
+           res.data.connection_status < ARRAY_SIZE(data_status))
+               s = res.data.connection_status;
+
+       blobmsg_add_string(&status, NULL, data_status[s]);
+}
+
+static enum qmi_cmd_result
+cmd_wds_get_packet_service_status_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+       qmi_set_wds_get_packet_service_status_request(msg);
+       return QMI_CMD_REQUEST;
+}
+
+#define cmd_wds_reset_cb no_cb
+static enum qmi_cmd_result
+cmd_wds_reset_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+       qmi_set_wds_reset_request(msg);
+       return QMI_CMD_REQUEST;
+}