Closed joshfarrant closed 7 years ago
If you're using --list
you should get something like this:
Espruino Command-line Tool 0.0.25
-----------------------------------
PORTS:
cf:71:de:4d:f8:48 (Puck.js F848)
c0:52:3f:50:42:c9 (Puck.js 42C9)
/dev/...
/dev/cu.Bluetooth-Incoming-Port
is a red herring - it's completely unrelated to Bluetooth LE and just appears to be a serial port that all Macs have.
At that point you could connect to one of the displayed ports, but if it's not listing the address then it's not going to be connectable.
I get the same thing if I try to connect using a simple node app
Not sure I understand - you're saying you can't connect to it via BLE at all? I guess you've been able to connect previously as you have the Mac address - so any idea what changed?
Have you tried running the nRF Connect
app on a phone and 'scanning' for advertised devices? It could be that Puck.js just isn't advertising, possibly because it's already connected?
For instance a Web Bluetooth page could already be open, or if you'd been trying the Puck.js HID example then your Mac might be automatically connecting to the device as soon as it appears - it's worth checking out the first few steps on the troubleshooting guide: http://www.espruino.com/Puck.js#troubleshooting
Running --list
just returns the following, nothing else.
Espruino Command-line Tool 0.0.25
-----------------------------------
PORTS:
/dev/cu.Bluetooth-Incoming-Port
I'd expect to see
c6:b9:c8:38:94:2b (Puck.js 942B)
in there too, as you suggested, but I don't get anything like that at all.
I've been able to connect to it using the Bluefruit app on iOS, and using the web IDE on the same Mac, which is how I got the MAC address of the Puck.
It could be that Puck.js just isn't advertising, possibly because it's already connected?
For instance a Web Bluetooth page could already be open
That's a point - I was connected to the Puck through the Web IDE at the time I was scanning, so you might well be right that it was no longer advertising while it was connected.
I'll test this later by ensuring I'm not connected to any other device and running --list
again and will report back.
Cheers for your advice!
I was connected to the Puck through the Web IDE at the time I was scanning
By itself that would stop the connection.
Let me know how it goes, but I imagine that would solve it.
After playing around with this a bit more I'm still not having any luck.
I've disconnected the Puck from the Web IDE (rebooted the Puck and my Mac for good measure), tried running --list
and I still get the same output.
I can connect seamlessly with the Web IDE, as well as the Bluefruit iOS app. Also just set up the puck as a HID and that connects to the Mac instantly and works, but still absolutely nothing in the --list
output.
If you've got any more suggestions I'd be happy to try them. This isn't crucial, so it's not the end of the world if it's not gonna work, but would be nice to play around with if it is possible.
That's odd - maybe it's to do with your installation of Noble (the Node.js library used to communicate via BLE).
I just answered your post here: http://forum.espruino.com/conversations/304383/#comment13617606
Perhaps you could have a go with that? If you have trouble getting that working, it might explain the problems you're having here
That's great, thanks. I'll have a look at the linked example and post back here if I figure out what's going on with the issues mentioned here.
Any updates?
I gave up on using the cli in the end, and switched to using the web ide. I may try again using my RPi, rather than my Macbook and if I have any updates I'll report back.
Hello, I'm trying out Espruino on my ESP32 board. Trying to upload code from the cli (from the IDE it works fine), but the --list
doesn't list anything and I get the Unable to connect!
when I try to upload code to it.
See attached screenshot for details.
Can you try running it with the verbose
command line option and see what it says? My guess is the node-serialport
npm module hasn't got installed for some reason
0.0.33
Espruino Command-line Tool 0.0.33
-----------------------------------
Acorn library not found - you'll need it for compiled code
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/libs/targz.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/libs/utf8.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/espruino.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/codeWriter.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/config.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/env.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/flasher.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/modules.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/notifications.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/serial.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/serial_audio.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/serial_chrome.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/serial_noble.js
'noble' module couldn't be loaded, no node.js Bluetooth Low Energy
{ Error: Cannot find module './build/Release/binding.node'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/henrique/Workspace/espruino-playground/node_modules/xpc-connection/index.js:3:15)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3) code: 'MODULE_NOT_FOUND' }
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/serial_nodeserial.js
No 'serialport' module found
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/serial_socket.js
No chrome.sockets - serial_socket disabled
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/serial_web_bluetooth.js
No navigator.bluetooth - Web Bluetooth not enabled
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/serial_websocket.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/serial_winnus.js
'winnus' module not found, no Windows Bluetooth Low Energy { Error: Cannot find module './build/Release/winnus'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/henrique/Workspace/espruino-playground/node_modules/winnus/winnus.js:1:78)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3) code: 'MODULE_NOT_FOUND' }
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/settingsAbout.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/status.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/terminal.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/utils.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/plugins/_examplePlugin.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/plugins/assembler.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/plugins/boardJSON.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/plugins/compiler.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/plugins/getGitHub.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/plugins/localModules.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/plugins/minify.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/plugins/npmModules.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/plugins/saveOnSend.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/plugins/setTime.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/plugins/uiMode.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/plugins/unicode.js
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/plugins/versionChecker.js
Initialising CodeWriter
Initialising Config
Initialising Env
Initialising Flasher
Initialising Modules
Initialising Notifications
Initialising Serial
Initialising SettingsAbout
Initialising Status
Initialising Utils
Initialising ExamplePlugin
Initialising Assembler
Initialising BoardJSON
Initialising Compiler
Initialising GetGitHub
Initialising LocalModules
Initialising Minify
Initialising NPMModules
Initialising SaveOnSend
Initialising SetTime
Initialising UiMode
Initialising Unicode
Initialising VersionChecker
Searching for serial ports...
PORTS:```
Didn't see those errors yesterday. I've put a `console.log()` up in the callstack, and the ports are always empty.
Specifically, your problem is:
Found /Users/henrique/Workspace/espruino-playground/node_modules/espruino/core/serial_nodeserial.js
No 'serialport' module found
So the modules it needs haven't been installed.
Try reinstalling espruino
- maybe globally with npm install -g espruino
, and then run it with just espruino
.
I do have a similar issue under osx, the following commands were entered within 20 seconds, only once the puck was found
# espruino --list
Espruino Command-line Tool 0.0.36
-----------------------------------
PORTS:
/dev/cu.Bluetooth-Incoming-Port
# espruino --list
Espruino Command-line Tool 0.0.36
-----------------------------------
PORTS:
f7:3c:85:8f:5c:84 (Puck.js 5c84)
/dev/cu.Bluetooth-Incoming-Port
# espruino --list
Espruino Command-line Tool 0.0.36
-----------------------------------
PORTS:
/dev/cu.Bluetooth-Incoming-Port
# espruino --list
Espruino Command-line Tool 0.0.36
-----------------------------------
PORTS:
/dev/cu.Bluetooth-Incoming-Port
# espruino --list
Espruino Command-line Tool 0.0.36
-----------------------------------
PORTS:
/dev/cu.Bluetooth-Incoming-Port
not sure what I can do about it. The IDE in the browser works flawless. espruino runs under the latest node LTS version.
Anything else I can do to help? Also happt to open a new issue if it helps.
Have you updated the firmware? The earliest batch of Pucks had a firmware that didn't advertise as often, which can cause problems finding them sometimes.
Also, could it be that the Mac is connecting to the Puck automatically? Specifically if you've ever programmed it with one of the USB HID examples the Mac will try and 'claim' it by connecting, which then stops it advertising so it can't be seen. Chrome might have a way to work around it.
To stop that, take a look at the heading about Mac OS in http://www.espruino.com/Puck.js#troubleshooting
i tried connecting to my esp8266 (a wemos d1 mini) using the cli on osx but it fails with the same error message.
i can use it as normal using the web ide and --list
shows me the correct TTY USB Port.
$ espruino --list
Espruino Command-line Tool 0.1.6
-----------------------------------
PORTS:
/dev/cu.wchusbserial1420
/dev/cu.Bluetooth-Incoming-Port
trying to connect fails with
$ espruino -p /dev/tty.wchusbserial1420 --verbose
Connecting to '/dev/tty.wchusbserial1420'
Noble: getPorts - not initialises
No navigator.bluetooth - Web Bluetooth not enabled
Noble: stateChange -> poweredOn
Noble: Disable Web Bluetooth as we have Noble instead
Noble: Starting scan
Noble: Found device: undefined unknown
Noble: Found device: undefined unknown
Port "/dev/tty.wchusbserial1420" not found - checking ports again (2 attempts left)
Noble: Found device: undefined unknown
Port "/dev/tty.wchusbserial1420" not found - checking ports again (1 attempts left)
Port "/dev/tty.wchusbserial1420" not found
Unable to connect!
Any idea why this is happening? Full verbose output
$ espruino -p /dev/tty.wchusbserial1420 --verbose
0.1.6
Espruino Command-line Tool 0.1.6
-----------------------------------
Acorn library not found - you'll need it for compiled code
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/libs/targz.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/libs/utf8.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/espruino.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/codeWriter.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/config.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/env.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/flasher.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/modules.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/notifications.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/serial.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/serial_chrome_serial.js
No chrome.serial - Chrome Serial disabled
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/serial_chrome_socket.js
No chrome.sockets - Chrome Socket disabled
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/serial_noble.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/serial_node_serial.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/serial_web_audio.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/serial_web_bluetooth.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/serial_websocket_local.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/serial_websocket_mqtt.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/serial_websocket_relay.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/serial_winnus.js
Not on Windows, Winnus not needed
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/terminal.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/core/utils.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/plugins/assembler.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/plugins/boardJSON.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/plugins/compiler.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/plugins/getGitHub.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/plugins/localModules.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/plugins/minify.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/plugins/saveOnSend.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/plugins/setTime.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/plugins/unicode.js
Found /Users/username/.nvm/versions/node/v7.2.0/lib/node_modules/espruino/plugins/versionChecker.js
Initialising CodeWriter
Initialising Config
Initialising Env
Initialising Flasher
Initialising Modules
Initialising Notifications
Initialising Serial
- Initialising Serial Noble Bluetooth LE
- Initialising Serial Node Serial
- Initialising Serial Web Bluetooth
Initialising Utils
Initialising Status
Initialising Assembler
Initialising BoardJSON
Initialising Compiler
Initialising GetGitHub
Initialising LocalModules
Initialising Minify
Initialising SaveOnSend
Initialising SetTime
Initialising Unicode
Initialising VersionChecker
Connecting to '/dev/tty.wchusbserial1420'
Noble: getPorts - not initialises
No navigator.bluetooth - Web Bluetooth not enabled
Noble: stateChange -> poweredOn
Noble: Disable Web Bluetooth as we have Noble instead
Noble: Starting scan
Noble: Found device: undefined unknown
Noble: Found device: undefined unknown
Port "/dev/tty.wchusbserial1420" not found - checking ports again (2 attempts left)
Noble: Found device: undefined unknown
Port "/dev/tty.wchusbserial1420" not found - checking ports again (1 attempts left)
Port "/dev/tty.wchusbserial1420" not found
Unable to connect!
It's saying you only have port /dev/cu.wchusbserial1420
but you're using tty
not cu
. Try using cu
and it'll probably work - although you also have to specify a baud rate as ESP8266/32 use a different rate to every other Espruino board.
For general support issues like this please ask on the ESP8266 forum (http://forum.espruino.com/microcosms/925/) - the folks on there usually have a better idea about ESP8266.
Hi, in my case, I have solved the problem in my OSX with the following steps:
TESTing
espruino --list Espruino Command-line Tool 0.1.19
PORTS: A: B: C: D: 67: d7 (Puck.js 67d7) /dev/cu.Bluetooth-Incoming-Port
espruino -p A: B: C: D: 67: d7
@martinjuhasz I am running into the same problem as you did. Did you handle the issue ?
@martinjuhasz I am running into the same problem as you did. Did you handle the issue ? Yes! If you install node 8.0.0, works fine.
Yes! If you install node 8.0.0, works fine.
I'm afraid this is the solution at the moment. The noble
library (which is basically the way everyone uses Bluetooth LE on node) no longer works on node 10 and above!
There are suggested changes that fix it but for some reason they're no longer being merged in. It looks like it would be possible to swap to https://www.npmjs.com/package/@abandonware/noble though as this seems to have the fixes in, and I think I may end up having to do that soon
im so stuck here!!! cant get it to work with @abandonware/noble installed in node 8.6.0 :((( i basically want to write code in my own IDE and use the command line to push it to the puck. I am at \mojave 10.4 and i have also tried installing noble-mac in node 10, 8, and 8.6.0, anything else I could try?
@gfwilliams do you know if its possible to upload code to a puck from terminal with node 8.6.0 nd mojave 10.4?
Just to check - it's Mac OS 10.14, not *10.4 I guess? I'm pretty sure 10.4 is too old.
Does the normal Espruino Web IDE work ok for you?
Please can you post as a new issue with the whole output of running npm install -g espruino
and the output of running espruino --list --verbose
?
10.14 yes! sorry!
Mac OSX Mojave 10.4
-> I can see the pug in the OSX bluetooth preferences dialog box.
Manuels-MacBook-Pro-2:bluetooth-node manuelabergcobo$ espruino --list --verbose
0.1.12
Espruino Command-line Tool 0.1.12
-----------------------------------
Acorn library not found - you'll need it for compiled code
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/libs/targz.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/libs/utf8.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/espruino.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/codeWriter.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/config.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/env.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/flasher.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/modules.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/notifications.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/serial.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/serial_chrome_serial.js
No chrome.serial - Chrome Serial disabled
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/serial_chrome_socket.js
No chrome.sockets - Chrome Socket disabled
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/serial_frame.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/serial_noble.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/serial_node_serial.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/serial_node_socket.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/serial_web_audio.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/serial_web_bluetooth.js
No navigator.bluetooth - Web Bluetooth not enabled
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/serial_websocket_local.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/serial_websocket_relay.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/serial_winnus.js
Not on Windows, Winnus not needed
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/terminal.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/core/utils.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/plugins/assembler.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/plugins/boardJSON.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/plugins/compiler.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/plugins/getGitHub.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/plugins/localModules.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/plugins/minify.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/plugins/saveOnSend.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/plugins/setTime.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/plugins/unicode.js
Found /Users/manuelabergcobo/.nvm/versions/node/v8.10.0/lib/node_modules/espruino/plugins/versionChecker.js
Initialising CodeWriter
Initialising Config
Initialising Env
Initialising Flasher
Initialising Modules
Initialising Notifications
Initialising Serial
- Initialising Serial Noble Bluetooth LE
- Initialising Serial Node Serial
- Initialising Serial Node Socket
Initialising Utils
Initialising Status
Initialising Assembler
Initialising BoardJSON
Initialising Compiler
Initialising GetGitHub
Initialising LocalModules
Initialising Minify
Initialising SaveOnSend
Initialising SetTime
Initialising Unicode
Initialising VersionChecker
Searching for serial ports...
Noble: getPorts - not initialised
Noble: stateChange -> poweredOn
Noble: Starting scan
PORTS:
/dev/cu.SOC
/dev/cu.MALS
/dev/cu.Bluetooth-Incoming-Port
web ide works just fine!
That's really weird - everything there seems to be working great.
If it possible that you've just left the Web IDE connected to the Puck so it's not connectable by any other device?
Can you try running node node_modules/noble/examples/advertisement-discovery.js
- which is just some example code for Noble which tries to find any Bluetooth LE devices in range
when i run that nothing happens, terminal just outputs nothing and stays there
var noble = require('noble-mac');
noble.on('stateChange', function(state) {
if (state === 'poweredOn') {
noble.startScanning();
} else {
noble.stopScanning();
}
});
noble.on('discover', function(peripheral) {
console.log('peripheral discovered:');
console.log('\thello my local name is:');
console.log('\t\t' + peripheral.advertisement.localName);
console.log('\tand I am advertising the following services:');
console.log('\t\t' + JSON.stringify(peripheral.advertisement.serviceUuids));
console.log();
});
if i run that code with noble-mac instead of noble, i can see both my pucks discovered as peripherals. but if i do espruino --list, i cant see them
Ok, that's promising then! So probably the issue is just that while you installed noble-mac, the tools aren't using it? Could you find out where the espruino
package is installed, and then edit core/serial_noble.js
?
Try changing:
function startNoble() {
try {
noble = require('noble');
} catch (e) {
console.log("Noble: module couldn't be loaded, no node.js Bluetooth Low Energy\n", e);
// super nasty workaround for https://github.com/sandeepmistry/noble/issues/502
process.removeAllListeners('exit');
errored = true;
return false;
}
...
to:
function startNoble() {
try {
noble = require('noble-mac');
} catch (e) {
try {
noble = require('noble');
} catch (e) {
console.log("Noble: module couldn't be loaded, no node.js Bluetooth Low Energy\n", e);
// super nasty workaround for https://github.com/sandeepmistry/noble/issues/502
process.removeAllListeners('exit');
errored = true;
return false;
}
}
...
so i went into where nvm install global modules by doing nvm which current
and there I modified the file like you showed by adding another level of try catching with noble-mac. first i made sure that peripheral discovery was still working with the code above to make sure every variable is the same.
mac osx mojave 10.14 node 8.6.0 espruino 0.1.28 core/serial_noble.js modified in nvm global modules directory
output is:
Manuels-MacBook-Pro-2:puck manuelabergcobo$ espruino --list
Espruino Command-line Tool 0.1.28
-----------------------------------
(node:3099) Warning: N-API is an experimental feature and could change at any time.
FATAL ERROR: Cannot read property 'indexOf' of undefined
1: node::Abort() [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node]
2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node]
3: node::OnFatalError(char const*, char const*) [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node]
4: napi_create_function [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node]
5: Napi::Error::Fatal(char const*, char const*) [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/lib/node_modules/noble-mac/native/noble_mac.node]
6: ThreadSafeCallback::Impl::static_async_callback(uv_async_s*) [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/lib/node_modules/noble-mac/native/noble_mac.node]
7: uv__async_io [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node]
8: uv__io_poll [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node]
9: uv_run [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node]
10: node::Start(v8::Isolate*, node::IsolateData*, int, char const* const*, int, char const* const*) [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node]
11: node::Start(uv_loop_s*, int, char const* const*, int, char const* const*) [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node]
12: node::Start(int, char**) [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node]
13: start [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node]
Abort trap: 6
Manuels-MacBook-Pro-2:puck manuelabergcobo$
i think step 5 and 6 of the stack trace are the problem. something in noble mac fails to initialize when doing it like this. surprisingly the other code we tried had require(noble-mac) and it had no problems :S confusing!
Honestly I'm not sure what to suggest - I guess maybe flailing around it might be an idea to try noble-mac with a more modern version of node now we've given up with standard noble?
Also you could post on noble-mac's github and see if they have any thoughts?
ok cool, thanks gordon for your time and help ! i will fight on
so i went into where nvm install global modules by doing
nvm which current
and there I modified the file like you showed by adding another level of try catching with noble-mac. first i made sure that peripheral discovery was still working with the code above to make sure every variable is the same.mac osx mojave 10.14 node 8.6.0 espruino 0.1.28 core/serial_noble.js modified in nvm global modules directory
output is:
Manuels-MacBook-Pro-2:puck manuelabergcobo$ espruino --list Espruino Command-line Tool 0.1.28 ----------------------------------- (node:3099) Warning: N-API is an experimental feature and could change at any time. FATAL ERROR: Cannot read property 'indexOf' of undefined 1: node::Abort() [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node] 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node] 3: node::OnFatalError(char const*, char const*) [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node] 4: napi_create_function [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node] 5: Napi::Error::Fatal(char const*, char const*) [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/lib/node_modules/noble-mac/native/noble_mac.node] 6: ThreadSafeCallback::Impl::static_async_callback(uv_async_s*) [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/lib/node_modules/noble-mac/native/noble_mac.node] 7: uv__async_io [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node] 8: uv__io_poll [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node] 9: uv_run [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node] 10: node::Start(v8::Isolate*, node::IsolateData*, int, char const* const*, int, char const* const*) [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node] 11: node::Start(uv_loop_s*, int, char const* const*, int, char const* const*) [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node] 12: node::Start(int, char**) [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node] 13: start [/Users/manuelabergcobo/.nvm/versions/node/v8.6.0/bin/node] Abort trap: 6 Manuels-MacBook-Pro-2:puck manuelabergcobo$
i think step 5 and 6 of the stack trace are the problem. something in noble mac fails to initialize when doing it like this. surprisingly the other code we tried had require(noble-mac) and it had no problems :S confusing!
So, this issue is simple some missing checks in the noble.on('discover') in serial_noble. Just add checks for the following and it works:
if (
dev.advertisement &&
dev.advertisement.localName &&
dev.advertisement.serviceUuids
) {
This is because you probably pick up nodes that don't have any services or a localName.
Thanks! I've just pushed a change. I didn't add your exact code since that actually stops a load of devices being recognised (standard Espruino ones get recognised by name even if they don't advertise the services).
I think what's happening is that on Linux you get dev.advertisement.serviceUuids = []
even if there are no UUIDs, but maybe on Mac OS dev.advertisement.serviceUuids = undefined
?
I'm trying to connect to my Puck.js in a couple of ways but having no joy.
Running
espruino -p c6:b9:c8:38:94:2b -v
gives me the following output.I get the same thing if I try to connect using a simple node app. Also I get the same if I use the output of
espruino --list
(/dev/cu.Bluetooth-Incoming-Port) instead of the MAC address.I feel like I might be missing something, but this appears to be what the README suggests should work.