You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/11/01 17:16:51 UTC
[08/11] incubator-mynewt-core git commit: Wifi: Event codes ->
callbacks
Wifi: Event codes -> callbacks
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/146da29e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/146da29e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/146da29e
Branch: refs/heads/develop
Commit: 146da29ec8e1aaa1b810ed24b581df11a52f98cc
Parents: d6f98b4
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Oct 31 18:53:06 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Nov 1 10:08:27 2016 -0700
----------------------------------------------------------------------
.../wifi_mgmt/include/wifi_mgmt/wifi_mgmt.h | 2 +-
net/wifi/wifi_mgmt/src/wifi.c | 45 ++++++++++----------
2 files changed, 23 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/146da29e/net/wifi/wifi_mgmt/include/wifi_mgmt/wifi_mgmt.h
----------------------------------------------------------------------
diff --git a/net/wifi/wifi_mgmt/include/wifi_mgmt/wifi_mgmt.h b/net/wifi/wifi_mgmt/include/wifi_mgmt/wifi_mgmt.h
index b7e2935..e78adec 100644
--- a/net/wifi/wifi_mgmt/include/wifi_mgmt/wifi_mgmt.h
+++ b/net/wifi/wifi_mgmt/include/wifi_mgmt/wifi_mgmt.h
@@ -59,7 +59,7 @@ struct wifi_if {
} wi_state, wi_tgt;
struct os_mutex wi_mtx;
struct os_event wi_event;
- struct os_callout_func wi_timer;
+ struct os_callout wi_timer;
const struct wifi_if_ops *wi_ops;
uint8_t wi_scan_cnt;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/146da29e/net/wifi/wifi_mgmt/src/wifi.c
----------------------------------------------------------------------
diff --git a/net/wifi/wifi_mgmt/src/wifi.c b/net/wifi/wifi_mgmt/src/wifi.c
index 1b1c459..f0be059 100644
--- a/net/wifi/wifi_mgmt/src/wifi.c
+++ b/net/wifi/wifi_mgmt/src/wifi.c
@@ -30,16 +30,29 @@
#include "wifi_mgmt/wifi_mgmt_if.h"
#include "wifi_priv.h"
-#define WIFI_EV_STATE OS_EVENT_T_PERUSER
-
static struct os_task wifi_os_task;
-struct os_eventq wifi_evq;
+struct os_eventq *wifi_evq;
static struct wifi_ap *wifi_find_ap(struct wifi_if *wi, char *ssid);
static void wifi_events(void *arg);
+static void wifi_event_state(struct os_event *ev);
+
static struct wifi_if *wifi_if;
+static struct os_eventq *
+wifi_evq_get(void)
+{
+ os_eventq_ensure(&wifi_evq, NULL);
+ return wifi_evq;
+}
+
+void
+wifi_evq_set(struct os_eventq *evq)
+{
+ os_eventq_designate(&wifi_evq, evq, NULL);
+}
+
/*
* Looks up interface based on port number.
*/
@@ -63,8 +76,8 @@ wifi_if_register(struct wifi_if *wi, const struct wifi_if_ops *ops)
wi->wi_ops = ops;
os_mutex_init(&wi->wi_mtx);
- os_callout_func_init(&wi->wi_timer, &wifi_evq, wifi_events, wi);
- wi->wi_event.ev_type = WIFI_EV_STATE;
+ os_callout_init(&wi->wi_timer, &wifi_evq, wifi_events, wi);
+ wi->wi_event.ev_cb = wifi_event_state;
wi->wi_event.ev_arg = wi;
return 0;
@@ -311,27 +324,13 @@ wifi_step(struct wifi_if *wi)
}
static void
-wifi_task(void *arg)
+wifi_event_state(struct os_event *ev)
{
- struct os_event *ev;
- struct os_callout_func *cf;
struct wifi_if *wi;
- while ((ev = os_eventq_get(&wifi_evq))) {
- switch (ev->ev_type) {
- case OS_EVENT_T_TIMER:
- cf = (struct os_callout_func *)ev;
- cf->cf_func(CF_ARG(cf));
- break;
- case WIFI_EV_STATE:
- wi = (struct wifi_if *)ev->ev_arg;
- while (wi->wi_state != wi->wi_tgt) {
- wifi_step(wi);
- }
- break;
- default:
- break;
- }
+ wi = (struct wifi_if *)ev->ev_arg;
+ while (wi->wi_state != wi->wi_tgt) {
+ wifi_step(wi);
}
}