robin-thoni / tesla-ble-esphome

7 stars 0 forks source link

Immediate disconnect if ~ >3meters away #1

Open raphmur opened 1 month ago

raphmur commented 1 month ago

Hi there, Nice work

My config: nodeMCU form factor, with ESP-WROOM-32.

In installed your component, all good. Paired the keys while in the car.

My issue: Immediate disconnect if getting too far away (about 2 / 3 meters, and especially behind by house door.

Any idea on the signal level threshold or anything around this? Is ESP32 BLE powerful enough?

I have captured the logs below (only putting relevant parts):

[22:18:35][C][esp32_ble:383]: ESP32 BLE:
[22:18:35][C][esp32_ble:385]:   MAC address: 24:DC:C3:46:11:A2
[22:18:35][C][esp32_ble:386]:   IO Capability: none
[22:18:35][C][ble_client:027]: BLE Client:
[22:18:35][C][ble_client:028]:   Address: xx:xx:xx:xx:xx:xx
[22:18:35][C][ble_client:029]:   Auto-Connect: TRUE
[22:18:35][C][esp32_ble_tracker:653]: BLE Tracker:
[22:18:35][C][esp32_ble_tracker:654]:   Scan Duration: 300 s
[22:18:35][C][esp32_ble_tracker:655]:   Scan Interval: 320.0 ms
[22:18:35][C][esp32_ble_tracker:656]:   Scan Window: 30.0 ms
[22:18:35][C][esp32_ble_tracker:657]:   Scan Type: ACTIVE
[22:18:35][C][esp32_ble_tracker:658]:   Continuous Scanning: True

Connect failed

[22:18:36][D][api.connection:1375]: Home Assistant 2024.7.0 (192.168.50.230): Connected successfully
[22:18:41][D][button:010]: 'Connect to car' Pressed.
[22:18:41][D][esp32_ble_tracker:237]: Stopping scan.
[22:18:41][I][esp32_ble_client:067]: [0] [xx:xx:xx:xx:xx:xx] 0x00 Attempting BLE connection
[22:18:41]lld_pdu_get_tx_flush_nb HCI packet count mismatch (0, 1)
[22:18:42]lld_pdu_get_tx_flush_nb HCI packet count mismatch (0, 1)
[22:18:42]lld_pdu_get_tx_flush_nb HCI packet count mismatch (0, 1)
[22:18:42]lld_pdu_get_tx_flush_nb HCI packet count mismatch (0, 1)
[22:18:42][D][esp32_ble_client:172]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_DISCONNECT_EVT, reason 62
[22:18:42][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_OPEN_EVT
[22:18:42][W][esp32_ble_client:143]: [0] [xx:xx:xx:xx:xx:xx] Connection failed, status=133
[22:18:42][D][esp32_ble_tracker:307]: End of scan.

Connect succeeded as I was at the car door

[22:19:42][D][button:010]: 'Connect to car' Pressed.
[22:19:42][D][esp32_ble_tracker:237]: Stopping scan.
[22:19:42][I][esp32_ble_client:067]: [0] [xx:xx:xx:xx:xx:xx] 0x00 Attempting BLE connection
[22:19:42][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_CONNECT_EVT
[22:19:42][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_OPEN_EVT
[22:19:43][D][esp32_ble_client:306]: [0] [xx:xx:xx:xx:xx:xx] Event 46
[22:19:43][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_SEARCH_CMPL_EVT
[22:19:43][I][esp32_ble_client:227]: [0] [xx:xx:xx:xx:xx:xx] Connected
[22:19:43][D][esp32_ble_client:188]: [0] [xx:xx:xx:xx:xx:xx] cfg_mtu status 0, mtu 115
[22:19:43][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_REG_FOR_NOTIFY_EVT
[22:19:43][D][esp32_ble_client:296]: Wrote notify descriptor 2, properties=32
[22:19:43][D][TESLA_BLE:246]: Writing 16 bytes
[22:19:44][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_WRITE_DESCR_EVT
[22:19:44][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_NOTIFY_EVT
[22:19:44][D][TESLA_BLE:063]: ESP_GATTC_NOTIFY_EVT, value_len=33
[22:19:44][D][TESLA_BLE:070]: Got message: 3
[22:19:44][D][TESLA_BLE:075]: Received authenticationRequest
[22:19:44][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_WRITE_CHAR_EVT
[22:19:44][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_NOTIFY_EVT
[22:19:44][D][TESLA_BLE:063]: ESP_GATTC_NOTIFY_EVT, value_len=74
[22:19:44][D][TESLA_BLE:070]: Got message: 16
[22:19:44][I][TESLA_BLE:100]: Received Whitelist Info numberOfEntries=8 whitelistEntries_count=8
[22:19:44][I][TESLA_BLE:101]:   Our Key: 5C.9F.82.A0
[22:19:44][I][TESLA_BLE:108]:   Key 0: 24.86.82.64
[22:19:44][I][TESLA_BLE:108]:   Key 1: 99.DA.C2.3D
[22:19:44][I][TESLA_BLE:108]:   Key 2: 0B.F7.18.5E
[22:19:44][I][TESLA_BLE:108]:   Key 3: 8D.34.B2.26
[22:19:44][I][TESLA_BLE:108]:   Key 4: A2.0B.83.47
[22:19:44][I][TESLA_BLE:108]:   Key 5: 34.1B.2A.84
[22:19:44][I][TESLA_BLE:108]:   Key 6: 75.40.D8.69
[22:19:44][I][TESLA_BLE:108]:   Key 7: 5C.9F.82.A0 *
[22:19:44][W][component:237]: Component esp32_ble took a long time for an operation (63 ms).
[22:19:44][W][component:238]: Components should block for at most 30 ms.
[22:19:44][D][TESLA_BLE:246]: Writing 16 bytes
[22:19:44][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_WRITE_CHAR_EVT
[22:19:44][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_NOTIFY_EVT
[22:19:44][D][TESLA_BLE:063]: ESP_GATTC_NOTIFY_EVT, value_len=71
[22:19:44][D][TESLA_BLE:070]: Got message: 2
[22:19:44][I][TESLA_BLE:081]: Received ephemeral key
[22:19:44][W][component:237]: Component esp32_ble took a long time for an operation (268 ms).
[22:19:44][W][component:238]: Components should block for at most 30 ms.
[22:19:44]
[22:19:44]before12041A020801
[22:19:44][D][TESLA_BLE:246]: Writing 38 bytes
[22:19:44][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_WRITE_CHAR_EVT
[22:19:44][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_NOTIFY_EVT
[22:19:44][D][TESLA_BLE:063]: ESP_GATTC_NOTIFY_EVT, value_len=12
[22:19:44][D][TESLA_BLE:070]: Got message: 4
[22:19:44][I][TESLA_BLE:119]: Received command status: 2
[22:19:44][I][TESLA_BLE:136]: Received new counter from the car: 3
[22:19:45][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_NOTIFY_EVT
//
[22:20:05][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_NOTIFY_EVT
[22:20:05][D][TESLA_BLE:063]: ESP_GATTC_NOTIFY_EVT, value_len=12
[22:20:05][D][TESLA_BLE:070]: Got message: 1
[22:20:05][I][TESLA_BLE:149]: Received status message:
[22:20:05][I][TESLA_BLE:152]: Car is "unlocked"
[22:20:05][I][TESLA_BLE:156]: Car is "awake"
[22:20:05][I][TESLA_BLE:160]: Charge port is "open"
[22:20:05][I][TESLA_BLE:164]: Front driver door is "closed"
//
[22:20:18][D][button:010]: 'Lock the car' Pressed.
[22:20:18]
[22:20:18]before12021001
[22:20:18][D][TESLA_BLE:246]: Writing 36 bytes
[22:20:18][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_WRITE_CHAR_EVT
[22:20:18][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_NOTIFY_EVT
[22:20:18][D][TESLA_BLE:063]: ESP_GATTC_NOTIFY_EVT, value_len=8
[22:20:18][D][TESLA_BLE:070]: Got message: 4
[22:20:18][I][TESLA_BLE:119]: Received command status: 0
[22:20:18][I][TESLA_BLE:136]: Received new counter from the car: 4
[22:20:18][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_NOTIFY_EVT
[22:20:18][D][TESLA_BLE:063]: ESP_GATTC_NOTIFY_EVT, value_len=14
[22:20:18][D][TESLA_BLE:070]: Got message: 1
[22:20:18][I][TESLA_BLE:149]: Received status message:
[22:20:18][I][TESLA_BLE:152]: Car is "locked"
[22:20:18][I][TESLA_BLE:156]: Car is "awake"
[22:20:18][I][TESLA_BLE:160]: Charge port is "open"
[22:20:18][I][TESLA_BLE:164]: Front driver door is "closed"
[22:20:19][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_NOTIFY_EVT
[22:20:19][D][TESLA_BLE:063]: ESP_GATTC_NOTIFY_EVT, value_len=5
[22:20:19][D][TESLA_BLE:070]: Got message: 44
//
[22:21:57][D][button:010]: 'Unlock the car' Pressed.
[22:21:57]
[22:22:00]before12021001
[22:22:00][D][TESLA_BLE:246]: Writing 36 bytes
[22:22:00][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_WRITE_CHAR_EVT
[22:22:00][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_NOTIFY_EVT
[22:22:00][D][TESLA_BLE:063]: ESP_GATTC_NOTIFY_EVT, value_len=8
[22:22:00][D][TESLA_BLE:070]: Got message: 4
[22:22:00][I][TESLA_BLE:119]: Received command status: 0
[22:22:00][I][TESLA_BLE:136]: Received new counter from the car: 9
[22:22:00][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_NOTIFY_EVT
[22:22:00][D][TESLA_BLE:063]: ESP_GATTC_NOTIFY_EVT, value_len=14
[22:22:00][D][TESLA_BLE:070]: Got message: 1
[22:22:00][I][TESLA_BLE:149]: Received status message:
[22:22:00][I][TESLA_BLE:152]: Car is "locked"
[22:22:00][I][TESLA_BLE:156]: Car is "awake"
[22:22:01][I][TESLA_BLE:160]: Charge port is "open"
[22:22:01][I][TESLA_BLE:164]: Front driver door is "closed"

These were strange

[22:22:06][D][esp32_ble_client:172]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_DISCONNECT_EVT, reason 8
[22:22:06][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_CLOSE_EVT

Then failures when modes ESP back in house (but still 2meters away from car)

[22:22:40][D][button:010]: 'Connect to car' Pressed.
[22:22:40][D][esp32_ble_tracker:237]: Stopping scan.
[22:22:40][I][esp32_ble_client:067]: [0] [xx:xx:xx:xx:xx:xx] 0x00 Attempting BLE connection
[22:22:40]lld_pdu_get_tx_flush_nb HCI packet count mismatch (0, 1)
[22:22:40]lld_pdu_get_tx_flush_nb HCI packet count mismatch (0, 1)
[22:22:40]lld_pdu_get_tx_flush_nb HCI packet count mismatch (0, 1)
[22:22:41]lld_pdu_get_tx_flush_nb HCI packet count mismatch (0, 1)
[22:22:41][D][esp32_ble_client:172]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_DISCONNECT_EVT, reason 62
[22:22:41][D][esp32_ble_client:110]: [0] [xx:xx:xx:xx:xx:xx] ESP_GATTC_OPEN_EVT
[22:22:41][W][esp32_ble_client:143]: [0] [xx:xx:xx:xx:xx:xx] Connection failed, status=133
robin-thoni commented 1 month ago

My issue: Immediate disconnect if getting too far away (about 2 / 3 meters, and especially behind by house door.

Well, I haven't tested BLE range at all yet. The video I made was literally the first test I made w/ the Watchy. The rest of my dev and tests were done using an AZ-Delivery ESP32-WROOM-32 devkit (same as you, AFAIU) plugged in about 3 meters away from the car, behind a 20 cm brick wall.

I can't really say more right now :/