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

Support for CoreBluetooth changes by iOS15 #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jooyyy
Copy link

@jooyyy jooyyy commented Sep 23, 2021

No description provided.

@netizen01
Copy link
Contributor

Thanks! Let me do a quick check on this and I'll merge.

@@ -275,7 +275,7 @@ extension Sensor: CBPeripheralDelegate {

/// :nodoc:
public func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
guard let service = services[characteristic.service.uuid.uuidString] else { return }
guard let service = services[characteristic.service?.uuid.uuidString ?? ""] else { return }
Copy link

@jlevine22 jlevine22 Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought but would it logically make more sense to use guard to check for the service/uuidString instead of defaulting to an empty string?

guard let uuidString = characteristic.service?.uuid.uuidString, let service = services[uuidString] else { return }

Functionally I think they're about the same but it seems weird you might try to access a service with the uuid of ""

Copy link
Contributor

@netizen01 netizen01 Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the service param change from an optional? you can't access a map value with an optional key, hence the ""

Edit: ... I think the service param here became an optional, so the "" is necessary.

... this might be weird...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is a callback from CoreBluetooth. You're already indexing services by uuid. If for some reason CB sends you an update for a service without a UUID, you're basically screwed, so, I'd say ignore it.

        guard let serviceUUID = characteristic.service?.uuid.uuidString else { return }
        guard let service = services[serviceUUID] else { return }

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

Successfully merging this pull request may close these issues.

4 participants