Skip to content

Commit

Permalink
Merge branch 'develop' into feature/add_bssid
Browse files Browse the repository at this point in the history
  • Loading branch information
thearaks committed Nov 12, 2019
2 parents 8c88904 + 7fdd9bd commit 6a2de82
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 6 additions & 2 deletions android/src/main/java/com/ly/wifi/WifiDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,15 @@ private WifiConfiguration createWifiConfig(String ssid, String Password) {
if (tempConfig != null) {
wifiManager.removeNetwork(tempConfig.networkId);
}
config.preSharedKey = "\"" + Password + "\"";
if (Password != null && !Password.isEmpty()) {
config.preSharedKey = "\"" + Password + "\"";
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
} else {
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
}
config.hiddenSSID = true;
config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
Expand Down
7 changes: 6 additions & 1 deletion ios/Classes/WifiPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
NSDictionary* argsMap = call.arguments;
NSString *ssid = argsMap[@"ssid"];
NSString *password = argsMap[@"password"];
NEHotspotConfiguration * hotspotConfig = [[NEHotspotConfiguration alloc] initWithSSID:ssid passphrase:password isWEP:NO];
NEHotspotConfiguration *hotspotConfig;
if ([password length] == 0) {
hotspotConfig = [[NEHotspotConfiguration alloc] initWithSSID:ssid];
} else {
hotspotConfig = [[NEHotspotConfiguration alloc] initWithSSID:ssid passphrase:password isWEP:NO];
}
[[NEHotspotConfigurationManager sharedManager] applyConfiguration:hotspotConfig completionHandler:^(NSError * _Nullable error) {
if(error == nil){
result(@1);
Expand Down
8 changes: 5 additions & 3 deletions lib/wifi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ class Wifi {
return resultList;
}

static Future<WifiState> connection(String ssid, String password) async {
static Future<WifiState> connection(String ssid, [String password]) async {
final Map<String, dynamic> params = {
'ssid': ssid,
'password': password,
'ssid': ssid
};
if (password != null && password.isNotEmpty) {
params.addEntries([MapEntry('password', password)]);
}
int state = await _channel.invokeMethod('connection', params);
switch (state) {
case 0:
Expand Down

0 comments on commit 6a2de82

Please sign in to comment.