mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-27 17:18:53 +00:00
wifi: support for scans in connected state
The 'connected_scan_interval' config attribute specifies the scan interval in seconds. The commit also removes the deprecated ram_fs component from the test run script.
This commit is contained in:
parent
9ba7b2edde
commit
104775aa56
@ -197,14 +197,7 @@ Configuration snippet:
|
||||
! <jitterentropy name="random"/>
|
||||
! <jitterentropy name="urandom"/>
|
||||
! </dir>
|
||||
! <inline name="wpa_supplicant.conf">
|
||||
!network={
|
||||
! id_str="foobar"
|
||||
! ssid="foobar"
|
||||
! key_mgmt=WPA-PSK
|
||||
! psk="foobarfoobar"
|
||||
!}
|
||||
! </inline>
|
||||
! <dir name="config"> <ram/> </dir>
|
||||
! </vfs>
|
||||
! </libc>
|
||||
! </config>
|
||||
@ -214,6 +207,17 @@ Configuration snippet:
|
||||
! </route>
|
||||
!</start
|
||||
|
||||
Per default, the driver scans for available networks only when not
|
||||
connected. This can be changed with the 'connected_scan_interval'
|
||||
config attribute, which specifies the interval for connected scans in
|
||||
seconds, e.g.
|
||||
|
||||
!<config connected_scan_interval="30">...</config>
|
||||
|
||||
Also, the driver can be switched to verbose logging with
|
||||
|
||||
!<config verbose="yes">...</config>
|
||||
|
||||
The wifi_drv creates two distinct reports to communicate its state and
|
||||
information about the wireless infrastructure to other components. The
|
||||
first one is a list of all available accesspoints. The following examplary
|
||||
|
@ -7,8 +7,7 @@ set build_components {
|
||||
drivers/timer drivers/wifi
|
||||
drivers/rtc
|
||||
server/report_rom
|
||||
server/ram_fs
|
||||
server/fs_rom
|
||||
server/dynamic_rom
|
||||
test/lwip/http_srv
|
||||
lib/vfs/jitterentropy
|
||||
}
|
||||
@ -60,55 +59,44 @@ set config {
|
||||
</start>
|
||||
<start name="report_rom">
|
||||
<resource name="RAM" quantum="2M"/>
|
||||
<provides> <service name="Report" /> <service name="ROM" /> </provides>
|
||||
<config> <rom/> </config>
|
||||
</start>
|
||||
<start name="config_fs">
|
||||
<binary name="ram_fs"/>
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides> <service name="File_system"/> </provides>
|
||||
<config>
|
||||
<policy label="config_rom" root="/"/>
|
||||
<policy label="wifi_drv -> config" root="/" writeable="yes"/>
|
||||
<content>
|
||||
<inline name="wlan_configuration">}
|
||||
append config "
|
||||
<selected_network ssid=\"$::env(GENODE_WIFI_SSID)\" protection=\"WPA-PSK\" psk=\"$::env(GENODE_WIFI_PSK)\"/>"
|
||||
append config {
|
||||
</inline>
|
||||
<inline name="wpa_supplicant.conf"></inline>
|
||||
</content>
|
||||
</config>
|
||||
<provides> <service name="Report"/> <service name="ROM"/> </provides>
|
||||
<config/>
|
||||
</start>
|
||||
<start name="config_rom">
|
||||
<binary name="fs_rom"/>
|
||||
<binary name="dynamic_rom"/>
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="ROM"/></provides>
|
||||
<route>
|
||||
<service name="File_system"> <child name="config_fs" /> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
<config verbose="yes">
|
||||
<rom name="wlan_configuration">
|
||||
<inline description="DISCONNECT"> <selected_network/> </inline>
|
||||
<sleep milliseconds="10000"/> <!-- 10 seconds -->
|
||||
<inline description="CONNECT">}
|
||||
append config "<selected_network ssid=\"$::env(GENODE_WIFI_SSID)\" protection=\"WPA-PSK\" psk=\"$::env(GENODE_WIFI_PSK)\"/>"
|
||||
append config {
|
||||
</inline>
|
||||
<sleep milliseconds="300000"/> <!-- 5 minutes -->
|
||||
</rom>
|
||||
</config>
|
||||
</start>
|
||||
<start name="wifi_drv">
|
||||
<resource name="RAM" quantum="32M"/>
|
||||
<provides> <service name="Nic"/> </provides>
|
||||
<config ld_verbose="yes" verbose="yes">
|
||||
<config ld_verbose="yes" verbose="yes" connected_scan_interval="30">
|
||||
<libc stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc">
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> <rtc/>
|
||||
<jitterentropy name="random"/>
|
||||
<jitterentropy name="urandom"/>
|
||||
</dir>
|
||||
<dir name="config"> <fs label="config"/> </dir>
|
||||
<dir name="config"> <ram/> </dir>
|
||||
</vfs>
|
||||
</libc>
|
||||
</config>
|
||||
<route>
|
||||
<service name="Rtc"> <any-child /> </service>
|
||||
<service name="File_system"> <child name="config_fs"/> </service>
|
||||
<service name="Rtc"> <any-child/> </service>
|
||||
<service name="Report"> <child name="report_rom"/> </service>
|
||||
<service name="ROM"> <if-arg key="label" value="wlan_configuration" /> <child name="config_rom" /> </service>
|
||||
<any-service> <parent/> <any-child /> </any-service>
|
||||
<service name="ROM" label="wlan_configuration"> <child name="config_rom"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
</start>}
|
||||
|
||||
@ -143,7 +131,7 @@ set firmware_modules {
|
||||
|
||||
# generic modules
|
||||
set boot_modules {
|
||||
core init timer rtc_drv ram_fs report_rom fs_rom
|
||||
core init timer rtc_drv report_rom dynamic_rom
|
||||
vfs_jitterentropy.lib.so
|
||||
ld.lib.so
|
||||
libc.lib.so libcrypto.lib.so libssl.lib.so
|
||||
|
@ -230,7 +230,8 @@ struct Main
|
||||
|
||||
Main(Genode::Env &env) : env(env)
|
||||
{
|
||||
bool const verbose = config_rom.xml().attribute_value("verbose", false);
|
||||
bool const verbose = config_rom.xml().attribute_value("verbose", false);
|
||||
long const interval = config_rom.xml().attribute_value("connected_scan_interval", 0L);
|
||||
|
||||
/*
|
||||
* Forcefully disable 11n but for convenience the attribute is used the
|
||||
@ -238,7 +239,7 @@ struct Main
|
||||
*/
|
||||
bool const disable_11n = !config_rom.xml().attribute_value("use_11n", true);
|
||||
|
||||
wpa = new (&heap) Wpa_thread(env, wpa_startup_lock(), verbose);
|
||||
wpa = new (&heap) Wpa_thread(env, wpa_startup_lock(), verbose, interval);
|
||||
|
||||
wpa->start();
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include <base/sleep.h>
|
||||
|
||||
/* entry function */
|
||||
extern "C" int wpa_main(int);
|
||||
extern "C" int wpa_main(int debug_msg, int connected_scan_interval);
|
||||
extern "C" void wpa_conf_reload(void);
|
||||
|
||||
class Wpa_thread : public Genode::Thread
|
||||
@ -28,19 +28,23 @@ class Wpa_thread : public Genode::Thread
|
||||
Genode::Lock &_lock;
|
||||
int _exit;
|
||||
bool _debug_msg;
|
||||
int _connected_scan_interval;
|
||||
|
||||
public:
|
||||
|
||||
Wpa_thread(Genode::Env &env, Genode::Lock &lock, bool debug_msg)
|
||||
Wpa_thread(Genode::Env &env, Genode::Lock &lock,
|
||||
bool debug_msg, int connected_scan_interval)
|
||||
:
|
||||
Thread(env, "wpa_supplicant", 8*1024*sizeof(long)),
|
||||
_lock(lock), _exit(-1), _debug_msg(debug_msg) { }
|
||||
_lock(lock), _exit(-1),
|
||||
_debug_msg(debug_msg), _connected_scan_interval(connected_scan_interval)
|
||||
{ }
|
||||
|
||||
void entry()
|
||||
{
|
||||
/* wait until the wifi driver is up and running */
|
||||
_lock.lock();
|
||||
_exit = wpa_main(_debug_msg);
|
||||
_exit = wpa_main(_debug_msg, _connected_scan_interval);
|
||||
Genode::sleep_forever();
|
||||
}
|
||||
};
|
||||
|
@ -981,11 +981,9 @@ void __free_page_frag(void *addr)
|
||||
|
||||
void __free_pages(struct page *page, unsigned int order)
|
||||
{
|
||||
if (!atomic_dec_and_test(&page->_count)) {
|
||||
Genode::warning("attempting to free page ", page, " with _count: ",
|
||||
atomic_read(&page->_count));
|
||||
if (!atomic_dec_and_test(&page->_count))
|
||||
/* reference counter did not drop to zero - do not free yet */
|
||||
return;
|
||||
}
|
||||
|
||||
Addr_to_page_mapping::remove(page);
|
||||
|
||||
|
@ -30,14 +30,31 @@
|
||||
/* local includes */
|
||||
#include "includes.h"
|
||||
#include "common.h"
|
||||
#include "eloop.h"
|
||||
#include "wpa_supplicant_i.h"
|
||||
#include "driver_i.h"
|
||||
#include "scan.h"
|
||||
|
||||
|
||||
static char const *conf_file = "/config/wpa_supplicant.conf";
|
||||
|
||||
static int connected_scan_interval;
|
||||
|
||||
int wpa_main(int debug_msg)
|
||||
static void connected_scan_handler(void *eloop_ctx, void *user_ctx)
|
||||
{
|
||||
struct wpa_supplicant *wpa_s = (struct wpa_supplicant *)eloop_ctx;
|
||||
|
||||
if (wpa_s->wpa_state >= WPA_ASSOCIATED)
|
||||
wpa_supplicant_req_scan(wpa_s, 0, 0);
|
||||
|
||||
eloop_register_timeout(connected_scan_interval, 0, connected_scan_handler, wpa_s, 0);
|
||||
}
|
||||
|
||||
|
||||
int wpa_main(int debug_msg, int interval)
|
||||
{
|
||||
connected_scan_interval = interval;
|
||||
|
||||
struct wpa_interface iface;
|
||||
int exitcode = 0;
|
||||
struct wpa_params params;
|
||||
@ -59,6 +76,10 @@ int wpa_main(int debug_msg)
|
||||
if (wpa_supplicant_add_iface(global, &iface) == NULL)
|
||||
exitcode = -1;
|
||||
|
||||
if (connected_scan_interval > 0)
|
||||
eloop_register_timeout(connected_scan_interval, 0,
|
||||
connected_scan_handler, global->ifaces, 0);
|
||||
|
||||
if (exitcode == 0)
|
||||
exitcode = wpa_supplicant_run(global);
|
||||
|
||||
@ -78,7 +99,7 @@ void wpa_conf_reload(void)
|
||||
|
||||
int wpa_write_conf(char const *buffer, size_t len)
|
||||
{
|
||||
int fd = open(conf_file, O_TRUNC|O_WRONLY);
|
||||
int fd = open(conf_file, O_CREAT|O_TRUNC|O_WRONLY);
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user