* draft: 临时提交 * feat: 实现扫描功能 * fix: 优化广播逻辑 * feat: 添加协程方法 * fix: 修改宏定义 * draft: 临时提交 * feat: 调整接口 * fix: 修改版本号 * feat: 4.1.1 * draft: 临时提交 * feat: 5.0.0-dev.2 * fix: 修复版本号错误 * draft: 临时提交 * fix: 修复连接断开异常 * fix: 修复问题 * fix: 优化代码 * fix: 优化 short UUID 格式化逻辑 * fix: 尝试实现 read_rssi 接口,当前此接口不可用,会报异常 * feat: 删除 getMaximumWriteLength 方法 * fix: 更新 CHANGELOG.md * feat: 5.0.0-dev.1 * fix: 更新依赖项 * feat: linux-5.0.0-dev.1 * fix: 更新 CHANGELOG.md * fix: 开始搜索设备时清空设备列表 * fix: 开始扫描时清空设备列表 * feat: 5.0.0-dev.2 * fix: 优化 MyGattService 和 MyGattCharacteristic * feat: 更新 interface 版本 -> 5.0.0-dev.4 * feat: 更新 interface 版本 -> 5.0.0-dev.4 * feat: 实现 flutter 部分 5.0.0 * fix: 移除 maximumWriteLength * fix: 移除 rssi * feat: 5.0.0-dev.1 * feat: 5.0.0-dev.2 * fix: 更新依赖项 * fix: 5.0.0-dev.4 * fix: 更新依赖项 * draft: 临时提交 * feat: 5.0.0-dev.5 * draft: 删除 MyCentralManager 和 MyPeripheralManager * fix: 更新依赖项 * fix: 更新依赖项 * feat: 适配新接口 * feat: 5.0.0-dev.6 * draft: 临时提交 * feat: 5.0.0-dev.7 * fix: 修改版本号 * feat: 5.0.0-dev.8 * feat: 5.0.0-dev.9 * fix: 修复 trimGATT 错误 * feat: 5.0.0-dev.6 * feat: 5.0.0-dev.3 * feat: 5.0.0-dev.4 * fix: 更新 pubspec.lock * feat: 5.0.0-dev.7 * feat: 5.0.0-dev.3 * fix: balabala * fix: balabala * draft: 5.0.0-dev.1 * fix: trim GATT when call the `writeCharacteristic` method. * fix: make difference of `trim` and `fragment`. * feat: 5.0.0-dev.1 * feat: 5.0.0-dev.1 * feat: 优化示例程序 * fix: 更新 README.md * fix: 修复插件引用 * draft: XXXX * feat: 增加调试信息 * fix: 更新 pubspec.lock * feat: 5.0.0-dev.4 * feat: 5.0.0-dev.3 * feat: 5.0.0 * feat: 5.0.0 * feat: 5.0.0 * feat: 5.0.0 * feat: 5.0.0 * feat: 5.0.0
221 lines
4.5 KiB
Dart
221 lines
4.5 KiB
Dart
import 'package:pigeon/pigeon.dart';
|
|
|
|
@ConfigurePigeon(
|
|
PigeonOptions(
|
|
dartOut: 'lib/src/my_api.g.dart',
|
|
dartOptions: DartOptions(),
|
|
dartPackageName: 'bluetooth_low_energy_windows',
|
|
cppHeaderOut: 'windows/my_api.g.h',
|
|
cppSourceOut: 'windows/my_api.g.cpp',
|
|
cppOptions: CppOptions(
|
|
namespace: 'bluetooth_low_energy_windows',
|
|
),
|
|
),
|
|
)
|
|
enum MyBluetoothLowEnergyStateArgs {
|
|
unknown,
|
|
disabled,
|
|
off,
|
|
on,
|
|
}
|
|
|
|
enum MyGattCharacteristicPropertyArgs {
|
|
read,
|
|
write,
|
|
writeWithoutResponse,
|
|
notify,
|
|
indicate,
|
|
}
|
|
|
|
enum MyGattCharacteristicWriteTypeArgs {
|
|
withResponse,
|
|
withoutResponse,
|
|
}
|
|
|
|
enum MyGattCharacteristicNotifyStateArgs {
|
|
none,
|
|
notify,
|
|
indicate,
|
|
}
|
|
|
|
class MyManufacturerSpecificDataArgs {
|
|
final int idArgs;
|
|
final Uint8List dataArgs;
|
|
|
|
MyManufacturerSpecificDataArgs(this.idArgs, this.dataArgs);
|
|
}
|
|
|
|
class MyAdvertisementArgs {
|
|
final String? nameArgs;
|
|
final List<String?> serviceUUIDsArgs;
|
|
final Map<String?, Uint8List?> serviceDataArgs;
|
|
final MyManufacturerSpecificDataArgs? manufacturerSpecificDataArgs;
|
|
|
|
MyAdvertisementArgs(
|
|
this.nameArgs,
|
|
this.serviceUUIDsArgs,
|
|
this.serviceDataArgs,
|
|
this.manufacturerSpecificDataArgs,
|
|
);
|
|
}
|
|
|
|
class MyCentralArgs {
|
|
final int addressArgs;
|
|
|
|
MyCentralArgs(this.addressArgs);
|
|
}
|
|
|
|
class MyPeripheralArgs {
|
|
final int addressArgs;
|
|
|
|
MyPeripheralArgs(this.addressArgs);
|
|
}
|
|
|
|
class MyGattDescriptorArgs {
|
|
final int handleArgs;
|
|
final String uuidArgs;
|
|
final Uint8List? valueArgs;
|
|
|
|
MyGattDescriptorArgs(
|
|
this.handleArgs,
|
|
this.uuidArgs,
|
|
this.valueArgs,
|
|
);
|
|
}
|
|
|
|
class MyGattCharacteristicArgs {
|
|
final int handleArgs;
|
|
final String uuidArgs;
|
|
final List<int?> propertyNumbersArgs;
|
|
final List<MyGattDescriptorArgs?> descriptorsArgs;
|
|
|
|
MyGattCharacteristicArgs(
|
|
this.handleArgs,
|
|
this.uuidArgs,
|
|
this.propertyNumbersArgs,
|
|
this.descriptorsArgs,
|
|
);
|
|
}
|
|
|
|
class MyGattServiceArgs {
|
|
final int handleArgs;
|
|
final String uuidArgs;
|
|
final List<MyGattCharacteristicArgs?> characteristicsArgs;
|
|
|
|
MyGattServiceArgs(
|
|
this.handleArgs,
|
|
this.uuidArgs,
|
|
this.characteristicsArgs,
|
|
);
|
|
}
|
|
|
|
@HostApi()
|
|
abstract class MyCentralManagerHostApi {
|
|
@async
|
|
void setUp();
|
|
void startDiscovery();
|
|
void stopDiscovery();
|
|
@async
|
|
void connect(int addressArgs);
|
|
void disconnect(int addressArgs);
|
|
@async
|
|
List<MyGattServiceArgs> discoverServices(int addressArgs);
|
|
@async
|
|
List<MyGattCharacteristicArgs> discoverCharacteristics(
|
|
int addressArgs,
|
|
int handleArgs,
|
|
);
|
|
@async
|
|
List<MyGattDescriptorArgs> discoverDescriptors(
|
|
int addressArgs,
|
|
int handleArgs,
|
|
);
|
|
@async
|
|
Uint8List readCharacteristic(int addressArgs, int handleArgs);
|
|
@async
|
|
void writeCharacteristic(
|
|
int addressArgs,
|
|
int handleArgs,
|
|
Uint8List valueArgs,
|
|
int typeNumberArgs,
|
|
);
|
|
@async
|
|
void setCharacteristicNotifyState(
|
|
int addressArgs,
|
|
int handleArgs,
|
|
int stateNumberArgs,
|
|
);
|
|
@async
|
|
Uint8List readDescriptor(int addressArgs, int handleArgs);
|
|
@async
|
|
void writeDescriptor(int addressArgs, int handleArgs, Uint8List valueArgs);
|
|
}
|
|
|
|
@FlutterApi()
|
|
abstract class MyCentralManagerFlutterApi {
|
|
void onStateChanged(int stateNumberArgs);
|
|
void onDiscovered(
|
|
MyPeripheralArgs peripheralArgs,
|
|
int rssiArgs,
|
|
MyAdvertisementArgs advertisementArgs,
|
|
);
|
|
void onConnectionStateChanged(
|
|
int addressArgs,
|
|
bool stateArgs,
|
|
);
|
|
void onCharacteristicNotified(
|
|
int addressArgs,
|
|
int handleArgs,
|
|
Uint8List valueArgs,
|
|
);
|
|
}
|
|
|
|
@HostApi()
|
|
abstract class MyPeripheralManagerHostApi {
|
|
@async
|
|
void setUp();
|
|
@async
|
|
void addService(MyGattServiceArgs serviceArgs);
|
|
void removeService(int handleArgs);
|
|
void clearServices();
|
|
@async
|
|
void startAdvertising(MyAdvertisementArgs advertisementArgs);
|
|
void stopAdvertising();
|
|
void sendReadCharacteristicReply(
|
|
int addressArgs,
|
|
int handleArgs,
|
|
bool statusArgs,
|
|
Uint8List valueArgs,
|
|
);
|
|
void sendWriteCharacteristicReply(
|
|
int addressArgs,
|
|
int handleArgs,
|
|
bool statusArgs,
|
|
);
|
|
@async
|
|
void notifyCharacteristic(
|
|
int addressArgs,
|
|
int handleArgs,
|
|
Uint8List valueArgs,
|
|
);
|
|
}
|
|
|
|
@FlutterApi()
|
|
abstract class MyPeripheralManagerFlutterApi {
|
|
void onStateChanged(int stateNumberArgs);
|
|
void onReadCharacteristicCommandReceived(
|
|
MyCentralArgs centralArgs,
|
|
int handleArgs,
|
|
);
|
|
void onWriteCharacteristicCommandReceived(
|
|
MyCentralArgs centralArgs,
|
|
int handleArgs,
|
|
Uint8List valueArgs,
|
|
);
|
|
void onCharacteristicNotifyStateChanged(
|
|
MyCentralArgs centralArgs,
|
|
int handleArgs,
|
|
bool stateArgs,
|
|
);
|
|
}
|