diff options
author | Dan Williams <dcbw@redhat.com> | 2013-03-12 16:50:49 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2013-03-12 16:50:49 -0500 |
commit | dd4be407b210aa710dc862bb246bbbec17c27805 (patch) | |
tree | cc1e26a84f89457a90ff3921590c1949005b7b90 | |
parent | 974471e2952b985d8d93de01b7f6f54086180365 (diff) |
qcdm: modepref: reset device after setting mode preference
Otherwise it doesn't actually take until you unplug/replug.
-rw-r--r-- | libqcdm/tests/modepref.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libqcdm/tests/modepref.c b/libqcdm/tests/modepref.c index e1c7c0eb..e6925324 100644 --- a/libqcdm/tests/modepref.c +++ b/libqcdm/tests/modepref.c @@ -384,6 +384,45 @@ error: return spref; } +static int +qcdm_set_mode (int fd, u_int8_t mode) +{ + int err; + char buf[512]; + size_t len; + QcdmResult *result; + size_t reply_len; + + len = qcdm_cmd_control_new (buf, sizeof (buf), mode); + assert (len); + + /* Send the command */ + if (!qcdm_send (fd, buf, len)) { + fprintf (stderr, "E: failed to send QCDM Control command\n"); + goto error; + } + + reply_len = qcdm_wait_reply (fd, buf, sizeof (buf)); + if (!reply_len) { + fprintf (stderr, "E: failed to receive Control command reply\n"); + goto error; + } + + /* Parse the response into a result structure */ + err = QCDM_SUCCESS; + result = qcdm_cmd_control_result (buf, reply_len, &err); + if (!result) { + fprintf (stderr, "E: failed to parse Control command reply: %d\n", err); + goto error; + } + + qcdm_result_unref (result); + return 0; + +error: + return -1; +} + /******************************************************************/ static void @@ -503,6 +542,12 @@ main (int argc, char *argv[]) if (set_evdo && qcdm_set_hdr_pref (fd, hdrpref)) return 1; + /* Send DM reset command */ + qcdm_set_mode (fd, QCDM_CMD_CONTROL_MODE_OFFLINE); + sleep (2); + qcdm_set_mode (fd, QCDM_CMD_CONTROL_MODE_RESET); + sleep (2); + fprintf (stdout, "Success setting mode to '%s': replug your device.\n", smode); } else { msg = qcdm_get_mode_pref (fd); |