2016/12/19

rtl8188eu ..

有人很好新 build 好了所有 kernel 版本的 ko..

...猜是從 這裡 build 的。

現在是 4.4.34+, build 930
所以 download path 是...https://dl.dropboxusercontent.com/u/80256631/8188eu-4.4.34-930.tar.gz
糟糕,dropbox public folder 功能要關了...


很麻煩。這個 wifi chip。

ap mode, trial1:
wifi dongle as access point, soft ap 8188eu on linux

這個是 source,要拉下來 make, make install
還好也有附 uninstall:
install:
        install -p -m 644 8188eu.ko  $(MODDESTDIR)
        @if [ -a /lib/modules/$(KVER)/kernel/drivers/staging/rtl8188eu/r8188eu.ko ] ; then modprobe -r r8188eu; fi;
        @echo "blacklist r8188eu" > /etc/modprobe.d/50-8188eu.conf
        cp rtl8188eufw.bin /lib/firmware/.
        /sbin/depmod -a ${KVER}
        mkdir -p /lib/firmware/rtlwifi
        cp rtl8188eufw.bin /lib/firmware/rtlwifi/.

uninstall:
        rm -f $(MODDESTDIR)/8188eu.ko
        /sbin/depmod -a ${KVER}
        @rm /etc/modprobe.d/50-8188eu.conf
build 好的安裝路徑是: /lib/modules/$(KVER)/kernel/drivers/net/wireless

2016/12/12

流水帳:wifi display...

WifiDisplaySetting.java: DEBUG=true
onCreate 後就啟動了...WifiP2pManager.initialize( )

framework/base/services/java/com/android/server/display/DisplayManagerService.java: DEBUG=true;
framework/base/services/java/com/android/server/display/WifiDisplayAdapter.java: DEBUG=true;
framework/base/services/java/com/android/server/display/WifiDisplayController.java: DEBUG=true

真正connect 的流程就在 WifiDisplayController.java: updateConnection()

大概就是..先 disconnect from the old one.
然後再call WifiP2pManager.connect( )
連線完成 call WifiP2pManager.setMiracastMode( )
然後叫 RemoteDispkay.listen( ) 這個 P2p connection...

有點跑掉...

framework/base/java/android/net/wifi/WifiNative.java: DBG=true;
doCommand : wifi_command
libhardware_legacy

wpa_ctrl_request( ) : TAG WifiHW
在 wpa_supplicant_8

是在 wpa_supplicant_8/wpa_supplicant/Android.mk
src/common/wpa_ctrl.c
有兩個 implement, depend on CTRL_IFACE_SOCKET 或是 CONFIG_CTRL_IFACE_NAMED_PIPE
因為 IFACE_UNIX, 所以是 IFACE_SOCKET
int wpa_ctrl_request(struct wpa_ctrl *ctrl, const char *cmd, size_t cmd_len,
                     char *reply, size_t *reply_len,
                     void (*msg_cb)(char *msg, size_t len))
..
wpa_ctrl structure 包含一個 socket.是 溝通的界面。
在 libhardware_legacy/wifi/wifi.c (wpa_supplicant 使用者) 中 是先呼叫:
wifi_connect_on_socket_path(const char *path)
{
   ctrl_conn = wpa_ctrl_open(path);
取得 connect socket
caller 是..
/* Establishes the control and monitor socket connections on the interface */
int wifi_connect_to_supplicant()
{
    static char path[PATH_MAX];

    if (access(IFACE_DIR, F_OK) == 0) {
        snprintf(path, sizeof(path), "%s/%s", IFACE_DIR, primary_iface);
    } else {
        snprintf(path, sizeof(path), "@android:wpa_%s", primary_iface);
    }
    return wifi_connect_on_socket_path(path);
}
其中..
static const char IFACE_DIR[]           = "/data/system/wpa_supplicant";
property_get("wifi.interface",primary_iface,..);
wifi.interface 定義在 system.prop : wlan0

完成後,用 android 的 system control:
    property_set("ctl.start", supplicant_name);
啟動 wpa_supplicant service.
根據 P2P 有沒有啟動, ctrl.start 的 service 不一樣:
static const char SUPPLICANT_NAME[]     = "wpa_supplicant";
static const char SUPP_PROP_NAME[]      = "init.svc.wpa_supplicant";
static const char P2P_SUPPLICANT_NAME[] = "p2p_supplicant";
static const char P2P_PROP_NAME[]       = "init.svc.p2p_supplicant";

找一下 libwpa_client..
其中只有:
  • src/common/wpa_ctrl.c
  • src/utils/os_unix.c

在 Android.mk:
include $(CLEAR_VARS)
LOCAL_MODULE = libwpa_client
LOCAL_CFLAGS = $(L_CFLAGS)
LOCAL_SRC_FILES = src/common/wpa_ctrl.c src/utils/os_$(CONFIG_OS).c
LOCAL_C_INCLUDES = $(INCLUDES)
LOCAL_SHARED_LIBRARIES := libcutils liblog
LOCAL_COPY_HEADERS_TO := libwpa_client
LOCAL_COPY_HEADERS := src/common/wpa_ctrl.h
include $(BUILD_SHARED_LIBRARY)
所以會把 wpa_ctrl.h copy 到 out folder 的 include/libwpa_client/ 下面。

所以有使用到的 project...
./frameworks/base/core/jni/Android.mk: libwpa_client \
./hardware/libhardware_legacy/wifi/Android.mk:LOCAL_SHARED_LIBRARIES += libnetutils libwpa_client
就 include "libwpa_client/wpa_ctrl.h"

framework/.../jni call 到 libhardware_legacy 的 wificommand.
沒有直接 call libwpa_client 的 api

所以所有call libwpa_client 的應該都是經過 libhardware_legacy