Have a bug in our app using Genric BLE channel.
Device is connected to garmin and characteristics are being written to device, we are merrily going through scenarios where connection is lost and regained (noisy env, obstructions).
Each time we get a reconnection we "freshen" service and chracteristics and 99% of time things keep on working fine.
Just occasionally that black spot where connection is blocked seems to be a little longer and on this occasion while trying to do that "freshen", I see "Error:Unexpected Type Error Details: Failed invoking symbol.
Char written 3F4E1401-D5C9-46C3-A2A5-090606023D85 status 0 Location Characteristic written 0 Char written 3F4E1401-D5C9-46C3-A2A5-090606023D85 status 0 Location Characteristic written 0 Char written 3F4E1401-D5C9-46C3-A2A5-090606023D85 status 0 Location Characteristic written 0 Char written 3F4E1401-D5C9-46C3-A2A5-090606023D85 status 0 Location Characteristic written 0 Char written 3F4E1401-D5C9-46C3-A2A5-090606023D85 status 0 Location Characteristic written 0 procConnection Obj: 218 status 0 procConnection Obj: 218 status 1 Error: Unexpected Type Error Details: Failed invoking <symbol> Stack: - freshenServiceAndChracteristics() at C:\NordicSemi\garmin\NovaThingy\source\NovaProfileModel.mc:40 0x1000012d - procDeviceConnected() at C:\NordicSemi\garmin\NovaThingy\source\DeviceDataModel.mc:98 0x10000eb0 - procConnection() at C:\NordicSemi\garmin\NovaThingy\source\DeviceDataModel.mc:35 0x10000caa - onConnectedStateChanged() at C:\NordicSemi\garmin\NovaThingy\source\ThingyDelegate.mc:30 0x1000096d
The procConnection Obj, status is the device and status from the BleDelegte.onConnectedStateChange().
function freshenServiceAndChracteristics() { _service = _device.get().getService( _profileManager.NOVA_SERVICE ); _pendingNotifies = []; _locationCharacteristic = _service.getCharacteristic( _profileManager.LOCATION_CHARACTERISTIC); _commandCharacteristic = _service.getCharacteristic( _profileManager.COMMAND_CHARACTERISTIC); _statusCharacteristic = _service.getCharacteristic( _profileManager.STATUS_CHARACTERISTIC); if( null != _statusCharacteristic ) { _pendingNotifies = _pendingNotifies.add( _statusCharacteristic ); } activateNextNotification(); }
And stack trace seems to indicate its on that first _service.getCharacteristic() it fails; but it seems to have done the _device.get().getService() ok.
I am at a loss to know why this logic seems to work 99% of times then just occasionaly fail. Has something in the background been timed out (garbage collected?) and is now nolonger valid? Why would the getService() work, but get this type of error on the getCharacteristic().
Any hints greatfuly accepted.