import 'package:ef/ef.dart'; import 'package:json_annotation/json_annotation.dart'; part 'blueteeth_bind_controller.g.dart'; // 由json_serializable自动生成的部分 @JsonSerializable() class BlueteethBindModel { int? read = 1; //是否不再提示教程 0 不再提示 1 需要提示 double? singal = -70; //扫描信号强度 List? devicelist = []; //蓝牙扫描到的设备数据列表 List? blelist = []; //蓝牙扫描到的设备数据列表 List? wifiList = []; List bindArr = ["", "", ""]; String connectedWifiName = ""; int connectedRssi = 0; String deviceName = ""; bool? deviceIndex0 = true; bool? deviceIndex1 = false; bool? deviceIndex2 = false; BlueteethBindModel(); // 从JSON反序列化时的异常处理 factory BlueteethBindModel.fromJson(Map json) { try { return _$BlueteethBindModelFromJson(json); } catch (e) { // 在实际应用中,应该有更细致的异常处理策略和错误日志 return BlueteethBindModel(); // 或者返回一个带有错误信息的特定DeviceInfoModel实例 } } // 序列化为JSON时的异常处理 Map toJson() => _$BlueteethBindModelToJson(this); } class BlueteethBindController extends GetControllerEx { BlueteethBindController() { attr = GetModel(BlueteethBindModel()).obs; } void updateDeviceStatus() { // try { // } catch (e) { // print(e); // EasyDartModule.logger.info("向后端请求设备绑定状态报错了:$e"); // } finally { // EasyDartModule.logger.info("向后端请求设备绑定状态"); // } } Future bindDevice(d) async { print("绑定参数:$d"); await Future.delayed(Duration(seconds: 1)); // return ApiService.request // .post("/api/device/info/bind", data: formdata.FormData.fromMap(d)); } }