getMobileInfo method
Implementation
Future<bool> getMobileInfo({int timeout = 5}) async {
bool ret = await _command
.writeCgi("trans_cmd_string.cgi?cmd=2138&command=0&", timeout: timeout);
if (ret) {
CommandResult result =
await _command.waitCommandResult((int cmd, Uint8List data) {
if (cmd == 24785) {
String str = utf8.decode(data);
return str.contains("cmd=2138;") && str.contains("command=0;");
}
return false;
}, timeout);
if (result.isSuccess == true) {
Map data = result.getMap();
if (data["result"] == "0") {
int index = int.tryParse(data["operator"] ?? "0") ?? 0;
if (index < MobileNetwork.values.length) {
mobileNetwork = MobileNetwork.values[index];
}
mobileSingle = int.tryParse(data["signal"] ?? "0") ?? 0;
mobileICCID = data["iccid"];
_command
.notifyListeners<MobileNotification>((MobileNotification func) {
func(_command, mobileNetwork, mobileSingle, mobileICCID);
});
}
return data["result"] == "0";
}
}
return false;
}