2

The system i'm working with uses the following scenario:

  1. Connecting to bluetooth LE device
  2. Discover Services & Characteristics
  3. Write command to TX characteristic and receive response

Above works fine 90% of time. Now and then the system gets into a state where 3rd step constantly fails (there is no response from device whatsoever even though step 1 and 2 succeeded. Restarting the app / phone / BLE device DOES not remedy this. Block is constant. What does resolve the problem is manually unpairing the device from iOS system settings. Looking at BLE diagnostic logs i get this:

"pon. mar 7 21:27:30 Preferences[380]: [CoreBluetooth] API MISUSE: can only accept commands while in the connected state"

However prior to sending the commands i've debugged the app and i'm 100% the connection is established and services&characteristics have been discovered. Any Idea? Anybody facing similiar problems?

Pawel Klapuch
  • 380
  • 4
  • 15

1 Answers1

1

Did you implement centralManager:didDisconnectPeripheral:error: in your central manager delegate?

It will notify you when a peripheral disconnects. Could be that the peripheral disconnected or there was a connection error. You should always make sure to only do read/write operations while in the connected state.

Maybe also have a look at this method: centralManager:didFailToConnectPeripheral:error:

p2pkit
  • 1,159
  • 8
  • 11
  • Actually i do both, additionallly i check for : CBPeripheralState state = self.dongleConnection.connectedDevice.peripheral.state; if (state == CBPeripheralStateConnected) before performing any read/writes from characteristic. – Pawel Klapuch Apr 07 '16 at 13:50