steamclock / bluejay

A simple Swift framework for building reliable Bluetooth LE apps.
MIT License
1.09k stars 98 forks source link

Feature Request - Indications and Notifications #268

Open beachcitiessoftware opened 1 year ago

beachcitiessoftware commented 1 year ago

Summary: I need to be able to distinguish between incoming BLE indications and incoming BLE notifications. I can't find a way to do this now, with the current BlueJay::listen methods. I would greatly appreciate having this feature added. You could use the following logic, then expose a new listen method, or extend ReadResult to indicate which it is.

func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {

        let isIndication = characteristic.isNotifying && characteristic.properties.contains(CBCharacteristicProperties.indicate) && !characteristic.properties.contains(CBCharacteristicProperties.notify)
        let isNotification = characteristic.isNotifying && characteristic.properties.contains(CBCharacteristicProperties.notify) && !characteristic.properties.contains(CBCharacteristicProperties.indicate)

// ...