I have connected Barcode Scanner device
Barcode Scanner Information
I want to know the paired status of it. Whether it is connected with device or not.
- (void) centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
self.connectingPeripheral = peripheral;
NSLog(@"@@@@@@Peripheral Name is:%@ Identifier:%@ Services:%@",peripheral.name,peripheral.identifier,peripheral.services);
[self.bluetoothManager connectPeripheral: self.connectingPeripheraloptions: nil];
}
I am getting information about Mac's which are nearby and enabled. But I am not getting Barcode Scanner information in this Method.
I need whether barcode scanner is connected to device or not.
can anyone suggest how to find connectivity of barcode scanner.
I appreciate your response, Thanks.
The Settings App can discover nearly all kinds of bluetooth devices,but the system only notify your app for BLE devices.
Reboot your Scanner , and make sure your iPhone and Scanner are not connected with any devices.Enable your Scanner's discoverabilty.
If Settings App can find the Scanner while your demo are not,the Scanner is not a BLE device, and is not supported by iOS since iPhone 4s.
If the Scanner is a BLE device,there are some extra work to do to figure out if they are connected.
You can check the state
of the discovered CBPeripheral
in func centralManager(_ central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData advertisementData: [String : AnyObject], RSSI RSSI: NSNumber)
.
Store CBPeripheral's identifier
,before you connect to it.Use this identifier in func retrievePeripheralsWithIdentifiers(_ identifiers: [NSUUID]) -> [CBPeripheral]
.And check if your Scanner is in the return Array.
If you don't store the identifier
,there is no way that you can access an connected BLE Device.
Read the below answer:
https://stackoverflow.com/a/11128869/5178107
Might help you. More over, CoreBluetooth only allows you to access Bluetooth Low Energy devices. You can pair these devices if you need encryption but typically you don't. However, there is no API to list the paired devices - you need to discover the device(s) that are offering the service you are interested in and present a list, if necessary using your own UI in your app. Once you have identified the target device you can initiate a connection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With