Basically my nodejs app need to have bluetooth environment,where i will get data from external device and write to that same device as well,for that my app has search for nearby bluetooth device or it may be hardcoded device(know device) with ip address,Then i’ll process data and send that to client,this is sort of use case (long stroy short)
Required things are
-
App needs to capable of turing on BT if not ON
-
Needs to find device and connect to device OR has to connect device which addresses are already known
-
Needs get data from external device/and should able to write as well
So this are all main functionality i need to integrate in my app basically normal bluetooth data read and write funtions
Things I Tried ..
I have Node Js V:16+
I dont have any code snippet cause i could not able to write single line of code using any node js bluetooth npm packegs, because most of them are not support windows or had version errors etc
After googling came accors may packegs
node-bluetooth:
This is one i tried Git repo i have read doc and went through,as it mentioned in doc i installed node-gyp affter setting up node-gyp i tried to install npm i node-bluetooth got error
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! code 1
npm ERR! path C:\GBMRS\GBMRS\server\node_modules\node-bluetooth
npm ERR! command failed
npm ERR! command C:\windows\system32\cmd.exe /d /s /c node-gyp configure build
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python version 3.11.7 found at "C:\Users\sammi\AppData\Local\Programs\Python\Python311\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS checking VS2022 (17.8.34322.80) found at:
npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools"
npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features"
npm ERR! gyp ERR! find VS - found VC++ toolset: v143
npm ERR! gyp ERR! find VS - missing any Windows SDK
npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack at VisualStudioFinder.fail (C:\GBMRS\GBMRS\server\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
npm ERR! gyp ERR! stack at C:\GBMRS\GBMRS\server\node_modules\node-gyp\lib\find-visualstudio.js:75:16
npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\GBMRS\GBMRS\server\node_modules\node-gyp\lib\find-visualstudio.js:363:14)
npm ERR! gyp ERR! stack at C:\GBMRS\GBMRS\server\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm ERR! gyp ERR! stack at C:\GBMRS\GBMRS\server\node_modules\node-gyp\lib\find-visualstudio.js:384:16
npm ERR! gyp ERR! stack at C:\GBMRS\GBMRS\server\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack at C:\GBMRS\GBMRS\server\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:406:5)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1092:16)
npm ERR! gyp ERR! System Windows_NT 10.0.22621
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\GBMRS\\GBMRS\\server\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "build"
npm ERR! gyp ERR! cwd C:\GBMRS\GBMRS\server\node_modules\node-bluetooth
node-gyp is installed successfully but this packeg is not installing
like wise i tried so many npm
**node-ble: LINK-this unable to run in windows
bluetoothLINK-this is pn for OS X (**IDK what the heck OS X is)
(I have some many error in each packes can’t really put here)
I’m so surprised that do we not have a npm package for bluetooth in node js haven’t anybody tried this before or am i lack of knowledge, there has to be a solution if any one have done this sort of adventure in nodeJs please guid me how to achive this through node js, please let me know any popular or commonly used approach or packegs that’s means lot
Thanks In ADVC …
take a look on NOBLE and/or BLENO. For latest Node.js versions you need packages from abandonware
You need to reach the Windows APIs for Bluetooth. To do that from node.js, you need proper language bindings. See e.g. github.com/NodeRT/NodeRT.