How to have multiple connections to a single Obd2 bluetooth device connected to car
Asked Answered
E

1

6

I have to do an Android application that reads value via Bluetooth from a Bluetooth device connected to OBD-II port of a car.

I use the UUID SPP UUID 00001101-0000-1000-8000-00805F9B34FB .

If I create 4 threads that want to connect to the OBD-II device, 3 connect()s fail and only one thread is able to connect to the device.

Is there a way to connect more thread to an OBD-II device via Bluetooth?

I don't know if the elm-237 device is able to communicate with more threads.

Eckenrode answered 1/9, 2012 at 12:7 Comment(1)
@Alice, please refrain from adding random code formatting, it reduces readability.Mullah
E
7

I am not an expert on OBD/OBD-II, but I know a little on serial ports.

Actually, what you see does not surprise me at all. Serial-port devices usually must operate in exclusive mode, so only one actor can talk to them at a single point of time. There is totally no point in creating multiple threads for that - this will not make your serial port "talk faster", nor it will make the external device (OBD chip) respond faster! This is not a network! To talk to several devices in parallel, you'd need to have actual several cables - and probably also several chips.

ELM327 is the device in your OBD-2 cable. It mediates the communication between the chips in the car and your USB port and exposes a virtual serial port over USB bus. I never heard of any cheap Bluetooth-enabled ELM327 clones, but I know that there are OBD-II Bluetooth adapters - the last I've seen costed about $2000 as it was coming with a large diagnostic software and database of car parts(strike: see comments) and of course worked without any cables. But I think that still it would provide only 1 virtual serial port to talk with 1 device.

Exenterate answered 1/9, 2012 at 12:21 Comment(2)
so the only way is one thread and single request/response for time ?Eckenrode
Yes, I think this is the only way. On en.wikipedia.org/wiki/On-board_diagnostics there's no mention of multiplexing the connection, only mentions the multi-master collision resolution, what is very different thing. Also, I've just found an ELM327+Bluetooth without specialistic software suite, and it is rather cheap: amazon.com/Soliport-Bluetooth-OBDII-Diagnostic-Scanner/dp/… but this will as usual take the whole OBD port and expose 1 serial.. just no cables.Exenterate

© 2022 - 2024 — McMap. All rights reserved.