从 "Accu-Chek Aviva Connect"BG 仪表收集数据的 iOS 应用程序。 (低功耗蓝牙)

标签 ios iphone bluetooth bluetooth-lowenergy core-bluetooth

我正在尝试创建一个 iOS 应用程序,该应用程序将从 Accu-Chek Aviva Connect 收集数据。

为了与 BG 仪表配对,我发送写入请求以记录访问控制点特征:

- (void)peripheral:(CBPeripheral *)aPeripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error {

    if ([service.UUID isEqual:[CBUUID UUIDWithString:@"1808"]]) {
        for (CBCharacteristic *aChar in service.characteristics) {

            // Read Glucose Measurement...

            // Read Glucose Measurement Context...

            // Read Glucose Feature...

            // Read Date Time...

            // Read Record Access Control Point
            if ([aChar.UUID isEqual:[CBUUID UUIDWithString:@"2A52"]]) {
                [aPeripheral readValueForCharacteristic:aChar];
                [aPeripheral setNotifyValue:YES forCharacteristic:aChar];

                uint8_t bytes[] = {0x04, 0x01, 0x00};
                NSData *data = [NSData dataWithBytes:(void*)&bytes length:sizeof(bytes)];

                [aPeripheral writeValue:data forCharacteristic:aChar type:CBCharacteristicWriteWithResponse];
            }

        }
    }
}

在 iPhone 上,我看到一个 UIAlert,其中包含一个用于输入安全代码的字段。我可以将 iPhone 与 Accu-Chek Aviva Connect 配对。但下次我向记录访问控制点特征发送一些写入请求时(设备断开连接后),我收到“错误:身份验证不足”,并且 iPhone 上没有 UIAlert。

我觉得我做的每件事都是错的。

我想从蓝牙设备的日志中读取记录。 AFAIU 我将字节写入读取记录访问控制点 ([aPeripheral writeValue:data forCharacteristic:aChar type:CBCharacteristicWriteWithResponse];) 并在 peripheral:didWriteValueForCharacteristic:error: 中获得答案。但我做不到,因为“错误:身份验证不足”挡住了我的路!

最佳答案

您需要通过身份验证才能向血糖仪发出写入请求。身份验证不足意味着您试图在未经过身份验证的情况下发出请求。您不能只是连接然后写入医学相关特征。

检查您是否真的发出了身份验证请求(这也需要输入 PIN)。如果是,请检查 PIN 是被接受还是被拒绝。

关于从 "Accu-Chek Aviva Connect"BG 仪表收集数据的 iOS 应用程序。 (低功耗蓝牙),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40208332/

相关文章:

java - 强制其他手机识别 Android 蓝牙设备名称中的更新

c++ - Xcode 7 对包含文件的处理已更改

ios - 使用私有(private)框架以编程方式发送 iMessage

ios - 前景和背景,哪些应用程序在哪里?

iphone - 在编辑模式下防止 UITableView 默认行为

ios - 核心蓝牙读取数据

android - Nearby Connections 2.0 中的错误代码

iPhone 分配和释放

ios - AVMutableComposition的AVPlayer无法播放音频和视频

ios - 点击 UIWebViews 时键盘消失