aboutsummaryrefslogtreecommitdiff
path: root/libqcdm/src/commands.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2010-02-22 13:27:25 -0800
committerDan Williams <dcbw@redhat.com>2010-02-22 13:27:25 -0800
commitc0e227a16bb320790e0cd10683abb3262f87d04f (patch)
treed09d9b9b0d2489c34390aeef9d2108653e9a3a76 /libqcdm/src/commands.c
parentcb59d2e64d8bb79cb7147e7ce2128c83ec66ef1c (diff)
qcdm: add status command and rework testcases a bit
Status command not completely working yet.
Diffstat (limited to 'libqcdm/src/commands.c')
-rw-r--r--libqcdm/src/commands.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/libqcdm/src/commands.c b/libqcdm/src/commands.c
index 41356935..97817202 100644
--- a/libqcdm/src/commands.c
+++ b/libqcdm/src/commands.c
@@ -219,6 +219,74 @@ qcdm_cmd_esn_result (const char *buf, gsize len, GError **error)
/**********************************************************************/
gsize
+qcdm_cmd_cdma_status_new (char *buf, gsize len, GError **error)
+{
+ char cmdbuf[3];
+ DMCmdHeader *cmd = (DMCmdHeader *) &cmdbuf[0];
+
+ g_return_val_if_fail (buf != NULL, 0);
+ g_return_val_if_fail (len >= sizeof (*cmd) + DIAG_TRAILER_LEN, 0);
+
+ memset (cmd, 0, sizeof (cmd));
+ cmd->code = DIAG_CMD_STATUS;
+
+ return dm_encapsulate_buffer (cmdbuf, sizeof (*cmd), sizeof (cmdbuf), buf, len);
+}
+
+QCDMResult *
+qcdm_cmd_cdma_status_result (const char *buf, gsize len, GError **error)
+{
+ QCDMResult *result = NULL;
+ DMCmdStatusRsp *rsp = (DMCmdStatusRsp *) buf;
+ char *tmp;
+ guint8 swapped[4];
+ guint32 tmp_num;
+
+ g_return_val_if_fail (buf != NULL, NULL);
+
+ if (!check_command (buf, len, DIAG_CMD_STATUS, sizeof (DMCmdStatusRsp), error))
+ return NULL;
+
+ result = qcdm_result_new ();
+
+ /* Convert the ESN from binary to a hex string; it's LE so we have to
+ * swap it to get the correct ordering.
+ */
+ swapped[0] = rsp->esn[3];
+ swapped[1] = rsp->esn[2];
+ swapped[2] = rsp->esn[1];
+ swapped[3] = rsp->esn[0];
+
+ tmp = bin2hexstr (&swapped[0], sizeof (swapped));
+ qcdm_result_add_string (result, QCDM_CMD_CDMA_STATUS_ITEM_ESN, tmp);
+ g_free (tmp);
+
+ tmp_num = (guint32) GUINT16_FROM_LE (rsp->cdma_rx_state);
+ qcdm_result_add_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_RX_STATE, tmp_num);
+
+ tmp_num = (guint32) GUINT16_FROM_LE (rsp->entry_reason);
+ qcdm_result_add_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_ENTRY_REASON, tmp_num);
+
+ tmp_num = (guint32) GUINT16_FROM_LE (rsp->curr_chan);
+ qcdm_result_add_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_CURRENT_CHANNEL, tmp_num);
+
+ qcdm_result_add_uint8 (result, QCDM_CMD_CDMA_STATUS_ITEM_CODE_CHANNEL, rsp->cdma_code_chan);
+
+ tmp_num = (guint32) GUINT16_FROM_LE (rsp->pilot_base);
+ qcdm_result_add_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_PILOT_BASE, tmp_num);
+
+ tmp_num = (guint32) GUINT16_FROM_LE (rsp->sid);
+ qcdm_result_add_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_RX_STATE, tmp_num);
+
+ tmp_num = (guint32) GUINT16_FROM_LE (rsp->nid);
+ qcdm_result_add_uint32 (result, QCDM_CMD_CDMA_STATUS_ITEM_RX_STATE, tmp_num);
+
+ return result;
+}
+
+/**********************************************************************/
+
+gsize
qcdm_cmd_nv_get_mdn_new (char *buf, gsize len, guint8 profile, GError **error)
{
char cmdbuf[sizeof (DMCmdNVReadWrite) + DIAG_TRAILER_LEN];