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

Unexpectedly found nil while unwrapping an Optional value #497

Open
dthornley opened this issue Mar 3, 2019 · 7 comments
Open

Unexpectedly found nil while unwrapping an Optional value #497

dthornley opened this issue Mar 3, 2019 · 7 comments

Comments

@dthornley
Copy link

dthornley commented Mar 3, 2019

When using the omnipod-testing branch the above error is being shown when I run RileyLink on my iPhone via xcode. The error is being shown when I click on cancel or pair in the Pod Pairing screen.

The errors are being raised from the functions cancelButtonPressed() and pair() in OmniKitUI/ViewControllers/PairPodSetupViewController.swift when the pumpManager is being used.

I'm new to swift, but I did notice that pumpManager is still nil when the getPodState or pairAndPrime methods are called.

@matthewjweaver
Copy link

I can reproduce reliably by clicking cancel after arriving on the pod setup dialog.

@dthornley
Copy link
Author

dthornley commented Mar 7, 2019

Logs from Xcode when clicking on Cancel:

2019-03-07 18:58:44.447840+0100 RileyLink[14016:2864356] [RileyLinkDeviceManager] centralManagerDidUpdateState: Powered On
2019-03-07 18:58:44.490171+0100 RileyLink[14016:2864356] [RileyLinkDeviceManager] Discovered <CBPeripheral: 0x281649040, identifier = DF339946-4D62-2EBB-4F4E-65BC7A259AC6, name = RileyLink, state = disconnected> at -66
2019-03-07 18:58:44.509875+0100 RileyLink[14016:2864355] [PeripheralManager] Error applying peripheral configuration: notReady
2019-03-07 18:58:44.509934+0100 RileyLink[14016:2864355] [RileyLinkDevice] Reading firmware versions for PeripheralManager configuration
2019-03-07 18:58:44.511522+0100 RileyLink[14016:2864355] [PeripheralManager] Error applying delegate configuration: peripheralManagerError(RileyLinkBLEKit.PeripheralManagerError.unknownCharacteristic)
2019-03-07 18:58:44.516396+0100 RileyLink[14016:2864356] [RileyLinkDeviceManager] Created device for peripheral <CBPeripheral: 0x281649040, identifier = DF339946-4D62-2EBB-4F4E-65BC7A259AC6, name = RileyLink, state = disconnected>
2019-03-07 18:58:44.516758+0100 RileyLink[14016:2864358] [PeripheralManager] Error applying peripheral configuration: notReady
2019-03-07 18:58:44.516999+0100 RileyLink[14016:2864358] [RileyLinkDevice] Reading firmware versions for PeripheralManager configuration
2019-03-07 18:58:44.519205+0100 RileyLink[14016:2864358] [PeripheralManager] Error applying delegate configuration: peripheralManagerError(RileyLinkBLEKit.PeripheralManagerError.unknownCharacteristic)
2019-03-07 18:58:44.545823+0100 RileyLink[14016:2864243] applicationDidBecomeActive
2019-03-07 18:58:45.139787+0100 RileyLink[14016:2864358] [RileyLinkDeviceManager] Discovered <CBPeripheral: 0x281649040, identifier = DF339946-4D62-2EBB-4F4E-65BC7A259AC6, name = RileyLink, state = connecting> at -65
2019-03-07 18:58:45.168726+0100 RileyLink[14016:2864358] [RileyLinkDevice] didConnect <CBPeripheral: 0x281649040, identifier = DF339946-4D62-2EBB-4F4E-65BC7A259AC6, name = RileyLink, state = connected>
2019-03-07 18:58:45.220909+0100 RileyLink[14016:2864356] [RileyLinkDevice] didConnect <CBPeripheral: 0x281649040, identifier = DF339946-4D62-2EBB-4F4E-65BC7A259AC6, name = RileyLink, state = connected>
2019-03-07 18:58:45.315415+0100 RileyLink[14016:2864355] [PeripheralManager] Peripheral configuration completed
2019-03-07 18:58:45.315462+0100 RileyLink[14016:2864355] [RileyLinkDevice] Reading firmware versions for PeripheralManager configuration
2019-03-07 18:58:45.474961+0100 RileyLink[14016:2864355] [PeripheralManager+RileyLink] RL Send (single): 0102
2019-03-07 18:58:45.585893+0100 RileyLink[14016:2864358] [PeripheralManager+RileyLink] RL Recv(single): dd737562675f726673707920322e32
2019-03-07 18:58:45.587905+0100 RileyLink[14016:2864358] [PeripheralManager+RileyLink] RileyLink response1: GetVersionResponse(code: RileyLinkBLEKit.ResponseCode.success, version: "subg_rfspy 2.2")
2019-03-07 18:58:45.588085+0100 RileyLink[14016:2864355] [PeripheralManager] Delegate configuration completed

Logs for when you click on Pair are the same.

@dthornley
Copy link
Author

Screenshot of the UI for the above logs.

file

@Lytrix
Copy link

Lytrix commented Mar 9, 2019

I've took a shot at looking into this. It looks like nil is returned on the OmnipodPumpManager which is Force unwrapped here:
https://github.com/ps2/rileylink_ios/blob/omnipod-testing/OmniKitUI/ViewControllers/PairPodSetupViewController.swift#L19
It returns a nil here:
pumpManager returns nil

Could it be that the OmnipodPumpManager cannot be loaded into the pumpManager variable? @ps2 do you have any pointers or an example if I am on the right track or where I could look further or maybe a similar example of the Medtronic loading of the pumpmanager?

@ps2
Copy link
Owner

ps2 commented Mar 9, 2019

The hosting nav controller should be passing the pump manager to its viewcontrollers.

@jasoncalabrese
Copy link

Is there a fix for this?

@Lytrix
Copy link

Lytrix commented Mar 31, 2019

@jasoncalabrese Not yet, The nil is returned because the omnipod pairing storyboard in xcode has a page before the pairing steps are starting to setup a basal schedule. In our Loop test setup this route is correctly shown the first time setting it up, but in rileylink_ios this page is apparently ignored on the first run resulting in a nil basal schedule. I do not have worked enough with storyboards yet to know how to reroute this in a proper way.

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

No branches or pull requests

5 participants