receiveHandler static method
bool
receiveHandler(
- dynamic result
)
Implementation
static bool receiveHandler(dynamic result){
if(result is! Map){return false;}
String? type = result["type"];
if(HBle.printDebug && type != "HBleDevice"){
debugPrint("HBle: result: $result");
}
if(type == null){
return false;
}else if(type == "HBleDevice"){
Map? data = result["data"];
if(data != null){HBleScanListen.setHBleDevice(HBleDevice.fromMap(data));}
return true;
} else if(type == "HBleDeviceList"){
List? data = result["data"];
int id = result["id"];
if(data != null){HBleHistoryScanListen.setHBleDevices(id,data);}
return true;
} else if(type == "print"){
return true;
}else if(type == "sendToDevice"){
String identifier = result["identifier"]??"";
Map data = result["data"];
NativeSendToDeviceListen.setDeviceInformation(identifier: identifier, data: data);
return true;
}else if(type == "hBleState"){
Map data = result["data"];
int? state = data["state"];
if(state != null && HBle.getHBleStateComplete!= null && state>0 && state<6){
HBle.getHBleStateComplete!(HBleState.values[state]);
}
return true;
}
return true;
}