I'm trying to observe velocity of my car using an OBD2, to try if the hardware works i had use the app "Auto Doctor" and it works. But i need some more features and so i started to create my own application
To send command to the characteristic i use the following code:
var commandSended = String() {
didSet {
if let peripheral = self.peripheralConnected {
for char in characteristicConnected {
peripheral.writeValue(self.commandSended.data(using: .utf8)!, for: char, type: .withoutResponse)
peripheral.writeValue(self.commandSended.data(using: .ascii)!, for: char, type: .withoutResponse)
peripheral.readValue(for: char)
}
} else {
self.myTerminal.printToTerminalCommand("You are not connected to the peripheral")
}
}
}
characteristicConnected: are all the characteristic found
Independently which command i send to the characteristic i receive every time the same amount of byte and i can't decode it using utf8 or ascii.
I hope I have supply you enough information.