Post

Replies

Boosts

Views

Activity

CoreBluetooth - which should be central/peripheral?
I'm developing a Mac application that monitors a piece of state on your computer and communicates it to a nearby iOS device. Both are using CoreBluetooth to communicate. You can think of the iOS device as a "status sign" for your Mac. I started out by making the Mac the "central" and the iOS device the "peripheral". The Mac tries to keep a persistent BL connection to the iOS device to write a value whenever the state changes. However, I find that the the iOS device often disconnects. I can also see an implementation where the iOS app is the central and subscribes to a characteristic of the Mac peripheral. Here's my question - for those of you with more Core Bluetooth experience, based on my use case, which should be the central and which should be the peripheral?
1
0
557
May ’21
Can Core Bluetooth connections be long lived?
I have a Mac app acting as as central and an iOS app acting as as peripheral. They are both using Core Bluetooth to communicate. How long can I expect the connection to live? Can connections be long lived? I find that the iOS peripheral disconnects quickly after some inactivity (maybe 10-15 seconds) and I have to keep reconnecting to send more data over. The error I get on disconnection is "Code=6 “The connection has timed out unexpectedly.” (happens all the time on an iOS device running iOS 10 and a newer one running iOS 14). The error message make it sound like this shouldn't happen, but maybe that's how BLE is supposed to work and I shouldn't expect to use it more like a web socket.
0
0
326
May ’21