0

ペアになっている 2 つ以上の BlueTooth キーボード (Belkin キーパッド..) のプロパティまたは名前を取得する方法

ラベルのみが存在する単純なテスト プロジェクトを作成しています。2 つの Bluetooth キーボード (Belkin キーパッド) が iPad に接続されています。ピンパッドから任意のキーを押したときにその名前を表示できる、各デバイス名、プロパティ、またはそれらのデバイスの一意のパスを見つけたいです。入力がどのデバイスから来たのかを知りたい。コア Bluetooth を使用してみましたが、Bluetooth キーパッド名が表示されていない周辺機器のみが表示されます。IOBluetooth も検索しますが、macOS 用です。iOS Swiftで使用する必要があります。親切に私を助けてください。

この方法を試しました...

//外部アクセサリを使用

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")
}


}
4

1 に答える 1