[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
devnull
Posts: 353
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: [nRF5x] How to connect using WebBluetooth REPL?

Post by devnull » Sun Oct 28, 2018 10:31 am

OK, I have succeeded in connecting and getting a REPL via bluetooth using: https://aykevl.nl/apps/nus/ on the holyiot board.

But the nus console which is using nodejs noble just sits there waiting forever for a connection, it seems that this may be related to noble incompatibility with osx mojave which I am running.

But I also notice that using the web console, the connection is dropped after exactly 40 seconds irregardless of whether you are typing something or not.

Is this a timeout configuration setting somewhere, either on the NRF device or in the javascript connection ?

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

Re: [nRF5x] How to connect using WebBluetooth REPL?

Post by WhiteHare » Sun Oct 28, 2018 11:34 am

devnull wrote:
Sun Oct 28, 2018 10:31 am
But the nus console which is using nodejs noble just sits there waiting forever for a connection, it seems that this may be related to noble incompatibility with osx mojave which I am running.
FWIW, I also couldn't get that to work either. However, I decided not to dwell on it, since the WebBluetooth repl seems to work fine. So, just take this as a confirmation.
devnull wrote:
Sun Oct 28, 2018 10:31 am
But I also notice that using the web console, the connection is dropped after exactly 40 seconds irregardless of whether you are typing something or not.
Mine stays connected without timeouts, seemingly forever, which is good. Maybe it's the bluetooth on the other end of your connection? I'm using a Bluetooth 4.0 usb dongle (I posted a link to it above) for that. Even though it's ancient, it seems to do the business.

User avatar
devnull
Posts: 353
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: [nRF5x] How to connect using WebBluetooth REPL?

Post by devnull » Sun Oct 28, 2018 12:12 pm

I am using the bluetooth built into my macbook, exactly 40 seconds after I connect, it disconnects.

Bluetooth HCI version is 4.2:

Code: Select all

  Apple Bluetooth Software Version:	6.0.8f6
  Hardware, Features and Settings:
  Address:	F4-0F-24-32-A6-33
  Bluetooth Low Energy Supported:	Yes
  Handoff Supported:	Yes
  Instant Hot Spot Supported:	Yes
  Manufacturer:	Broadcom
  Transport:	UART
  Chipset:	20703A2
  Firmware Version:	v71 c4274
  Bluetooth Power:	On
  Discoverable:	On
  Connectable:	Yes
  Auto Seek Pointing:	On
  Remote wake:	On
  Vendor ID:	0x05AC
  Product ID:	0x007E
  HCI Version:	4.2 (0x8)
  HCI Revision:	0x10B2
  LMP Version:	4.2 (0x8)
  LMP Subversion:	0x2247
  Device Type (Major):	Computer
  Device Type (Complete):	Mac Portable
  Composite Class Of Device:	0x38010C
  Device Class (Major):	0x01
  Device Class (Minor):	0x03
  Service Class:	0x1C0
  Auto Seek Keyboard:	On

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

Re: [nRF5x] How to connect using WebBluetooth REPL?

Post by WhiteHare » Sun Oct 28, 2018 12:32 pm

Do you happen to have a raspberry pi 3 with built-in bluetooth? Maybe try that. It also worked for me.

User avatar
devnull
Posts: 353
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: [nRF5x] How to connect using WebBluetooth REPL?

Post by devnull » Sun Oct 28, 2018 1:14 pm

OK, managed to get nodejs version running on raspberry pi and no disconnects so that is workable.

I am using NVM and running nodejs 8.12 LTS:

Code: Select all

node index.js
Found device with local name: mpus
advertising the following service uuid's: 6e400001b5a3f393e0a9e50e24dcca9e


>>> help()
Welcome to MicroPython!

For online help please visit http://micropython.org/help/.

Quick overview of commands for the board:
If compiled with SD=<softdevice> the additional commands are
available:
  ble.enable()    -- enable bluetooth stack
  ble.disable()   -- disable bluetooth stack
  ble.enabled()   -- check whether bluetooth stack is enabled
  ble.address()   -- return device address as text string

Control commands:
  CTRL-A        -- on a blank line, enter raw REPL mode
  CTRL-B        -- on a blank line, enter normal REPL mode
  CTRL-D        -- on a blank line, do a soft reset of the board
  CTRL-E        -- on a blank line, enter paste mode

For further help on a specific object, type help(obj)
>>> 
>>> 
>>> help('modules')
__main__          gc                random            ubluepy
array             machine           scan              ucollections
ble               math              sys               uos
board             micropython       time              ustruct
builtins          os                time              utime
Plus any modules on the filesystem
>>> 

User avatar
devnull
Posts: 353
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: [nRF5x] How to connect using WebBluetooth REPL?

Post by devnull » Tue Oct 30, 2018 6:20 am

I just created a NUS Telnet gateway based on the original nus_gateway design in nodejs using noble.

I can connect locally via localhost or remotely via the network using telnet, screen or rshell, however rshell fails with the same error as when connecting to the serial port.

So this effectively means that I would be able to connect to the NRF via Bluetooth using RSHELL's telnet connection mode which does make the bluetooth REPL very useful (to me).

Code: Select all

telnet 192.168.0.85
Trying 192.168.0.85...
Connected to ubu64dev.
Escape character is '^]'.


>>> help()
help()
Welcome to MicroPython!

For online help please visit http://micropython.org/help/.

Quick overview of commands for the board:
If compiled with SD=<softdevice> the additional commands are
available:
  ble.enable()    -- enable bluetooth stack
  ble.disable()   -- disable bluetooth stack
  ble.enabled()   -- check whether bluetooth stack is enabled
  ble.address()   -- return device address as text string

Control commands:
  CTRL-A        -- on a blank line, enter raw REPL mode
  CTRL-B        -- on a blank line, enter normal REPL mode
  CTRL-D        -- on a blank line, do a soft reset of the board
  CTRL-E        -- on a blank line, enter paste mode

For further help on a specific object, type help(obj)
>>> 
I have also tried just creating a Linux rfcomm device port which, if it worked would have been much simpler and easier to implement, but I was not able to get it to work.

Code: Select all

rfcomm bind 0 FE:08:48:84:FE:28
screen /dev/rfcomm0 115200

User avatar
sebi
Posts: 26
Joined: Tue Mar 29, 2016 9:36 pm
Location: France

Re: [nRF5x] How to connect using WebBluetooth REPL?

Post by sebi » Fri Sep 13, 2019 5:19 pm

devnull wrote:
Tue Oct 30, 2018 6:20 am
I just created a NUS Telnet gateway based on the original nus_gateway design in nodejs using noble.
Interesting! Can you share that work with us?

Post Reply