I have android6.0.1 I want to enable the wps when hotspot on.
Can anyone give some ideas and give whatever changes i want to do in someother files.?
Can anyone provide any application for wps server.?
Thanks, VinothS,
Funny coincidence. I was looking for this, too, today for Debian. Currently I'm following:
http://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/external/bsd/wpa/dist/hostapd/README-WPS and a bit of https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf
I just needed to copy these lines:
wpa_psk_file=/home/<username>/etc/hostapd/hostapd.psk ctrl_interface=/var/run/hostapd eap_server=1 wps_state=2 ap_setup_locked=1 wps_pin_requests=/var/run/hostapd.pin-req device_name=USB2.0 WLAN manufacturer=ATHEROS model_name=WAP model_number=123 serial_number=12345 device_type=6-0050F204-1 os_version=01020300 config_methods=label display push_button keypad into my hostapd.conf file. I created a custom one for myself in ~/etc/hostapd.conf, but normally there is one in /etc/hostapd/hostapd.conf. In your case you might have to change device_type. I tried to mostly verify the information like manufacturer, ... but I don't think they are that important. I was able to find manufacturer and serial number using lsusb and then sudo lsusb -v -s 5:7 (the numbers after -s are the bus and device numbers shown by lsusb)
After that I restarted hostapd with the new configuration file:
sudo pkill hostapd sudo bash -c "nohup hostapd '$HOME/etc/hostapd/hostapd.conf' > '$HOME/nohupHostapd.out'" & and did a quick sudo hostapd_cli wps_pbc and then was able to connect the printer using WPS.
/var/run/hostapd is created automatically. The error message Failed to connect to hostapd should only happen if you forgot the line ctrl_interface=/var/run/hostapd or if you apply the changes by restarting hostapd, see also here Note that I didn't need to add ctrl_interface_group=0 like the answers writes. If /var/run/ itself is missing, then I can't really help.Must be an android problem then. Try creating it with mkdir... Needs to add the string (wps_state, eap_server) in the following files,
system/netd/server/SoftapController.cpp
int SoftapController::setSoftap(int argc, char *argv[]) { int hidden = 0; int channel = AP_CHANNEL_DEFAULT; int wps_state = 2; if (argc < 5) { ALOGE("Softap set is missing arguments. Please use:"); ALOGE("softap <wlan iface> <SSID> <hidden/broadcast> <channel> <wpa2?-psk|open> <passphrase>"); return ResponseCode: : CommandSyntaxError; } if (!strcasecmp(argv[4], "hidden")) hidden = 1; if (argc >= 5) { channel = atoi(argv[5]); if (channel <= 0) channel = AP_CHANNEL_DEFAULT; } std::string wbuf(StringPrintf("interface=%s\n" "driver=nl80211\n" "ctrl_interface=/data/misc/wifi/hostapd\n" "ssid=%s\n" "channel=%d\n" "ieee80211n=1\n" "hw_mode=%c\n" "ignore_broadcast_ssid=%d, eap_server = 1, wps_state = %d\n", argv[2], argv[3], channel, (channel <= 14) ? 'g' : 'a', hidden,wps_state)); std::string fbuf; if (argc > 7) { char psk_str[2*SHA256_DIGEST_LENGTH+1]; if (!strcmp(argv[6], "wpa-psk")) { if (!generatePsk(argv[3], argv[7], psk_str)) { return ResponseCode: : OperationFailed; } fbuf = StringPrintf("%swpa=3\nwpa_pairwise=TKIP CCMP\nwpa_psk=%s\n", wbuf.c_str(), psk_str); } else if (!strcmp(argv[6], "wpa2-psk")) { if (!generatePsk(argv[3], argv[7], psk_str)) { return ResponseCode: : OperationFailed; } fbuf = StringPrintf("%swpa=2\nrsn_pairwise=CCMP\nwpa_psk=%s\n", wbuf.c_str(), psk_str); } else if (!strcmp(argv[6], "open")) { fbuf = wbuf; } } else if (argc > 6) { if (!strcmp(argv[6], "open")) { fbuf = wbuf; } } else { fbuf = wbuf; } if (!WriteStringToFile(fbuf, HOSTAPD_CONF_FILE, 0660, AID_SYSTEM, AID_WIFI)) { ALOGE("Cannot write to \"%s\": %s", HOSTAPD_CONF_FILE, strerror(errno)); return ResponseCode::OperationFailed; } else { return ResponseCode::SoftapStatusResult; } Testing,
hostapd_cli wps_pbc
Here is a minimal setup:
ctrl_interface=/var/run/hostapd wps_state=2 config_methods=virtual_push_button It is then possible to use hostapd_cli to push the virtual button. Run hostapd_cli without arguments (so it stays open and shows connection attempts), and in that shell, use the commands:
wps_get_status # optional, show current status wps_pbc # push the virtual button wps_cancel # optional, cancel discovery mode