-
Notifications
You must be signed in to change notification settings - Fork 67
Add on write handler and errors #36
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
base: master
Are you sure you want to change the base?
Add on write handler and errors #36
Conversation
Sunbreak
left a comment
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
| "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
| ]) | ||
| } | ||
|
|
||
| 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
| 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
| } | ||
| 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
| @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
| @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
| 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
|
|
||
| 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