wlancond and dbus

wlancond and dbus

Gabriel Grise

2007-09-26 21:41 UTC
Hi,

Because i saw some questions about how to access to wlancond with dbus
And because I had the same question last week, i decided to send to this
list a code sample. This code sample simulate an "iwlist scan" call.

I hope this will be useful for someone.

Gabriel Grise

from dbus.glib import *
import gobject
import dbus
import array

loop=None
#function to handle response from wlancond
def scan_results(*args):
#first parameter is the number of Cell
#each cell have an essid, bssid, rssi, channel, capabilities bytes.
for i in range(0, args[0]):
pos = 1+(i*5)
(essid, bssid, rssi, channel, capbits) = args[pos:pos+5]

print """
Cell %d - Address: %s
ESSID: %s
Channel: %d
Signal Level: %d
""" % (i, "%02X:%02X:%02X:%02X:%02X:%02X" % (bssid[0],bssid[1],bssid[2],bssid[3],bssid[4],bssid[5]),
array.array("b", essid).tostring(), channel, rssi)
loop.quit()

if __name__ == "__main__":

#mandatory to receive dbus signal
loop=gobject.MainLoop();

bus = dbus.SystemBus()



#get wlancond object
wlancond = bus.get_object('com.nokia.wlancond', '/com/nokia/wlancond/request');
#request interface
request = dbus.Interface(wlancond, 'com.nokia.wlancond.request')

#you will receive the scan reply through a signal
bus.add_signal_receiver(scan_results, dbus_interface="com.nokia.wlancond.signal", signal_name="scan_results");

#send a request to wlancond
#the first parameter seem to be the power level, WLANCOND_TX_POWER10 or WLANCOND_TX_POWER100
#but i have no idea of what value have these two constants, so i found one of them with a strace.

#the second parameter is an ESSID, it's a bytes array
request.scan(dbus.Int32(8), dbus.Array([], signature="y"))

#you need to wait for the signal.
loop.run()
  •  Reply

Re: wlancond and dbus

Nicolas DERIJCKE
Karma: 28
2008-11-06 11:30 UTC
Hi!

Your Python code sample does not work anymore on OS2008. When calling the
scan method Python complains about a wrong dbus signature being passed
(iay).

I haven't found a way to discover the signature using dbus-send. Any idea on
how to do this?

Best regards,

Nicolas.



On Wed, Sep 26, 2007 at 10:41 PM, Gabriel Grise <ggrise@mit.edu> wrote:

> Hi,
>
> Because i saw some questions about how to access to wlancond with dbus
> And because I had the same question last week, i decided to send to this
> list a code sample. This code sample simulate an "iwlist scan" call.
>
> I hope this will be useful for someone.
>
> Gabriel Grise
>
>
>
  •  Reply