OBD2_BLE is a Swift framework for interfacing with OBD-II devices using iOS Bluetooth Low Energy capabilities.
To run the example project, clone the repo, and run pod install
from the Example directory first.
OBD2_BLE is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "OBD2_BLE"
import OBD2_BLE
...
let obd2 = OBD2_BLE.sharedInstance
OBD2_BLE is implemented as a Singleton class.
override func viewDidLoad() {
super.viewDidLoad()
OBD2_BLE.setup(restoreId: "myAppID.Bluetooth.RestoreID")
let obd2 = OBD2_BLE.sharedInstance
}
var centralManager: CBCentralManager!
var obd2: CBPeripheral?
var dataCharacteristic:CBCharacteristic?
var obdCommands:[String: String]! = [
"speed": "010D",
"rpm": "010C",
"engineLoad": "0104",
"coolantTemp": "0105",
"vin": "0902"
]
var configurationCommands = [
"ATE0", // Echo Off
"ATH0", // Headers Off
"ATS0", // printing of Spaces Off
"ATL0", // Linefeeds Off
"ATSP0" // Set Protocol to 0 (Auto)
]
-
createCommand(name: String, command: String)
-
clearConfigurationCommands()
-
setConfigurationCommands(commands: [String])
-
addConfigurationCommands(commands: [String])
-
configureOBD()
-
getVin()
-
getSpeed()
-
sendCommandNamed(name: String)
-
getVehicleInfo(vinNumber: String, completion: @escaping (_ vehicleInfo: [String: Any]) -> ())
Nick Nordale, nicknordale@gmail.com
OBD2_BLE is available under the MIT license. See the LICENSE file for more info.