* 临时提交 * 临时提交 * 临时提交 * fix: 调整接口 * fix: 修复问题 * fix: 调整 iOS 实现 * fix: 添加注释 * fix: 修改预览版本号 * fix: 修复已知问题 * fix: 优化接口 * fix: 解决 32 位 UUID 报错问题 * fix: 修复问题 * fix: 修复依赖项 * fix: 移除多余代码 * fix: 修复已知问题 * fix: 修复问题 * fix: 修改版本号 * fix: 修复问题 * fix: 发布正式版本
242 lines
5.3 KiB
Dart
242 lines
5.3 KiB
Dart
import 'package:pigeon/pigeon.dart';
|
|
|
|
@ConfigurePigeon(
|
|
PigeonOptions(
|
|
dartOut: 'lib/src/my_api.g.dart',
|
|
dartOptions: DartOptions(),
|
|
swiftOut: 'darwin/Classes/MyApi.g.swift',
|
|
swiftOptions: SwiftOptions(),
|
|
),
|
|
)
|
|
@HostApi()
|
|
abstract class MyCentralManagerHostApi {
|
|
@async
|
|
MyCentralManagerArgs setUp();
|
|
void startDiscovery();
|
|
void stopDiscovery();
|
|
@async
|
|
void connect(int peripheralHashCodeArgs);
|
|
@async
|
|
void disconnect(int peripheralHashCodeArgs);
|
|
int getMaximumWriteLength(int peripheralHashCodeArgs, int typeNumberArgs);
|
|
@async
|
|
int readRSSI(int peripheralHashCodeArgs);
|
|
@async
|
|
List<MyGattServiceArgs> discoverGATT(int peripheralHashCodeArgs);
|
|
@async
|
|
Uint8List readCharacteristic(
|
|
int peripheralHashCodeArgs,
|
|
int characteristicHashCodeArgs,
|
|
);
|
|
@async
|
|
void writeCharacteristic(
|
|
int peripheralHashCodeArgs,
|
|
int characteristicHashCodeArgs,
|
|
Uint8List valueArgs,
|
|
int typeNumberArgs,
|
|
);
|
|
@async
|
|
void notifyCharacteristic(
|
|
int peripheralHashCodeArgs,
|
|
int characteristicHashCodeArgs,
|
|
bool stateArgs,
|
|
);
|
|
@async
|
|
Uint8List readDescriptor(
|
|
int peripheralHashCodeArgs,
|
|
int descriptorHashCodeArgs,
|
|
);
|
|
@async
|
|
void writeDescriptor(
|
|
int peripheralHashCodeArgs,
|
|
int descriptorHashCodeArgs,
|
|
Uint8List valueArgs,
|
|
);
|
|
}
|
|
|
|
@FlutterApi()
|
|
abstract class MyCentralManagerFlutterApi {
|
|
void onStateChanged(int stateNumberArgs);
|
|
void onDiscovered(
|
|
MyPeripheralArgs peripheralArgs,
|
|
int rssiArgs,
|
|
MyAdvertiseDataArgs advertiseDataArgs,
|
|
);
|
|
void onPeripheralStateChanged(
|
|
MyPeripheralArgs peripheralArgs,
|
|
bool stateArgs,
|
|
);
|
|
void onCharacteristicValueChanged(
|
|
MyGattCharacteristicArgs characteristicArgs,
|
|
Uint8List valueArgs,
|
|
);
|
|
}
|
|
|
|
@HostApi()
|
|
abstract class MyPeripheralManagerHostApi {
|
|
@async
|
|
MyPeripheralManagerArgs setUp();
|
|
@async
|
|
void addService(MyGattServiceArgs serviceArgs);
|
|
void removeService(int serviceHashCodeArgs);
|
|
void clearServices();
|
|
@async
|
|
void startAdvertising(MyAdvertiseDataArgs advertiseDataArgs);
|
|
void stopAdvertising();
|
|
int getMaximumWriteLength(int centralHashCodeArgs);
|
|
void sendReadCharacteristicReply(
|
|
int centralHashCodeArgs,
|
|
int characteristicHashCodeArgs,
|
|
int idArgs,
|
|
int offsetArgs,
|
|
bool statusArgs,
|
|
Uint8List valueArgs,
|
|
);
|
|
void sendWriteCharacteristicReply(
|
|
int centralHashCodeArgs,
|
|
int characteristicHashCodeArgs,
|
|
int idArgs,
|
|
int offsetArgs,
|
|
bool statusArgs,
|
|
);
|
|
@async
|
|
void notifyCharacteristicValueChanged(
|
|
int centralHashCodeArgs,
|
|
int characteristicHashCodeArgs,
|
|
Uint8List valueArgs,
|
|
);
|
|
}
|
|
|
|
@FlutterApi()
|
|
abstract class MyPeripheralManagerFlutterApi {
|
|
void onStateChanged(int stateNumberArgs);
|
|
void onReadCharacteristicCommandReceived(
|
|
MyCentralArgs centralArgs,
|
|
MyGattCharacteristicArgs characteristicArgs,
|
|
int idArgs,
|
|
int offsetArgs,
|
|
);
|
|
void onWriteCharacteristicCommandReceived(
|
|
MyCentralArgs centralArgs,
|
|
MyGattCharacteristicArgs characteristicArgs,
|
|
int idArgs,
|
|
int offsetArgs,
|
|
Uint8List valueArgs,
|
|
);
|
|
void onNotifyCharacteristicCommandReceived(
|
|
MyCentralArgs centralArgs,
|
|
MyGattCharacteristicArgs characteristicArgs,
|
|
bool stateArgs,
|
|
);
|
|
}
|
|
|
|
class MyCentralManagerArgs {
|
|
final int stateNumberArgs;
|
|
|
|
MyCentralManagerArgs(this.stateNumberArgs);
|
|
}
|
|
|
|
class MyPeripheralManagerArgs {
|
|
final int stateNumberArgs;
|
|
|
|
MyPeripheralManagerArgs(this.stateNumberArgs);
|
|
}
|
|
|
|
class MyCentralArgs {
|
|
final int hashCodeArgs;
|
|
final String uuidArgs;
|
|
|
|
MyCentralArgs(this.hashCodeArgs, this.uuidArgs);
|
|
}
|
|
|
|
class MyPeripheralArgs {
|
|
final int hashCodeArgs;
|
|
final String uuidArgs;
|
|
|
|
MyPeripheralArgs(this.hashCodeArgs, this.uuidArgs);
|
|
}
|
|
|
|
class MyAdvertiseDataArgs {
|
|
final String? nameArgs;
|
|
final List<String?> serviceUUIDsArgs;
|
|
final Map<String?, Uint8List?> serviceDataArgs;
|
|
final MyManufacturerSpecificDataArgs? manufacturerSpecificDataArgs;
|
|
|
|
MyAdvertiseDataArgs(
|
|
this.nameArgs,
|
|
this.serviceUUIDsArgs,
|
|
this.serviceDataArgs,
|
|
this.manufacturerSpecificDataArgs,
|
|
);
|
|
}
|
|
|
|
class MyManufacturerSpecificDataArgs {
|
|
final int idArgs;
|
|
final Uint8List dataArgs;
|
|
|
|
MyManufacturerSpecificDataArgs(this.idArgs, this.dataArgs);
|
|
}
|
|
|
|
class MyGattServiceArgs {
|
|
final int hashCodeArgs;
|
|
final String uuidArgs;
|
|
final List<MyGattCharacteristicArgs?> characteristicsArgs;
|
|
|
|
MyGattServiceArgs(
|
|
this.hashCodeArgs,
|
|
this.uuidArgs,
|
|
this.characteristicsArgs,
|
|
);
|
|
}
|
|
|
|
class MyGattCharacteristicArgs {
|
|
final int hashCodeArgs;
|
|
final String uuidArgs;
|
|
final List<int?> propertyNumbersArgs;
|
|
final List<MyGattDescriptorArgs?> descriptorsArgs;
|
|
|
|
MyGattCharacteristicArgs(
|
|
this.hashCodeArgs,
|
|
this.uuidArgs,
|
|
this.propertyNumbersArgs,
|
|
this.descriptorsArgs,
|
|
);
|
|
}
|
|
|
|
class MyGattDescriptorArgs {
|
|
final int hashCodeArgs;
|
|
final String uuidArgs;
|
|
final Uint8List? valueArgs;
|
|
|
|
MyGattDescriptorArgs(
|
|
this.hashCodeArgs,
|
|
this.uuidArgs,
|
|
this.valueArgs,
|
|
);
|
|
}
|
|
|
|
enum MyBluetoothLowEnergyStateArgs {
|
|
unknown,
|
|
unsupported,
|
|
unauthorized,
|
|
poweredOff,
|
|
poweredOn,
|
|
}
|
|
|
|
enum MyGattCharacteristicPropertyArgs {
|
|
read,
|
|
write,
|
|
writeWithoutResponse,
|
|
notify,
|
|
indicate,
|
|
}
|
|
|
|
enum MyGattCharacteristicWriteTypeArgs {
|
|
// Write with response
|
|
withResponse,
|
|
// Write without response
|
|
withoutResponse,
|
|
// Write with response and waiting for confirmation
|
|
// reliable,
|
|
}
|