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

Fixing uuidAsString calls in Helper key method #1237

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

BMR11
Copy link
Contributor

@BMR11 BMR11 commented Jun 17, 2024

In iOS code, We are building a unique key for a given peripheral / characteristic / descriptor, with using Helper.key method.

Here we are using peripheral.uuidAsString to build the final key but as this is a function and not a value, this will always return instead of the actual uuid string. and so, if we are reading BLE characteristic values for different peripherals, it will always return the same key. And eventually app will be updated with the same readcallbacks every time instead of reporting readcallbacks as per peripheral.
To get the correct string we should be calling peripheral.uuidAsString() and so we get a unique key built for each use-case

Understanding by printing values:

static func key(forPeripheral peripheral: CBPeripheral,
                   andCharacteristic characteristic: CBCharacteristic) -> String {
       print("uuidAsString=>%@",peripheral.uuidAsString)
       print("uuidAsString()=>%@",peripheral.uuidAsString())
       print("old1 %@","\(String(describing: peripheral.uuidAsString))|\(characteristic.uuid)")
       print("new1  %@","\(String(describing: peripheral.uuidAsString()))|\(characteristic.uuid)")
       return "\(String(describing: peripheral.uuidAsString))|\(characteristic.uuid)"
   }

We get logs

uuidAsString=>%@ (Function)
uuidAsString()=>%@ my-actual-uuid-for-this-peripheral
old1 %@ (Function)|my-actual-uuid-for-this-characteristic
new1  %@ my-actual-uuid-for-this-peripheral|my-actual-uuid-for-this-characteristic

@BMR11
Copy link
Contributor Author

BMR11 commented Jun 17, 2024

@marcosinigaglia ,
This is a syntax usage error that is replacing calls from peripheral.uuidAsString to peripheral.uuidAsString().
In our use case, we are reading multiple ble sensors and the app is always getting the same read values due to this issue,
Let me know if you need to have more details on this.

@marcosinigaglia
Copy link
Member

Hi @BMR11 thanks!

@marcosinigaglia marcosinigaglia merged commit 8840db3 into innoveit:master Jun 18, 2024
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.

2 participants