The specific use case is for a wearable application (Wear OS) that I want to automatically connect to a wifi network that is specified in a config file for easy cross-site deployments without even telling that it is being done. I have tried wifi_iot and plugin_wifi_connect with some odd results. Both seemed to connect to the correct ssid, but they gave some sort of weird prompt that said something about connecting to the device and seemed to actually mess up the connection afterward.
wifi_iot implementation:
check for wifi setting
WiFiForIoTPlugin.isEnabled().then((val) {
_isEnabled = val;
});
print('isEnabled: $_isEnabled');
//check if connected to wifi
WiFiForIoTPlugin.isConnected().then((val) {
_isConnected = val;
});
print('isConnected: $_isConnected');
//enable and connect if not
if (!_isEnabled) {
//enable wifi
WiFiForIoTPlugin.setWiFiAPEnabled(true);
WiFiForIoTPlugin.setEnabled(true);
}
if (!_isConnected) {
//connect to wifi
WiFiForIoTPlugin.connect(_ssid,
password: _psk, security: NetworkSecurity.WPA);
}
plugin_wifi_connect implementation:
var _connectedTo = await PluginWifiConnect.ssid;
print("Comparing $_connectedTo to $_ssid"); //#_connectedTo returns <unidentified_ssid>#
if (_connectedTo.toString() != _ssid) { //#this always fails
try {
await PluginWifiConnect.connectToSecureNetwork(_ssid, _psk,
saveNetwork: true);
print("Connected to $_ssid");
} catch (e) {
print("Couldn't connect to $_ssid");
}
} else {
print("Already connected to $_ssid");
}
Does anyone have any experience with this? Possibly that I am not using the correct permissions for this or if I need to make something if this is even possible anymore. There seemed to be some changes for API above 29 that changed certain things about it. The plugin_wifi_connect did not have much documentation and seems like it might be based on an older package that wasn't null safe that was not really up to date with the same documentation.