CoreBluetooth iOS 10 - Write commands are "acknowledged"?

I am running iOS 10 beta 2. I have noticed that you will now get a peripheral:didWriteValueForCharacteristic:error: callback even when using characteristic write commands (CBCharacteristicWriteWithoutResponse). Previously you would only get this when using write requests (CBCharacteristicWriteWithResponse).. This, to me, is not an improvement to the API, but rather makes it worse.


First of all, it is a bit counter intuitive to get a confirmation that you have written data when there is no guarantee that the data will arrive on the other side, or even be sent in the first place. At first I thought that this callback was added as a confirmation that at least the bluetooth stack has received the message, but that does not appear to be the case. If that had been the case, then you could have used it as sort of like a "flow control" mechanism (like you can on Android) to avoid packets being lost due to buffer limitations in the bluetooth stack. I did however test this and when sending data at a rapid pace, with each new packet being sent in the callback of the previous one, the bluetooth stack starts to discard packets after around 30 packets with 20 bytes payload. This appears to be the same as if you just add the packets in a loop directly. So, my point here is that I do not understand why this feature was added?


Second, I believe that this API breaking change could generate a lot of unsuspected bugs in applications that have presumed that you would not get this callback. In the current documentation on Apple's website for the writeValue:forCharacteristic:type: method it explicitly says:


When you call this method to write the value of a characteristic, the peripheral calls the
peripheral:didWriteValueForCharacteristic:error: method of its delegate object only if you
specified the write type as CBCharacteristicWriteWithResponse.


Additionally, for the documentation of peripheral:didWriteValueForCharacteristic:error: it says:


This method is invoked only when your app calls the writeValue:forCharacteristic:type: method with the
CBCharacteristicWriteWithResponse constant specified as the write type.


And lastly I can add that in the CBPeripheral.h header file of the latest iOS 10 beta it still states something similar (although in different words):


If the CBCharacteristicWriteWithResponse type is specified,
peripheral:didWriteValueForCharacteristic:error: is called with the result of the write request.


and


This method returns the result of a writeValue:forCharacteristic:type: call, 
when the CBCharacteristicWriteWithResponse type is used.


Any comments on this?


/Anton

Sorry, I obviously mixed up write commands (CBCharacteristicWriteWithoutResponse) with write request (CBCharacteristicWriteWithResponse) in the first section of my post! The post is still valid regardless.

Yes, we have noticed the same thing - the behavior in iOS10 is completely against what the documentation states. This bug needs to be resolved in future iOS10 beta / GM releases!

Hi, same is happened in our project. iOS 10 Beta 5. An application is not able send data to a BLE device in iOS 10, however I have not tried to implement reaction on didWriteValueForCharacterstic as in your test. Does it help?

We also use packets to send limitation. It is 28 for iOS 9.


After a code check I've found a bug in my code provoked by didWritevalueForCharacteristic called after writeWithoutResponse. If I just ignore didWriteValueForCharacterstic, then application works as before.

I can add to this that I have also submitted a bug report about this. No response so far though.

Does anyone know if this bug will be fixed before the general iOS 10 release date? This change in behavior still exists in iOS 10 beta 8. We have an app that fails due to this bug. Easy to work around so I guess we will submit an update, but curious if anyone has more information about the status of this bug. Very much appreciate the information in this thread!

Still not fixed, even with people running 10.0.1.

any news on this? I do have the same behavior on iOS 10.1...


Is this bug "official"? Need to have some "proof" for a customer...

it seems to me as if the bug is fixed with 10.2 beta; did you get a response to your bug report? Do you have a link to the radar?

The issue is still present as of 10.1.1 (14B150). I still have not recieved any response on my bug report.

It seems that it was fixed on iOS 10.2 beta 4 (14C82).

CoreBluetooth iOS 10 - Write commands are "acknowledged"?
 
 
Q