“ CoreBluetooth / CBATTErrorDomain代码= 6”不支持该请求。

时间:2019-01-20 11:25:43

标签: ios swift core-bluetooth

Declare @ds TABLE (id int, value int, acc_no int, dt datetime) INSERT INTO @ds SELECT 1, 12, 1, '2019-01-01 07:40:38.250' UNION SELECT 2, 14, 1, '2019-01-02 07:41:05.883' UNION SELECT 3, 15, 1, '2019-01-13 07:41:22.377' UNION SELECT 4, 10, 2, '2019-01-14 08:15:53.403' UNION SELECT 5, 16, 2, '2019-01-03 13:52:47.347' UNION SELECT 6, 19, 1, '2019-01-09 13:53:56.317' UNION SELECT 7, 7, 3, '2019-01-17 00:00:00.000' UNION SELECT 8, 24, 2, '2019-01-17 00:00:00.000' UNION SELECT 9, 19, 2, '2019-01-02 00:00:00.000' UNION SELECT 10, 7, 1, '2019-01-07 00:00:00.000' UNION SELECT 11, 24, 1, '2019-01-05 14:12:47.080' UNION SELECT 12, 20, 3, '2019-01-28 00:00:00.000' SELECT id, value, acc_no, dt, value - previous AS result FROM ( SELECT ROW_NUMBER() OVER (PARTITION BY DS1.id ORDER BY DS2.dt DESC) AS rn ,DS1.*, COALESCE(DS2.value,0) AS previous FROM @ds DS1 LEFT JOIN @ds DS2 ON DS2.acc_no = DS1.acc_no AND DS2.dt < DS1.dt ) AS dt WHERE rn = 1 一起使用时,读取特性值时,我在CoreBluetooth协议的 peripheral(_:didUpdateValueFor:error:)函数中遇到错误

我一直在调试控制台中收到此消息:

CBPeripheralDelegate

我为解决该问题所做的一切尝试都失败了。

有人有这样的经验并找到了解决方案吗?

以下是一些相关代码:

Error in peripheral(_:didUpdateValueFor:error:) :
Error Domain=CBATTErrorDomain Code=6 "The request is not supported."
      UserInfo={NSLocalizedDescription=The request is not supported.}

这是外围应用程序中创建特征的代码块:

// CBPeripheralDelegate protocol implementation.

func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
    print(#function)
    if error != nil {
        print("Error in \(#function) :\n\(error!)")
        return
    }

    for service in peripheral.services ?? [] {
        print("Discovered service \(service)")
        if service.uuid == service_UUID {
            peripheral.discoverCharacteristics(nil, for: service)
            //peripheral.discoverCharacteristics([svcCharac_UUID], for: service) (Same problem!)
        }
    }
}


func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor
    service: CBService, error: Error?) {
    print(#function)
    if error != nil {
        print("Error in \(#function) :\n\(error!)")
        return
    }

    for characteristic in service.characteristics ?? [] {
        print("Discovered characteristic \(characteristic)")
        if characteristic.uuid ==  svcCharac_UUID {
            peripheral.setNotifyValue(true, for: characteristic)
            peripheral.readValue(for: characteristic)
        }
    }
}


func peripheral(_ peripheral: CBPeripheral,
                didUpdateValueFor characteristic: CBCharacteristic,
                error: Error?) {
    print(#function)
    if error != nil {
        print("Error in \(#function) :\n\(error!)")
        return
    }

    .................
}

0 个答案:

没有答案