sequence of associating to a new WAP using PHP and DBus

don don at waldohealth.com
Mon Jul 5 13:48:46 EDT 2010


On Mon, 5 Jul 2010 10:01:21 +0200, Holger Schurig
[snip]
> 
> Did you try this:
> 
> a) run wpa_supplicant with a .conf file
> b) use wpa_cli to display the network blocks
> c) now use you DBUS code to make the changes you want
> d) again use wpa_cli to display the network blocks again
>    (maybe you use "get_network", but if you think the PSK hasn't
>    been transferred correctly, you might want to try "save_config"
>    and look at the newly written config file)
> 
> If the network blocks aren't what you expected, change you code and
repeat
> at 
> c). You now know at least what piece of information is missing.

I tried a simpler task, getting it to switch between pre-configured
(loaded from the conf) networks, and I've succeeded, somewhat.

One of my issues was that I didn't understand the difference between an
object path, i.e., a string, and a 'path o'. That could use more clarity.

With the PHP5 code below, I've been able to take a selected BSSID object
(like $ap_path =
'/fi/epitest/hostap/WPASupplicant/Interfaces/0/BSSIDs/00904c7e006e'), turn
it into an object, and send a selectNetwork() that succeeds some of the
time. I seem to be losing commands due to the scanning process or they are
being queued for a   v e r y   long time (on an Atom netbook). Using
Holger's suggestion to observe using wpa_cli, I can see that if it's in the
right place in the scanning state machine, it succeeds, but if scanning is
happening or it's trying to associate, it mostly ignores the command. I can
see from the C code that selectNetwork() is supposed to scan, but it's
supposed to disable every WAP except the one I want before doing so. Even
if I turn off the timer that triggers my scan and update of available WAPs,
THEN wait ten seconds before issuing my selectNetwork() command, I still
see the command ignored a good part of the time and the scan doesn't
disable the unwanted networks.

TIA for any understandfing that can be imparted!

<code>
try {
        sleep(10);
        $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"
);

        echo $path->getData();
        echo "<br /><br />";
        $which = $if->state();
        $name = $_POST[name];
        $ap_path = $_POST[path];
        echo($ap_path . "<br /><br />");
        $ap_sel = $d->createProxy( "fi.epitest.hostap.WPASupplicant",
                               $ap_path,
                              
"fi.epitest.hostap.WPASupplicant.Interfaces" );

        $success = $if->selectNetwork($ap_sel);
        echo "Success: $success<br />";

} catch (Exception $e) {
echo "<pre>error: " . $e->getMessage() . "</pre>";
}
</code> 
-- 
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