Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotspot for generic mediatek deviceS. #1

Open
wants to merge 1 commit into
base: lp5.1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 58 additions & 2 deletions server/SoftapController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <private/android_filesystem_config.h>
#include "wifi.h"
#include "ResponseCode.h"

#include "cutils/properties.h"
#include "SoftapController.h"

#ifdef LIBWPA_CLIENT_EXISTS
Expand Down Expand Up @@ -210,6 +210,8 @@ bool SoftapController::isSoftapStarted() {
return (mPid != 0);
}

#define USE_MTK_WLAN

/*
* Arguments:
* argv[2] - wlan interface
Expand All @@ -227,6 +229,11 @@ int SoftapController::setSoftap(int argc, char *argv[]) {
int channel = AP_CHANNEL_DEFAULT;
char *wbuf = NULL;
char *fbuf = NULL;
#ifdef USE_MTK_WLAN
char ap_channel[PROPERTY_VALUE_MAX] = {'\0'};
const char AP_CHANNEL_PROP_NAME[]="wifi.tethering.channel";
char mode;
#endif

if (argc < 5) {
ALOGE("Softap set is missing arguments. Please use:");
Expand All @@ -238,15 +245,64 @@ int SoftapController::setSoftap(int argc, char *argv[]) {
hidden = 1;

if (argc >= 5) {
#ifndef USE_MTK_WLAN
channel = atoi(argv[5]);
if (channel <= 0)
channel = AP_CHANNEL_DEFAULT;
#else
if (property_get(AP_CHANNEL_PROP_NAME, ap_channel, NULL)){
channel = atoi(ap_channel);
} else {
channel = atoi(argv[5]);
}

if (channel < 0) {
channel = AP_CHANNEL_DEFAULT;
mode = 'g';
} else if (channel >= 0 && channel <= 14) {
/* 2.4G channel, 0 will trigger MTK auto channel selection */
mode = 'g';
} else {
/* 5G channel */
mode = 'a';
}
#endif
}

#ifndef USE_MTK_WLAN
asprintf(&wbuf, "interface=%s\ndriver=nl80211\nctrl_interface="
"/data/misc/wifi/hostapd\nssid=%s\nchannel=%d\nieee80211n=1\n"
"hw_mode=g\nignore_broadcast_ssid=%d\nwowlan_triggers=any\n",
argv[2], argv[3], channel, hidden);
#else
/*
* Arguments:
* argv[2] - wlan interface
* argv[3] - SSID
* argv[4] - Broadcast/Hidden
* argv[5] - Channel
* argv[6] - Security
* argv[7] - Key
* argv[8] - Channel width
* argv[9] - Max connection
*/
if (argc > 9) {
asprintf(&wbuf, "interface=%s\ndriver=nl80211\nctrl_interface="
"/data/misc/wifi/hostapd\nssid=%s\nchannel=%d\nieee80211n=1\n"
"hw_mode=%c\nignore_broadcast_ssid=%d\nmax_num_sta=%d\n"
"eap_server=1\nwps_state=2\nconfig_methods=display physical_display push_button\n"
"device_name=AndroidAP\nmanufacturer=MediaTek Inc.\nmodel_name=MTK Wireless Model\n"
"model_number=66xx\nserial_number=1.0\ndevice_type=10-0050F204-5\nwowlan_triggers=disconnect\n",
"ap0", argv[3], channel, mode, hidden, atoi(argv[9]));
} else {
asprintf(&wbuf, "interface=%s\ndriver=nl80211\nctrl_interface="
"/data/misc/wifi/hostapd\nssid=%s\nchannel=%d\nieee80211n=1\n"
"hw_mode=%c\nignore_broadcast_ssid=%d\n"
"eap_server=1\nwps_state=2\nconfig_methods=display physical_display push_button\n"
"device_name=AndroidAP\nmanufacturer=MediaTek Inc.\nmodel_name=MTK Wireless Model\n"
"model_number=66xx\nserial_number=1.0\ndevice_type=10-0050F204-5\nwowlan_triggers=disconnect\n",
"ap0", argv[3], channel, mode, hidden);
}
#endif

if (argc > 7) {
if (!strcmp(argv[6], "wpa-psk")) {
Expand Down