sequence of associating to a new WAP using PHP and DBus

don don at waldohealth.com
Wed Jul 7 18:30:44 EDT 2010


It's working, thanks to a little insight from Derick Rethans, the writer
of both php DBus extension and Xdebug. Here's the code so the example is on
the Net.

The assumption at this point is that the networks are predefined from
wpa_supplicant.conf. Next step is to add networks on the fly, which I have
not had success with yet. The $wap parameter is a string representing the
network object, such as: 

              /fi/epitest/hostap/WPASupplicant/Interfaces/0/Networks/0

One note for users of the PHP dbus-0.1.0 extension. Although convention
spells DBus with a capital B, and Derick's slide deck on the net shows
that, the source code has the objects defined with a small 'b' as shown
here.

function doSelectWap($wap) {

        // Connect to DBus SYSTEM bus
    $d = new Dbus(Dbus::BUS_SYSTEM, true);

        // Fetch the Supplicant Daemon
    $supplicant = $d->createProxy( 
                          "fi.epitest.hostap.WPASupplicant", 
                          "/fi/epitest/hostap/WPASupplicant", 
                          "fi.epitest.hostap.WPASupplicant" 
                                 );

        // Get the Supplicant's interface object path for our wireless 
    $path = $supplicant->getInterface("wlan0");

        // Create a proxy to the interface API
    $if = $d->createProxy( 
                          "fi.epitest.hostap.WPASupplicant",
                          $path->getData(),
                          "fi.epitest.hostap.WPASupplicant.Interface" 
                         );

        // Create a path object for the WAP we want to connect to

        // Choose our WAP and disable all others
    $if->selectNetwork(new DbusObjectPath($wap));
}  // end doSelectWap()


On Tue, 06 Jul 2010 12:59:20 -0500, don <don at waldohealth.com> wrote:
> I found an old python example from 2/17/2009 hostap archives, but it
does
> not seem to select. 
> 
> I have three networks defined in my conf file, and wpa_cli shows them
> properly loading and associating. I'm faking the three network strings
as
> follows:
> <code>
>         $name = trim($_POST[name], "'");
>         $p0 =
"/fi/epitest/hostap/WPASupplicant/Interfaces/0/Networks/0";
>         $p1 =
"/fi/epitest/hostap/WPASupplicant/Interfaces/0/Networks/1";
>         $p2 =
"/fi/epitest/hostap/WPASupplicant/Interfaces/0/Networks/2";
>         if ($name == "WaldoDemo") {
>             $psel = $p0;
>         } else if ($name == "Shepherd") {
>             $psel = $p1;
>         } else {
>             $psel = $p2;
>         } 
>         $d = new Dbus(Dbus::BUS_SYSTEM, true);
>         $supplicant = $d->createProxy(
"fi.epitest.hostap.WPASupplicant", 
>                                       
"/fi/epitest/hostap/WPASupplicant",
> 
>                                        "fi.epitest.hostap.WPASupplicant"
> );
>         $path = $supplicant->getInterface("wlan0");
>         $if = $d->createProxy( "fi.epitest.hostap.WPASupplicant",
>                                $path->getData(),
>                               
"fi.epitest.hostap.WPASupplicant.Interface"
> );
>         $rnet = $d->createProxy( "fi.epitest.hostap.WPASupplicant",
>                                "$psel",
>                                "fi.epitest.hostap.WPASupplicant.Network"
> );
>         $if->selectNetwork($rnet);
> </code>
> ... but this still does not work. It triggers a re-associate, but it
does
> not select my choice.
> 
> The python example did an addNetwork() and took its return as the path
> that was inserted into the $rnet proxy, but if I just fake the strings
that
> should work too, should it not? What am I missing?

-- 
Don Wilde
Waldo Health, Inc.
http://www.waldohealth.com
o: +11 512-219-0302
c: +11 512-749-6447


More information about the HostAP mailing list