I'm trying to implement an ANCS client in C on Linux with the BlueZ stack (newest version, 5.39). So far I can set the BLE advertisement data with the service soliciation UUID provided by Apple.
My device does show up in the iPhone (iOS 9) settings. I can also connect to the device, the connection is very unstable though, meaning, sometimes after a while, and always when I close the bluetooth settings submenu on the iPhone the connection is terminated. It's also not bonding, after the disconnect, the device is not showing up under "my devices" on the iPhone.
I looked at the hcidump, apparently is just reads a bunch of ATT data, then stops:
Pastebin link, because it didn't format it correctly on here
After the connection is terminated is outputs the lower part of the pastebin.
Now, my question is, what would be the next step to create a ANCS client that receives notifications from the iOS device? I have read countless articles and sample code about BLE and ANCS, but still I'm clueless.
Do I have to open a L2CAP socket in my C code to accept the connection from the iPhone? I already tried that, didn't work. I also tried to connect to the iPhone with gatttool, while it was connected, but it said "resource or device busy".
I'd be very thankful for some pointers in the right direction, on what to do next.
Ok, after a lot of research I can finally answer by own question:
What I already accomplished before I asked this question:
What's necessary after that:
One should definitely look at tools/btgatt-client.c & tools/bt-gatt-server.c in the BlueZ source code. It shows exactly how to open the socket (with sockopt, etc.)
Hope this helps anyone who is struggling to figure this out like I was.