Can iOS re-connect to Bluetooth LE peripheral by specifying )CBPeripheral *)peripheral instead of doing retrievePeripherals?

Doug Null

When I get delegate didConnectPeripheral:(CBPeripheral *)peripheral can I just store peripheral in an array, and then use it to re-connect later, instead of using retrievePeripherals and its subsequent didRetrievePeripherals? Seems like it would be easier, if it's feasible and has no risk.

How much later can (CBPeripheral *)peripheral be re-used? Is it still valid after disconnection with that peripheral?

Workflow:

  1. scanForPeripheralsWithServices() - to scan for a peripheral
  2. didDiscoverPeripheral:(CBPeripheral *)peripheral - when it's detected connectPeripheral:peripheral
  3. didConnectPeripheral:(CBPeripheral *)peripheral stopScan and store the (CBPeripheral *)peripheral for later.
  4. ... read or write characteristics ...
  5. cancelPeripheralConnection
  6. didDisconnectPeripheral

LATER, TO RE-CONNECT...

  1. connectPeripheral:peripheral - from array with peripheral
  2. didConnectPeripheral:(CBPeripheral *)peripheral ...
Tommy Devoy

YES, it will work (but it's terrible practice). The retrievePeripherals: method was specifically created so that you can reconnect to peripherals between subsequent launches of an application. You can use your method, but once the app is shutdown, you will never be able to connect to the peripheral again (without putting it into advertising mode and starting from scratch basically). You can store the uuid between launches, but you cannot store a CBPeripheral object. So there's the big downside right there.

So to sum up: it will work, but it doesn't really gain you anything. It is not faster than calling retrievePeripherals: and then connecting them. Your suggested method is only limiting your abilities for connections in CoreBluetooth. But an interesting question nonetheless.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Can iOS re-connect to Bluetooth LE peripheral by specifying )CBPeripheral *)peripheral instead of doing retrievePeripherals?

From Dev

iOS App Bluetooth cannot connect to peripheral device

From Dev

Android 4.3 as a Bluetooth LE Peripheral

From Dev

iOS: Bluetooth LE peripheral no longer updating after coming back into range

From Dev

CBPeripheral, Get Local Peripheral Identifier

From Dev

iOS 7 Core Bluetooth Peripheral running in background

From Dev

Central writing characteristic to Peripheral (iOS Core Bluetooth)

From Dev

OSX Bluetooth LE Peripheral transfer rates are slow

From Dev

Bluetooth 4.0 LE -- Conceptual -- Sending data form master to peripheral AND from peripheral to master

From Dev

Get MAC address of bluetooth low energy peripheral in iOS

From Dev

Bluetooth peripheral connected to iOS doesn't work in the background

From Dev

Bluetooth peripheral connected to iOS doesn't work in the background

From Dev

BlueZ/Pybluez - Bluetooth LE scan while connected to peripheral

From Dev

how to make a linux system as a bluetooth LE peripheral device

From Dev

Core Bluetooth unable to discover peripheral

From Dev

Can an iPhone be a BLE peripheral?

From Dev

Can a BLE peripheral connect to a background app on an Android phone?

From Dev

Connect to BLE peripheral on Windows 10

From Dev

Connected peripheral in background mode (Core Bluetooth)

From Dev

bluetooth - UUID from peripheral device is a normal String

From Dev

Connected peripheral in background mode (Core Bluetooth)

From Dev

Android Bluetooth Peripheral Mode Notification Descriptor

From Dev

Does Android KitKat allows devices that support Bluetooth LE to act as a peripheral device?

From Dev

iOS peripheral service still empty after discovering

From Dev

iOS: Not receiving the write requests from Central to Peripheral

From Dev

Can I add peripheral power connectors to server?

From Dev

Can I solder an USB peripheral to an USB port?

From Dev

Bluetooth Peripheral ADVERTISE_FAILED_DATA_TOO_LARGE

From Dev

Which platforms have Bluetooth 4.0 peripheral / slave support?

Related Related

  1. 1

    Can iOS re-connect to Bluetooth LE peripheral by specifying )CBPeripheral *)peripheral instead of doing retrievePeripherals?

  2. 2

    iOS App Bluetooth cannot connect to peripheral device

  3. 3

    Android 4.3 as a Bluetooth LE Peripheral

  4. 4

    iOS: Bluetooth LE peripheral no longer updating after coming back into range

  5. 5

    CBPeripheral, Get Local Peripheral Identifier

  6. 6

    iOS 7 Core Bluetooth Peripheral running in background

  7. 7

    Central writing characteristic to Peripheral (iOS Core Bluetooth)

  8. 8

    OSX Bluetooth LE Peripheral transfer rates are slow

  9. 9

    Bluetooth 4.0 LE -- Conceptual -- Sending data form master to peripheral AND from peripheral to master

  10. 10

    Get MAC address of bluetooth low energy peripheral in iOS

  11. 11

    Bluetooth peripheral connected to iOS doesn't work in the background

  12. 12

    Bluetooth peripheral connected to iOS doesn't work in the background

  13. 13

    BlueZ/Pybluez - Bluetooth LE scan while connected to peripheral

  14. 14

    how to make a linux system as a bluetooth LE peripheral device

  15. 15

    Core Bluetooth unable to discover peripheral

  16. 16

    Can an iPhone be a BLE peripheral?

  17. 17

    Can a BLE peripheral connect to a background app on an Android phone?

  18. 18

    Connect to BLE peripheral on Windows 10

  19. 19

    Connected peripheral in background mode (Core Bluetooth)

  20. 20

    bluetooth - UUID from peripheral device is a normal String

  21. 21

    Connected peripheral in background mode (Core Bluetooth)

  22. 22

    Android Bluetooth Peripheral Mode Notification Descriptor

  23. 23

    Does Android KitKat allows devices that support Bluetooth LE to act as a peripheral device?

  24. 24

    iOS peripheral service still empty after discovering

  25. 25

    iOS: Not receiving the write requests from Central to Peripheral

  26. 26

    Can I add peripheral power connectors to server?

  27. 27

    Can I solder an USB peripheral to an USB port?

  28. 28

    Bluetooth Peripheral ADVERTISE_FAILED_DATA_TOO_LARGE

  29. 29

    Which platforms have Bluetooth 4.0 peripheral / slave support?

HotTag

Archive