feat: 5.0.0 (#35)

* 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
This commit is contained in:
iAMD
2023-12-31 00:53:48 +08:00
committed by GitHub
parent cfe0eda4a3
commit 87fe3e2447
137 changed files with 14108 additions and 8393 deletions

View File

@ -8,152 +8,54 @@ import 'package:pigeon/pigeon.dart';
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,
);
enum MyBluetoothLowEnergyStateArgs {
unknown,
resetting,
unsupported,
unauthorized,
poweredOff,
poweredOn,
}
@FlutterApi()
abstract class MyCentralManagerFlutterApi {
void onStateChanged(int stateNumberArgs);
void onDiscovered(
MyPeripheralArgs peripheralArgs,
int rssiArgs,
MyAdvertisementArgs advertisementArgs,
);
void onPeripheralStateChanged(
MyPeripheralArgs peripheralArgs,
bool stateArgs,
);
void onCharacteristicValueChanged(
MyGattCharacteristicArgs characteristicArgs,
Uint8List valueArgs,
);
enum MyGattCharacteristicPropertyArgs {
read,
write,
writeWithoutResponse,
notify,
indicate,
}
@HostApi()
abstract class MyPeripheralManagerHostApi {
@async
MyPeripheralManagerArgs setUp();
@async
void addService(MyGattServiceArgs serviceArgs);
void removeService(int serviceHashCodeArgs);
void clearServices();
@async
void startAdvertising(MyAdvertisementArgs advertisementArgs);
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,
);
enum MyGattCharacteristicWriteTypeArgs {
withResponse,
withoutResponse,
}
@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,
);
enum MyGattErrorArgs {
success,
invalidHandle,
readNotPermitted,
writeNotPermitted,
invalidPDU,
insufficientAuthentication,
requestNotSupported,
invalidOffset,
insufficientAuthorization,
prepareQueueFull,
attributeNotFound,
attributeNotLong,
insufficientEncryptionKeySize,
invalidAttributeValueLength,
unlikelyError,
insufficientEncryption,
unsupportedGroupType,
insufficientResources,
}
class MyCentralManagerArgs {
final int stateNumberArgs;
class MyManufacturerSpecificDataArgs {
final int idArgs;
final Uint8List dataArgs;
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);
MyManufacturerSpecificDataArgs(this.idArgs, this.dataArgs);
}
class MyAdvertisementArgs {
@ -170,22 +72,27 @@ class MyAdvertisementArgs {
);
}
class MyManufacturerSpecificDataArgs {
final int idArgs;
final Uint8List dataArgs;
class MyCentralArgs {
final String uuidArgs;
MyManufacturerSpecificDataArgs(this.idArgs, this.dataArgs);
MyCentralArgs(this.uuidArgs);
}
class MyGattServiceArgs {
class MyPeripheralArgs {
final String uuidArgs;
MyPeripheralArgs(this.uuidArgs);
}
class MyGattDescriptorArgs {
final int hashCodeArgs;
final String uuidArgs;
final List<MyGattCharacteristicArgs?> characteristicsArgs;
final Uint8List? valueArgs;
MyGattServiceArgs(
MyGattDescriptorArgs(
this.hashCodeArgs,
this.uuidArgs,
this.characteristicsArgs,
this.valueArgs,
);
}
@ -203,39 +110,118 @@ class MyGattCharacteristicArgs {
);
}
class MyGattDescriptorArgs {
class MyGattServiceArgs {
final int hashCodeArgs;
final String uuidArgs;
final Uint8List? valueArgs;
final List<MyGattCharacteristicArgs?> characteristicsArgs;
MyGattDescriptorArgs(
MyGattServiceArgs(
this.hashCodeArgs,
this.uuidArgs,
this.valueArgs,
this.characteristicsArgs,
);
}
enum MyBluetoothLowEnergyStateArgs {
unknown,
unsupported,
unauthorized,
poweredOff,
poweredOn,
@HostApi()
abstract class MyCentralManagerHostApi {
void setUp();
void startDiscovery();
void stopDiscovery();
@async
void connect(String uuidArgs);
@async
void disconnect(String uuidArgs);
int getMaximumWriteValueLength(String uuidArgs, int typeNumberArgs);
@async
int readRSSI(String uuidArgs);
@async
List<MyGattServiceArgs> discoverServices(String uuidArgs);
@async
List<MyGattCharacteristicArgs> discoverCharacteristics(
String uuidArgs,
int hashCodeArgs,
);
@async
List<MyGattDescriptorArgs> discoverDescriptors(
String uuidArgs,
int hashCodeArgs,
);
@async
Uint8List readCharacteristic(String uuidArgs, int hashCodeArgs);
@async
void writeCharacteristic(
String uuidArgs,
int hashCodeArgs,
Uint8List valueArgs,
int typeNumberArgs,
);
@async
void setCharacteristicNotifyState(
String uuidArgs,
int hashCodeArgs,
bool stateArgs,
);
@async
Uint8List readDescriptor(String uuidArgs, int hashCodeArgs);
@async
void writeDescriptor(String uuidArgs, int hashCodeArgs, Uint8List valueArgs);
}
enum MyGattCharacteristicPropertyArgs {
read,
write,
writeWithoutResponse,
notify,
indicate,
@FlutterApi()
abstract class MyCentralManagerFlutterApi {
void onStateChanged(int stateNumberArgs);
void onDiscovered(
MyPeripheralArgs peripheralArgs,
int rssiArgs,
MyAdvertisementArgs advertisementArgs,
);
void onConnectionStateChanged(String uuidArgs, bool stateArgs);
void onCharacteristicNotified(
String uuidArgs,
int hashCodeArgs,
Uint8List valueArgs,
);
}
enum MyGattCharacteristicWriteTypeArgs {
// Write with response
withResponse,
// Write without response
withoutResponse,
// Write with response and waiting for confirmation
// reliable,
@HostApi()
abstract class MyPeripheralManagerHostApi {
void setUp();
@async
void addService(MyGattServiceArgs serviceArgs);
void removeService(int hashCodeArgs);
void clearServices();
@async
void startAdvertising(MyAdvertisementArgs advertisementArgs);
void stopAdvertising();
int getMaximumUpdateValueLength(String uuidArgs);
void respond(int idArgs, int errorNumberArgs, Uint8List? valueArgs);
@async
void updateCharacteristic(
int hashCodeArgs,
Uint8List valueArgs,
List<String>? uuidsArgs,
);
}
@FlutterApi()
abstract class MyPeripheralManagerFlutterApi {
void onStateChanged(int stateNumberArgs);
void onCharacteristicReadRequest(
MyCentralArgs centralArgs,
int hashCodeArgs,
int idArgs,
int offsetArgs,
);
void onCharacteristicWriteRequest(
MyCentralArgs centralArgs,
int hashCodeArgs,
int idArgs,
int offsetArgs,
Uint8List valueArgs,
);
void onCharacteristicNotifyStateChanged(
MyCentralArgs centralArgs,
int hashCodeArgs,
bool stateArgs,
);
}