[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: 58
Joined: Thu Oct 04, 2018 4:00 am

[nRF5x] How to connect using WebBluetooth REPL?

Post by WhiteHare » Tue Oct 09, 2018 6:31 pm

I built the Bluetooth REPL for nRF52832, and uploaded it to my nRF52832-DK. Attached is the firmware.

Then, as described here: https://github.com/micropython/micropyt ... /ports/nrf
I tried connecting to it with nRF UART. However, the Bluetooth REPL doesn't seem to be broadcasting anything that I can connect with.

What to do?
Attachments
firmware.zip
(157.86 KiB) Downloaded 3 times
Last edited by WhiteHare on Tue Oct 16, 2018 2:33 pm, edited 1 time in total.

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

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

Post by WhiteHare » Tue Oct 09, 2018 7:40 pm

As near as I can tell, the Bluetooth REPL is not discoverable, and so there is no way to connect to it.

How is it done?

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

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

Post by WhiteHare » Tue Oct 09, 2018 8:11 pm

OK, attached is corrected Bluetooth REPL firmware, but it's still not discoverable.
Attachments
firmware.zip
(158.25 KiB) Downloaded 1 time

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

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

Post by WhiteHare » Tue Oct 09, 2018 8:37 pm

Attached are the bluetooth configuration settings that I used as part of the firmware compile.
Attachments
bluetooth_conf.zip
(425 Bytes) Downloaded 6 times

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

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

Post by c45713 » Thu Oct 11, 2018 8:48 pm

I cannot see any error in your bluetooth_conf.h.

The device name advertised should be "mpus". Can you see this when scanning for BLE device using a PC or other scanner app?
Also, make sure that you also flash the SoftDevice before "make flash", by issuing "make sd", else the app will not run at all. After first flash of SD, there is only needed to update the micropython firmware using "flash".

Also, to add in, there is several other ways to also connect to the BLE REPL using a PC,
1. chromium with "Experimental Web Platform features" enabled (chrome://flags). Then using this webbluetooth page to get the BLE connection and REPL in the browser: https://aykevl.nl/apps/nus/
2. https://github.com/aykevl/pynus
3. https://github.com/tralamazza/nus_console

kak
Posts: 14
Joined: Fri Oct 05, 2018 11:35 am

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

Post by kak » Fri Oct 12, 2018 7:20 am

Here's what I did to get Bluetooth REPL running on a pca10059 dongle (beginning with a fresh git clone):

git clone https://github.com/micropython/micropython.git
cd micropython
git submodule update --init
make -C mpy-cross
cd boards/nrf
./drivers/bluetooth/download_ble_stack.sh
modify bluetooth_conf.h

Code: Select all

#elif (BLUETOOTH_SD == 140)

#define MICROPY_PY_BLE                  (1)
#define MICROPY_PY_BLE_NUS 	      (1)
make BOARD=pca10056 SD=s140

Open nRF Connect, connect to the dongle running in DFU mode, add both
micropython/ports/nrf/build-pca10056-s140/firmware.hex and
micropython/ports/nrf/drivers/bluetooth/s140_nrf52_6.0.0/s140_nrf52_6.0.0_softdevice.hex
and flash the to the dongle.

The dongle now comes up and advertises as "mpus".

I connected to it using Google Chrome running on an Android phone, via the website https://aykevl.nl/apps/nus/.

Thanks again for your help, c45713

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

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

Post by WhiteHare » Fri Oct 12, 2018 5:04 pm

Thank you Kak and c45713 for both your posts. The extra details are very welcome. :D

I suspect my error may have been using Nordic's drag-and-drop approach to .hex flashing, which may not be sufficient in this case. I'm short on time over the next few days, but I will try again, but this time using Kak's step-by-step instructions on a fresh non-vm x86 Debian system (with Bluetooth!) next week. I'll report back afterward.

User avatar
WhiteHare
Posts: 58
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 2:27 am

I'm stuck on

Code: Select all

make flash
It fails, saying it can't find jlinkarm.dll, but I've been unsuccessful on finding it either.

kak
Posts: 14
Joined: Fri Oct 05, 2018 11:35 am

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

Post by kak » Sat Oct 13, 2018 12:43 pm

Did you install the JLINK software for Linux from Segger?
https://www.segger.com/downloads/jlink/ ... tationPack

If not, use nRF Connect to flash.

User avatar
WhiteHare
Posts: 58
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 4:17 pm

kak wrote:
Sat Oct 13, 2018 12:43 pm
Did you install the JLINK software for Linux from Segger?
https://www.segger.com/downloads/jlink/ ... tationPack

If not, use nRF Connect to flash.
Thanks! I used J-Link Software and Documentation pack for Linux, DEB installer, 64-bit, and it worked.

I made it through the entire bluetooth build. Unlike before, I can now find mpus and connect with it over bluetooth using nRF UART 2.0 on my Galaxy 8 phone. However, whatever I send it is not replied to, and after awhile it just disconnects on me. :(

Same result using both the nRF52-DK and the nRF52840-DK.

Am I supposed to flash something onto it *after* doing the bluetooth flash? I tried doing that too, but it seemed to erase the bluetooth flash, rendering bluetooth no longer operative again.

Well, definitely getting closer at least. :)

Post Reply