troystribling / BlueCap

iOS Bluetooth LE framework
MIT License
714 stars 114 forks source link

CBMutableDescriptors can't be added to MutableCharacteristics #65

Closed MrCocoDev closed 7 years ago

MrCocoDev commented 7 years ago

As far as I can tell there is no way to add a CDMutableDescriptor to BlueCap's MutableCharacteristic class. The underlying CBMutableCharacteristic is not exposed either so there is no way to add the descriptors directly to the characteristic itself.

troystribling commented 7 years ago

CDMutableDescriptor is not currently supported because I have one seen them implemented on a device.

MrCocoDev commented 7 years ago

I'm in the process of trying to implement the HID specification and they are required. Would it be possible to make the underlying characteristic visible as a short term workaround until a larger need for CBMutableDescriptors arise?

troystribling commented 7 years ago

I am sure not understand this question "Would it be possible to make the underlying characteristic visible?".

Now the interfaces to access Descriptors are not exposed on the protocols that wrap the CoreBluetooth objects. You could add the methods to discover, access and add descriptors to the protocols to expose them. The CoreBluetooth wrapper protocols are here https://github.com/troystribling/BlueCap/blob/master/BlueCapKit/Injectables.swift. You could add the methods you need to the appropriate protocols. You could then write methods on BlueCapKit Peripheral and Characteristic that delegate to these methods on the CoreBluetooth objects.

MrCocoDev commented 7 years ago

I'm willing to take a stab at it, but I've only just figured out how to use this library. If you can give me some help I'm willing to put in the effort!

MrCocoDev commented 7 years ago

Hmmm... That was a lot easier than I was expecting. All I did was add a function that exposed .descriptors on the underlying CBCharacteristic. I imagine its not in line with the spirit of the project, but it seems to be sufficient for what I need. Swift is cool language...

troystribling commented 7 years ago

To get things working so that it useful is a small change.Making it as a first level citizen is not much more work. If you want to keep using the framework we can discuss it further.