2016-10-26 9 views
0
<CBCharacteristic: 0x156d48cf0, UUID = BLevel, properties = 0x18, value = <32353732 380d0a>, notifying = YES> 

값 필드에있는 내용을 추출하고 싶습니다.CBCharacteristic에서 정확한 값을 얻는 방법?

NSData *data = c.value; // c is of type CBCharacteristic 

그러나 나는 어떤 종류의 가치가 있는지 알지 못합니다.

+0

사용 NSString합니다. String, struct, uint32 등이 될 수 있습니다. 참조 : http://stackoverflow.com/questions/38718841/ios-core-bluetooth-get-all-features-description-from-device/38719661#38719661 'BLevel '배터리 수준? 당신은 reverse engeenering을하거나 문서를 읽어야합니다. ("알려진"것이거나 장치 문서라면 BLE doc) – Larme

+0

@Larme, 예, "Battery level"입니다. 너는 그것의 유형이야? – Hemang

+0

doc : https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.battery_level.xml에 따르면 UUID가 0x2A19이지만 int8의 경우에는 길어 보입니다. – Larme

답변

2

당신은 변환 할 수 NSData 당신은`NSData`을 무엇을 의미하는지 알 필요가

NSString *str = [[NSString alloc] initWithData:c.value encoding:NSUTF8StringEncoding];