add --set-device-operating-mode
authorFelix Fietkau <nbd@openwrt.org>
Sun, 23 Jun 2013 23:01:08 +0000 (01:01 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 23 Jun 2013 23:01:08 +0000 (01:01 +0200)
commands-dms.c
commands-dms.h

index af8b3cebeaefc7b68193738fd7c1f76503b9216b..c40a38e4cbec3425cf4a1724662147db4644ae0d 100644 (file)
@@ -98,3 +98,37 @@ cmd_dms_reset_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_m
        qmi_set_dms_reset_request(msg);
        return QMI_CMD_REQUEST;
 }
+
+#define cmd_dms_set_operating_mode_cb no_cb
+static enum qmi_cmd_result
+cmd_dms_set_operating_mode_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+       static const char *modes[] = {
+               [QMI_DMS_OPERATING_MODE_ONLINE] = "online",
+               [QMI_DMS_OPERATING_MODE_LOW_POWER] = "low_power",
+               [QMI_DMS_OPERATING_MODE_FACTORY_TEST] = "factory_test",
+               [QMI_DMS_OPERATING_MODE_OFFLINE] = "offline",
+               [QMI_DMS_OPERATING_MODE_RESET] = "reset",
+               [QMI_DMS_OPERATING_MODE_SHUTTING_DOWN] = "shutting_down",
+               [QMI_DMS_OPERATING_MODE_PERSISTENT_LOW_POWER] = "persistent_low_power",
+               [QMI_DMS_OPERATING_MODE_MODE_ONLY_LOW_POWER] = "mode_only_low_power",
+       };
+       static struct qmi_dms_set_operating_mode_request sreq = {
+               QMI_INIT(mode, QMI_DMS_OPERATING_MODE_ONLINE),
+       };
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(modes); i++) {
+               if (!modes[i])
+                       continue;
+
+               if (strcmp(arg, modes[i]) != 0)
+                       continue;
+
+               sreq.data.mode = i;
+               qmi_set_dms_set_operating_mode_request(msg, &sreq);
+               return QMI_CMD_REQUEST;
+       }
+
+       return uqmi_add_error("Invalid argument");
+}
index df0d91b672e05d4760e44587cfd5a6d072412f43..18643ca4c60025d310c356fd4e93b40dbaa1f287 100644 (file)
@@ -3,6 +3,7 @@
        __uqmi_command(dms_verify_pin1, verify-pin1, required, QMI_SERVICE_DMS), \
        __uqmi_command(dms_verify_pin2, verify-pin2, required, QMI_SERVICE_DMS), \
        __uqmi_command(dms_get_imsi, get-imsi, no, QMI_SERVICE_DMS), \
+       __uqmi_command(dms_set_operating_mode, set-device-operating-mode, required, QMI_SERVICE_DMS), \
        __uqmi_command(dms_reset, reset-dms, no, QMI_SERVICE_DMS) \
 
 #define dms_helptext \
@@ -11,4 +12,8 @@
                "  --verify-pin2 <pin>:              Verify PIN2\n" \
                "  --get-imsi:                       Get International Mobile Subscriber ID\n" \
                "  --reset-dms:                      Reset the DMS service\n" \
+               "  --set-device-operating-mode <m>   Set the device operating mode\n" \
+               "                                    (modes: online, low_power, factory_test, offline\n" \
+               "                                     reset, shutting_down, persistent_low_power,\n" \
+               "                                     mode_only_low_power)\n" \