Closed pursual closed 4 years ago
Hi, we already cache services and characteristics after the first access see here
PeripheralWinrt::GetService
will first check if the service is already in the cache and if not it will ask windows to get the service 'from the device' and cache it
Yes, I'm referring to manually adding to the cache, without any access at all to the device. This is useful in situations where you are always connecting to the same type of device, and want to import the services from a file, as opposed to having to discover them. It's faster. You can see how it works in the examples I mentioned in noble.
Windows takes care of the services, what you could use is GetGattServicesForUuidAsync with BluetoothCacheMode = Cached
to try to get the service without asking the device and if that fails try it with BluetoothCacheMode = Uncached
This is a different concept. This is telling winrt what services exist, not asking it. Please look at the example code in noble.
Could you provide a link to the code? I can't find in the noble example directory.
Anyway unfortunately I don't think that this is possible with winrt as Windows takes care of the service discovery and caching.
Sorry, its in the @abandonware fork, which is probably the most popular now. https://github.com/abandonware/noble/tree/master/examples
I came to the same conclusion that it might be hard to create a windows service object outside of discovery. There does appear to be a few constructors.
Closing, this is probably not possible with any binding other than the hci.
Noble has a caching mechanism for services/chars. See the examples folder for
cache-gatt
. For a binding to support this, it needs to have an addService and addCharacteristic method.Do we know if it would be possible to create a windows
GattDeviceService
orGattCharacteristic
manually, and inject it intocachedServices/Chars
?I looked at service, and the noble representation is
I was unable to determine how I would create this manually from looking at: https://docs.microsoft.com/en-us/uwp/api/windows.devices.bluetooth.genericattributeprofile.gattdeviceservice?view=winrt-19041
I assume you would need to call some GattDeviceService constructor, and then somehow set the uuid and handles? Sorry, C++ is not my forte.