41 lines
1.1 KiB
Dart
Executable File
41 lines
1.1 KiB
Dart
Executable File
|
|
enum DataTransmissionMode {
|
|
ble,
|
|
}
|
|
|
|
class IoManager {
|
|
factory IoManager() => share();
|
|
IoManager._init();
|
|
|
|
static IoManager? _ioManager;
|
|
static IoManager share(){
|
|
_ioManager ??= IoManager._init();
|
|
return _ioManager!;
|
|
}
|
|
IoManager get manager => share();
|
|
|
|
//数据传输方式
|
|
DataTransmissionMode _dataTransmissionMode = DataTransmissionMode.ble;
|
|
bool get isBleChannel =>_dataTransmissionMode == DataTransmissionMode.ble;
|
|
|
|
///蓝牙传输协议
|
|
void bleTransmission() => _dataTransmissionMode = DataTransmissionMode.ble;
|
|
|
|
///协议帧序号
|
|
int _commandIndex = 1;
|
|
int configCommandIdx(int idx) => _commandIndex = idx;
|
|
Future<void> increaseCommandIndex() async {
|
|
_commandIndex < 255 ? _commandIndex++ : _commandIndex = 0;
|
|
}
|
|
void resetCommandIndex() => _commandIndex = 0;
|
|
int get commandIndex => _commandIndex;
|
|
|
|
/// 当前设备连接的lockId
|
|
String _currentDeviceLockId = '';
|
|
String configCurrentDeviceLockId(String lockId) => _currentDeviceLockId = lockId;
|
|
String get getCurrentDeviceLockId => _currentDeviceLockId;
|
|
|
|
void resetAllFlags() {
|
|
resetCommandIndex();
|
|
}
|
|
} |