qcdm: add HDR State Info command
This commit is contained in:
@@ -450,3 +450,48 @@ qcdm_cmd_cm_subsys_state_info_result (const char *buf, gsize len, GError **error
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
gsize
|
||||
qcdm_cmd_hdr_subsys_state_info_new (char *buf, gsize len, GError **error)
|
||||
{
|
||||
char cmdbuf[sizeof (DMCmdSubsysHeader) + 2];
|
||||
DMCmdSubsysHeader *cmd = (DMCmdSubsysHeader *) &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_SUBSYS;
|
||||
cmd->subsys_id = DIAG_SUBSYS_HDR;
|
||||
cmd->subsys_cmd = GUINT16_TO_LE (DIAG_SUBSYS_HDR_STATE_INFO);
|
||||
|
||||
return dm_encapsulate_buffer (cmdbuf, sizeof (*cmd), sizeof (cmdbuf), buf, len);
|
||||
}
|
||||
|
||||
QCDMResult *
|
||||
qcdm_cmd_hdr_subsys_state_info_result (const char *buf, gsize len, GError **error)
|
||||
{
|
||||
QCDMResult *result = NULL;
|
||||
DMCmdSubsysHDRStateInfoRsp *rsp = (DMCmdSubsysHDRStateInfoRsp *) buf;
|
||||
|
||||
g_return_val_if_fail (buf != NULL, NULL);
|
||||
|
||||
if (!check_command (buf, len, DIAG_CMD_SUBSYS, sizeof (DMCmdSubsysHDRStateInfoRsp), error))
|
||||
return NULL;
|
||||
|
||||
result = qcdm_result_new ();
|
||||
|
||||
qcdm_result_add_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_AT_STATE, rsp->at_state);
|
||||
qcdm_result_add_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_SESSION_STATE, rsp->session_state);
|
||||
qcdm_result_add_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_ALMP_STATE, rsp->almp_state);
|
||||
qcdm_result_add_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_INIT_STATE, rsp->init_state);
|
||||
qcdm_result_add_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_IDLE_STATE, rsp->idle_state);
|
||||
qcdm_result_add_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_CONNECTED_STATE, rsp->connected_state);
|
||||
qcdm_result_add_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_ROUTE_UPDATE_STATE, rsp->route_update_state);
|
||||
qcdm_result_add_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_OVERHEAD_MSG_STATE, rsp->overhead_msg_state);
|
||||
qcdm_result_add_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_HDR_HYBRID_MODE, rsp->hdr_hybrid_mode);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
|
@@ -112,8 +112,6 @@ QCDMResult *qcdm_cmd_nv_get_mdn_result (const char *buf,
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
/* Values for QCDM_CMD_CM_SUBSYS_STATE_INFO_ITEM_OPERATING_MODE */
|
||||
enum {
|
||||
QCDM_CMD_CM_SUBSYS_STATE_INFO_OPERATING_MODE_ONLINE = 5
|
||||
@@ -149,4 +147,52 @@ QCDMResult *qcdm_cmd_cm_subsys_state_info_result (const char *buf,
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
/* Values for QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_AT_STATE */
|
||||
enum {
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_INACTIVE = 0,
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_ACQUISITION = 1,
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_SYNC = 2,
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_IDLE = 3,
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_ACCESS = 4,
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_CONNECTED = 5
|
||||
};
|
||||
|
||||
/* Values for QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_SESSION_STATE */
|
||||
enum {
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_CLOSED = 0,
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_SETUP = 1,
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_AT_INIT = 2, /* initiated by Access Terminal */
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_AN_INIT = 3, /* initiated by Access Node */
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_OPEN = 4,
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_CLOSING = 5
|
||||
};
|
||||
|
||||
/* Values for QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_ALMP_STATE */
|
||||
enum {
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_ALMP_STATE_INACTIVE = 0, /* initial state */
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_ALMP_STATE_INIT = 1, /* terminal has yet to acquire network */
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_ALMP_STATE_IDLE = 2, /* network acquired but no connection */
|
||||
QCDM_CMD_HDR_SUBSYS_STATE_INFO_ALMP_STATE_CONNECTED = 3, /* open connection to the network */
|
||||
};
|
||||
|
||||
#define QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_AT_STATE "at-state" /* State of Access Terminal */
|
||||
#define QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_SESSION_STATE "session-state" /* Current session state */
|
||||
#define QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_ALMP_STATE "almp-state" /* Air Link Management Protocol (ALMP) state */
|
||||
#define QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_INIT_STATE "init-state" /* Initialization State Protocol (ISP) state */
|
||||
#define QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_IDLE_STATE "idle-state" /* Idle State Protocol (IDP) state */
|
||||
#define QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_CONNECTED_STATE "connected-state" /* Connected State Protocol (CSP) state */
|
||||
#define QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_ROUTE_UPDATE_STATE "route-update-state" /* Route Update Protocol (RUP) state */
|
||||
#define QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_OVERHEAD_MSG_STATE "overhead-msg-state"
|
||||
#define QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_HDR_HYBRID_MODE "hdr-hybrid-mode"
|
||||
|
||||
gsize qcdm_cmd_hdr_subsys_state_info_new (char *buf,
|
||||
gsize len,
|
||||
GError **error);
|
||||
|
||||
QCDMResult *qcdm_cmd_hdr_subsys_state_info_result (const char *buf,
|
||||
gsize len,
|
||||
GError **error);
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
#endif /* LIBQCDM_COMMANDS_H */
|
||||
|
@@ -235,5 +235,20 @@ struct DMCmdSubsysCMStateInfoRsp {
|
||||
} __attribute__ ((packed));
|
||||
typedef struct DMCmdSubsysCMStateInfoRsp DMCmdSubsysCMStateInfoRsp;
|
||||
|
||||
/* DIAG_SUBSYS_HDR_STATE_INFO subsys command */
|
||||
struct DMCmdSubsysHDRStateInfoRsp {
|
||||
DMCmdSubsysHeader header;
|
||||
guint8 at_state;
|
||||
guint8 session_state;
|
||||
guint8 almp_state;
|
||||
guint8 init_state;
|
||||
guint8 idle_state;
|
||||
guint8 connected_state;
|
||||
guint8 route_update_state;
|
||||
guint8 overhead_msg_state;
|
||||
guint8 hdr_hybrid_mode;
|
||||
} __attribute__ ((packed));
|
||||
typedef struct DMCmdSubsysHDRStateInfoRsp DMCmdSubsysHDRStateInfoRsp;
|
||||
|
||||
#endif /* LIBQCDM_DM_COMMANDS_H */
|
||||
|
||||
|
@@ -539,3 +539,141 @@ test_com_cm_subsys_state_info (void *f, void *data)
|
||||
qcdm_result_unref (result);
|
||||
}
|
||||
|
||||
void
|
||||
test_com_hdr_subsys_state_info (void *f, void *data)
|
||||
{
|
||||
TestComData *d = data;
|
||||
gboolean success;
|
||||
GError *error = NULL;
|
||||
char buf[100];
|
||||
gint len;
|
||||
QCDMResult *result;
|
||||
gsize reply_len;
|
||||
guint8 num;
|
||||
const char *detail;
|
||||
|
||||
len = qcdm_cmd_hdr_subsys_state_info_new (buf, sizeof (buf), NULL);
|
||||
g_assert (len == 7);
|
||||
|
||||
/* Send the command */
|
||||
success = send_command (d, buf, len);
|
||||
g_assert (success);
|
||||
|
||||
/* Get a response */
|
||||
reply_len = wait_reply (d, buf, sizeof (buf));
|
||||
|
||||
/* Parse the response into a result structure */
|
||||
result = qcdm_cmd_hdr_subsys_state_info_result (buf, reply_len, &error);
|
||||
if (!result) {
|
||||
/* 1x-only devices won't implement the HDR subsystem of course */
|
||||
g_assert_error (error, QCDM_COMMAND_ERROR, QCDM_COMMAND_BAD_COMMAND);
|
||||
g_message ("%s: device does not implement the HDR subsystem", __func__);
|
||||
return;
|
||||
}
|
||||
g_assert (result);
|
||||
|
||||
num = 0;
|
||||
detail = NULL;
|
||||
qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_AT_STATE, &num);
|
||||
switch (num) {
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_INACTIVE:
|
||||
detail = "inactive";
|
||||
break;
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_ACQUISITION:
|
||||
detail = "acquisition";
|
||||
break;
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_SYNC:
|
||||
detail = "sync";
|
||||
break;
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_IDLE:
|
||||
detail = "idle";
|
||||
break;
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_ACCESS:
|
||||
detail = "access";
|
||||
break;
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_AT_STATE_CONNECTED:
|
||||
detail = "connected";
|
||||
break;
|
||||
default:
|
||||
detail = "unknown";
|
||||
break;
|
||||
}
|
||||
g_message ("%s: AT State: %u (%s)", __func__, num, detail);
|
||||
|
||||
num = 0;
|
||||
detail = NULL;
|
||||
qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_SESSION_STATE, &num);
|
||||
switch (num) {
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_CLOSED:
|
||||
detail = "closed";
|
||||
break;
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_SETUP:
|
||||
detail = "setup";
|
||||
break;
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_AT_INIT:
|
||||
detail = "AT init";
|
||||
break;
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_AN_INIT:
|
||||
detail = "AN init";
|
||||
break;
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_OPEN:
|
||||
detail = "open";
|
||||
break;
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_SESSION_STATE_CLOSING:
|
||||
detail = "closing";
|
||||
break;
|
||||
default:
|
||||
detail = "unknown";
|
||||
break;
|
||||
}
|
||||
g_message ("%s: Session State: %u (%s)", __func__, num, detail);
|
||||
|
||||
num = 0;
|
||||
detail = NULL;
|
||||
qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_ALMP_STATE, &num);
|
||||
switch (num) {
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_ALMP_STATE_INACTIVE:
|
||||
detail = "inactive";
|
||||
break;
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_ALMP_STATE_INIT:
|
||||
detail = "init";
|
||||
break;
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_ALMP_STATE_IDLE:
|
||||
detail = "idle";
|
||||
break;
|
||||
case QCDM_CMD_HDR_SUBSYS_STATE_INFO_ALMP_STATE_CONNECTED:
|
||||
detail = "connected";
|
||||
break;
|
||||
default:
|
||||
detail = "unknown";
|
||||
break;
|
||||
}
|
||||
g_message ("%s: ALMP State: %u (%s)", __func__, num, detail);
|
||||
|
||||
num = 0;
|
||||
qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_INIT_STATE, &num);
|
||||
g_message ("%s: Init State: %u", __func__, num);
|
||||
|
||||
num = 0;
|
||||
qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_IDLE_STATE, &num);
|
||||
g_message ("%s: Idle State: %u", __func__, num);
|
||||
|
||||
num = 0;
|
||||
qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_CONNECTED_STATE, &num);
|
||||
g_message ("%s: Connected State: %u", __func__, num);
|
||||
|
||||
num = 0;
|
||||
qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_ROUTE_UPDATE_STATE, &num);
|
||||
g_message ("%s: Route Update State: %u", __func__, num);
|
||||
|
||||
num = 0;
|
||||
qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_OVERHEAD_MSG_STATE, &num);
|
||||
g_message ("%s: Overhead Msg State: %u", __func__, num);
|
||||
|
||||
num = 0;
|
||||
qcdm_result_get_uint8 (result, QCDM_CMD_HDR_SUBSYS_STATE_INFO_ITEM_HDR_HYBRID_MODE, &num);
|
||||
g_message ("%s: HDR Hybrid Mode: %u", __func__, num);
|
||||
|
||||
qcdm_result_unref (result);
|
||||
}
|
||||
|
||||
|
@@ -35,5 +35,7 @@ void test_com_sw_version (void *f, void *data);
|
||||
|
||||
void test_com_cm_subsys_state_info (void *f, void *data);
|
||||
|
||||
void test_com_hdr_subsys_state_info (void *f, void *data);
|
||||
|
||||
#endif /* TEST_QCDM_COM_H */
|
||||
|
||||
|
@@ -95,6 +95,7 @@ int main (int argc, char **argv)
|
||||
g_test_suite_add (suite, TESTCASE (test_com_status, data->com_data));
|
||||
g_test_suite_add (suite, TESTCASE (test_com_sw_version, data->com_data));
|
||||
g_test_suite_add (suite, TESTCASE (test_com_cm_subsys_state_info, data->com_data));
|
||||
g_test_suite_add (suite, TESTCASE (test_com_hdr_subsys_state_info, data->com_data));
|
||||
}
|
||||
|
||||
result = g_test_run ();
|
||||
|
Reference in New Issue
Block a user