swift 如何从SAE j1939总线读取数据

s3fp2yjn  于 5个月前  发布在  Swift
关注(0)|答案(1)|浏览(51)

在这里,我们试图从J1939 SAE总线设备读取数据,但似乎它没有与iOS读取,我们正在与Core bluetooth连接,我们已经在Android和Android中完成了工作,但相同的设备没有与iOS读取可以任何一个请帮助我。
这里我附上我的代码片段
Bluetooth设备连接为SEA J1939

var manager:CBCentralManager! 
manager.connect(connectPeripheral, options: nil) 
connectPeripheral.delegate = self

字符串
蓝牙连接成功

func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
         print("Connected!")
         self.showAlertOneButton(withTitle: "", with: key.KBluetoothConnect, firstButton: key.KOk) { (UIAlertAction) in
             self.navigationItem.rightBarButtonItem?.tintColor = UIColor.blue
             self.vwBLTSub.removeFromSuperview()
             //all services
             self.connectPeripheral.discoverServices(nil)
         }
     }


从设备读取数据

func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService,
                    error: Error?) {
        guard let characteristics = service.characteristics else { return }

        for characteristic in characteristics {
            print(characteristic)
            if characteristic.properties.contains(.read) {
                print("\(characteristic.uuid): properties contains .read")

                peripheral.readValue(for: characteristic)
            }
            if characteristic.properties.contains(.notify) {
                print("\(characteristic.uuid): properties contains .notify")

            }
        }
    }

2vuwiymt

2vuwiymt1#

iOS设备上的股票操作系统阻止应用程序访问USB和蓝牙服务,除非那些明确记录为苹果白名单,或那些在苹果的MFI计划(根据NDA)注册的设备。
解决方案我用它来连接到非苹果允许的USB和蓝牙配置文件设备与树莓派,然后通过网络插座(通过WiFi,或有线以太网,苹果通过各种加密狗在iOS上支持),或使用核心蓝牙BLE(这是白名单,但要慢得多)从Pi到iOS设备的数据。

相关问题