ble 특성에 쓰기를 시도했습니다. 그러나 반환 오류는 "쓰기가 허용되지 않습니다."입니다.iOS에서 ble 특성에 쓰기 오류
이것은 특성을 발견하는 것입니다. // 지정된 서비스의 특성을 발견하면 호출됩니다.
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error
{
if ([service.UUID isEqual:[CBUUID UUIDWithString:DEVICE_SERVICE_UUID]]) {
for (CBCharacteristic *aChar in service.characteristics)
{
if ([aChar.UUID isEqual:dev2appcharacteristicsUUID]) {
[devicePeripheral setNotifyValue:YES forCharacteristic:aChar];
NSLog(@"Found R-Motion device with characteristics: %@\n", aChar);
dev2appCharacteristic = aChar;
}
if ([aChar.UUID isEqual:app2devcharacteristicsUUID]) {
//[devicePeripheral setNotifyValue:NO forCharacteristic:aChar];
NSLog(@"Found R-Motion device with characteristics: %@\n", aChar);
app2devCharacteristic = aChar;
}
}
}
}
제대로 발견 할 수 있습니다. 그리고 app2devCharacteristic에 쓰려고합니다. _properties unsigned long long 4
및 _isNotifying bool false
입니다. 나는 오류가 반환되지 있습니다
- (IBAction)RequestResult:(id)sender {
unsigned char bytes[] = {0x00, 0xCC, 0xFF};//{0xFF, 0xCC, 0x00};//
NSData *transactData = [NSData dataWithBytes:bytes length:3];
[devicePeripheral writeValue:transactData forCharacteristic:app2devCharacteristic type:CBCharacteristicWriteWithoutResponse];
}
로 withoutresponse을 변경 한 경우
가 나는 오류"Writing is not permitted"
와 didWriteValueForCharacteristic
에서 수익을
- (IBAction)RequestResult:(id)sender {
unsigned char bytes[] = {0x00, 0xCC, 0xFF};//{0xFF, 0xCC, 0x00};//
NSData *transactData = [NSData dataWithBytes:bytes length:3];
[devicePeripheral writeValue:transactData forCharacteristic:app2devCharacteristic type:CBCharacteristicWriteWithResponse];
}
으로 바이트 배열을 작성했습니다. 하지만 내 주변 장치는 아무것도받지 못합니다.
당신은'_properties unsigned long long 4'가'app2devCharacteristic'을위한 것이라고 말했습니다. 글쎄,'CBCharacteristicPropertyWriteWithoutResponse = 0x04,''writeValue : type : :'의'type'에서'CBCharacteristicWriteWithResponse'를 할 수 없습니다. 나머지 (기록되지 않음)는 어떻게 알 수 있습니까? 'transactData'는 유효합니까? 귀하의 장치가 실제로 그것을 기대합니까? – Larme