1

I am developping my first Smart Bluetooth (BLE) software on IOS 6.

I am able to receive notifications and read chracteristics values exchanged with a Nordic Development kit including from a custom GATT profile I have created (with specific UUIDs for service and characteristics).

But, everytime I am trying to write a value in a characteristic, I get the error message Unknown Error without more information. No error code, no CoreBluetooth[WARNING] from XCode.

I have set my service and characteristics attributes permissions to write without authentication. Using a development Nordic tool, I am able to write a value in my characteristic, so it would not be a permission problem.

Here is the code I am using to write the value

uint16_t val = 2;
NSData * valData = [NSData dataWithBytes:(void*)&val length:sizeof(val)];
[testPeripheral writeValue:valData forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse];

And the callback where the error "Unknown error" is rised

 - (void) peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:
                     (CBCharacteristic *)characteristic error:(NSError *)error
{   
    NSLog(@"Did write characteristic value : %@ with ID %@", characteristic.value, characteristic.UUID);
    NSLog(@"With error: %@", [error localizedDescription]);

    //code...
}

The error text in the console is

Did write characteristic value : <068c0e00 fedc070c 050b3200 04> with ID Unknown (<4444>)
With error: Unknown error.

The value in the error message is not what I am trying to write??!! 444 is the correct UUID I am using for my tests.

Is the length of the value to write important?

After looking hoirs on the internet and tried a lot tests, I need SO to figure it out. Any advice?

4

3 回答 3

1

您应该检查 CBCharacteristic 的属性。如果属性指示不可写的特性,您可能会收到此错误。

祝你好运。

于 2015-07-04T08:51:19.823 回答
0

问题出在设备数据库管理中,而不是在 IOS 端。但是,如果没有来自 CoreBluetooth 的错误代码,很难弄清楚!

于 2013-07-17T06:59:14.180 回答
0

sdespont 是对的。

我遇到了同样的问题。只需双击主页按钮并向上滑动以终止应用程序,然后重新启动它,BLE 就可以工作了!我认为它位于设备数据库管理中,即使在调试期间我们也应该取消连接。

于 2014-02-18T03:56:44.683 回答