ReferenceError: navigator is not defined
oumartraore opened this issue · 7 comments
Hello, thanks for this ble with serial port library
I got this error while trying to connect:
return navigator.bluetooth.requestDevice ({
^
ReferenceError: navigator is not defined
Here is my code :
var BluetoothTerminal = require('bluetooth-terminal');
var SERVICE_ID = 'c1b25000caaf6d0e4c337dae30052840';
var CHARACTERISTIC_ID = 'c1b25010caaf6d0e4c337dae30052840';
var CCC_ID = '2902'; // for Client Characteristic Configuration ID
// Obtain configured instance.
var terminal = new BluetoothTerminal(SERVICE_ID, CHARACTERISTIC_ID);
// Request the device for connection and get its name after successful connection.
terminal.connect().then(function() {
alert(terminal.getDeviceName() + ' is connected!');
});
Hi @oumartraore
Your browser doesn't support Web Bluetooth: https://caniuse.com/#feat=web-bluetooth
I just used your library in a console project. If I understand you correctly, I have to do it in an Express project with a browser ? I thank you for your help
Web Bluetooth is client side API, so it's supported in browsers only: https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/implementation-status.md
Hi @1oginov
I'm working on a node console project that runs locally on my computer using 'node' command in my command prompt. It communicates with another installed software using a local TCP port and transmits data to a BLE hardware. I've successfully done this project with Bluetooth v2 using 'node-Bluetooth' package before but my newer hardware works with BLE now and I need to change the Bluetooth part of the js code. Since your package is the only BLE support for node js could you please provide a way to use this 'node-terminal' package locally on cmd as @oumartraore mentioned?
thank in advance.
Try the https://github.com/IjzerenHein/node-web-bluetooth to extend Node's global scope with look-a-like API.
Thank you @1oginov
Does this package support BLE?
@thefakhreddin this package said to mimic Web Bluetooth API, which works only with BLE.