I was told by the bluetooth manufacturer that I need to send the following to the peripheral: 'P'(0x50)
How do I do this with Objective-C and how do I get the response?
A code sample would be preferrable.
This almost answers my question, but doesn't give any code samples: peripheral writeValue: forCharacteristic: type: return null error and value
Here is some sample code: https://code.tutsplus.com/tutorials/ios-7-sdk-core-bluetooth-practical-lesson--mobile-20741
To send data back and forth it is a multistep process
[peripheral writeValue:data forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse]
For the data you can create it using a hex-string to NSData method (https://opensource.apple.com/source/Security/Security-55471.14.18/libsecurity_transform/NSData+HexString.m).- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
once you get that callback you can read the peripheral with [_peripheral readValueForCharacteristic:characteristic]
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
at that point you can look at characteristic.value to see the value.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With