app-starlock/lib/blue/io_reply.dart

144 lines
4.7 KiB
Dart
Raw Permalink Normal View History

import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
2024-04-26 15:38:59 +08:00
import '../app_settings/app_settings.dart';
2023-12-11 13:44:15 +08:00
import 'io_type.dart';
abstract class Reply {
Reply.parseData(this.commandType, List<int> dataDetail);
CommandType? commandType;
//command key flag
int status = 0;
List<int> data = [];
static String logTag = '锁 -> App指令订阅类型 :';
void errorWithStstus(int status) {
switch (status) {
case 0x00:
// 成功
AppLog.log('$logTag ${commandType?.typeName} 0x00 成功');
break;
case 0x01:
// 包格式错误
AppLog.log('$logTag ${commandType!.typeName} 0x01 包格式错误');
2024-08-20 09:53:39 +08:00
// showErrorMessage('包格式错误');
break;
case 0x02:
// 密码错误
AppLog.log('$logTag ${commandType!.typeName} 0x02 密码错误');
2024-08-20 09:53:39 +08:00
showErrorMessage('密码错误'.tr);
break;
case 0x03:
// 网络中断
AppLog.log('$logTag ${commandType!.typeName} 0x03 网络中断');
2024-08-20 09:53:39 +08:00
showErrorMessage('网络中断'.tr);
break;
case 0x04:
// 用户未登记
AppLog.log('$logTag ${commandType!.typeName} 0x04 用户未登记');
showErrorMessage('用户未登记'.tr);
break;
case 0x05:
// 参数错误
AppLog.log('$logTag ${commandType!.typeName} 0x05 参数错误');
2024-08-20 09:53:39 +08:00
// showErrorMessage('参数错误');
break;
case 0x06:
// 需要鉴权
AppLog.log('$logTag ${commandType!.typeName} 0x06 需要鉴权');
// showErrorMessage("需要鉴权");
break;
case 0x07:
// 无权限
AppLog.log('$logTag ${commandType!.typeName} 0x07 无权限');
2024-04-26 15:38:59 +08:00
// showErrorMessage("无权限");
break;
case 0x08:
// 应答超时
AppLog.log('$logTag ${commandType!.typeName} 0x08 应答超时');
2024-08-20 09:53:39 +08:00
// showErrorMessage('应答超时');
break;
case 0x09:
// 权限校验错误
AppLog.log('$logTag ${commandType!.typeName} 0x09 权限校验错误');
2024-08-20 09:53:39 +08:00
// showErrorMessage('权限校验错误');
break;
case 0x0a:
// 钥匙不存在
2024-08-20 09:53:39 +08:00
showErrorMessage('钥匙不存在'.tr);
AppLog.log('$logTag ${commandType!.typeName} 0x0a 钥匙不存在');
break;
case 0x0b:
// 钥匙过期
2024-08-20 09:53:39 +08:00
showErrorMessage('钥匙过期'.tr);
AppLog.log('$logTag ${commandType!.typeName} 0x0b 钥匙过期');
break;
case 0x0c:
// 钥匙数量已到上限
2024-08-20 09:53:39 +08:00
// showErrorMessage('钥匙数量已到上限');
AppLog.log('$logTag ${commandType!.typeName} 0x0c 钥匙数量已到上限');
break;
case 0x0d:
// 钥匙无效
2024-08-20 09:53:39 +08:00
showErrorMessage('钥匙无效'.tr);
AppLog.log('$logTag ${commandType!.typeName} 0x0d 钥匙无效');
break;
case 0x0e:
// 钥匙已存在
2024-08-20 09:53:39 +08:00
showErrorMessage('钥匙已存在'.tr);
AppLog.log('$logTag ${commandType!.typeName} 0x0e 钥匙已存在');
break;
case 0x0f:
// 用户已存在
AppLog.log('$logTag ${commandType!.typeName} 0x0f 用户已存在');
2024-08-20 09:53:39 +08:00
// showErrorMessage('用户已存在');
break;
case 0x10:
// 密码失效
AppLog.log('$logTag ${commandType!.typeName} 0x11 密码失效');
showErrorMessage('密码失效');
break;
case 0x11:
// 无效指令
AppLog.log('$logTag ${commandType!.typeName} 0x11 无效指令');
2024-08-20 09:53:39 +08:00
// showErrorMessage('无效指令');
break;
case 0x12:
// 门锁时间异常
AppLog.log('$logTag ${commandType!.typeName} 0x12 门锁时间异常');
2024-08-20 09:53:39 +08:00
showErrorMessage('门锁时间异常'.tr);
break;
case 0x15:
// APP(手机)未联网
AppLog.log('$logTag ${commandType!.typeName} 0x15 APP(手机)未联网');
2024-08-20 09:53:39 +08:00
showErrorMessage('APP(手机)未联网'.tr);
break;
case 0x16:
// 正在开锁中...
AppLog.log('$logTag ${commandType!.typeName} $status 正在开锁中...');
2024-08-20 09:53:39 +08:00
showErrorMessage('正在开锁中...'.tr);
break;
case 0xff:
// 异常,未知错误
AppLog.log('$logTag ${commandType!.typeName} 0xff 异常,未知错误');
2024-08-20 09:53:39 +08:00
// showErrorMessage('异常,未知错误');
break;
default:
//失败
AppLog.log('$logTag ${commandType!.typeName} $status 蓝牙返回其他错误问题');
break;
}
}
void showErrorMessage(String message) {
EasyLoading.showToast(message, duration: 2000.milliseconds);
}
@override
String toString() {
return 'Reply{commandType: $commandType, status: $status, data: $data}';
}
}