Here we are trying to read data from J1939 SAE bus devices but seems it not read with iOS we are working with Core bluetooth
connectivity we have done in android and in android work fine but same device not read with iOS can any one please help me on that.
Here i am attaching my code snippets
Connecting Bluetooth
devices as SEA J1939
var manager:CBCentralManager!
manager.connect(connectPeripheral, options: nil)
connectPeripheral.delegate = self
Bluetooth Connection success
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)
}
}
Read Data from device
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")
}
}
}