qcdm: add event reporting on/off command
Doesn't parse any events yet since we don't know what any events are. We also need to fix up ModemManager to handle unsolicited responses in the QcdmSerialPort class.
This commit is contained in:
@@ -1094,6 +1094,35 @@ qcmd_cmd_ext_logmask_result_get_item (QCDMResult *result,
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
gsize
|
||||
qcdm_cmd_event_report_new (char *buf, gsize len, gboolean start, GError **error)
|
||||
{
|
||||
char cmdbuf[4];
|
||||
DMCmdEventReport *cmd = (DMCmdEventReport *) &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_EVENT_REPORT;
|
||||
cmd->on = start ? 1 : 0;
|
||||
|
||||
return dm_encapsulate_buffer (cmdbuf, sizeof (*cmd), sizeof (cmdbuf), buf, len);
|
||||
}
|
||||
|
||||
QCDMResult *
|
||||
qcdm_cmd_event_report_result (const char *buf, gsize len, GError **error)
|
||||
{
|
||||
g_return_val_if_fail (buf != NULL, NULL);
|
||||
|
||||
if (!check_command (buf, len, DIAG_CMD_EVENT_REPORT, sizeof (DMCmdEventReport), error))
|
||||
return NULL;
|
||||
|
||||
return qcdm_result_new ();
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
gsize
|
||||
qcdm_cmd_zte_subsys_status_new (char *buf, gsize len, GError **error)
|
||||
{
|
||||
|
@@ -459,6 +459,17 @@ gboolean qcmd_cmd_ext_logmask_result_get_item (QCDMResult *result,
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
gsize qcdm_cmd_event_report_new (char *buf,
|
||||
gsize len,
|
||||
gboolean start,
|
||||
GError **error);
|
||||
|
||||
QCDMResult *qcdm_cmd_event_report_result (const char *buf,
|
||||
gsize len,
|
||||
GError **error);
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
#define QCDM_CMD_ZTE_SUBSYS_STATUS_ITEM_SIGNAL_INDICATOR "signal-indicator"
|
||||
|
||||
gsize qcdm_cmd_zte_subsys_status_new (char *buf,
|
||||
|
@@ -377,6 +377,20 @@ struct DMCmdExtLogMask {
|
||||
} __attribute__ ((packed));
|
||||
typedef struct DMCmdExtLogMask DMCmdExtLogMask;
|
||||
|
||||
struct DMCmdEventReport {
|
||||
guint8 code;
|
||||
guint8 on;
|
||||
} __attribute__ ((packed));
|
||||
typedef struct DMCmdEventReport DMCmdEventReport;
|
||||
|
||||
struct DMCmdEventReportRsp {
|
||||
guint8 code;
|
||||
guint16 len;
|
||||
guint16 event_id;
|
||||
guint8 data[0];
|
||||
} __attribute__ ((packed));
|
||||
typedef struct DMCmdEventReportRsp DMCmdEventReportRsp;
|
||||
|
||||
/* DIAG_SUBSYS_NW_CONTROL_* subsys command */
|
||||
struct DMCmdSubsysNwSnapshotReq {
|
||||
DMCmdSubsysHeader hdr;
|
||||
|
@@ -1253,6 +1253,49 @@ test_com_ext_logmask (void *f, void *data)
|
||||
reply_len = wait_reply (d, buf, sizeof (buf));
|
||||
}
|
||||
|
||||
void
|
||||
test_com_event_report (void *f, void *data)
|
||||
{
|
||||
TestComData *d = data;
|
||||
gboolean success;
|
||||
GError *error = NULL;
|
||||
char buf[520];
|
||||
gint len;
|
||||
QCDMResult *result;
|
||||
gsize reply_len;
|
||||
|
||||
/* Turn event reporting on */
|
||||
len = qcdm_cmd_event_report_new (buf, sizeof (buf), TRUE, NULL);
|
||||
|
||||
/* Send the command */
|
||||
success = send_command (d, buf, len);
|
||||
g_assert (success);
|
||||
|
||||
/* Get a response */
|
||||
reply_len = wait_reply (d, buf, sizeof (buf));
|
||||
|
||||
g_print ("\n");
|
||||
|
||||
/* Parse the response into a result structure */
|
||||
result = qcdm_cmd_event_report_result (buf, reply_len, &error);
|
||||
g_assert (result);
|
||||
|
||||
qcdm_result_unref (result);
|
||||
|
||||
/* Wait for an event */
|
||||
reply_len = wait_reply (d, buf, sizeof (buf));
|
||||
|
||||
/* Turn event reporting off */
|
||||
len = qcdm_cmd_event_report_new (buf, sizeof (buf), FALSE, NULL);
|
||||
|
||||
/* Send the command */
|
||||
success = send_command (d, buf, len);
|
||||
g_assert (success);
|
||||
|
||||
/* Get a response */
|
||||
reply_len = wait_reply (d, buf, sizeof (buf));
|
||||
}
|
||||
|
||||
void
|
||||
test_com_zte_subsys_status (void *f, void *data)
|
||||
{
|
||||
|
@@ -47,6 +47,8 @@ void test_com_hdr_subsys_state_info (void *f, void *data);
|
||||
|
||||
void test_com_ext_logmask (void *f, void *data);
|
||||
|
||||
void test_com_event_report (void *f, void *data);
|
||||
|
||||
void test_com_zte_subsys_status (void *f, void *data);
|
||||
|
||||
void test_com_nw_subsys_modem_snapshot_cdma (void *f, void *data);
|
||||
|
@@ -108,6 +108,7 @@ int main (int argc, char **argv)
|
||||
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));
|
||||
g_test_suite_add (suite, TESTCASE (test_com_ext_logmask, data->com_data));
|
||||
g_test_suite_add (suite, TESTCASE (test_com_event_report, data->com_data));
|
||||
g_test_suite_add (suite, TESTCASE (test_com_zte_subsys_status, data->com_data));
|
||||
g_test_suite_add (suite, TESTCASE (test_com_nw_subsys_modem_snapshot_cdma, data->com_data));
|
||||
}
|
||||
|
Reference in New Issue
Block a user