Score:0

Having trouble understanding bluetooth connection

cn flag
sgt

I am trying to troubleshoot my connection to a cheap elm327 OBDII adapter, can pair it using bluetoothctl and i can trust it, can establish a serial connection using rfcomm, i then proceed to use screen with 9600 baud rate but i struggle to get any data and at the prompt i can only insert two characters ?

I use btmon to capture my bt connection, but i am having trouble understanding it, i see i can connect and exchange MTU rates, from my understanding it use the lowest rate:

= Note: Bluetooth subsystem version 2.22                                                                                                                                            0.304925
= New Index: 60:F2:62:0B:05:EE (Primary,USB,hci0)                                                                                                                            [hci0] 0.304925
= Open Index: 60:F2:62:0B:05:EE                                                                                                                                              [hci0] 0.304926
= Index Info: 60:F2:62:0B:05:EE (Intel Corp.)                                                                                                                                [hci0] 0.304926
@ MGMT Open: bluetoothd (privileged) version 1.22                                                                                                                          {0x0001} 0.304927
> HCI Event: Extended Inquiry Result (0x2f) plen 255                                                                                                                      #1 [hci0] 1.946471
        Num responses: 1
        Address: 00:10:CC:4F:36:03 (CLP COMPUTER LOGISTIK PLANUNG GmbH)
        Page scan repetition mode: R1 (0x01)
        Page period mode: P0 (0x00)
        Class: 0x000000
          Major class: Miscellaneous
          Minor class: 0x00
        Clock offset: 0x4b8e
        RSSI: -45 dBm (0xd3)
        Name (complete): OBDII
        Company: not assigned (29282)
          Data: 32327878112233445566aabb0000
@ MGMT Event: Device Found (0x0012) plen 45                                                                                                                         {0x0001} [hci0] 1.946526
        BR/EDR Address: 00:10:CC:4F:36:03 (CLP COMPUTER LOGISTIK PLANUNG GmbH)
        RSSI: -45 dBm (0xd3)
        Flags: 0x00000000
        Data length: 31
        Name (complete): OBDII
        Company: not assigned (29282)
          Data: 32327878112233445566aabb0000
        Class: 0x000000
          Major class: Miscellaneous
          Minor class: 0x00
< HCI Command: Inquiry Cancel (0x01|0x0002) plen 0                                                                                                                        #2 [hci0] 3.532687
> HCI Event: Command Complete (0x0e) plen 4                                                                                                                               #3 [hci0] 3.534686
      Inquiry Cancel (0x01|0x0002) ncmd 2
        Status: Success (0x00)
@ MGMT Event: Discovering (0x0013) plen 2                                                                                                                           {0x0001} [hci0] 3.534740
        Address type: 0x01
          BR/EDR
        Discovery: Disabled (0x00)
< HCI Command: Create Connection (0x01|0x0005) plen 13                                                                                                                    #4 [hci0] 3.534748
        Address: 00:10:CC:4F:36:03 (CLP COMPUTER LOGISTIK PLANUNG GmbH)
        Packet type: 0xcc18
          DM1 may be used
          DH1 may be used
          DM3 may be used
          DH3 may be used
          DM5 may be used
          DH5 may be used
        Page scan repetition mode: R2 (0x02)
        Page scan mode: Mandatory (0x00)
        Clock offset: 0x0000
        Role switch: Allow peripheral (0x01)
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                 #5 [hci0] 3.535531
      Create Connection (0x01|0x0005) ncmd 1
        Status: Success (0x00)
> HCI Event: Vendor (0xff) plen 4                                                                                                                                         #6 [hci0] 6.407132
        26 00 01 01                                      &...            
> HCI Event: Connect Complete (0x03) plen 11                                                                                                                              #7 [hci0] 6.407938
        Status: Success (0x00)
        Handle: 256
        Address: 00:10:CC:4F:36:03 (CLP COMPUTER LOGISTIK PLANUNG GmbH)
        Link type: ACL (0x01)
        Encryption: Disabled (0x00)
< HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2                                                                                                        #8 [hci0] 6.408166
        Handle: 256
> HCI Event: Max Slots Change (0x1b) plen 3                                                                                                                               #9 [hci0] 6.408950
        Handle: 256
        Max slots: 5
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                #10 [hci0] 6.409923
      Read Remote Supported Features (0x01|0x001b) ncmd 1
        Status: Success (0x00)
< HCI Command: Write Scan Enable (0x03|0x001a) plen 1                                                                                                                    #11 [hci0] 6.410018
        Scan enable: No Scans (0x00)
> HCI Event: Command Complete (0x0e) plen 4                                                                                                                              #12 [hci0] 6.410968
      Write Scan Enable (0x03|0x001a) ncmd 2
        Status: Success (0x00)
> HCI Event: Read Remote Supported Features (0x0b) plen 11                                                                                                               #13 [hci0] 6.413957
        Status: Success (0x00)
        Handle: 256
        Features: 0xbf 0xfe 0x8d 0xfa 0xc8 0x2d 0x71 0x83
          3 slot packets
          5 slot packets
          Encryption
          Slot offset
          Timing accuracy
          Role switch
          Sniff mode
          Power control requests
          Channel quality driven data rate (CQDDR)
          SCO link
          HV2 packets
          HV3 packets
          u-law log synchronous data
          A-law log synchronous data
          CVSD synchronous data
          Power control
          Transparent synchronous data
          Broadcast Encryption
          Enhanced Data Rate ACL 2 Mbps mode
          Enhanced inquiry scan
          Interlaced inquiry scan
          Interlaced page scan
          RSSI with inquiry results
          Extended SCO link (EV3 packets)
          AFH capable peripheral
          LE Supported (Controller)
          3-slot Enhanced Data Rate ACL packets
          5-slot Enhanced Data Rate ACL packets
          Pause encryption
          AFH capable central
          Enhanced Data Rate eSCO 2 Mbps mode
          Extended Inquiry Response
          Encapsulated PDU
          Erroneous Data Reporting
          Non-flushable Packet Boundary Flag
          Link Supervision Timeout Changed Event
          Inquiry TX Power Level
          Extended features
< HCI Command: Read Remote Extended Features (0x01|0x001c) plen 3                                                                                                        #14 [hci0] 6.414046
        Handle: 256
        Page: 1
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                #15 [hci0] 6.414916
      Read Remote Extended Features (0x01|0x001c) ncmd 1
        Status: Success (0x00)
> HCI Event: Read Remote Extended Features (0x23) plen 13                                                                                                                #16 [hci0] 6.418963
        Status: Success (0x00)
        Handle: 256
        Page: 1/2
        Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
< HCI Command: Remote Name Request (0x01|0x0019) plen 10                                                                                                                 #17 [hci0] 6.419074
        Address: 00:10:CC:4F:36:03 (CLP COMPUTER LOGISTIK PLANUNG GmbH)
        Page scan repetition mode: R2 (0x02)
        Page scan mode: Mandatory (0x00)
        Clock offset: 0x0000
< ACL Data TX: Handle 256 flags 0x00 dlen 10                                                                                                                             #18 [hci0] 6.419104
      L2CAP: Information Request (0x0a) ident 1 len 2
        Type: Extended features supported (0x0002)
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                #19 [hci0] 6.419930
      Remote Name Request (0x01|0x0019) ncmd 1
        Status: Success (0x00)
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                   #20 [hci0] 6.425023
        Num handles: 1
        Handle: 256
        Count: 1
> HCI Event: Remote Name Req Complete (0x07) plen 255                                                                                                                    #21 [hci0] 6.430003
        Status: Success (0x00)
        Address: 00:10:CC:4F:36:03 (CLP COMPUTER LOGISTIK PLANUNG GmbH)
        Name: OBDII
@ MGMT Event: Device Connected (0x000b) plen 20                                                                                                                     {0x0001} [hci0] 6.430056
        BR/EDR Address: 00:10:CC:4F:36:03 (CLP COMPUTER LOGISTIK PLANUNG GmbH)
        Flags: 0x00000008
          Connection Locally Initiated
        Data length: 7
        Name (complete): OBDII
> ACL Data RX: Handle 256 flags 0x02 dlen 16                                                                                                                             #22 [hci0] 6.437601
      L2CAP: Information Response (0x0b) ident 1 len 8
        Type: Extended features supported (0x0002)
        Result: Success (0x0000)
        Features: 0x00000000
< ACL Data TX: Handle 256 flags 0x00 dlen 12                                                                                                                             #23 [hci0] 6.437668
      L2CAP: Connection Request (0x02) ident 2 len 4
        PSM: 3 (0x0003)
        Source CID: 64
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                   #24 [hci0] 6.441004
        Num handles: 1
        Handle: 256
        Count: 1
> ACL Data RX: Handle 256 flags 0x02 dlen 16                                                                                                                             #25 [hci0] 6.453672
      L2CAP: Connection Response (0x03) ident 2 len 8
        Destination CID: 64
        Source CID: 64
        Result: Connection successful (0x0000)
        Status: No further information available (0x0000)
> ACL Data RX: Handle 256 flags 0x02 dlen 16                                                                                                                             #26 [hci0] 6.453675
      L2CAP: Configure Request (0x04) ident 1 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 668
< ACL Data TX: Handle 256 flags 0x00 dlen 16                                                                                                                             #27 [hci0] 6.453761
      L2CAP: Configure Request (0x04) ident 3 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 1021
< ACL Data TX: Handle 256 flags 0x00 dlen 18                                                                                                                             #28 [hci0] 6.453780
      L2CAP: Configure Response (0x05) ident 1 len 10
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 668
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                   #29 [hci0] 6.459103
        Num handles: 1
        Handle: 256
        Count: 1
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                   #30 [hci0] 6.459979
        Num handles: 1
        Handle: 256
        Count: 1
> ACL Data RX: Handle 256 flags 0x02 dlen 18                                                                                                                             #31 [hci0] 6.465671
      L2CAP: Configure Response (0x05) ident 3 len 10
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 1021
< ACL Data TX: Handle 256 flags 0x00 dlen 8                                                                                                                              #32 [hci0] 6.465833
      Channel: 64 len 4 [PSM 3 mode Basic (0x00)] {chan 0}
      RFCOMM: Set Async Balance Mode (SABM) (0x2f)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0x3f poll/final 1
         Length: 0
         FCS: 0x1c
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                   #33 [hci0] 6.474195
        Num handles: 1
        Handle: 256
        Count: 1
> ACL Data RX: Handle 256 flags 0x02 dlen 8                                                                                                                              #34 [hci0] 6.481715
      Channel: 64 len 4 [PSM 3 mode Basic (0x00)] {chan 0}
      RFCOMM: Unnumbered Ack (UA) (0x63)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0x73 poll/final 1
         Length: 0
         FCS: 0xd7
< ACL Data TX: Handle 256 flags 0x00 dlen 18                                                                                                                             #35 [hci0] 6.481922
      Channel: 64 len 14 [PSM 3 mode Basic (0x00)] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0xef poll/final 0
         Length: 10
         FCS: 0x70
         MCC Message type: DLC Parameter Negotiation CMD (0x20)
...skipping...
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 668
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                   #29 [hci0] 6.459103
        Num handles: 1
        Handle: 256
        Count: 1
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                   #30 [hci0] 6.459979
        Num handles: 1
        Handle: 256
        Count: 1
> ACL Data RX: Handle 256 flags 0x02 dlen 18                                                                                                                             #31 [hci0] 6.465671
      L2CAP: Configure Response (0x05) ident 3 len 10
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 1021
< ACL Data TX: Handle 256 flags 0x00 dlen 8                                                                                                                              #32 [hci0] 6.465833
      Channel: 64 len 4 [PSM 3 mode Basic (0x00)] {chan 0}
      RFCOMM: Set Async Balance Mode (SABM) (0x2f)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0x3f poll/final 1
         Length: 0
         FCS: 0x1c
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                   #33 [hci0] 6.474195
        Num handles: 1
        Handle: 256
        Count: 1
> ACL Data RX: Handle 256 flags 0x02 dlen 8                                                                                                                              #34 [hci0] 6.481715
      Channel: 64 len 4 [PSM 3 mode Basic (0x00)] {chan 0}
      RFCOMM: Unnumbered Ack (UA) (0x63)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0x73 poll/final 1
         Length: 0
         Length: 0
         FCS: 0xd7
< ACL Data TX: Handle 256 flags 0x00 dlen 18                                                                                                                             #35 [hci0] 6.481922
      Channel: 64 len 14 [PSM 3 mode Basic (0x00)] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0xef poll/final 0
         Length: 10
         FCS: 0x70
         MCC Message type: DLC Parameter Negotiation CMD (0x20)
           Length: 8
           dlci 4 frame_type 0 credit_flow 15 pri 7
           ack_timer 0 frame_size 663 max_retrans 0 credits 7
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                   #36 [hci0] 6.484969
        Num handles: 1
           dlci 4 frame_type 0 credit_flow 15 pri 7
           ack_timer 0 frame_size 663 max_retrans 0 credits 7
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                   #36 [hci0] 6.484969
        Num handles: 1
        Handle: 256
        Count: 1
> ACL Data RX: Handle 256 flags 0x02 dlen 18                                                                                                                             #37 [hci0] 6.493479
      Channel: 64 len 14 [PSM 3 mode Basic (0x00)] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x01 cr 0 dlci 0x00
         Control: 0xef poll/final 0
         Length: 10
         FCS: 0xaa
         MCC Message type: DLC Parameter Negotiation RSP (0x20)
           Length: 8
           dlci 4 frame_type 0 credit_flow 14 pri 7
           ack_timer 0 frame_size 662 max_retrans 0 credits 0
< ACL Data TX: Handle 256 flags 0x00 dlen 8                                                                                                                              #38 [hci0] 6.493701
      Channel: 64 len 4 [PSM 3 mode Basic (0x00)] {chan 0}
      RFCOMM: Set Async Balance Mode (SABM) (0x2f)
         Address: 0x13 cr 1 dlci 0x04
         Control: 0x3f poll/final 1
         Length: 0
         FCS: 0x96
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                   #39 [hci0] 6.498304
        Num handles: 1
        Handle: 256
        Count: 1
> ACL Data RX: Handle 256 flags 0x02 dlen 8                                                                                                                              #40 [hci0] 6.498359
      Channel: 64 len 4 [PSM 3 mode Basic (0x00)] {chan 0}
      RFCOMM: Unnumbered Ack (UA) (0x63)
         Address: 0x13 cr 1 dlci 0x04
         Control: 0x73 poll/final 1
         Length: 0
         FCS: 0x5d
< ACL Data TX: Handle 256 flags 0x00 dlen 12                                                                                                                             #41 [hci0] 6.498649
      Channel: 64 len 8 [PSM 3 mode Basic (0x00)] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0xef poll/final 0
         Length: 4
         FCS: 0x70
         MCC Message type: Modem Status Command CMD (0x38)
           Length: 2
           dlci 4 
           fc 0 rtc 1 rtr 1 ic 0 dv 1

i'm seeing "RFCOMM: Unnumbered Ack (UA) (0x63)" which i am not sure what it means, and it seems from there onwards the connection has some problems, "RFCOMM: Unnumbered Info with Header Check (UIH)" is another one i spoted but not sure what it is.

what am i missing ?

waltinator avatar
it flag
You're assuming the OBD2 device speaks ASCII text. It does not. See https://learn.sparkfun.com/tutorials/getting-started-with-obd-ii/all
sgt avatar
cn flag
sgt
@waltinator again thanks for the response after reading the tutorial i am still confused, it doesn´t mention anything about ascii, what mode should i be using ? how can i change it ?
waltinator avatar
it flag
Search the software repositories for OBD2/OBDII compatible software, install it, and read the `man` page. Use `apt-cache search OBD2; apt-cache search OBDII` to find the packages.
waltinator avatar
it flag
Some of the "Additional Resources" in the tutorial might help your understanding, like (https://sourceforge.net/projects/freediag/ ) and (https://theksmith.com/software/hack-vehicle-bus-cheap-easy-part-2/).
vidarlo avatar
om flag
@waltinator ELM327 talks OBD2 to the car. *You* talk AT-commands to the ELM327. Your links is simply wildly misleading when it comes to ELM327, as you do indeed talk ascii to it. [Refer to the datasheet for ELM327 for details](https://www.elmelectronics.com/wp-content/uploads/2017/01/ELM327DS.pdf)
vidarlo avatar
om flag
E.g. [sparkfun.com documents the command set](https://www.sparkfun.com/datasheets/Widgets/ELM327_AT_Commands.pdf) fairly well, and afaik sells ELM327 based adapters.
waltinator avatar
it flag
The "rules" for communicating across a wire is referred to as a "protocol". What you've been calling "ASCII text" isn't. It's "Serial protocol 8N1" at an agreed-upon baud rate. Eght bits per character, No parity, 1 Stop bit. The eight data bits may contain an ASCII character or an eight bit binary value from 0 to 255, or the eight bits might have individual meanings, depending on the protocol in use. You're desiring serial 8N1 ASCII encoded text. The adapter is sending OBD2 protocol data. Use the tools, write a `perl` script.
vidarlo avatar
om flag
@waltinator ELM327 is a PIC microcontroller that translates between protocols. It has a RS232 interface that accepts AT-style commands, and translates it into ODB2 commands that's sent over J1939 or similar. Read the links I provided. I *know* this stuff; it's literally my job. The ***purpose*** of the ELM327 is to provide an interface to OBD2. If you suggest that ELM327 is *not* using ASCII, please tell sparkfun.com and ELM that their datasheet is wrong.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.