145 lines
4.6 KiB
Dart
145 lines
4.6 KiB
Dart
|
||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||
import 'package:get/get.dart';
|
||
|
||
import '../app_settings/app_settings.dart';
|
||
import 'io_type.dart';
|
||
|
||
abstract class Reply{
|
||
|
||
CommandType? commandType;
|
||
|
||
//command key flag
|
||
int status = 0;
|
||
List<int> data = [];
|
||
static String logTag= '锁 -> App,指令订阅类型 :';
|
||
Reply.parseData(this.commandType, List<int> dataDetail);
|
||
|
||
void errorWithStstus(int status){
|
||
switch(status){
|
||
case 0x00:
|
||
// 成功
|
||
AppLog.log("$logTag ${commandType?.typeName} 0x00 成功");
|
||
break;
|
||
case 0x01:
|
||
// 包格式错误
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x01 包格式错误");
|
||
showErrorMessage("包格式错误");
|
||
break;
|
||
case 0x02:
|
||
// 密码错误
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x02 密码错误");
|
||
showErrorMessage("密码错误");
|
||
break;
|
||
case 0x03:
|
||
// 网络中断
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x03 网络中断");
|
||
showErrorMessage("网络中断");
|
||
break;
|
||
case 0x04:
|
||
// 用户未登记
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x04 用户未登记");
|
||
showErrorMessage("用户未登记");
|
||
break;
|
||
case 0x05:
|
||
// 参数错误
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x05 参数错误");
|
||
showErrorMessage("参数错误");
|
||
break;
|
||
case 0x06:
|
||
// 需要鉴权
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x06 需要鉴权");
|
||
// showErrorMessage("需要鉴权");
|
||
break;
|
||
case 0x07:
|
||
// 无权限
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x07 无权限");
|
||
// showErrorMessage("无权限");
|
||
break;
|
||
case 0x08:
|
||
// 应答超时
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x08 应答超时");
|
||
showErrorMessage("应答超时");
|
||
break;
|
||
case 0x09:
|
||
// 权限校验错误
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x09 权限校验错误");
|
||
showErrorMessage("权限校验错误");
|
||
break;
|
||
case 0x0a:
|
||
// 钥匙不存在
|
||
showErrorMessage("钥匙不存在");
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x0a 钥匙不存在");
|
||
break;
|
||
case 0x0b:
|
||
// 钥匙过期
|
||
showErrorMessage("钥匙过期");
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x0b 钥匙过期");
|
||
break;
|
||
case 0x0c:
|
||
// 钥匙数量已到上限
|
||
showErrorMessage("钥匙数量已到上限");
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x0c 钥匙数量已到上限");
|
||
break;
|
||
case 0x0d:
|
||
// 钥匙无效
|
||
showErrorMessage("钥匙无效");
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x0d 钥匙无效");
|
||
break;
|
||
case 0x0e:
|
||
// 钥匙已存在
|
||
showErrorMessage("钥匙已存在");
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x0e 钥匙已存在");
|
||
break;
|
||
case 0x0f:
|
||
// 用户已存在
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x0f 用户已存在");
|
||
showErrorMessage("用户已存在");
|
||
break;
|
||
case 0x10:
|
||
// 密码失效
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x11 密码失效");
|
||
showErrorMessage("密码失效");
|
||
break;
|
||
case 0x11:
|
||
// 无效指令
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x11 无效指令");
|
||
showErrorMessage("无效指令");
|
||
break;
|
||
case 0x12:
|
||
// 门锁时间异常
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x12 门锁时间异常");
|
||
showErrorMessage("门锁时间异常");
|
||
break;
|
||
case 0x15:
|
||
// APP(手机)未联网
|
||
AppLog.log("$logTag ${commandType!.typeName} 0x15 APP(手机)未联网");
|
||
showErrorMessage("APP(手机)未联网");
|
||
break;
|
||
case 0x16:
|
||
// 正在开锁中...
|
||
AppLog.log("$logTag ${commandType!.typeName} $status 正在开锁中...");
|
||
showErrorMessage("正在开锁中...");
|
||
break;
|
||
case 0xff:
|
||
// 异常,未知错误
|
||
AppLog.log("$logTag ${commandType!.typeName} 0xff 异常,未知错误");
|
||
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}';
|
||
}
|
||
}
|