-
Notifications
You must be signed in to change notification settings - Fork 64
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
base: master
Are you sure you want to change the base?
Add on write handler and errors #36
Conversation
There was a problem hiding this 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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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?) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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', { |
There was a problem hiding this comment.
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', { |
There was a problem hiding this comment.
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', { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OnWriteValue
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