npm package: @iotize/device-com-ble.node
Description: Bluetooth Low Energy (BLE) communication protocol for IoTize device
Author: IoTize
Latest version: 2.1.1

# Iotize BLE

Iotize device communication protocol for BLE on node environment.

It works with a compatible dongle or an up to date windows 10 build.

## Prerequisities

This library depends on open source project [https://github.com/noble/noble](https://github.com/noble/noble). See their README for
complete instruction on how to setup BLE on different OS.

Need WinUSB driver
[https://github.com/pbatard/libwdi/wiki/Zadig](https://github.com/pbatard/libwdi/wiki/Zadig)

Not working on all bluetooth adapter. See list in noble project [https://github.com/noble/node-bluetooth-hci-socket#windows](https://github.com/noble/node-bluetooth-hci-socket#windows)...

### Windows

With an elevated shell (only required with old Node.js version ?)

```shell
npm install --global --production windows-build-tools
```

#### Troubleshooting

```
npm ERR! C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets(44,5): error MSB8020: The builds tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, either click the Project menu or right-click the solution, and then select "Update VC++ Projects...". Install v140 to build using the v140 build tools. [C:\Users\scale\dev\iotize\bitbucket\standalone\device-com-ble.node\node_modules\@abandonware\noble\build\noble.vcxproj]
```

> **Solution 1:** Install visual studio 2015 C++ toolkit (see image doc/visual-studio-installation-setup.png)

> **Solution 2:** Make sure `MSBuild.exe` is in your PATH

```
npm ERR! C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\x64\PlatformToolsets\v140\Toolset.targets(36,5): error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [C:\Users\scale\dev\iotize\bitbucket\standalone\device-com-ble.node\node_modules\@abandonware\noble\build\noble.vcxproj]

```

> **Solution:** Run installation of setup/windows-sdk-8.1-setup.exe

```
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack     at VisualStudioFinder.fail (C:\ProgramData\nvm\v16.14.1\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
npm ERR! gyp ERR! stack     at C:\ProgramData\nvm\v16.14.1\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:75:16
npm ERR! gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\ProgramData\nvm\v16.14.1\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:363:14)
npm ERR! gyp ERR! stack     at C:\ProgramData\nvm\v16.14.1\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm ERR! gyp ERR! stack     at C:\ProgramData\nvm\v16.14.1\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:396:20
npm ERR! gyp ERR! stack     at C:\ProgramData\nvm\v16.14.1\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack     at C:\ProgramData\nvm\v16.14.1\node_modules\npm\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:526:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1092:16)
```

> **Solution:** Check your `npm config get msvs_version` version configured. To set version do `npm config set msvs_version 2019 --global`