Using wpa_supplicant via dbus in python - error

Dan Williams dcbw at redhat.com
Mon Aug 18 16:13:00 EDT 2008


On Thu, 2008-08-14 at 14:26 -0400, Dan Williams wrote:
> On Thu, 2008-08-14 at 06:53 -0700, James Rayner wrote:
> > Hi
> > 
> > I'm writing a client using python and the dbus interface. Having
> > looked at the example and the wpa_supplicant code, I've got as far as
> > being able to scan, add/remove networks and interfaces. However when I
> > try to set anything for a new network, it complains at the .set():
> > 
> > dbus.exceptions.DBusException:
> > fi.epitest.hostap.WPASupplicant.InvalidOptions: Did not receive
> > correct message arguments.
> > 
> > As suggested to someone else on the list, passing as a dbus Byte array
> > didn't help.
> > 
> > The code is here: http://pastebin.com/f122abeb8
> 
> You do need to pass a d-bus byte array, since SSIDs can contain embedded
> NULLs and are not necessarily UTF-8.  I think you can just cast the SSID
> value to a dbus.ByteArray() when setting the dictionary member.

So the SSID value does need to be cased to a ByteArray(), but you also
need to specify the signature of the dict too, since the current
supplicant dbus interface doesn't support introspection.

opts = dbus.Dictionary({"ssid": dbus.ByteArray('rayner')}, signature="sv")
rnet.set(opts)

Element values are packed into "variants" because at the time I did the
supplicant dbus bits, python's dbus bindings always sent dictionaries as
"a{sv}" which allows easy handling of dict elements in any language.
The python dbus bindings got a lot of love recently and this has
apparently changed; now you get to send the signature too.

Dan




More information about the HostAP mailing list