Setting up for iOS app

Setting up the environment


  • Add a key to Info.plist file of your app with a description of the requirement why they need Bluetooth: Privacy - Bluetooth Peripheral Usage Description

  • In xCode, in the Signing & Capabilities project section, add the following items:
    + Uses Bluetooth LE accessories
    + Acts as a Bluetooth LE accessory

  • When initialisingRaxelPulse SDK library, be sure to call:

[[RPCPermissionsWizard returnInstance] setupBluetoothEnabled];
[RPEntry enableELM: YES];

Setting up the connection


To set up the connection between SDK and device, please follow the steps below:

1. Search Bluetooth device

[[RPELMEntry instance] getELMDevicesWithCompletion:^(id  _Nullable response, NSArray * _Nullable errors) {
    for(RPELMItem *item in response) {
        NSLog(@"item.tag = %@ item.uuid = %@", item.name, item.uuid);
    }
}];

2. Get a vehicle

if you haven't registered a vehicle yet, please refer to the _Vehicle management

[[RPELMEntry instance] getVehicles:^(id  _Nullable response, NSArray * _Nullable errors) {
    NSLog(@"%@",response);
}];

3. Connect Bluetooth OBD to the vehicle (from the step above)

[[RPELMEntry instance] connectDevice:@"92D29DC3-48C0-D6A6-3700-4264BEEB4762" vehicleToken:@"28e4f4ea-b495-40ec-875b-17b48c39bc07" withCompletion:^(BOOL response, NSArray * _Nullable errors) {
    if (response) {
        // Success
    } else {
        for error in errors {
            NSLog(@"error - %@", [error localizedDescription])
    }
}];

📘

Troubleshouting

When connecting to ELM, you may experience difficulties getting a repetitive response in the [RPELMEntry instance] connectDevice method.
We recommend doing DispatchQueue.once (token: "com..elm").

Please refer to the code example below

RPELMEntry.instance().connectDevice(@"92D29DC3-48C0-D6A6-3700-4264BEEB4762", vehicleToken: ct!, withCompletion: {[weak self] response, errors in
    guard let strongSelf = self else {
        return
    }
    
    if let theErrors = errors as? [NSError] {
        var isNetwork = false
        for item in theErrors {
            if item.code == 2005 {
                isNetwork = true
                break;
            }
        }
        if isNetwork {
            //Internet connection error
        }
        
        DispatchQueue.main.async {
                    
            if response == true {
                print("\(response)")
            } else {
                print("\(response)")

                DispatchQueue.once(token: "com.<YOURAPPNAME>.elm") {
                    //Next connection action
                }
            }
    })

Get connection status

At any time you can request the status of the connection to ELM (connected/not connected) and the timestamp date of the last connection.

Connection status

let isConnect = RPELMEntry.instance().getLastSession().isConnect

Timestamp date of the last connection.

let lastConnect = RPELMEntry.instance().getLastSession().lastConnect

Did this page help you?