espruino / BangleApps

Bangle.js App Loader (and Apps)
https://banglejs.com/apps
MIT License
473 stars 1.12k forks source link

[apploader] Can't connect to Bangle.js on Ubuntu #3492

Open mkrl opened 3 days ago

mkrl commented 3 days ago

Affected hardware version

Bangle 2

Your firmware version

2v23

The bug

When connecting to Bangle.js 2 from the App Loader and Espruino Web IDE I get an immidiate connection drop with a toast popping up saying

<TOAST>[error] Device connection failed, 

and no further info is provided like usual. Reading the logs in devtools (attached below) reveals the problem is most likely related to

GATT Server is disconnected. Cannot retrieve services. (Re)connect first with `device.gatt.connect`

More context

While this bug occurs on a Ubuntu derivative (Linux username 5.15.0-107-generic #117~20.04.1-Ubuntu SMP Tue Apr 30 10:35:57 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux) in Google Chrome 126.0.6478.61, the connection is just fine while using Windows 11 on the same machine (both App Loader and Web IDE work).

I used to be able to do this on the same distro until I installed a firmware update to 2v23 (I am not entirely sure what was the previous version, but I think it was probably 2v17).

Shortly after the update I got a similar error to https://github.com/espruino/BangleApps/issues/631, which was fixed by resetting the Bangle. After that I was not able to connect using Chrome in Ubuntu.

Devtools logs

App Loader ``` ============================================= comms.js:3 Type 'Puck.debug=3' for full BLE debug info comms.js:4 ============================================= espruinotools.js:5031 GET window.localStorage = null espruinotools.js:54 Initialising Notifications espruinotools.js:54 Initialising Status espruinotools.js:54 Initialising Utils espruinotools.js:54 Initialising Config espruinotools.js:54 Initialising Serial espruinotools.js:54 Initialising CodeWriter espruinotools.js:54 Initialising Modules espruinotools.js:54 Initialising Env espruinotools.js:54 Initialising Compiler espruinotools.js:54 Initialising Assembler espruinotools.js:54 Initialising GetGitHub espruinotools.js:54 Initialising Minify espruinotools.js:54 Initialising CoreModules espruinotools.js:54 Initialising Pretokenise espruinotools.js:54 Initialising SaveOnSend espruinotools.js:54 Initialising SetTime pwa.js:5 👍 beforeinstallprompt BeforeInstallPromptEvent {isTrusted: true, platforms: Array(1), userChoice: Promise, type: 'beforeinstallprompt', target: Window, …} Puck.debug=3 3 loader.js:190 Chosen device BANGLEJS2 puck.js:212 Web Bluetooth is experimental on this platform. See https://github.com/WebBluetoothCG/web-bluetooth/blob/main/implementation-status.md puck.js:409 Device Name: Bangle.js d2bc puck.js:409 Device ID: bp93cz5jt+0LdCn7PfA33Q== puck.js:409 Connected puck.js:409 Disconnected (gattserverdisconnected) ui.js:86 [error] Device connection failed, puck.js:409 ERROR: NetworkError: GATT Server is disconnected. Cannot retrieve services. (Re)connect first with `device.gatt.connect` ```
Espruino Web IDE ``` No chrome.serial - Chrome Serial disabled index.js:96721 No chrome.sockets - Chrome Socket disabled index.js:96721 serial_frame: Not running inside an iframe index.js:96721 Remote Connection enabled index.js:96721 UTF8 Library loaded successfully index.js:96721 No chrome.storage API - disabling Offline mode index.js:96721 GET window.localStorage = "{\"BAUD_RATE\":9600,\"SERIAL_IGNORE\":\"/dev/ttyS*|/dev/*.SOC|/dev/*.MALS\",\"SERIAL_FLOW_CONTROL\":true,\"SERIAL_AUDIO\":\"0\",\"WEB_BLUETOOTH\":true,\"WEB_SERIAL\":true,\"EMULATOR_BANGLEJS\":true,\"RELAY_KEY\":\"\",\"WEBRTC_BRIDGE_ID\":\"\",\"RESET_BEFORE_SEND\":true,\"STORE_LINE_NUMBERS\":true,\"MODULE_URL\":\"https://www.espruino.com/modules\",\"MODULE_EXTENSIONS\":\".min.js|.js\",\"MODULE_AS_FUNCTION\":true,\"MODULE_PROXY_ENABLED\":false,\"MODULE_PROXY_URL\":\"\",\"MODULE_PROXY_PORT\":\"\",\"ENV_ON_CONNECT\":true,\"BLOCKLY_TO_JS\":false,\"BLOCKLY_LANGUAGE\":\"en\",\"BLOCKLY_EXTENSIONS\":\"|bluetooth|robot|\",\"KEYMAP\":\"sublime\",\"THEME\":\"default\",\"INDENTATION_TYPE\":\"spaces\",\"TAB_SIZE\":2,\"DISABLE_CODE_HINTS\":false,\"BOARD_JSON_URL\":\"https://www.espruino.com/json\",\"SERIAL_THROTTLE_SEND\":0,\"COMPILATION\":true,\"COMPILATION_URL\":\"https://www.espruino.com/service/compiler\",\"UNICODE\":false,\"MINIFICATION_LEVEL\":\"\",\"MODULE_MINIFICATION_LEVEL\":\"ESPRIMA\",\"MINIFICATION_Mangle\":true,\"SHOW_WEBCAM_ICON\":0,\"WEBCAM_CONSTRAINTS\":0,\"FONT_SIZE\":12,\"UI_MODE\":\"Normal\",\"SHOW_CODE_LINK_ICON\":false,\"ENABLE_Testing\":false,\"Sound_Success\":\"\",\"Sound_Warning\":\"\",\"Sound_Error\":\"\",\"Sound_Info\":\"\",\"Speak_Success\":false,\"Speak_Warning\":false,\"Speak_Error\":false,\"Speak_Info\":false,\"SHOW_TERMINAL_LOGGER_ICON\":false,\"TERMINAL_LOGGER_SAVE_TO_LOCALSTORAGE\":false,\"PRETOKENISE\":false,\"SAVE_ON_SEND\":0,\"SAVE_STORAGE_FILE\":\"\",\"LOAD_STORAGE_FILE\":2,\"SET_TIME_ON_WRITE\":true,\"NOT_FIRST_RUN\":true,\"WEB_BLUETOOTH_FILTER\":\"\"}" index.js:96721 Initialising SettingsConsole index.js:96721 Initialising Utils index.js:96721 Initialising Config index.js:96721 Initialising HTML index.js:96721 Initialising Notifications index.js:96721 Initialising Status index.js:96721 Initialising App index.js:96721 Initialising File index.js:96721 Initialising Serial index.js:96721 - Initialising Serial Web Audio index.js:96721 - Initialising Serial Web Bluetooth index.js:96721 BT> bluetooth.getDevices exists - grab known devices index.js:100534 Web Bluetooth is experimental on this platform. See https://github.com/WebBluetoothCG/web-bluetooth/blob/main/implementation-status.md index.js:96721 - Initialising Serial Web Serial index.js:96721 Serial> serial.getPorts exists - grab known devices index.js:96721 - Initialising Serial Remote Connection index.js:96721 - Initialising Serial Emulator index.js:96721 Initialising RemoteConnection index.js:96721 Initialising Terminal index.js:96721 Initialising CodeWriter index.js:96721 Initialising Modules index.js:96721 Initialising Env index.js:96721 Initialising Flasher index.js:96721 Initialising FlasherESP8266 index.js:96721 Initialising EditorBlockly index.js:96721 Initialising EditorJavaScript index.js:96721 Initialising Send index.js:96721 Initialising MenuPortSelector index.js:96721 Initialising MenuSettings index.js:96721 Initialising MenuFlasher index.js:96721 Initialising SettingsAbout index.js:96721 Initialising SettingsFlasher index.js:96721 Initialising BoardJSON index.js:96721 Initialising VersionChecker index.js:96721 Initialising Compiler index.js:96721 Initialising Assembler index.js:96721 Initialising GetGitHub index.js:96721 Initialising Unicode index.js:96721 Initialising Minify index.js:96721 Initialising Tutorial index.js:96721 Initialising Webcam index.js:96721 Initialising FontSize index.js:96721 Initialising UiMode index.js:96721 Initialising URLHandler index.js:96721 Initialising CodeLink index.js:96721 Initialising Testing index.js:96721 Initialising Notification_Sound index.js:96721 Initialising Tern index.js:96721 Initialising Debugger index.js:96721 Initialising Tour index.js:96721 Initialising SettingsProfile index.js:96721 Initialising HelpLinks index.js:96721 Initialising Arrows index.js:96721 Initialising Storage index.js:96721 Initialising KeyShortcuts index.js:96721 Initialising TerminalLogger index.js:96721 Initialising CoreModules index.js:96721 Initialising Pretokenise index.js:96721 Initialising SaveOnSend index.js:96721 Initialising SetTime index.js:96721 serviceworker> active blockly_espruino.js:38 window.onload ?lang=en&Enable=%7Cbluetooth%7Crobot%7C index.js:96721 Handling URL "https://www.espruino.com/ide/" index.js:96721 >>> Connecting... index.js:96721 Set Slow Write = true ('Throttle Send'='Auto') index.js:96721 BT> Starting device chooser index.js:100586 Web Bluetooth is experimental on this platform. See https://github.com/WebBluetoothCG/web-bluetooth/blob/main/implementation-status.md index.js:96721 >>> Connecting to Bangle.js d2bc index.js:96721 BT> Device Name: Bangle.js d2bc index.js:96721 BT> Device ID: S2Rn1mZ79sFvxtZtyslUBw== index.js:96721 >>> Connected to BLE index.js:96721 BT> Connected index.js:96721 BT> Disconnected (gattserverdisconnected) index.js:96731 [notify_error] Connection Failed. (anonymous) @ index.js:96731 error @ index.js:98122 (anonymous) @ index.js:104680 (anonymous) @ index.js:99648 closeSerial @ index.js:100660 (anonymous) @ index.js:100599 index.js:96721 >>> Connection Failed. index.js:96721 BT> ERROR: NetworkError: GATT Server is disconnected. Cannot retrieve services. (Re)connect first with `device.gatt.connect`. ```

Steps attempted to fix

  1. Multiple restarts and resets
  2. Restarting the bluetooth service with /etc/init.d/bluetooth restart
  3. Setting different combinations of "Programmable / BLE / HID"
  4. Trying the connection in incognito mode to make sure no browser extensions mess it up

Let me know if I can provide more info to help! Thank you.

Installed apps

boot (0.62), daisy (0.11), antonclk (0.11), widlock (0.08), widid (0.03), welcome (0.14), calculator (0.07), widbt (0.09), dvdbounce (0.01), warsawjs (undefined), widbat (0.12), pomodo (0.02), calendar (0.18), linuxclock (0.06), widalarm (0.02), flipper (undefined), hidmsicswipe (0.01), launch (0.21), sched (0.26), mylocation (0.11), notify (0.14), clock_info (0.12), setting (0.72), alarm (0.48), health (0.30), pebble (0.11), impwclock (0.07), slevel (0.04), sched (0.26), files (0.08), qrcode (0.06), about (0.15), recorder (0.43), run (0.19)

bobrippling commented 3 days ago

Could be related to #2913 - have a look if any versions match up :)

mkrl commented 3 days ago

That might just be it @bobrippling, thank you!

I'll give it a try, I think I might have done a kernel update recently while not connecting Bangle for a long time before so this could be a coincidence.

However, I still have some suspicions because I was able to connect before a firmware update (in order to do the update in the first place) and then not able to connect directly after updating.

thyttan commented 3 days ago

Leaving some links in case they'd help: https://www.espruino.com/Troubleshooting+Bangle.js https://www.espruino.com/Firmware+Update#nrf52 https://www.espruino.com/Troubleshooting+BLE https://forum.espruino.com/conversations/373768/