During development I got a problem witch related to the connection central and peripheral. When one of the central already connected with perepheral I have to don't allow to connect other central. Maybe someone nows how can I check does the peripheral already connected?
Core Bluetooth. How can I check does peripheral already connect?
1.9k Views Asked by Uladzislau Simanau AtThere are 2 best solutions below
Rob Napier
On
Call retrieveConnectedPeripherals(withServices:) to get a list of currently-connected peripherals for a given list of service UUIDs. These are connected to the phone, not to your app. You still need to call connect to connect them the currently running app (exactly like you would if you discovered them). This call is synchronous, since the OS already knows all the connected devices and can just return them.
Typically this list is empty. The most common production reason for it to be non-empty is that another app has connected to the device (LightBlue or some other Bluetooth scanner for example). During development, however, it is very common that the app gets killed, and in that case the phone may not have dropped the connection yet when you relaunch the app, and this will handle that situation.
While you can scan for all devices by passing nil to scanForPeripherals, there is no equivalent way to retrieve "all connected devices" You must list the desired service UUIDs. I don't believe this should be a problem in your case.
Related Questions in SWIFT
- Navigate after logged in with webservice
- URLSession requesting JSON array from server not working
- When using onDrag in SwiftUI on Mac how can I detect when the dragged object has been released anywhere?
- Protect OpenAI key using Firebase function
- How to correct error: "Cannot convert value of type 'MyType.Type' to expected argument type 'Binding<MyType>'"?
- How to share metadata of an audio url file to a WhatsApp conversation with friends
- Using @Bindable with a Observable type in SwiftUI
- How to make a scroll view of 9 images in a forEach loop open on image 6 if image 6 is clicked on from a grid?
- Using MTLPixelFormat.rgba16Float results in random round-off errors
- Search and highlight text of current text in PDFKit Swift
- How is passing a function as a parameter related to escaping autoclosure?
- Actionable notification api call not working in background
- Custom layout occupies all horizontal space
- Is it possible to fix slow CKAsset loading on Cloudkit?
- Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value - MapView.isMyLocationEnabled
Related Questions in UIKIT
- Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value - MapView.isMyLocationEnabled
- Can't display the simplest UIToolbar
- Label not showing on Tutorial SKScene
- UIViewRepresentable how do you change UIToolBar UIBarButtonItem image when it is selected?
- UIScrollView.setContentOffset() cannot set to the specified position in certain cases
- Need event when iOS app terminated by the user
- Custom context menu corner radius
- Override show(_:sender:) of UIViewController freezes the UI
- How to dismiss the first scene in UIKit Application?
- How to use RxSwift to draw the UICollectionView cells according to the number of data
- How can I trigger macOS system gamepad API based on a value received from iOS app through core bluetooth
- How to make tableview reload correct data?
- How can I implement this transition in pure Swift (UIKit)
- Present UIViewController using sheetPresentationController inside UINavigationController
- Access UINavigationItem from within MAUI ContentPage (in order to add native buttons to navigationbar)
Related Questions in CORE-BLUETOOTH
- Detect connected bluetooth devices to iPhone
- What is Accessory protocol string (com.apple.blabla ???) of Apple Watch
- How can I trigger macOS system gamepad API based on a value received from iOS app through core bluetooth
- (corebluetooth didUpdateValueFor) data is not being sent properly between my peripheral arduino 33 nano and iOS app
- Add Report Reference Descriptor to characteristic in CoreBluetooth (BLE)
- BLE Omron BP Monitor has it's Custom Service and Characteristics
- Looking for source/list/documenation of Apple Bluetooth Services & UUIDs, like Apple Continuity, Apple Nearby
- How to show my BLE device battery percentage on iPhone battery app?
- Establishing BLE & Persistent Bluetooth Classic Connection for Headphones in iOS App Without Requiring Users to Visit Settings
- How to send BLE commands using CoreBluetooth?
- Troubleshooting ASHA Protocol Audio Streaming Issue: LEAP Error in CoreBluetooth BLE Connection
- Getting the device appearance of a BLE peripheral in iOS
- Wrap Core Bluetooth Callbacks to Async/Wait
- Qualcomm takes over CSR and now my Bluetooth Programming Interface is missing?
- CoreBluetooth peripheral on Mac not advertising service
Related Questions in PERIPHERALS
- Is there a difference in how bitfields behave depending on the underlying type width?
- What type is `peripherals.APB_SARADC.split()`?
- GD32F303RBT6 - TIMER_0 - PWM Settings
- Get the usage timestamps for previously connected external devices in PowerShell
- STM32- Can not initialize eMMC, because is stuck in performing GetCardCSD() function
- Bash script that detect when a joypad is plugged in and retrive its ID_MODEL in a variable, then execute commands
- STM32 SPDIFRX Peripheral problem (interupts not firing)
- Win32 Scard.h c++ - having issues with the api
- Peripheral BLE - Can Simulate BLE device on IOS using Flutter?
- If two computers have the same CPU ( same machine instructions ) then what prevents a program from being compatible for both computers?
- Connecting 3 uart peripherals with esp32
- Peripheral devices connection (COM connection) problem with Win 11
- Can't modify peripheral registers on the rp2040
- Razer Chroma POST Request hangs Python Script indefinitely
- Why are periperal registers 16 bit only on 32 bit MCUs such as STM32 and GD32VF103?
Related Questions in CENTRAL
- How do i uninstall ODK Central?
- Identify the individual corresponding to a representative sequence
- What is official search engine for Maven Central?
- Sybase Python SQL Anywhere 17 SQL Central
- Core Bluetooth. How can I check does peripheral already connect?
- Positionating a layout over the top of a Central Widget in Python
- How do I authenticate with biometrics on every activity centrally
- SharePoint 2016 Custom Timer Job Not Showing in Job Definition
- Port 8013 unavailable installing the Data Hub Central warfile in MarkLogic running in a docker container
- Registering call logging service into RingCentral Embeddable results in undefined error
- Getting apereo/cas in docker to authenticate from whitelist
- Name error in the command window when running function
- Filebeat Central Management Alternative
- How can users run a python script without installing python on their local machines and without converting the script into an executable?
- using eigenvector centrality for weighted graph in python
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
If you simply want to know whether a peripheral is connected to a central, then you can simply check its state. You can do this immediately during discovery.