agrippa1994 / Vehicle-Instruments

iOS application which communicates with a vehicle via an OBD interface (WLAN only)
MIT License
7 stars 3 forks source link

I am new to Swift programming and having trouble understanding your program. #2

Open milapj opened 7 years ago

milapj commented 7 years ago

What is the basic method of communicating with elm327? Or how to send commands to elm327 over bluetooth or wifi. Is there a tutorial for that? Any help is appreciated.:)

agrippa1994 commented 7 years ago

Hey, sorry for my late answer.

The whole communication between the ELM327 adapter and the phone is based on a TCP connection, thus it only works with a wifi module. However, the magic for this app happens in the OBDII.swift and OBDIIPID.swift.

If you want to develop your own app or if you want to unterstand the communication between the ELM327 device and your client, check this out: http://www.obdtester.com/elm-usb-commands Sending these ELM commands is rather easy. Use a telnet client to connect to the ELM327 device (the port of the device should be 35000 is far as I know) and send the commands as described in the tutorial. Further commands are documented here: https://en.wikipedia.org/wiki/OBD-II_PIDs

With the source code and the tutorial it should be quite easy to unterstand the basics. I'm not an expert, and I don't know if I use the interface to the car correctly, but it works for me :)

In addition you can take a look of a simple implementation for reading the power and speed here, which is more comfortable to read if you're familiar with C++ code.