handle timeout, disconnect, reconnect
When the underlying MDS library gets a timeout exception, it disconnects and reconnects to the Movesense device.
With the way I have the plugin written now, this triggers a second return on the MethodChannel from connect
, which in turn crashes the app.
I/Komposti(13121): [SDS RESPONSE] type: POST status: CREATED header: {"Location": "194430000790", "TaskId": 45, "Uri": "suunto://MDS/ConnectedDevices", "Content-Length": 0, "Reason": "CREATED", "Status": 201}
D/MdsOperationHandler(13121): SDSInternalCallback with call type: 2 header: {"Content-Type": "application/json", "Uri": "MDS/EventListener/24", "Content-Length": 702, "Reason": "CUSTOM_STATUS", "Status": 0}
D/Mds (13121): mdsConnectionListener onNotification: {"Response": {"Status": 201}, "Body": {"DeviceInfo": {"Mode": 5, "SwVersion": "1.9.4", "productName": "Movesense", "design": null, "addressInfo": [{"name": "BLE", "address": "0C-8C-DC-31-6F-C0"}, {"name": "DFU-BLE", "address": "CC-6A-31-07-38-D6"}], "brandName": null, "manufacturerName": "Suunto", "hwCompatibilityId": "C", "hw": "H3", "variant": "Avocado", "sw": "1.9.4", "serial": "194430000790", "additionalVersionInfo": null, "pcbaSerial": "91091328880937100000100022666H3194", "Serial": "194430000790", "Description": "", "apiLevel": "1", "Name": "Movesense"}, "Connection": {"UUID": "10000002", "Type": "BLE"}, "Serial": "194430000790"}, "Uri": "suunto://MDS/ConnectedDevices", "Method": "POST"}
V/Mds (13121): - connected: true
V/Mds (13121): - disconnected: false
V/Mds (13121): - status: 201
V/Mds (13121): - serial: 194430000790
V/Mds (13121): - bleMacAddess: 0C:8C:DC:31:6F:C0
D/MovesenseFlutterPlugin(13121): mds.connect onConnectionComplete: MAC: 0C:8C:DC:31:6F:C0, serial #: 194430000790
D/MovesenseFlutterPlugin(13121): returning serial # 194430000790 as type Long
D/AndroidRuntime(13121): Shutting down VM
E/AndroidRuntime(13121): FATAL EXCEPTION: main
E/AndroidRuntime(13121): Process: works.otter.movesense_log, PID: 13121
E/AndroidRuntime(13121): java.lang.IllegalStateException: Reply already submitted