write operation from Central Manager to Peripheral in BLE is failing

Hi,


This is an issue regarding BLE operations. I am using iOS 8.3 and Xcode 6.3

I am trying to pair a iOS based peripheral with an iOS based CentralManager. The CentralManager is detecting the advertised data of the peripheral. But when i am trying to write something back to the peripheral from the CB it is failing.please let me know if there are any sample programs that i can refer to for my issue.


I am also trying the do the same using a iOS peripheral and Android running Central Manager.


it is very urgent issue to resolve, kindly help.

Replies

There are a number of BLE test applications out there, such as LightBlue, as well as a number of sample Core Bluetooth applications which connect to a device and read/write to characteristics. I'd actually recommend downloading one of the sample source code packages, and tweaking it, just so you can walk through the process if it works and see what you're doing differently.


Beyond that, I'd say you might need to provide more information for folks to help, like what actual flow your program takes. Are you connecting, then retrieving services, then retrieving characteristics on the service? (Holding onto a characteristic across connections doesn't always work.) Are you making certain that the characteristic is seen as writeable? Etc.

Hello,

I have a BLE app running on my iPad in Peripheral mode. I have my Central running on an Android board.

How my app works:

1. First my iOS app advertises itself along with a few characteristics.

2. The central detects it and tries to connect to it by writiWe ng a particular value.

3. After I read that value i do some comparisions and then send another Characteristic (this time only one characteristic).

At this stage the Android is not receiving any read request. And nor is my iOS app or device logs is showing any errors.

Please let me know if you need any additional information.

FYI - we are using iOS 8.3 on iPad.

You can't just see the advertisement data and then try to write the device.


For your android setup are you using API 18/19 or 21/22 (Android Lollypop and later or KitKat and earlier?)


You cannot connect to a device simply by writing or reading a characteristic. You must first issue a conneciton request and perform a service discovery. Once you get the BluetoothGattCharacteristic reference, you can read or write to it. From your description above I can't tell if you are doing this or not.


Android after you call connectGatt, you will get the onConnectionStateChanged callback. Then perform the service discovery (android everything happens at once and it is important to note that these services and characteristics are cached NOT queried each connection like iOS). Finally, it is now appropriate for the client (your android central) to ask the server (your iOS peripheral) for its data. If you setup notifications or indications, note that not only do you have to enable them, but also write the CCC descriptor of that characteristic you are trying to get automatic updates from. Apple does this automatically for you, and disallows discovery of the CCC descriptor of any characteristic.


Add sample code.