[nRF5x] How to connect using WebBluetooth REPL?

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

Re: How to connect with Bluetooth REPL using nRF UART app?

Post by WhiteHare » Sat Oct 13, 2018 5:34 pm

Unfortunately, I couldn't get NUS console to work at all:

Code: Select all

root@debian:/home/david/micropython/ports/nrf/nus_console# node index.js
module.js:550
    throw err;
    ^

Error: Cannot find module '/home/david/micropython/ports/nrf/nus_console/node-bluetooth-hci-socket/lib/binding/binding.node'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/david/micropython/ports/nrf/nus_console/node-bluetooth-hci-socket/lib/native.js:6:15)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
root@debian:/home/david/micropython/ports/nrf/nus_console# 
:(

User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

Re: How to connect with Bluetooth REPL using nRF UART app?

Post by WhiteHare » Sat Oct 13, 2018 8:39 pm

Well, I tried using WebBluetooth REPL, but it claims "No Bluetooth support" on either of my PC's (one Windows 10 and the other the freshly installed Debian Linux).

Maybe it's incompatible with the bluetooth adapter?

So, I'm ordering this usb Bluetooth adapter:
https://www.amazon.com/gp/product/B00BC ... 4659&psc=1
in the hope that I'll find more joy.

If anyone has suggestions for any other Debian friendly usb Bluetooth adapter to try, I'd love to hear about it.

I'm not sure it will make a difference, though, because it appears that Debian can is able to find the bluetooth adapter:

Code: Select all

root@debian:~# sudo rfkill list
0: phy0: Wireless LAN
	Soft blocked: no
	Hard blocked: no
2: hci0: Bluetooth
	Soft blocked: no
	Hard blocked: no
root@debian:~# 
[Edit: Debian can definitely find the "mcus" device over bluetooth, but for whatever reason WebBluetooth REPL can't seem to. ]

User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

Re: How to connect with Bluetooth REPL using nRF UART app?

Post by WhiteHare » Sun Oct 14, 2018 2:49 am

I suddenly remembered that my raspberry pi 3 has bluetooth built into it, so tried it. Same result:
nus.png
nus.png (46.56 KiB) Viewed 6468 times
Furthermore, the raspberry pi's bluetooth can see the "mpus" device, but it can't pair with it.

c45713
Posts: 51
Joined: Fri Dec 09, 2016 7:09 pm

Re: How to connect with Bluetooth REPL using nRF UART app?

Post by c45713 » Sun Oct 14, 2018 8:35 am

Just to confirm, did you enable the Chrome flag "Experimental Web Platform features" in chrome://flags?

User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

Re: How to connect with Bluetooth REPL using nRF UART app?

Post by WhiteHare » Sun Oct 14, 2018 1:47 pm

Thank you. No, I hadn't. So, doing that, I do get further:
nus2.png
nus2.png (51.84 KiB) Viewed 6452 times
However, now nothing I type into the NUS console gets echoed back, and I also don't hear anything from the nRF52-DK that it has connected to over Bluetooth.

So, though I definitely seem to be getting closer, still no joy yet. What should I do next?

User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

Re: How to connect with Bluetooth REPL using nRF UART app?

Post by WhiteHare » Sun Oct 14, 2018 11:15 pm

Today I received and installed on my Debian 9 laptop the Panda Bluetooth usb adapter that I referenced above. The results I am now getting with it are the same as with the Raspberry Pi 3 (above). That is to say, "mpus" is detected and paired with, but nothing I type into the WebBluetooth REPL gets either echoed or responded to.

Not sure why I would be experiencing anything different than either kak or c45713, who seem to be succeeding with it. I lack the insight on how it was put together, so it's hard for me to guess what is going wrong. :(

Any further suggestions?

User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

Re: How to connect with Bluetooth REPL using nRF UART app?

Post by WhiteHare » Mon Oct 15, 2018 8:20 am

The third and final thing I tried was running the pynus nus console:

Code: Select all

root@debian:/home/david/micropython/ports/nrf/pynus# python3 pynus.py
Connecting to mpus (F1:A2:C2:2F:77:F3)...
Resolving services...
Exit console using Ctrl-X.

However, as before, nothing I type in gets echoed or reacted to.

It's strange. On the one hand, the bluetooth connection is made, but no information flows. If I do a normal build without bluetooth, then I have no trouble reading/writing from/to the REPL over usb or serial. What would explain that?

At this point I'm not sure what else to try.

User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

Re: How to connect with Bluetooth REPL using nRF UART app?

Post by WhiteHare » Mon Oct 15, 2018 5:01 pm

Not sure if this sheds any light, but using a bluetooth app on my phone, and connecting with "mcus" to view its services, the app says that mcus "supports notifications/indications", but that mcus is not Readable nor is it Writeable.

So, does that mean mcus is missing those services on its firmware, or they just aren't enabled?

Anyhow, I tried my best, but I'm not getting any traction.

Who wrote the entry on micropython github for nrf the port? Who is doing the development? Is it all done by glennrub? Is he the one to ask about this?

c45713
Posts: 51
Joined: Fri Dec 09, 2016 7:09 pm

Re: How to connect with Bluetooth REPL using nRF UART app?

Post by c45713 » Mon Oct 15, 2018 9:13 pm

Who wrote the entry on micropython github for nrf the port? Who is doing the development? Is it all done by glennrub? Is he the one to ask about this?
You are already talking to me (glennrub). When you refer to nrf52832-dk, do you mean pca10040? If so i can provide a hex file that works for me, just to rule out compilation issues.

There are some different ways of debugging this further, like running the python equivalent of the BLE service using UART REPL: https://github.com/micropython/micropyt ... .h#L40-L70

I do see a BLE disconnect event (17) when i try to write a character on the Chrome REPL, which sounds similar to what you are experiencing. I'll have a look at it, to see what the issue could be. I'll report back.

c45713
Posts: 51
Joined: Fri Dec 09, 2016 7:09 pm

Re: How to connect with Bluetooth REPL using nRF UART app?

Post by c45713 » Mon Oct 15, 2018 9:43 pm

I believe i managed to reproduce your issue.

#1. Create one connection using nus_console which works. Terminate the connection using "CTRL+C".
#2. Power toggle the device.
#3. Reconnect using chrome, connection is established.

Now, in my chromium-browser, the input-prompt looks activated, but no characters are being echoed. In my case, i had to go into bluetooth controller on my Ubuntu to clear the entry of "mpus" in the BluetoothManager device list. Shown in the image below:
wipe_mpus.png
wipe_mpus.png (151.79 KiB) Viewed 6403 times
Now, reloading the chrome page, followed up by a connect to "mpus", and its working as expected again for me.

Post Reply