meshtastic / firmware

Meshtastic device firmware
https://meshtastic.org
GNU General Public License v3.0
3.37k stars 825 forks source link

[Bug]: Bluetooth pairing always fails #2793

Closed mverch67 closed 1 year ago

mverch67 commented 1 year ago

Category

BLE

Hardware

heltec_v3, t3s3, t-deck, t-watch s3

Firmware Version

2.2.3 - 2.2.6

Description

Since firmware 2.2.3 the pairing with Android APP fails for devices when installed using flash erase. The APP constantly tries to re-connect but pairing fails when entering the proper 6 digit pin code.

Workaround: Install firmware version 2.2.2, then connect with APP via bluetooth. After successful connect an update (but not install with flash erase) to firmware 2.2.3 -2.2.6 is possible which will then allow to connect with the APP via BT.

Relevant log output

INFO  | ??:??:?? 4 [PowerFSM] Initialise the NimBLE bluetooth module
I NimBLEDevice: BLE Host Task Started
I NimBLEDevice: NimBle host synced.
D NimBLEDevice: >> setPower: 11 (type: 11)
D NimBLEDevice: << setPower
D NimBLEDevice: Setting bonding: 1, mitm: 1, sc: 1
D NimBLEServer: >> createService - 6ba1b218-15a8-461f-9fa8-5dcae273eafd
D NimBLEServer: << createService
D NimBLEService: >> start(): Starting service: UUID: 6ba1b218-15a8-461f-9fa8-5dcae273eafd, handle: 0xffff
D NimBLEService: Adding 3 characteristics for service UUID: 6ba1b218-15a8-461f-9fa8-5dcae273eafd, handle: 0xffff
D NimBLEService: << start()
D NimBLEAdvertising: >> Advertising start: customAdvData: 0, customScanResponseData: 0
primary service
           uuid 0x1800
         handle 1
     end_handle 5
characteristic
           uuid 0x2a00
     def_handle 2
     val_handle 3
   min_key_size 0
          flags [READ]
characteristic
           uuid 0x2a01
     def_handle 4
     val_handle 5
   min_key_size 0
          flags [READ]
primary service
           uuid 0x1801
         handle 6
     end_handle 9
characteristic
           uuid 0x2a05
     def_handle 7
     val_handle 8
   min_key_size 0
          flags [INDICATE]
ccc descriptor
           uuid 0x2902
         handle 9
   min_key_size 0
          flags [READ|WRITE]
primary service
           uuid 6ba1b218-15a8-461f-9fa8-5dcae273eafd
         handle 10
     end_handle 17
characteristic
           uuid f75c76d2-129e-4dad-a1dd-7866124401e7
     def_handle 11
     val_handle 12
   min_key_size 0
          flags [WRITE|WRITE_ENC|WRITE_AUTHEN]
characteristic
           uuid 2c55e69e-4993-11ed-b878-0242ac120002
     def_handle 13
     val_handle 14
   min_key_size 0
          flags [READ|READ_ENC|READ_AUTHEN]
characteristic
           uuid ed9da18c-a800-4f66-a670-aa7547e34453
     def_handle 15
     val_handle 16
   min_key_size 0
          flags [READ|NOTIFY|READ_ENC|READ_AUTHEN]
ccc descriptor
           uuid 0x2902
         handle 17
   min_key_size 0
          flags [READ|WRITE]
D NimBLEAdvertising: << Advertising start
INFO  | ??:??:?? 6 [Screen] Done with boot screen...
DEBUG | ??:??:?? 6 [Screen] showing standard frames
DEBUG | ??:??:?? 6 [Screen] Showing 0 module frames
DEBUG | ??:??:?? 6 [Screen] Total frame count: 103
DEBUG | ??:??:?? 6 [Screen] Added modules.  numframes: 0
DEBUG | ??:??:?? 6 [Screen] Finished building frames. numframes: 2
D NimBLEServer: >> handleGapEvent: 
D NimBLEServerCallbacks: onConnect(): Default
D NimBLEServerCallbacks: onConnect(): Default
D NimBLEServer: >> handleGapEvent: 
D NimBLEServer: Connection parameters updated.
D NimBLEServer: >> handleGapEvent: 
I NimBLEServer: mtu update event; conn_handle=1 mtu=255
D NimBLEServerCallbacks: onMTUChange(): Default
D NimBLEServer: >> handleGapEvent: 
D NimBLEServer: Connection parameters updated.
D NimBLEServer: >> handleGapEvent: 
INFO  | ??:??:?? 16 Using random passkey
INFO  | ??:??:?? 16 *** Enter passkey 882336 on the peer side ***
D NimBLEServer: BLE_SM_IOACT_DISP; ble_sm_inject_io result: 0
D NimBLEServer: << handleGATTServerEvent
DEBUG | ??:??:?? 16 [Screen] showing bluetooth screen
DEBUG | ??:??:?? 21 [Power] Battery: usbPower=0, isCharging=0, batMv=4111, batPct=90
INFO  | ??:??:?? 21 [PowerFSM] Loss of power in Powered
DEBUG | ??:??:?? 21 [PowerFSM] Enter state: ON
DEBUG | ??:??:?? 21 [Screen] Screen: Unpowered...
INFO  | ??:??:?? 31 [NodeInfoModule] Sending our nodeinfo to mesh (wantReplies=1)
INFO  | ??:??:?? 31 [NodeInfoModule] sending owner !fa68adb8/Meshtastic adb8/adb8
DEBUG | ??:??:?? 31 [NodeInfoModule] Initial packet id 1388697640, numPacketId 4294967295
DEBUG | ??:??:?? 31 [NodeInfoModule] Update DB node 0xfa68adb8, rx_time=0, channel=0
DEBUG | ??:??:?? 31 [NodeInfoModule] handleReceived(LOCAL) (id=0x52c5d82a fr=0xb8 to=0xff, WantAck=0, HopLim=3 Ch=0x0 Portnum=4 WANTRESP priority=10)
DEBUG | ??:??:?? 31 [NodeInfoModule] No modules interested in portnum=4, src=LOCAL
DEBUG | ??:??:?? 31 [NodeInfoModule] localSend to channel 0
DEBUG | ??:??:?? 31 [NodeInfoModule] Add packet record (id=0x52c5d82a fr=0xb8 to=0xff, WantAck=0, HopLim=3 Ch=0x0 Portnum=4 WANTRESP priority=10)
DEBUG | ??:??:?? 31 [NodeInfoModule] Expanding short PSK #1
DEBUG | ??:??:?? 31 [NodeInfoModule] Using AES128 key!
DEBUG | ??:??:?? 31 [NodeInfoModule] ESP32 crypt fr=fa68adb8, num=52c5d82a, numBytes=50!
WARN  | ??:??:?? 31 [NodeInfoModule] send - lora tx disable because RegionCode_Unset
D NimBLEServer: >> handleGapEvent: 
D NimBLEServer: Connection parameters updated.
D NimBLEServer: >> handleGapEvent: 
I NimBLEServer: mtu update event; conn_handle=1 mtu=255
D NimBLEServerCallbacks: onMTUChange(): Default
D NimBLEServer: >> handleGapEvent: 
D NimBLEServer: Connection parameters updated.
D NimBLEServer: >> handleGapEvent: 
D NimBLEServerCallbacks: onDisconnect(): Default
INFO  | ??:??:?? 34 BLE disconnect
D NimBLEAdvertising: >> Advertising start: customAdvData: 0, customScanResponseData: 0
D NimBLEAdvertising: << Advertising start
D NimBLEServer: >> handleGapEvent: 
D NimBLEServerCallbacks: onConnect(): Default
D NimBLEServerCallbacks: onConnect(): Default
D NimBLEServer: >> handleGapEvent: 
D NimBLEServer: Connection parameters updated.
D NimBLEServer: >> handleGapEvent: 
I NimBLEServer: mtu update event; conn_handle=1 mtu=255
D NimBLEServerCallbacks: onMTUChange(): Default
D NimBLEServer: >> handleGapEvent: 
D NimBLEServer: Connection parameters updated.
D NimBLEServer: >> handleGapEvent: 
INFO  | ??:??:?? 38 Using random passkey
INFO  | ??:??:?? 38 *** Enter passkey 414459 on the peer side ***
DEBUG | ??:??:?? 38 Enter state: ON
DED NimBLEServer: BBLE_SM_UGIOACT_DISP; ble_sm_inject_io result: 0
D NimBLEServer: << handleGATTServerEvent
 | ??:??:?? 38 [Screen] showing bluetooth screen
garthvh commented 1 year ago

Does forgetting the device also work? Are you checking the checkbox or using the drop down in the web flasher?

mverch67 commented 1 year ago

Forgetting the device does not work. Using CLI device-install.

Something must have changed between firmware 2.2.2 and 2.2.3 that causes this issue.

me639276639936 commented 1 year ago

T-watch, iPhone pairing. Same problem

cordelster commented 1 year ago

I can confirm, from iPhone app, and Android I am seeing the same issue 2.2.3 to current 2.2.6 on all platforms (techo, heltec, tbeam, tloras). If anyone needs output from any of these devices, I can add, though it dont look like it specific to device. I dont have a screen for any of my RAK so not using a random pin there and can pair using default 123456.

liveacid commented 1 year ago

Confirmed, I am receiving this issue on the latest Android app release (2.2.4) for firmaware v2.2.4 and above on a Heltec LoRa32 v3. I am able to pair on firmware v2.2.3 and below. I was able to pair one time on firmware v2.2.6 but was not able to set the region. I have not been able to reproduce a successful pairing since on versions (2.2.4-2.2.6). Erasing and installing firmware (v2.2.3 and below) on the Heltec LoRa32 V3 solved the problem for me.

S5NC commented 1 year ago

Narrowing root cause down: https://github.com/meshtastic/firmware/pull/2809#issuecomment-1724147557

ppyzik commented 1 month ago

For t3-s3 bug also occurs on firmware versions 2.4.0.46d7b82 Beta 2.3.15.deb7c27 Beta 2.3.13.83f5ba0 Beta 2.3.12.24458a7 Beta 2.4.1.394e0e1 Alpha 2.3.14.64531fa Alpha 2.3.9.f06c56a Alpha