unlock method
Implementation
Future<CuppsCommandResponse> unlock() async {
if (haveLock) {
try {
if (locked) {
DeviceUnlockRequest req = DeviceUnlockRequest(messageID: currentMessageID);
String unlockResXML = await send(xml: req.toXML());
DeviceUnlockResponse unlockRes = DeviceUnlockResponse.fromXML(unlockResXML);
if (unlockRes.result.toLowerCase() == "ok") {
locked = false;
CUPPS().notifier!();
return CuppsCommandResponse(status: true, msg: "Device :$deviceName Unlocked Successfully");
} else {
if (unlockRes.result == "deviceNotLocked") {
locked = false;
CUPPS().notifier!();
return CuppsCommandResponse(status: true, msg: unlockRes.result);
} else {
return CuppsCommandResponse(status: false, msg: unlockRes.result);
}
}
} else {
return CuppsCommandResponse(status: false, msg: "Device Not Locked");
}
} catch (e) {
return CuppsCommandResponse(status: false, msg: "Device $deviceName unlock Exception: $e");
}
} else {
return CuppsCommandResponse(status: false, msg: "Illogical Action");
}
}