wmc: STATUS is appears to be NETWORK_INFO
So rename it in various places.
This commit is contained in:
@@ -200,7 +200,7 @@ wmc_cmd_device_info_result (const char *buf, size_t buflen)
|
||||
/**********************************************************************/
|
||||
|
||||
size_t
|
||||
wmc_cmd_status_new (char *buf, size_t buflen)
|
||||
wmc_cmd_network_info_new (char *buf, size_t buflen)
|
||||
{
|
||||
WmcCmdHeader *cmd = (WmcCmdHeader *) buf;
|
||||
|
||||
@@ -209,7 +209,7 @@ wmc_cmd_status_new (char *buf, size_t buflen)
|
||||
|
||||
memset (cmd, 0, sizeof (*cmd));
|
||||
cmd->marker = WMC_CMD_MARKER;
|
||||
cmd->cmd = WMC_CMD_STATUS;
|
||||
cmd->cmd = WMC_CMD_NET_INFO;
|
||||
return sizeof (*cmd);
|
||||
}
|
||||
|
||||
@@ -221,40 +221,40 @@ sanitize_dbm (u_int8_t in_dbm)
|
||||
}
|
||||
|
||||
WmcResult *
|
||||
wmc_cmd_status_result (const char *buf, size_t buflen)
|
||||
wmc_cmd_network_info_result (const char *buf, size_t buflen)
|
||||
{
|
||||
WmcResult *r = NULL;
|
||||
WmcCmdStatusRsp *rsp = (WmcCmdStatusRsp *) buf;
|
||||
WmcCmdStatus2Rsp *rsp2 = (WmcCmdStatus2Rsp *) buf;
|
||||
WmcCmdNetworkInfoRsp *rsp = (WmcCmdNetworkInfoRsp *) buf;
|
||||
WmcCmdNetworkInfo2Rsp *rsp2 = (WmcCmdNetworkInfo2Rsp *) buf;
|
||||
char tmp[65];
|
||||
|
||||
wmc_return_val_if_fail (buf != NULL, NULL);
|
||||
|
||||
if (check_command (buf, buflen, WMC_CMD_STATUS, sizeof (WmcCmdStatus2Rsp)) < 0) {
|
||||
if (check_command (buf, buflen, WMC_CMD_NET_INFO, sizeof (WmcCmdNetworkInfo2Rsp)) < 0) {
|
||||
rsp2 = NULL;
|
||||
if (check_command (buf, buflen, WMC_CMD_STATUS, sizeof (WmcCmdStatusRsp)) < 0)
|
||||
if (check_command (buf, buflen, WMC_CMD_NET_INFO, sizeof (WmcCmdNetworkInfoRsp)) < 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
r = wmc_result_new ();
|
||||
|
||||
wmc_result_add_u8 (r, WMC_CMD_STATUS_ITEM_CDMA_DBM, sanitize_dbm (rsp->cdma1x_dbm));
|
||||
wmc_result_add_u8 (r, WMC_CMD_NETWORK_INFO_ITEM_CDMA_DBM, sanitize_dbm (rsp->cdma1x_dbm));
|
||||
|
||||
if (rsp2) {
|
||||
wmc_result_add_u8 (r, WMC_CMD_STATUS_ITEM_HDR_DBM, sanitize_dbm (rsp2->hdr_dbm));
|
||||
wmc_result_add_u8 (r, WMC_CMD_STATUS_ITEM_LTE_DBM, sanitize_dbm (rsp2->lte_dbm));
|
||||
wmc_result_add_u8 (r, WMC_CMD_NETWORK_INFO_ITEM_HDR_DBM, sanitize_dbm (rsp2->hdr_dbm));
|
||||
wmc_result_add_u8 (r, WMC_CMD_NETWORK_INFO_ITEM_LTE_DBM, sanitize_dbm (rsp2->lte_dbm));
|
||||
|
||||
memset (tmp, 0, sizeof (tmp));
|
||||
if (sanitize_dbm (rsp2->lte_dbm)) {
|
||||
/* LTE operator name */
|
||||
wmc_assert (sizeof (rsp2->lte_opname) <= sizeof (tmp));
|
||||
memcpy (tmp, rsp2->lte_opname, sizeof (rsp2->lte_opname));
|
||||
wmc_result_add_string (r, WMC_CMD_STATUS_ITEM_OPNAME, tmp);
|
||||
wmc_result_add_string (r, WMC_CMD_NETWORK_INFO_ITEM_OPNAME, tmp);
|
||||
} else if (sanitize_dbm (rsp2->hdr_dbm) || sanitize_dbm (rsp2->cdma1x_dbm)) {
|
||||
/* CDMA2000 operator name */
|
||||
wmc_assert (sizeof (rsp2->cdma_opname) <= sizeof (tmp));
|
||||
memcpy (tmp, rsp2->cdma_opname, sizeof (rsp2->cdma_opname));
|
||||
wmc_result_add_string (r, WMC_CMD_STATUS_ITEM_OPNAME, tmp);
|
||||
wmc_result_add_string (r, WMC_CMD_NETWORK_INFO_ITEM_OPNAME, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -47,14 +47,14 @@ WmcResult * wmc_cmd_device_info_result (const char *buf, size_t len);
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
#define WMC_CMD_STATUS_ITEM_CDMA_DBM "cdma-dbm"
|
||||
#define WMC_CMD_STATUS_ITEM_HDR_DBM "hdr-dbm"
|
||||
#define WMC_CMD_STATUS_ITEM_LTE_DBM "lte-dbm"
|
||||
#define WMC_CMD_STATUS_ITEM_OPNAME "opname"
|
||||
#define WMC_CMD_NETWORK_INFO_ITEM_CDMA_DBM "cdma-dbm"
|
||||
#define WMC_CMD_NETWORK_INFO_ITEM_HDR_DBM "hdr-dbm"
|
||||
#define WMC_CMD_NETWORK_INFO_ITEM_LTE_DBM "lte-dbm"
|
||||
#define WMC_CMD_NETWORK_INFO_ITEM_OPNAME "opname"
|
||||
|
||||
size_t wmc_cmd_status_new (char *buf, size_t buflen);
|
||||
size_t wmc_cmd_network_info_new (char *buf, size_t buflen);
|
||||
|
||||
WmcResult * wmc_cmd_status_result (const char *buf, size_t len);
|
||||
WmcResult * wmc_cmd_network_info_result (const char *buf, size_t len);
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
|
@@ -23,7 +23,7 @@
|
||||
enum {
|
||||
WMC_CMD_DEVICE_INFO = 0x06,
|
||||
WMC_CMD_IP_INFO = 0x0A,
|
||||
WMC_CMD_STATUS = 0x0B,
|
||||
WMC_CMD_NET_INFO = 0x0B,
|
||||
WMC_CMD_INIT = 0x0D,
|
||||
WMC_CMD_EPS_BEARER_INFO = 0x4D,
|
||||
};
|
||||
@@ -94,7 +94,7 @@ struct WmcCmdDeviceInfo2Rsp {
|
||||
typedef struct WmcCmdDeviceInfo2Rsp WmcCmdDeviceInfo2Rsp;
|
||||
|
||||
/* Shorter response used by earlier devices like PC5740 */
|
||||
struct WmcCmdStatusRsp {
|
||||
struct WmcCmdNetworkInfoRsp {
|
||||
WmcCmdHeader hdr;
|
||||
u_int8_t _unknown1;
|
||||
u_int8_t _unknown2[3]; /* Always zero */
|
||||
@@ -108,10 +108,10 @@ struct WmcCmdStatusRsp {
|
||||
u_int8_t cdma1x_dbm;
|
||||
u_int8_t _unknown8[37]; /* Always zero */
|
||||
} __attribute__ ((packed));
|
||||
typedef struct WmcCmdStatusRsp WmcCmdStatusRsp;
|
||||
typedef struct WmcCmdNetworkInfoRsp WmcCmdNetworkInfoRsp;
|
||||
|
||||
/* Long-format response used on newer devices like the UML290 */
|
||||
struct WmcCmdStatus2Rsp {
|
||||
struct WmcCmdNetworkInfo2Rsp {
|
||||
WmcCmdHeader hdr;
|
||||
u_int8_t _unknown1; /* 0x00 on LTE, 0x07 or 0x1F on CDMA */
|
||||
u_int8_t _unknown2[3]; /* Always zero */
|
||||
@@ -137,9 +137,9 @@ struct WmcCmdStatus2Rsp {
|
||||
u_int8_t _unknown14[3]; /* Always zero */
|
||||
u_int8_t _unknown15[4];
|
||||
} __attribute__ ((packed));
|
||||
typedef struct WmcCmdStatus2Rsp WmcCmdStatus2Rsp;
|
||||
typedef struct WmcCmdNetworkInfo2Rsp WmcCmdNetworkInfo2Rsp;
|
||||
|
||||
struct WmcCmdIpInfoRsp {
|
||||
struct WmcCmdConnectionInfoRsp {
|
||||
WmcCmdHeader hdr;
|
||||
u_int32_t rx_bytes;
|
||||
u_int32_t tx_bytes;
|
||||
@@ -150,6 +150,6 @@ struct WmcCmdIpInfoRsp {
|
||||
u_int8_t _unknown6[8]; /* Netmask? */
|
||||
u_int8_t ip6_address[40]; /* String format */
|
||||
} __attribute__ ((packed));
|
||||
typedef struct WmcCmdIpInfoRsp WmcCmdIpInfoRsp;
|
||||
typedef struct WmcCmdConnectionInfoRsp WmcCmdConnectionInfoRsp;
|
||||
|
||||
#endif /* LIBWMC_PROTOCOL_H */
|
||||
|
@@ -326,7 +326,7 @@ test_com_status (void *f, void *data)
|
||||
WmcResult *result;
|
||||
size_t reply_len;
|
||||
|
||||
len = wmc_cmd_status_new (buf, sizeof (buf));
|
||||
len = wmc_cmd_network_info_new (buf, sizeof (buf));
|
||||
g_assert (len == 2);
|
||||
|
||||
/* Send the command */
|
||||
@@ -337,25 +337,25 @@ test_com_status (void *f, void *data)
|
||||
reply_len = wait_reply (d, buf, sizeof (buf));
|
||||
|
||||
/* Parse the response into a result structure */
|
||||
result = wmc_cmd_status_result (buf, reply_len);
|
||||
result = wmc_cmd_network_info_result (buf, reply_len);
|
||||
g_assert (result);
|
||||
|
||||
g_print ("\n");
|
||||
|
||||
dbm = 0;
|
||||
wmc_result_get_u8 (result, WMC_CMD_STATUS_ITEM_CDMA_DBM, &dbm);
|
||||
wmc_result_get_u8 (result, WMC_CMD_NETWORK_INFO_ITEM_CDMA_DBM, &dbm);
|
||||
g_message ("%s: CDMA 1x dBm: %d", __func__, dbm);
|
||||
|
||||
dbm = 0;
|
||||
wmc_result_get_u8 (result, WMC_CMD_STATUS_ITEM_HDR_DBM, &dbm);
|
||||
wmc_result_get_u8 (result, WMC_CMD_NETWORK_INFO_ITEM_HDR_DBM, &dbm);
|
||||
g_message ("%s: HDR dBm: %d", __func__, dbm);
|
||||
|
||||
dbm = 0;
|
||||
wmc_result_get_u8 (result, WMC_CMD_STATUS_ITEM_LTE_DBM, &dbm);
|
||||
wmc_result_get_u8 (result, WMC_CMD_NETWORK_INFO_ITEM_LTE_DBM, &dbm);
|
||||
g_message ("%s: LTE dBm: %d", __func__, dbm);
|
||||
|
||||
str = NULL;
|
||||
wmc_result_get_string (result, WMC_CMD_STATUS_ITEM_OPNAME, &str);
|
||||
wmc_result_get_string (result, WMC_CMD_NETWORK_INFO_ITEM_OPNAME, &str);
|
||||
g_message ("%s: Operator Name: %s", __func__, str ? str : "(none)");
|
||||
|
||||
wmc_result_unref (result);
|
||||
|
Reference in New Issue
Block a user