steamclock / bluejay

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

Successful Write but Disconnection on Data Retrieval #272

Open pksa opened 6 months ago

pksa commented 6 months ago

Summary: Device: Buerer BM96 The connection is lost when attempting to write to the characteristic.

`let writeHeartRateCharacteristic = CharacteristicIdentifier( uuid: BM96CharacteristicUUID.heartServiceUUID.rawValue, service: ServiceIdentifier(uuid: BM96CharacteristicUUID.customServiceUUID.rawValue) )

private func writeGetAllHeartUser1Measurements() {
    let OP_CODE_REPORT_STORED_RECORDS: UInt8 = 0x02
    let OPERATOR_SENDING_RECORD_1: UInt8 = 0x00
    let OPERATOR_SENDING_RECORD_2: UInt8 = 0x00

    let command = [OP_CODE_REPORT_STORED_RECORDS, OPERATOR_SENDING_RECORD_1, OPERATOR_SENDING_RECORD_2]

    bluejay.write(to: writeHeartRateCharacteristic, value: Data(command), type: .withoutResponse) { result in
        switch result {
        case .success:
            Logger.shared.log("Write to sensor location is successful.")
            self.listenHeartRateData()

        case .failure(let error):
            print("Failed to write sensor location with error: \(error.localizedDescription)")
        }
    }
}`

Actual Result: Write to sensor location is successful. failure(Bluejay.BluejayError.notConnected) Failed to listen to heart rate with error: Not connected to a peripheral

Expected Result: Retrieve data upon successful write. Also, do not disconnect device.

Device, Build, OS: