mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-14 12:05:03 +00:00
wimax: add Center Frequency, RSSI, CINR, TX Power, and BSID properties
Useful diagnostic/support info when device is connected.
This commit is contained in:
parent
263c05118b
commit
9d24269e30
|
@ -20,6 +20,46 @@
|
|||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
<property name="CenterFrequency" type="u" access="read">
|
||||
<tp:docstring>
|
||||
Center frequency (in KHz) of the radio channel the device is using to
|
||||
communicate with the network when connected. Has no meaning when the
|
||||
device is not connected.
|
||||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
<property name="Rssi" type="i" access="read">
|
||||
<tp:docstring>
|
||||
RSSI of the current radio link in dBm. This value indicates how strong
|
||||
the raw received RF signal from the base station is, but does not
|
||||
indicate the overall quality of the radio link. Has no meaning when the
|
||||
device is not connected.
|
||||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
<property name="Cinr" type="i" access="read">
|
||||
<tp:docstring>
|
||||
CINR (Carrier to Interference + Noise Ratio) of the current radio link
|
||||
in dB. CINR is a more accurate measure of radio link quality. Has no
|
||||
meaning when the device is not connected.
|
||||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
<property name="TxPower" type="i" access="read">
|
||||
<tp:docstring>
|
||||
Average power of the last burst transmitted by the device, in units of
|
||||
0.5 dBm. i.e. a TxPower of -11 represents an actual device TX power of
|
||||
-5.5 dBm. Has no meaning when the device is not connected.
|
||||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
<property name="Bsid" type="s" access="read">
|
||||
<tp:docstring>
|
||||
The ID of the serving base station as received from the network. Has
|
||||
no meaning when the device is not connected.
|
||||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
<property name="ActiveNsp" type="o" access="read">
|
||||
<tp:docstring>
|
||||
Object path of the NSP currently used by the WiMax device.
|
||||
|
|
|
@ -167,10 +167,15 @@ global:
|
|||
nm_vpn_connection_get_type;
|
||||
nm_vpn_connection_get_vpn_state;
|
||||
nm_vpn_connection_new;
|
||||
nm_device_wimax_get_bsid;
|
||||
nm_device_wimax_get_center_frequency;
|
||||
nm_device_wimax_get_cinr;
|
||||
nm_device_wimax_get_hw_address;
|
||||
nm_device_wimax_get_active_nsp;
|
||||
nm_device_wimax_get_nsp_by_path;
|
||||
nm_device_wimax_get_nsps;
|
||||
nm_device_wimax_get_rssi;
|
||||
nm_device_wimax_get_tx_power;
|
||||
nm_device_wimax_get_type;
|
||||
nm_device_wimax_new;
|
||||
nm_wimax_nsp_get_name;
|
||||
|
|
|
@ -47,18 +47,34 @@ typedef struct {
|
|||
NMWimaxNsp *active_nsp;
|
||||
gboolean null_active_nsp;
|
||||
GPtrArray *nsps;
|
||||
|
||||
guint center_freq;
|
||||
gint rssi;
|
||||
gint cinr;
|
||||
gint tx_power;
|
||||
char *bsid;
|
||||
} NMDeviceWimaxPrivate;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_HW_ADDRESS,
|
||||
PROP_ACTIVE_NSP,
|
||||
PROP_CENTER_FREQ,
|
||||
PROP_RSSI,
|
||||
PROP_CINR,
|
||||
PROP_TX_POWER,
|
||||
PROP_BSID,
|
||||
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
#define DBUS_PROP_HW_ADDRESS "HwAddress"
|
||||
#define DBUS_PROP_ACTIVE_NSP "ActiveNsp"
|
||||
#define DBUS_PROP_HW_ADDRESS "HwAddress"
|
||||
#define DBUS_PROP_ACTIVE_NSP "ActiveNsp"
|
||||
#define DBUS_PROP_CENTER_FREQUENCY "CenterFrequency"
|
||||
#define DBUS_PROP_RSSI "Rssi"
|
||||
#define DBUS_PROP_CINR "Cinr"
|
||||
#define DBUS_PROP_TX_POWER "TxPower"
|
||||
#define DBUS_PROP_BSID "Bsid"
|
||||
|
||||
enum {
|
||||
NSP_ADDED,
|
||||
|
@ -321,6 +337,135 @@ clean_up_nsps (NMDeviceWimax *self, gboolean notify)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_wimax_get_center_frequency:
|
||||
* @device: a #NMDeviceWimax
|
||||
*
|
||||
* Gets the center frequency (in KHz) of the radio channel the device is using
|
||||
* to communicate with the network when connected. Has no meaning when the
|
||||
* device is not connected.
|
||||
*
|
||||
* Returns: the center frequency in KHz, or 0
|
||||
**/
|
||||
guint
|
||||
nm_device_wimax_get_center_frequency (NMDeviceWimax *wimax)
|
||||
{
|
||||
NMDeviceWimaxPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), 0);
|
||||
|
||||
priv = NM_DEVICE_WIMAX_GET_PRIVATE (wimax);
|
||||
if (!priv->center_freq) {
|
||||
priv->center_freq = _nm_object_get_uint_property (NM_OBJECT (wimax),
|
||||
NM_DBUS_INTERFACE_DEVICE_WIMAX,
|
||||
DBUS_PROP_CENTER_FREQUENCY);
|
||||
}
|
||||
return priv->center_freq;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_wimax_get_rssi:
|
||||
* @device: a #NMDeviceWimax
|
||||
*
|
||||
* Gets the RSSI of the current radio link in dBm. This value indicates how
|
||||
* strong the raw received RF signal from the base station is, but does not
|
||||
* indicate the overall quality of the radio link. Has no meaning when the
|
||||
* device is not connected.
|
||||
*
|
||||
* Returns: the RSSI in dBm, or 0
|
||||
**/
|
||||
gint
|
||||
nm_device_wimax_get_rssi (NMDeviceWimax *wimax)
|
||||
{
|
||||
NMDeviceWimaxPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), 0);
|
||||
|
||||
priv = NM_DEVICE_WIMAX_GET_PRIVATE (wimax);
|
||||
if (!priv->rssi) {
|
||||
priv->rssi = _nm_object_get_int_property (NM_OBJECT (wimax),
|
||||
NM_DBUS_INTERFACE_DEVICE_WIMAX,
|
||||
DBUS_PROP_RSSI);
|
||||
}
|
||||
return priv->rssi;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_wimax_get_cinr:
|
||||
* @device: a #NMDeviceWimax
|
||||
*
|
||||
* Gets the CINR (Carrier to Interference + Noise Ratio) of the current radio
|
||||
* link in dB. CINR is a more accurate measure of radio link quality. Has no
|
||||
* meaning when the device is not connected.
|
||||
*
|
||||
* Returns: the CINR in dB, or 0
|
||||
**/
|
||||
gint
|
||||
nm_device_wimax_get_cinr (NMDeviceWimax *wimax)
|
||||
{
|
||||
NMDeviceWimaxPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), 0);
|
||||
|
||||
priv = NM_DEVICE_WIMAX_GET_PRIVATE (wimax);
|
||||
if (!priv->cinr) {
|
||||
priv->cinr = _nm_object_get_int_property (NM_OBJECT (wimax),
|
||||
NM_DBUS_INTERFACE_DEVICE_WIMAX,
|
||||
DBUS_PROP_CINR);
|
||||
}
|
||||
return priv->cinr;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_wimax_get_tx_power:
|
||||
* @device: a #NMDeviceWimax
|
||||
*
|
||||
* Average power of the last burst transmitted by the device, in units of
|
||||
* 0.5 dBm. i.e. a TxPower of -11 represents an actual device TX power of
|
||||
* -5.5 dBm. Has no meaning when the device is not connected.
|
||||
*
|
||||
* Returns: the TX power in dBm, or 0
|
||||
**/
|
||||
gint
|
||||
nm_device_wimax_get_tx_power (NMDeviceWimax *wimax)
|
||||
{
|
||||
NMDeviceWimaxPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), 0);
|
||||
|
||||
priv = NM_DEVICE_WIMAX_GET_PRIVATE (wimax);
|
||||
if (!priv->tx_power) {
|
||||
priv->tx_power = _nm_object_get_int_property (NM_OBJECT (wimax),
|
||||
NM_DBUS_INTERFACE_DEVICE_WIMAX,
|
||||
DBUS_PROP_TX_POWER);
|
||||
}
|
||||
return priv->tx_power;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_wimax_get_bsid:
|
||||
* @device: a #NMDeviceWimax
|
||||
*
|
||||
* Gets the ID of the serving Base Station when the device is connected.
|
||||
*
|
||||
* Returns: the ID of the serving Base Station, or NULL
|
||||
**/
|
||||
const char *
|
||||
nm_device_wimax_get_bsid (NMDeviceWimax *wimax)
|
||||
{
|
||||
NMDeviceWimaxPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL);
|
||||
|
||||
priv = NM_DEVICE_WIMAX_GET_PRIVATE (wimax);
|
||||
if (!priv->bsid) {
|
||||
priv->bsid = _nm_object_get_string_property (NM_OBJECT (wimax),
|
||||
NM_DBUS_INTERFACE_DEVICE_WIMAX,
|
||||
DBUS_PROP_BSID);
|
||||
}
|
||||
return priv->bsid;
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
static void
|
||||
|
@ -343,19 +488,68 @@ get_property (GObject *object,
|
|||
case PROP_ACTIVE_NSP:
|
||||
g_value_set_object (value, nm_device_wimax_get_active_nsp (self));
|
||||
break;
|
||||
case PROP_CENTER_FREQ:
|
||||
g_value_set_uint (value, nm_device_wimax_get_center_frequency (self));
|
||||
break;
|
||||
case PROP_RSSI:
|
||||
g_value_set_int (value, nm_device_wimax_get_rssi (self));
|
||||
break;
|
||||
case PROP_CINR:
|
||||
g_value_set_int (value, nm_device_wimax_get_cinr (self));
|
||||
break;
|
||||
case PROP_TX_POWER:
|
||||
g_value_set_int (value, nm_device_wimax_get_tx_power (self));
|
||||
break;
|
||||
case PROP_BSID:
|
||||
g_value_set_string (value, nm_device_wimax_get_bsid (self));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clear_link_status (NMDeviceWimax *self)
|
||||
{
|
||||
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
|
||||
|
||||
if (priv->center_freq) {
|
||||
priv->center_freq = 0;
|
||||
_nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_CENTER_FREQUENCY);
|
||||
}
|
||||
|
||||
if (priv->rssi) {
|
||||
priv->rssi = 0;
|
||||
_nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_RSSI);
|
||||
}
|
||||
|
||||
if (priv->cinr) {
|
||||
priv->cinr = 0;
|
||||
_nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_CINR);
|
||||
}
|
||||
|
||||
if (priv->tx_power) {
|
||||
priv->tx_power = 0;
|
||||
_nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_TX_POWER);
|
||||
}
|
||||
|
||||
if (priv->bsid) {
|
||||
g_free (priv->bsid);
|
||||
priv->bsid = NULL;
|
||||
_nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_BSID);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
|
||||
{
|
||||
NMDeviceWimax *self = NM_DEVICE_WIMAX (device);
|
||||
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
|
||||
NMDeviceState state;
|
||||
|
||||
switch (nm_device_get_state (device)) {
|
||||
state = nm_device_get_state (device);
|
||||
switch (state) {
|
||||
case NM_DEVICE_STATE_UNKNOWN:
|
||||
case NM_DEVICE_STATE_UNMANAGED:
|
||||
case NM_DEVICE_STATE_UNAVAILABLE:
|
||||
|
@ -367,6 +561,13 @@ state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
|
|||
priv->null_active_nsp = FALSE;
|
||||
}
|
||||
_nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_WIMAX_ACTIVE_NSP);
|
||||
clear_link_status (self);
|
||||
break;
|
||||
case NM_DEVICE_STATE_PREPARE:
|
||||
case NM_DEVICE_STATE_CONFIG:
|
||||
case NM_DEVICE_STATE_NEED_AUTH:
|
||||
case NM_DEVICE_STATE_IP_CONFIG:
|
||||
clear_link_status (self);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -420,6 +621,11 @@ register_for_property_changed (NMDeviceWimax *wimax)
|
|||
const NMPropertiesChangedInfo property_changed_info[] = {
|
||||
{ NM_DEVICE_WIMAX_HW_ADDRESS, _nm_object_demarshal_generic, &priv->hw_address },
|
||||
{ NM_DEVICE_WIMAX_ACTIVE_NSP, demarshal_active_nsp, &priv->active_nsp },
|
||||
{ NM_DEVICE_WIMAX_CENTER_FREQUENCY, _nm_object_demarshal_generic, &priv->center_freq },
|
||||
{ NM_DEVICE_WIMAX_RSSI, _nm_object_demarshal_generic, &priv->rssi },
|
||||
{ NM_DEVICE_WIMAX_CINR, _nm_object_demarshal_generic, &priv->cinr },
|
||||
{ NM_DEVICE_WIMAX_TX_POWER, _nm_object_demarshal_generic, &priv->tx_power },
|
||||
{ NM_DEVICE_WIMAX_BSID, _nm_object_demarshal_generic, &priv->bsid },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
|
@ -485,23 +691,15 @@ dispose (GObject *object)
|
|||
|
||||
priv->disposed = TRUE;
|
||||
|
||||
g_free (priv->hw_address);
|
||||
g_free (priv->bsid);
|
||||
|
||||
clean_up_nsps (NM_DEVICE_WIMAX (object), FALSE);
|
||||
g_object_unref (priv->proxy);
|
||||
|
||||
G_OBJECT_CLASS (nm_device_wimax_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (object);
|
||||
|
||||
if (priv->hw_address)
|
||||
g_free (priv->hw_address);
|
||||
|
||||
G_OBJECT_CLASS (nm_device_wimax_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class)
|
||||
{
|
||||
|
@ -513,7 +711,6 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class)
|
|||
object_class->constructor = constructor;
|
||||
object_class->get_property = get_property;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
/* properties */
|
||||
|
||||
|
@ -543,6 +740,81 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class)
|
|||
NM_TYPE_WIMAX_NSP,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/**
|
||||
* NMDeviceWimax:center-frequency:
|
||||
*
|
||||
* The center frequency (in KHz) of the radio channel the device is using to
|
||||
* communicate with the network when connected. Has no meaning when the
|
||||
* device is not connected.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CENTER_FREQ,
|
||||
g_param_spec_uint (NM_DEVICE_WIMAX_CENTER_FREQUENCY,
|
||||
"Center frequency",
|
||||
"Center frequency",
|
||||
0, G_MAXUINT, 0,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/**
|
||||
* NMDeviceWimax:rssi:
|
||||
*
|
||||
* RSSI of the current radio link in dBm. This value indicates how strong
|
||||
* the raw received RF signal from the base station is, but does not
|
||||
* indicate the overall quality of the radio link. Has no meaning when the
|
||||
* device is not connected.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_RSSI,
|
||||
g_param_spec_int (NM_DEVICE_WIMAX_RSSI,
|
||||
"RSSI",
|
||||
"RSSI",
|
||||
G_MININT, G_MAXINT, 0,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/**
|
||||
* NMDeviceWimax:cinr:
|
||||
*
|
||||
* CINR (Carrier to Interference + Noise Ratio) of the current radio link
|
||||
* in dB. CINR is a more accurate measure of radio link quality. Has no
|
||||
* meaning when the device is not connected.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CINR,
|
||||
g_param_spec_int (NM_DEVICE_WIMAX_CINR,
|
||||
"CINR",
|
||||
"CINR",
|
||||
G_MININT, G_MAXINT, 0,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/**
|
||||
* NMDeviceWimax:tx-power:
|
||||
*
|
||||
* Average power of the last burst transmitted by the device, in units of
|
||||
* 0.5 dBm. i.e. a TxPower of -11 represents an actual device TX power of
|
||||
* -5.5 dBm. Has no meaning when the device is not connected.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_TX_POWER,
|
||||
g_param_spec_int (NM_DEVICE_WIMAX_TX_POWER,
|
||||
"TX Power",
|
||||
"TX Power",
|
||||
G_MININT, G_MAXINT, 0,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/**
|
||||
* NMDeviceWimax:bsid:
|
||||
*
|
||||
* The ID of the serving base station as received from the network. Has
|
||||
* no meaning when the device is not connected.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_BSID,
|
||||
g_param_spec_string (NM_DEVICE_WIMAX_BSID,
|
||||
"BSID",
|
||||
"BSID",
|
||||
NULL,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/* signals */
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,8 +36,13 @@ G_BEGIN_DECLS
|
|||
#define NM_IS_DEVICE_WIMAX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_DEVICE_WIMAX))
|
||||
#define NM_DEVICE_WIMAX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxClass))
|
||||
|
||||
#define NM_DEVICE_WIMAX_HW_ADDRESS "hw-address"
|
||||
#define NM_DEVICE_WIMAX_ACTIVE_NSP "active-nsp"
|
||||
#define NM_DEVICE_WIMAX_HW_ADDRESS "hw-address"
|
||||
#define NM_DEVICE_WIMAX_ACTIVE_NSP "active-nsp"
|
||||
#define NM_DEVICE_WIMAX_CENTER_FREQUENCY "center-frequency"
|
||||
#define NM_DEVICE_WIMAX_RSSI "rssi"
|
||||
#define NM_DEVICE_WIMAX_CINR "cinr"
|
||||
#define NM_DEVICE_WIMAX_TX_POWER "tx-power"
|
||||
#define NM_DEVICE_WIMAX_BSID "bsid"
|
||||
|
||||
typedef struct {
|
||||
NMDevice parent;
|
||||
|
@ -63,6 +68,12 @@ NMWimaxNsp *nm_device_wimax_get_nsp_by_path (NMDeviceWimax *wimax,
|
|||
|
||||
const GPtrArray *nm_device_wimax_get_nsps (NMDeviceWimax *wimax);
|
||||
|
||||
guint nm_device_wimax_get_center_frequency (NMDeviceWimax *self);
|
||||
gint nm_device_wimax_get_rssi (NMDeviceWimax *self);
|
||||
gint nm_device_wimax_get_cinr (NMDeviceWimax *self);
|
||||
gint nm_device_wimax_get_tx_power (NMDeviceWimax *self);
|
||||
const char * nm_device_wimax_get_bsid (NMDeviceWimax *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_DEVICE_WIMAX_H */
|
||||
|
|
|
@ -550,6 +550,42 @@ WIMAX_API_CONNECTED_NSP_INFO_EX *iwmx_sdk_get_connected_network(struct wmxsdk *w
|
|||
return nsp_info;
|
||||
}
|
||||
|
||||
/*
|
||||
* Asks the WiMAX API to report current link statistics.
|
||||
*
|
||||
* Returns NULL on error.
|
||||
*
|
||||
*/
|
||||
WIMAX_API_LINK_STATUS_INFO_EX *iwmx_sdk_get_link_status_info(struct wmxsdk *wmxsdk)
|
||||
{
|
||||
WIMAX_API_LINK_STATUS_INFO_EX *stats = NULL;
|
||||
WIMAX_API_RET r;
|
||||
char errstr[512];
|
||||
UINT32 errstr_size = sizeof(errstr);
|
||||
|
||||
/* Only report if connected */
|
||||
if (iwmxsdk_status_get(wmxsdk) < WIMAX_API_DEVICE_STATUS_Connecting) {
|
||||
nm_log_err(LOGD_WIMAX, "wmxsdk: cannot get link status info unless connected");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
stats = malloc(sizeof (*stats));
|
||||
if (!stats) {
|
||||
nm_log_err(LOGD_WIMAX, "wmxsdk: cannot allocate links status info");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
r = GetLinkStatusEx(&wmxsdk->device_id, stats);
|
||||
if (r != WIMAX_API_RET_SUCCESS) {
|
||||
GetErrorString(&wmxsdk->device_id, r, errstr, &errstr_size);
|
||||
nm_log_err(LOGD_WIMAX, "wmxsdk: Cannot get link status info: %d (%s)", r, errstr);
|
||||
free (stats);
|
||||
stats = NULL;
|
||||
}
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for a RF State command
|
||||
*
|
||||
|
|
|
@ -97,6 +97,7 @@ int iwmx_sdk_connect(struct wmxsdk *wmxsdk, const char *nsp_name);
|
|||
int iwmx_sdk_disconnect(struct wmxsdk *wmxsdk);
|
||||
int iwmx_sdk_set_fast_reconnect_enabled(struct wmxsdk *wmxsdk, int enabled);
|
||||
WIMAX_API_CONNECTED_NSP_INFO_EX *iwmx_sdk_get_connected_network(struct wmxsdk *wmxsdk);
|
||||
WIMAX_API_LINK_STATUS_INFO_EX *iwmx_sdk_get_link_status_info(struct wmxsdk *wmxsdk);
|
||||
const char *iwmx_sdk_dev_status_to_str(WIMAX_API_DEVICE_STATUS status);
|
||||
const char *iwmx_sdk_reason_to_str(WIMAX_API_STATUS_REASON reason);
|
||||
const char *iwmx_sdk_media_status_to_str(WIMAX_API_MEDIA_STATUS status);
|
||||
|
|
|
@ -56,6 +56,11 @@ enum {
|
|||
PROP_0,
|
||||
PROP_HW_ADDRESS,
|
||||
PROP_ACTIVE_NSP,
|
||||
PROP_CENTER_FREQ,
|
||||
PROP_RSSI,
|
||||
PROP_CINR,
|
||||
PROP_TX_POWER,
|
||||
PROP_BSID,
|
||||
|
||||
LAST_PROP
|
||||
};
|
||||
|
@ -93,6 +98,13 @@ typedef struct {
|
|||
|
||||
GSList *nsp_list;
|
||||
NMWimaxNsp *current_nsp;
|
||||
|
||||
/* interesting stuff when connected */
|
||||
guint center_freq;
|
||||
gint rssi;
|
||||
gint cinr;
|
||||
gint tx_power;
|
||||
char *bsid;
|
||||
} NMDeviceWimaxPrivate;
|
||||
|
||||
/***********************************************************/
|
||||
|
@ -153,6 +165,46 @@ nm_device_wimax_get_hw_address (NMDeviceWimax *self, struct ether_addr *addr)
|
|||
memcpy (addr, &(priv->hw_addr), sizeof (struct ether_addr));
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_device_wimax_get_center_frequency (NMDeviceWimax *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
|
||||
|
||||
return NM_DEVICE_WIMAX_GET_PRIVATE (self)->center_freq;
|
||||
}
|
||||
|
||||
gint
|
||||
nm_device_wimax_get_rssi (NMDeviceWimax *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
|
||||
|
||||
return NM_DEVICE_WIMAX_GET_PRIVATE (self)->rssi;
|
||||
}
|
||||
|
||||
gint
|
||||
nm_device_wimax_get_cinr (NMDeviceWimax *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
|
||||
|
||||
return NM_DEVICE_WIMAX_GET_PRIVATE (self)->cinr;
|
||||
}
|
||||
|
||||
gint
|
||||
nm_device_wimax_get_tx_power (NMDeviceWimax *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
|
||||
|
||||
return NM_DEVICE_WIMAX_GET_PRIVATE (self)->tx_power;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_device_wimax_get_bsid (NMDeviceWimax *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), NULL);
|
||||
|
||||
return NM_DEVICE_WIMAX_GET_PRIVATE (self)->bsid;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
impl_device_get_nsp_list (NMDeviceWimax *self, GPtrArray **nsps, GError **error)
|
||||
{
|
||||
|
@ -945,14 +997,92 @@ wmx_removed_cb (struct wmxsdk *wmxsdk, void *user_data)
|
|||
|
||||
/*************************************************************************/
|
||||
|
||||
static inline gint
|
||||
sdk_rssi_to_dbm (guint raw_rssi)
|
||||
{
|
||||
/* Values range from 0x00 to 0x53, where -123dBm is encoded as 0x00 and
|
||||
* -40dBm encoded as 0x53 in 1dB increments.
|
||||
*/
|
||||
return raw_rssi - 123;
|
||||
}
|
||||
|
||||
static inline gint
|
||||
sdk_cinr_to_db (guint raw_cinr)
|
||||
{
|
||||
/* Values range from 0x00 to 0x3F, where -10dB is encoded as 0x00 and
|
||||
* 53dB encoded as 0x3F in 1dB increments.
|
||||
*/
|
||||
return raw_cinr - 10;
|
||||
}
|
||||
|
||||
static inline gint
|
||||
sdk_tx_pow_to_dbm (guint raw_tx_pow)
|
||||
{
|
||||
/* Values range from 0x00 to 0xFF, where -84dBm is encoded as 0x00 and
|
||||
* 43.5dBm is encoded as 0xFF in 0.5dB increments. Normalize so that
|
||||
* 0 dBm == 0.
|
||||
*/
|
||||
return (int) (((double) raw_tx_pow / 2.0) - 84) * 2;
|
||||
}
|
||||
|
||||
static void
|
||||
set_link_status (NMDeviceWimax *self, WIMAX_API_LINK_STATUS_INFO_EX *link_status)
|
||||
{
|
||||
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
|
||||
guint center_freq = 0;
|
||||
gint conv_rssi = 0, conv_cinr = 0, conv_tx_pow = 0;
|
||||
char *new_bsid = NULL;
|
||||
|
||||
if (link_status) {
|
||||
center_freq = link_status->centerFrequency;
|
||||
conv_rssi = sdk_rssi_to_dbm (link_status->RSSI);
|
||||
conv_cinr = sdk_cinr_to_db (link_status->CINR);
|
||||
conv_tx_pow = sdk_tx_pow_to_dbm (link_status->txPWR);
|
||||
new_bsid = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
link_status->bsId[0], link_status->bsId[1],
|
||||
link_status->bsId[2], link_status->bsId[3],
|
||||
link_status->bsId[4], link_status->bsId[5]);
|
||||
}
|
||||
|
||||
if (priv->center_freq != center_freq) {
|
||||
priv->center_freq = center_freq;
|
||||
g_object_notify (G_OBJECT (self), NM_DEVICE_WIMAX_CENTER_FREQUENCY);
|
||||
}
|
||||
|
||||
if (priv->rssi != conv_rssi) {
|
||||
priv->rssi = conv_rssi;
|
||||
g_object_notify (G_OBJECT (self), NM_DEVICE_WIMAX_RSSI);
|
||||
}
|
||||
|
||||
if (priv->cinr != conv_cinr) {
|
||||
priv->cinr = conv_cinr;
|
||||
g_object_notify (G_OBJECT (self), NM_DEVICE_WIMAX_CINR);
|
||||
}
|
||||
|
||||
if (priv->tx_power != conv_tx_pow) {
|
||||
priv->tx_power = conv_tx_pow;
|
||||
g_object_notify (G_OBJECT (self), NM_DEVICE_WIMAX_TX_POWER);
|
||||
}
|
||||
|
||||
if (g_strcmp0 (priv->bsid, new_bsid) != 0) {
|
||||
g_free (priv->bsid);
|
||||
priv->bsid = new_bsid;
|
||||
g_object_notify (G_OBJECT (self), NM_DEVICE_WIMAX_BSID);
|
||||
} else
|
||||
g_free (new_bsid);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
connected_poll_cb (gpointer user_data)
|
||||
{
|
||||
NMDeviceWimax *self = NM_DEVICE_WIMAX (user_data);
|
||||
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
|
||||
WIMAX_API_CONNECTED_NSP_INFO_EX *sdk_nsp;
|
||||
WIMAX_API_LINK_STATUS_INFO_EX *link_status;
|
||||
|
||||
g_return_val_if_fail (priv->sdk != NULL, FALSE);
|
||||
|
||||
/* Get details of the connected NSP */
|
||||
sdk_nsp = iwmx_sdk_get_connected_network (priv->sdk);
|
||||
if (sdk_nsp) {
|
||||
const char *nsp_name = (const char *) sdk_nsp->NSPName;
|
||||
|
@ -978,6 +1108,13 @@ connected_poll_cb (gpointer user_data)
|
|||
free (sdk_nsp);
|
||||
}
|
||||
|
||||
/* Get details of the current radio link */
|
||||
link_status = iwmx_sdk_get_link_status_info (priv->sdk);
|
||||
if (link_status) {
|
||||
set_link_status (self, link_status);
|
||||
free (link_status);
|
||||
}
|
||||
|
||||
return TRUE; /* reschedule */
|
||||
}
|
||||
|
||||
|
@ -1008,9 +1145,11 @@ device_state_changed (NMDevice *device,
|
|||
/* poll link quality and BSID */
|
||||
clear_connected_poll (self);
|
||||
priv->poll_id = g_timeout_add_seconds (10, connected_poll_cb, self);
|
||||
connected_poll_cb (self);
|
||||
} else {
|
||||
clear_link_timeout (self);
|
||||
clear_connected_poll (self);
|
||||
set_link_status (self, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1133,6 +1272,21 @@ get_property (GObject *object, guint prop_id,
|
|||
else
|
||||
g_value_set_boxed (value, "/");
|
||||
break;
|
||||
case PROP_CENTER_FREQ:
|
||||
g_value_set_uint (value, priv->center_freq);
|
||||
break;
|
||||
case PROP_RSSI:
|
||||
g_value_set_int (value, priv->rssi);
|
||||
break;
|
||||
case PROP_CINR:
|
||||
g_value_set_int (value, priv->cinr);
|
||||
break;
|
||||
case PROP_TX_POWER:
|
||||
g_value_set_int (value, priv->tx_power);
|
||||
break;
|
||||
case PROP_BSID:
|
||||
g_value_set_string (value, priv->bsid);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -1162,6 +1316,8 @@ dispose (GObject *object)
|
|||
wmxsdk_unref (priv->sdk);
|
||||
}
|
||||
|
||||
g_free (priv->bsid);
|
||||
|
||||
set_current_nsp (self, NULL);
|
||||
|
||||
g_slist_foreach (priv->nsp_list, (GFunc) g_object_unref, NULL);
|
||||
|
@ -1216,6 +1372,46 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *klass)
|
|||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CENTER_FREQ,
|
||||
g_param_spec_uint (NM_DEVICE_WIMAX_CENTER_FREQUENCY,
|
||||
"Center frequency",
|
||||
"Center frequency",
|
||||
0, G_MAXUINT, 0,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_RSSI,
|
||||
g_param_spec_int (NM_DEVICE_WIMAX_RSSI,
|
||||
"RSSI",
|
||||
"RSSI",
|
||||
G_MININT, G_MAXINT, 0,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CINR,
|
||||
g_param_spec_int (NM_DEVICE_WIMAX_CINR,
|
||||
"CINR",
|
||||
"CINR",
|
||||
G_MININT, G_MAXINT, 0,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_TX_POWER,
|
||||
g_param_spec_int (NM_DEVICE_WIMAX_TX_POWER,
|
||||
"TX Power",
|
||||
"TX Power",
|
||||
G_MININT, G_MAXINT, 0,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_BSID,
|
||||
g_param_spec_string (NM_DEVICE_WIMAX_BSID,
|
||||
"BSID",
|
||||
"BSID",
|
||||
NULL,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/* Signals */
|
||||
signals[NSP_ADDED] =
|
||||
g_signal_new ("nsp-added",
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2010 Red Hat, Inc.
|
||||
* Copyright (C) 2010 - 2011 Red Hat, Inc.
|
||||
* Copyright (C) 2009 Novell, Inc.
|
||||
*/
|
||||
|
||||
|
@ -35,8 +35,13 @@ G_BEGIN_DECLS
|
|||
#define NM_IS_DEVICE_WIMAX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_WIMAX))
|
||||
#define NM_DEVICE_WIMAX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxClass))
|
||||
|
||||
#define NM_DEVICE_WIMAX_HW_ADDRESS "hw-address"
|
||||
#define NM_DEVICE_WIMAX_ACTIVE_NSP "active-nsp"
|
||||
#define NM_DEVICE_WIMAX_HW_ADDRESS "hw-address"
|
||||
#define NM_DEVICE_WIMAX_ACTIVE_NSP "active-nsp"
|
||||
#define NM_DEVICE_WIMAX_CENTER_FREQUENCY "center-frequency"
|
||||
#define NM_DEVICE_WIMAX_RSSI "rssi"
|
||||
#define NM_DEVICE_WIMAX_CINR "cinr"
|
||||
#define NM_DEVICE_WIMAX_TX_POWER "tx-power"
|
||||
#define NM_DEVICE_WIMAX_BSID "bsid"
|
||||
|
||||
typedef struct {
|
||||
NMDevice parent;
|
||||
|
@ -62,6 +67,16 @@ void nm_device_wimax_get_hw_address (NMDeviceWimax *self,
|
|||
|
||||
NMWimaxNsp *nm_device_wimax_get_active_nsp (NMDeviceWimax *self);
|
||||
|
||||
guint nm_device_wimax_get_center_frequency (NMDeviceWimax *self);
|
||||
|
||||
gint nm_device_wimax_get_rssi (NMDeviceWimax *self);
|
||||
|
||||
gint nm_device_wimax_get_cinr (NMDeviceWimax *self);
|
||||
|
||||
gint nm_device_wimax_get_tx_power (NMDeviceWimax *self);
|
||||
|
||||
const char *nm_device_wimax_get_bsid (NMDeviceWimax *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_DEVICE_WIMAX_H */
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* nm-tool - information tool for NetworkManager
|
||||
*
|
||||
* Dan Williams <dcbw@redhat.com>
|
||||
|
@ -16,10 +17,11 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* (C) Copyright 2005 - 2010 Red Hat, Inc.
|
||||
* (C) Copyright 2005 - 2011 Red Hat, Inc.
|
||||
* (C) Copyright 2007 Novell, Inc.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glib.h>
|
||||
#include <dbus/dbus.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
@ -473,13 +475,58 @@ detail_device (gpointer data, gpointer user_data)
|
|||
print_string (" Carrier", "off");
|
||||
#if WITH_WIMAX
|
||||
} else if (NM_IS_DEVICE_WIMAX (device)) {
|
||||
NMDeviceWimax *wimax = NM_DEVICE_WIMAX (device);
|
||||
NMWimaxNsp *active_nsp = NULL;
|
||||
const char *active_name = NULL;
|
||||
const GPtrArray *nsps;
|
||||
|
||||
if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) {
|
||||
active_nsp = nm_device_wimax_get_active_nsp (NM_DEVICE_WIMAX (device));
|
||||
guint tmp_uint;
|
||||
gint tmp_int;
|
||||
const char *tmp_str;
|
||||
|
||||
active_nsp = nm_device_wimax_get_active_nsp (wimax);
|
||||
active_name = active_nsp ? nm_wimax_nsp_get_name (active_nsp) : NULL;
|
||||
|
||||
printf ("\n Link Status\n");
|
||||
|
||||
tmp_uint = nm_device_wimax_get_center_frequency (wimax);
|
||||
if (tmp_uint)
|
||||
tmp = g_strdup_printf ("%'.1f MHz", (double) tmp_uint / 1000.0);
|
||||
else
|
||||
tmp = g_strdup ("(unknown)");
|
||||
print_string (" Center Freq.", tmp);
|
||||
g_free (tmp);
|
||||
|
||||
tmp_int = nm_device_wimax_get_rssi (wimax);
|
||||
if (tmp_int)
|
||||
tmp = g_strdup_printf ("%d dBm", tmp_int);
|
||||
else
|
||||
tmp = g_strdup ("(unknown)");
|
||||
print_string (" RSSI", tmp);
|
||||
g_free (tmp);
|
||||
|
||||
tmp_int = nm_device_wimax_get_cinr (wimax);
|
||||
if (tmp_int)
|
||||
tmp = g_strdup_printf ("%d dB", tmp_int);
|
||||
else
|
||||
tmp = g_strdup ("(unknown)");
|
||||
print_string (" CINR", tmp);
|
||||
g_free (tmp);
|
||||
|
||||
tmp_int = nm_device_wimax_get_tx_power (wimax);
|
||||
if (tmp_int)
|
||||
tmp = g_strdup_printf ("%'.2f dBm", (float) tmp_int / 2.0);
|
||||
else
|
||||
tmp = g_strdup ("(unknown)");
|
||||
print_string (" TX Power", tmp);
|
||||
g_free (tmp);
|
||||
|
||||
tmp_str = nm_device_wimax_get_bsid (wimax);
|
||||
if (tmp_str)
|
||||
print_string (" BSID", tmp_str);
|
||||
else
|
||||
print_string (" BSID", "(unknown)");
|
||||
}
|
||||
|
||||
printf ("\n WiMAX NSPs %s\n", active_nsp ? "(* current NSP)" : "");
|
||||
|
|
Loading…
Reference in a new issue