-5

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

            }
        }
    }
C8H10N4O2
  • 18,312
  • 8
  • 98
  • 134
Ketan Sodvadiya
  • 464
  • 5
  • 11
  • Hi Ketan. Please provide some more specific details about the implementation you've tried so far, and exactly what problem you're facing. That will be needed for someone to help you here. – TheNeil May 01 '19 at 16:32
  • @TheNeil i have added code in my question please check. – Ketan Sodvadiya May 02 '19 at 06:55

1 Answers1

0

The stock OS on iOS devices block application access to USB and Bluetooth services, except for those clearly documented as whitelisted by Apple, or those devices enrolled in Apple's MFI program (under NDA).

The solution I use it to connect to non-Apple-permitted USB and Bluetooth profile devices with a Raspberry Pi, and then serve the data from the Pi to iOS devices over a network socket (via WiFi, or wired ethernet, which Apple supports on iOS via various dongles), or using Core Bluetooth BLE (which is whitelisted, but much slower).

hotpaw2
  • 70,107
  • 14
  • 90
  • 153