I have my app running on two iOS device (both have 6.1.4) where one device acts as the Central and one acts as a Peripheral.
I have been successful in getting notifications (characteristics set up to notify) from the Peripheral over to the Central just fine.
However, I was wanting to write a value from the Central to the Peripheral to a specific writable characteristic but that always fails. The peripheral:didWriteValueForCharacteristic:error: delegate method is immediately called where the error description says:
"One or more parameters were invalid"
I have been searching the net for any clues but have yet to come up with what is wrong.
This is how I setup the characteristic on the peripheral side:
[[CBMutableCharacteristic alloc] initWithType:<My CBUUID> properties:CBCharacteristicPropertyWrite value:nil permissions:0];
I see that when I discover characteristics on the Central side that my writeable characteristic is there. I do store away a reference at that point that I later try to use when writing my value. The value that I am writing is just a text string that I convert to a NSData like so:
NSString *payloadMessage = @"Hello";
NSData *payload = [payloadMessage dataUsingEncoding:NSUTF8StringEncoding];
[peripheral writeValue:payload forCharacteristic:<myCharacteristic> type:CBCharacteristicWriteWithResponse];
The only odd thing I can see is that my characteristic's properties is set to 138. It looks like it is both writeable as well as having extended properties. Not sure why that is automatically added by the CoreBluetooth framework. Don't know if it matters.
It seems like something is wrong with the characteristic or the data that I am trying to send but for the life of me I can not figure it out. If anyone out there has any suggestions or ideas I would appreciate the help
Thanks |