Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add on write handler and errors #36

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rohitsangwan01
Copy link
Contributor

@rohitsangwan01 rohitsangwan01 commented Jun 19, 2022

Added onWriteValue Handler , which will pass DeviceId , Characteristic and String? Error
if Error Null , means Success Write Call

also Added error in OnConnectionStatusChang , to get Correct reason of Disconnection , on Flutter Side

Currently implemented in
Mac / Ios/ Android

Copy link
Collaborator

@Sunbreak Sunbreak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many changes in only one PR. If you want other errors, then commit with different PRs please

cleanConnection(gatt)
sendMessage(messageConnector, mapOf(
"deviceId" to gatt.device.address,
"ConnectionState" to "disconnected"
"ConnectionState" to "disconnected",
"error" to "Disconnection Reason : Status $status"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to connection error's PR

sendMessage(messageConnector, mapOf(
"deviceId" to deviceID,
"characteristic" to characteristic.uuid.toString(),
"error" to "Write Command Status : $status"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Write Command Status : $status" is a error message, not a program recongized code

An ErrorCode with optional ErrorMessage is a better choice

@@ -200,12 +200,22 @@ extension QuickBlueDarwin: CBCentralManagerDelegate {
"ConnectionState": "connected",
])
}

public func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral,error: Error?) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to connection error's PR


public func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {
print("centralManager:didDisconnectPeripheral: \(peripheral.uuid.uuidString) error: \(String(describing: error))")
messageConnector.sendMessage([
"deviceId": peripheral.uuid.uuidString,
"ConnectionState": "disconnected",
"error": String(describing: error)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to connection error's PR

@@ -248,6 +258,7 @@ extension QuickBlueDarwin: CBPeripheralDelegate {
}
self.messageConnector.sendMessage([
"deviceId": peripheral.uuid.uuidString,
"error": String(describing: error),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to discover error's PR

}
}

@override
Future<void> setNotifiable(String deviceId, String service, String characteristic, BleInputProperty bleInputProperty) async {
_method.invokeMethod('setNotifiable', {
await _method.invokeMethod('setNotifiable', {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to notify error's PR

@@ -106,7 +109,7 @@ class MethodChannelQuickBlue extends QuickBluePlatform {

@override
Future<void> readValue(String deviceId, String service, String characteristic) async {
_method.invokeMethod('readValue', {
await _method.invokeMethod('readValue', {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to read error's PR

@@ -134,7 +137,7 @@ class MethodChannelQuickBlue extends QuickBluePlatform {

@override
Future<int> requestMtu(String deviceId, int expectedMtu) async {
_method.invokeMethod('requestMtu', {
await _method.invokeMethod('requestMtu', {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to mtu error's PR

@@ -103,19 +103,24 @@ class QuickBlueLinux extends QuickBluePlatform {
@override
void connect(String deviceId) {
_findDeviceById(deviceId).connect().then((_) {
onConnectionChanged?.call(deviceId, BlueConnectionState.connected);
onConnectionChanged?.call(deviceId, BlueConnectionState.connected,null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to connection error's PR


OnServiceDiscovered? onServiceDiscovered;

Future<void> setNotifiable(String deviceId, String service, String characteristic, BleInputProperty bleInputProperty);

OnValueChanged? onValueChanged;

OnWrite? onWrite;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OnWriteValue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants