我正在尝试创建一个 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/