5

I am using Apple's Core Bluetooth example code (here, with slight modifications) to scan for Bluetooth Low Energy devices and connect with the device I want. On the first connect this brings up the iOS pairing dialog. Also, if the device is forgotten and then scanned and connected to again, that brings up the pairing dialog again.

The dialog comes up not when [central connectPeripheral] is called, but the first time that there is a call to either [peripheral setNotifyValue:YES forCharacteristic:c] or [peripheral writeValue:data forCharacteristic:c].

Is there a way to tell if the pairing dialog will come up before it does? (i.e. whether the OS has stored pairing info for a particular peripheral?)

I need to know before I do either of the calls that might bring up the dialog whether the dialog would come up, so I can show some instructions to the user.

Alex I
  • 19,689
  • 9
  • 86
  • 158
  • If the characteristic requires encryption, then paring is required – Paulw11 Sep 28 '16 at 03:57
  • @Paulw11 The characteristics on the device I'm working on do require encryption. That's not the question though... When connected to a device, is there a way to know if the dialog will come up? We may have connected to that device before (and let's say the app stored the mac address), so we may think it won't show the dialog. However the user may gave then forgotten the device in settings, or they may have entered an incorrect passkey the first time, so having connected before is not a guarantee of the pairing dialog not being shown again. – Alex I Sep 28 '16 at 04:35
  • Sorry, I misread your question. Unfortunately, you can now when it *might* come up in the sense that whenever you use an encrypted attribute there is the potential for a pairing dialog to be displayed in the circumstances you described. Unfortunately there is no way of knowing that it *will* come up on *this* particular access – Paulw11 Sep 28 '16 at 04:38

0 Answers0