How to fetch properties or name of paired two or more BlueTooth keyboards (Belkin keypad..)
I am creating a simple test project in that only label is present. Two Bluetooth keyboards (Belkin keypad)is connected to iPad. I want to find each device name or any properties or any unique path of those devices that I can show its name when pressing any key from pin pad. I want to find input come from which device. I tried using core Bluetooth but it only shows peripherals not showing my Bluetooth keypad name.I also search IOBluetooth but it is for macOS. I require to use it in iOS swift. kindly help me .
tried this way...
//Using External accessory
import UIKit
import ExternalAccessory
class ViewController: UIViewController
{
@IBOutlet weak var tableView: UITableView!
var manager = EAAccessoryManager.shared()
override func viewDidLoad() {
super.viewDidLoad()
let a = manager.connectedAccessories.count
print(a)// print 0
NotificationCenter.default.addObserver(self, selector: #selector(deviceConnected), name: NSNotification.Name.EAAccessoryDidConnect, object: nil)
}
@objc func deviceConnected(notification: NSNotification)
{
if let acc = notification.userInfo![EAAccessoryKey]
{
showAccessoryInfo(accessory: acc as! EAAccessory)
print("Connected:", acc)
}
tableView.reloadData()
}
func showAccessoryInfo(accessory: EAAccessory)
{
print("title\(accessory.manufacturer) and name :\(accessory.name) and message \(accessory.description)")
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return manager.connectedAccessories.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
print("10")
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
let acc = manager.connectedAccessories[indexPath.row]
cell.textLabel?.text = "\(acc.manufacturer) \(acc.name)"
cell.detailTextLabel?.text = "\(acc.modelNumber) \(acc.serialNumber)\n fr:\(acc.firmwareRevision) hr: \(acc.hardwareRevision)"
print("11")
return cell
}
func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) {
let acc = manager.connectedAccessories[indexPath.row]
showAccessoryInfo(accessory: acc)
print("12")
}
}