X-Git-Url: http://git.maemo.org/git/?p=pyiw;a=blobdiff_plain;f=pyiw.c;h=59f22eb330241942f8bd6371014be57ca30690ca;hp=8a78c0f6d56cf3c3841db57afb4d4fc1fab34bf1;hb=2f8395239085654f6d1ba75e180b3180f32ae091;hpb=9f9f6e4593b75e314882c26040b89718d0d9b320 diff --git a/pyiw.c b/pyiw.c index 8a78c0f..59f22eb 100644 --- a/pyiw.c +++ b/pyiw.c @@ -44,12 +44,15 @@ typedef enum { PYIW_KE_PROTOCOL, PYIW_KE_QUALITY, PYIW_KE_BITRATE, - PYIW_KE_AP_MAC + PYIW_KE_AP_MAC, + PYIW_KE_LEVEL, + PYIW_KE_NOISE, + PYIW_KE_TXPOWER } WirelessInterfaceKeyEnum; typedef struct { - WirelessInterfaceKeyEnum keys[2]; - PyObject* objs[2]; + WirelessInterfaceKeyEnum keys[3]; + PyObject* objs[3]; int num; } WirelessInterfaceScanData; @@ -63,7 +66,10 @@ static char* WirelessInterfaceKeys[] = { "protocol", "quality", "bitrate", - "ap_mac" + "ap_mac", + "level", + "noise", + "txpower" }; int WirelessInterfaceNumKeys(void) { @@ -119,6 +125,9 @@ static char* PYIW_DOC_STRING = "- frequency [double]: The GHz freq level.\n" "- protocol [string]: The name representing A, B, or G WiFi.\n" "- quality [int ]: Signal quality, 1-100%.\n" + "- level [int ]: Signal level (dBm).\n" + "- noise [int ]: Noise level (dBm).\n" + "- txpower [int ]: Transmit power (dBm).\n" "- bitrate [int ]: Number of BPS; 1:1 ratio.\n" "- ap_mac [string]: The address of the current AP.\n\n" "--- EXAMPLE USAGE --------------------------------------\n\n" @@ -344,11 +353,26 @@ static PyObject* WirelessInterface_mapget(PyObject* self, PyObject* arg) { "i", wi->info.bitrate.value ); + /* TXPOWER */ + else if(!strncmp(key, "txpower", 7)) return Py_BuildValue( + "i", wi->info.txpower.value + ); + /* QUALITY */ else if(!strncmp(key, "quality", 7)) return Py_BuildValue( "i", wi->info.stats.qual.qual ); + /* LEVEL */ + else if(!strncmp(key, "level", 5)) return Py_BuildValue( + "i", wi->info.stats.qual.level - 0x100 + ); + + /* NOISE */ + else if(!strncmp(key, "noise", 5)) return Py_BuildValue( + "i", wi->info.stats.qual.noise - 0x100 + ); + /* AP_MAC */ else if(!strncmp(key, "ap_mac", 6)) { /* iw_pr_ether(buf, wi->info.ap_addr.sa_data); */ @@ -726,10 +750,22 @@ static int WirelessInterface_ScanItem(iwevent* event, iwrange* range, wifacesd* return 0; } + case SIOCGIWTXPOW: { + data->keys[0] = PYIW_KE_TXPOWER; + data->objs[0] = Py_BuildValue("i", event->u.txpower.value); + data->num = 1; + + return 0; + } + case IWEVQUAL: { data->keys[0] = PYIW_KE_QUALITY; + data->keys[1] = PYIW_KE_LEVEL; + data->keys[2] = PYIW_KE_NOISE; data->objs[0] = Py_BuildValue("i", event->u.qual.qual); - data->num = 1; + data->objs[1] = Py_BuildValue("i", event->u.qual.level - 0x100); + data->objs[2] = Py_BuildValue("i", event->u.qual.noise - 0x100); + data->num = 3; return 0; }