anakod / WConfigurator

Lilygo TTGO T-Watch-2020 bluetooth configurator
MIT License
5 stars 2 forks source link

Trouble connecting #1

Open datacute opened 3 years ago

datacute commented 3 years ago

Windows & Chrome

Looking at the console output, the times I get continued spinning dots is always after selecting the device to pair to, and when WConfigurator receives either no response, or a battery status update, but no list of buttons:

{"filters":[{"services":["6e400001-b5a3-f393-e0a9-e50e24dcca9e"]}]}                                                                                  JSInterop.js:9 
BluetoothDevice {id: "d24NbMlbQWALgTpS0EIhQw==", name: "Espruino (T-Watch2020)", gatt: BluetoothRemoteGATTServer, ongattserverdisconnected: null}    JSInterop.js:96 
Characteristics listening

Sometimes that's all, other times I also receive:

[13,10,123,116,58,34,115,116,97,116,117,115,34,44,32,98,97,116,58,54]        JSInterop.js:106
[55,125,13,10]                                                               JSInterop.js:106

Which is {t:"status", bat:77} surrounded by CR LF, with no \x03

I have had it work too, when the console includes [3,123,34,97,112,112,34,58,34,105,114,34,44,34,114,34,58,34,108,105] ({"app":"ir","r":"li) etc

anakod commented 3 years ago

Thanks for feedback. Unfortunately in my case application works in most cases, I see issues relatively rarely. Can you please provide full connection logs from both Clock (UART output) and App (browser console)? I think it will be very helpful to resolve this issue.

datacute commented 3 years ago

Today I captured the serial log when a connection failed, and saw that the message was incomplete:

[I][blectl.cpp:210] onWrite(): msg: {"r":"list","t":"
...
[I][callback.cpp:196] callback_send(): call blectl cb (0x400d634c:0040:ir-remote setup)
[E][bluejsonrequest.h:23] BluetoothJsonRequest(): deserializeJson() failed: IncompleteInput

Retrying I received:

[I][blectl.cpp:210] onWrite(): msg: {"r":"list","t":"req","app":"ir"}
...
[I][callback.cpp:196] callback_send(): call blectl cb (0x400d634c:0040:ir-remote setup)
[I][IRController.cpp:143] IRController_bluetooth_event_cb(): RECEIVED cmd: list, msg: {"r":"list","t":"req","app":"ir"}

So I think the problem is on the watch, where I suspect the onWrite method is running concurrently with onConnect (which now deletes the message queue).

Actually - the log before the above gives more insight:

[I][BLEDevice.cpp:253] gapEventHandler(): ESP_GAP_BLE_AUTH_CMPL_EVT
[I][blectl.cpp:118] onAuthenticationComplete(): Bluetooth pairing successful
[I][callback.cpp:196] callback_send(): call blectl cb (0x400ef620:0001:pmu blectl)
[I][callback.cpp:196] callback_send(): call blectl cb (0x400eb8bc:0001:statusbar bluetooth)
[I][callback.cpp:196] callback_send(): call blectl cb (0x400db23c:0001:OsmAnd main)
[I][blectl.cpp:78] onConnect(): BLE connected
[I][callback.cpp:196] callback_send(): call blectl cb (0x400ef620:0001:pmu blectl)
[I][callback.cpp:196] callback_send(): call blectl cb (0x400eb8bc:0001:statusbar bluetooth)
[I][callback.cpp:196] callback_send(): call blectl cb (0x400db23c:0001:OsmAnd main)
[I][blectl.cpp:78] onConnect(): BLE connected
[I][BLEAdvertising.cpp:507] handleGAPEvent(): STOP advertising
[I][BLEAdvertising.cpp:507] handleGAPEvent(): STOP advertising
[I][callback.cpp:196] callback_send(): call pmu cb (0x400eb784:0004:statusbar pmu)
[I][callback.cpp:196] callback_send(): call pmu cb (0x400ec62c:0004:bluetooth battery)
[I][callback.cpp:196] callback_send(): call pmu cb (0x400eb784:0002:statusbar pmu)
[I][callback.cpp:196] callback_send(): call pmu cb (0x400ec62c:0002:bluetooth battery)
[I][callback.cpp:196] callback_send(): call pmu cb (0x400eb784:0001:statusbar pmu)
[I][callback.cpp:196] callback_send(): call pmu cb (0x400ec62c:0001:bluetooth battery)
[I][blectl.cpp:638] blectl_loop(): send 20byte [ "??{t:"status", bat:9" ] chunk
[I][blectl.cpp:656] blectl_loop(): send  4byte [ "8}??" ] chunk
[I][blectl.cpp:202] onWrite(): message complete, fire BLTCTL_MSG callback
[I][blectl.cpp:210] onWrite(): msg: {"r":"list","t":"

It is reporting that it is connected twice!? Likewise the disconnect is getting reported twice.

anakod commented 3 years ago

Is it receiving onConnect() event twice in both cases, or only in case when part of message was lost?

drunkscientist commented 3 years ago
I][main_tile.cpp:276] main_tile_update_time(): renew time_str: 8:52 != 8:51
[I][blectl.cpp:80] onConnect(): BLE connected
[I][BLEAdvertising.cpp:518] handleGAPEvent(): STOP advertising
[I][blectl.cpp:585] blectl_send_chunk(): send 20byte [ "??{t:"status", bat:9" ] chunk
[I][blectl.cpp:585] blectl_send_chunk(): send  4byte [ "7}??" ] chunk
lld_pdu_get_tx_flush_nb HCI packet count mismatch (0, 1)
[I][blectl.cpp:91] onDisconnect(): BLE disconnected
[I][blectl.cpp:95] onDisconnect(): BLE advertising...
[I][BLEDevice.cpp:253] gapEventHandler(): ESP_GAP_BLE_AUTH_CMPL_EVT
[I][blectl.cpp:120] onAuthenticationComplete(): Bluetooth pairing unsuccessful
[I=��f�.�␆��␆␆�␃���f�x���␆�␅f���f�af��␘~ g��␀��~␆Þ`�f5
;f�]�f�չcpp:33␞�W�͞f}�␆~a�␆x�f␆Ø␘'��������silf�3�f␖������␁␘~i�f,.        �xmin
[I][pmu.cpp:346] pmu_standby(): go standby, enable 2800mV standby voltage

sorry about platform io not grabbing all the characters. i have no idea why, so i tried a couple times

[�␀␀����m�␀=��W␀H␁��������␀c␀��␀p�␀0�␀�����뀠␖␀���V��_␀����␋�␀)�␀:␀␚���␀�t����␀ ��␁␀�␡␀������␀e�␀���&�␀ �␀���␀5�����␟␀��␀�␀�␖����,��e␀␀�␀*������PM/DFS support, 80/10MHz with light sleep [I][blectl.cpp:80] onConnect(): BLE connected [I]␃�␁␀��Q␀�␀␀����␀@.���␀k��␀����␀�p␚�␀�Ҫ���handleGAPEvent(): STOP advertising [I][␀␀�␀�␀��␀р␀��.�␀�␀��␀��␀␀␀�����␀␒�␀��␡,␗�5���}��չ��): send 20byte [ "??{t:"status", bat:9" ] chunk [I][bl��␀4␃��l��␀�␀��␀退�␀␀�␀��␅␀␀␀���ѱ}͕��}��չ��): send 4byte [ "7}??" ] chunk [I][blectl.cpp:91] onDisconnect(): BLE disconnected [I][blectl.cpp:95] onDisconnect(): BLE advertising... [I][BLEDevice.cpp:253] gapEventHandler(): ESP_GAP_BLE_AUTH_CMPL_EVT [I][blectl.cpp:120] onAuthenticationComplete(): Bluetooth pairing unsuccessful [I][blectl.cpp:80] onConnect(): BLE connected [I][BLE�␀␀�␗�␀�␀.���␀s�␀���␀�␀i�␀�␏�␀5␇␀␀ꀀ␀␀handleGAPEvent(): STOP advertising [I][blectl.cpp:585] blectl_send_chunk(): send 20byte [ "??{t:"status", bat:9" ] chunk [I][blectl.cpp:585] blectl_send_chunk(): s����� 4byte [␀␒␀�S���␀␀␀␀␀ ��␀␚�␀���␀����␀␀ [I][blectl.cpp:91] onDisconnect(): BLE disconnected [I][blectl.cpp:95] onDisconnect(): BLE advertising... [I][BLEDevice.cpp:253] gapEventHandler(): ESP_GAP_BLE_AUTH_CMPL_EVT [I][blectl.cpp:120] onAuthenticationComplete(): Bluetooth pairing unsuccessful [I][powermgm.cpp:104] powermgm_loop(): go silence wakeup`

␚[I][blectl.cpp:80] onConnect(): BLE connected␀�,����␀�␀� ��␀�n␁�␀␀�␀����␀�␀�5�DFS support, 80/10MHz with light sleep [I]��$␁␀␕␡��␀W�ѥͥ���cp␀�␎�S␀␀�handleGAPEvent(): STOP advertising [I][blectl.cpp:585] blectl_send_chunk(): send 20byte [ "??{t:"status", bat:9" ] chunk [I][blec␀�b␇�␀c␀��585] blectl_send_chunk(): send 4␂�䁀�␖ڀ�␀r�␀���?" ] chunk�␀ [I][blectl.cpp:91] onDisconnect(): BLE disconnected [I][blectl.cpp:95] onDisconnect(): BLE advertising... [I][BLEDevice.cpp:253] gapEventHandler(): ESP_GAP_BLE_AUTH_CMPL_EVT [I][blectl.cpp:120] onAuthenticationComplete(): Bluetooth pairing unsuccessful [I][blectl.cpp:80] onConnect(): BLE connected [I][␆� �␀�␄�ٕ�ѥͥ���cpp:518] handleGAPEvent(): STOP ␁�␁��e�␀�␀����␀�␁XVHh�um����ѱ�cpp:585] blectl_send_chunk(): send 20byte [ "??{t:"status", bat:9" ] chunk [I][bl��␀h?��␋�␀�␀��␀退�␀� �␀�\␀␀␐���ѱ}͕��}��չ��): send 4byte [ "7}??" ] chunk [I][blectl.cpp:91] onDisconnect(): BLE disconnected [I][blectl.cpp:95] onDisconnect(): BLE advertising... [I][BLEDevice.cpp:253] gapEventHandler(): ESP_GAP_BLE_AUTH_CMPL_EVT [I][blectl.cpp:120] onAuthenticationComplete(): Bluetooth pairing unsuccessful

it kinda worked the first few times i used it, but anymore i cant get anything but "An unhandled error has occurred. Reload" at the bottom of my screen

anakod commented 3 years ago

That's strange.

Bluetooth pairing unsuccessful

May be this is the issue reason? Is https://my-ttgo-watch.co.uk BT pairing working in your case?

drunkscientist commented 3 years ago

so i almost said that page worked fine (since it did yesterday) but i decided to try again to verify: it connects briefly before disconnecting again. the first time was too quick to do anything so i restarted my bt and tried again, it connected long enough for me to click on and get the step counter data before losing the connection again. grabbed logs from that page: --- Miniterm on /dev/ttyUSB0 115200,8,N,1 --- --- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H --- [I][blectl.cpp:80] onConnect(): BLE connected [I]��%␁␀���T�␀␀����␀��␁���␀k��␀���␀�␀�␀�␀��␀�␀5␡␀␀ꀁhandleGAPEvent(): STOP advertising [I];�␀␀����X␀р␀��␀�␀�␀␁�␀���␀␀5���␀␒�␀�P�␀�␀␗���P␀�n␀␀��5�␀�P�␀���-�␀�␀I␀␀␀s��␀�␀��␀��␀␀b��␀W␀�␀��␀␀��␀�ڀ␀�H~␀␀�.���␀��͉, bat:9" ] chunk [I][b쀀 ��␀��l��␀�,�␀退�␀�}␀��␅␀␀␀�␡�␀��,��␀�␃�␀�␁��␀ր��␀������n?��␀)�␀␀�@��␀��Y��␀,␀␀D>␀��x�����␀���� �␀␀�N����␀␀␀␀␀␚��␀␚�␀���␀����␀␀��[I][blectl.cpp:91] onDisconnect(): BLE disconnected [I][blectl.cpp:95] onDisconnect(): BLE advertising... [I][BLEDevice.cpp:253] gapEventHandler(): ESP_GAP_BLE_AUTH_CMPL_EVT [I][blectl.cpp:120] onAuthenticationComplete(): Bluetooth pairing unsuccessful [I][blectl.cpp:80] onConnect(): BLE connected ����␀������␀c␀��␀��␀1␀��␀B�␐���␡�␝␅A␕ٕ�ѡ): STOP advertising [I]��%␁���␘␑�l␀i�␀��585] blec␜��5␏��␀ր�,��␀k��(␟���␀������␁�␀␀␒�y␀���␀ڀ�@�␀���ڀ␀�␒�х��͉, ␀␀ ␇�␀�␀␒␀ ����␀���]�h␋�@␁[I][blectl.cpp:91] onDisconnect(): BLE disconnected [I][blectl.cpp:95] onDisconnect(): BLE advertising... [I][BLEDevice.cpp:253] gapEventHandler(): ESP_GAP_BLE_AUTH_CMPL_EVT [I][blectl.cpp:120] onAuthenticationComplete(): Bluetooth pairing unsuccessful`

[I][blectl.cpp:80] onConnect(): BLE connected [I]�� ␁␀�E␁�␀␀��␅␀�␀.���␀��␡␀��n�␀�␀i�␀�␁�␀j␁␀␀�handleGAPEvent(): STOP advertising [I]��H␁����␀р␀ˀ␀c␀��␀��␀8���␀␒�␅␀�␡��5���}��չ��): send 20byte [ "??{t:"status", bat:9" ] chunk [I][blectl.cpp:91] onDisconnect(): BLE disconnected [I][blectl.cpp:95] onDisconnect(): BLE advertising... [I][BLEDevice.cpp:253] gapEventHandler(): ESP_GAP_BLE_AUTH_CMPL_EVT [I][blectl.cpp:120] onAuthenticationComplete(): Bluetooth pairing unsuccessful [I][blectl.cpp:80] onConnect(): BLE connected [I]���� ␁␀���T�␀␀�?�␀�␀.���␀����␀���␀�␀i�␀��␀�␀518] handleGAPEvent(): STOP advertising [I][blectl.cpp:585] blectl_send_chunk(): send ␀␀�␀␀␀������ ␁␀���␂�␀␀␀��␀��р␀� d␀�␀W�␀����␀H␂�␀␀␒��␀��␀�␀9␂␀␀ꀀ␀␀c␀���������␀␀�␀[I][blectl.cpp:91] onDisconnect(): BLE disconnected [I][blectl.cpp:95] onDisconnect(): BLE advertising... [I][BLEDevice.cpp:253] gapEventHandler(): ESP_GAP_BLE_AUTH_CMPL_EVT [I][blectl.cpp:120] onAuthenticationComplete(): Bluetooth pairing unsuccessful [I][blectl.cpp:80] onConnect(): BLE connected [I]�(␀␕�␀��␀W␀H␁�������n�␀�����␀��@̀␀�␀�W␀h�␀��dleGAPEvent(): STOP advertising [I]␃%␁����,��␀ˀ�,��␀��␀� �P�␀␒�␀�␀h␁����5�e�����5�␀���␟�␋␟�J�␀ �␀��␀�� �␀��␀␀�␀W␀␂␎�␅␀␀�␀?��р␀��␀�␁��␇p���.␀␀,␀␒��␀␑�:?␒�␀ꀀ␀�␀�␟������␀ [I][blectl.cpp:91] onDisconnect(): BLE disconnected [I][blectl.cpp:95] onDisconnect(): BLE advertising... [I][BLEDevice.cpp:253] gapEventHandler(): ESP_GAP_BLE_AUTH_CMPL_EVT [I][blectl.cpp:120] onAuthenticationComplete(): Bluetooth pairing unsuccessful [I][blectl.cpp:80] onConnect(): BLE connected [I]ۀ␀␀�␀�␀��␀␑�␀��?␀�t␁���␀��␀�@␖�␀�␀␁�␀退�␀���handleGAPEvent(): STOP advertising [I]��%�␀���Y␀�␀���␀�4␟�␀ ␀��������␀]␀␀␀�����␀��␀��l�����␀�␀�������,����\␡�����␀�␀␀'␀�␀��␀�@␖␀␀&␀␀␀�␀���Y␀���␀␀␀���␀�/��␀�␒␀�␀D��␀W���␀�␀�␀␀␂␀��␀р␀�ʀ␀␀␀␀ ��␀␚�␀��␁����␀␀�␀[I][blectl.cpp:91] onDisconnect(): BLE disconnected [I][blectl.cpp:95] onDisconnect(): BLE advertising... [I][BLEDevice.cpp:253] gapEventHandler(): ESP_GAP_BLE_AUTH_CMPL_EVT [I][blectl.cpp:120] onAuthenticationComplete(): Bluetooth pairing unsuccessful`

anakod commented 3 years ago

So looks like issue isn't in WConfigurator application directly?

drunkscientist commented 3 years ago

since i have an iphone, i cant use gagetbridge and afaik cant do much else with bt atm, so it could be faulty hardware for all i know. it definately DID work previously, and now doesnt. not on my desktop in linux or windows 10, nor my brothers laptop which is win10. i didnt touch any bt related code, nor do i use any in anything ive written. im assuming you havnt changed anything, which leaves something upstream, are the 2 pages built on common framework? is it worth trying with a different browser, say firefox instead of chrome?