本文源码仓库地址:https://github.com/NordicSemiconductor/pc-nrfconnect-ble/blob/main/package.json
nRF Connect for Desktop是nordic自己做的一个PC端的蓝牙工具,配合nordic的dongle可以实现蓝牙的很多功能,要浏览本文要有如下知识储备:
1.nRF Connect for Desktop的APP是用js开发,所以要了解js并且安装了js的编译环境nodejs,编辑软件最好是vscode
2.已经成功安装了nRF Connect for Desktop上位机软件,可以看文章:https://blog.csdn.net/chengdong1314/article/details/109506931(好像最新版本的软件很好安装使用)
1.克隆一个nordic的app到C:\Users\Administrator.nrfconnect-apps\local目录(window),参考文章:
https://nordicsemiconductor.github.io/pc-nrfconnect-docs/create_new_app
2.安装依赖,请看文章:https://nordicsemiconductor.github.io/pc-nrfconnect-docs/app_development
我这里安装依赖提醒如下log:
Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。
尝试新的跨平台 PowerShell https://aka.ms/pscore6
PS F:\download\pc-nrfconnect-ble> npm install
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN old lockfile Error: git dep preparation failed
npm WARN old lockfile at ChildProcess.<anonymous> (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27)
npm WARN old lockfile at ChildProcess.emit (node:events:526:28)
npm WARN old lockfile at maybeClose (node:internal/child_process:1092:16)
npm WARN old lockfile at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm WARN old lockfile Could not fetch metadata for pc-nrfconnect-shared@git+ssh://git@github.com/NordicSemiconductor/pc-nrfconnect-shared.git#fa442365b33fd2dd2df5d0ea20cfe2160cac088f Error: git dep preparation failed
npm WARN old lockfile at ChildProcess.<anonymous> (D:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27)
npm WARN old lockfile at ChildProcess.emit (node:events:526:28)
npm WARN old lockfile at maybeClose (node:internal/child_process:1092:16)
npm WARN old lockfile at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5) {
npm WARN old lockfile cmd: 'D:\\Program Files\\nodejs\\node.exe',
npm WARN old lockfile args: [
npm WARN old lockfile 'D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm WARN old lockfile 'install',
npm WARN old lockfile '--force',
npm WARN old lockfile '--cache=C:\\Users\\Administrator\\AppData\\Local\\npm-cache',
npm WARN old lockfile '--prefer-offline=false',
npm WARN old lockfile '--prefer-online=false',
npm WARN old lockfile '--offline=false',
npm WARN old lockfile '--no-progress',
npm WARN old lockfile '--no-save',
npm WARN old lockfile '--no-audit',
npm WARN old lockfile '--include=dev',
npm WARN old lockfile '--include=peer',
npm WARN old lockfile '--include=optional',
npm WARN old lockfile '--no-package-lock-only',
npm WARN old lockfile '--no-dry-run'
npm WARN old lockfile ],
npm WARN old lockfile code: 1,
npm WARN old lockfile signal: null,
npm WARN old lockfile stdout: '',
npm WARN old lockfile stderr: 'npm WARN using --force Recommended protections disabled.\n' +
npm WARN old lockfile 'npm WARN old lockfile \n' +
npm WARN old lockfile 'npm WARN old lockfile The package-lock.json file was created with an old version of npm,\n' +
npm WARN old lockfile 'npm WARN old lockfile so supplemental metadata must be fetched from the registry.\n' +
npm WARN old lockfile 'npm WARN old lockfile \n' +
npm WARN old lockfile 'npm WARN old lockfile This is a one-time fix-up, please be patient...\n' +
npm WARN old lockfile 'npm WARN old lockfile \n' +
npm WARN old lockfile "npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.\n" +
npm WARN old lockfile 'npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated\n' +
npm WARN old lockfile 'npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility\n' +
npm WARN old lockfile 'npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated\n' +
npm WARN old lockfile 'npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated\n' +
npm WARN old lockfile 'npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated\n' +
npm WARN old lockfile 'npm WARN deprecated uuid@3.4.0: 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.\n' +
npm WARN old lockfile 'npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.\n' +
npm WARN old lockfile 'npm WARN deprecated redux-devtools-extension@2.13.9: Package moved to @redux-devtools/extension.\n' +
npm WARN old lockfile 'npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.\n' +
npm WARN old lockfile 'npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142\n' +
npm WARN old lockfile 'npm WARN deprecated node-pre-gyp@0.15.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future\n' +
npm WARN old lockfile 'npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.\n' +
npm WARN old lockfile 'npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.\n' +
npm WARN old lockfile 'npm WARN deprecated har-validator@5.1.5: this library is no longer supported\n' +
npm WARN old lockfile 'npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated\n' +
npm WARN old lockfile 'npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies\n' +
npm WARN old lockfile 'npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.\n' +
npm WARN old lockfile "npm WARN deprecated @types/date-fns@2.6.0: This is a stub types definition for date-fns (https://github.com/date-fns/date-fns). date-fns provides its own type definitions, so you don't need @types/date-fns installed!\n" +
npm WARN old lockfile 'npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs\n' +
npm WARN old lockfile 'npm WARN deprecated core-js-pure@3.16.3: core-js-pure@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims,
feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js-pure.\n' +
npm WARN old lockfile 'npm ERR! code 1\n' +
npm WARN old lockfile 'npm ERR! path C:\\Users\\Administrator\\AppData\\Local\\npm-cache\\_cacache\\tmp\\git-cloneOTG7x9\\node_modules\\@nordicsemiconductor\\nrf-device-lib-js\n' +
npm WARN old lockfile 'npm ERR! command failed\n' +
npm WARN old lockfile 'npm ERR! command C:\\Windows\\system32\\cmd.exe /d /s /c node do_prebuild.js --decompress-only || node do_prebuild.js --install-only || node do_prebuild.js\n' +
npm WARN old lockfile 'npm ERR! Decompressing local prebuild.\n' +
npm WARN old lockfile 'npm ERR! Unable to decompress local prebuild. File does not exist: prebuilds\\@nordicsemiconductor\\nrf-device-lib-js-v0.4.13-napi-v7-win32-x64.tar.gz\n' +
npm WARN old lockfile 'npm ERR! Installing prebuild from developer.nordicsemi.no.\n' +
npm WARN old lockfile 'npm ERR! Trying to install prebuild from developer.nordicsemi.no...\n' +
npm WARN old lockfile 'npm ERR! Runtime: napi\n' +
npm WARN old lockfile 'npm ERR! Target: 7\n' +
npm WARN old lockfile 'npm ERR! Running command: npx prebuild-install -r napi -t 7 --verbose\n' +
npm WARN old lockfile 'npm ERR! \n' +
npm WARN old lockfile 'npm ERR! npm WARN using --force Recommended protections disabled.\n' +
npm WARN old lockfile 'npm ERR! npm WARN using --force Recommended protections disabled.\n' +
npm WARN old lockfile 'npm ERR! prebuild-install info begin Prebuild-install version 7.1.1\n' +
npm WARN old lockfile 'npm ERR! prebuild-install info looking for local prebuild @ prebuilds\\nrf-device-lib-js-v0.4.13-napi-v7-win32-x64.tar.gz\n' +
npm WARN old lockfile 'npm ERR! prebuild-install info looking for cached prebuild @ C:\\Users\\Administrator\\AppData\\Local\\npm-cache\\_prebuilds\\596c67-nrf-device-lib-js-v0.4.13-napi-v7-win32-x64.tar.gz\n' +
npm WARN old lockfile 'npm ERR! prebuild-install http request GET https://developer.nordicsemi.com/.pc-tools/nrf-libs/nrf-device-lib-js/v0.4.13/nrf-device-lib-js-v0.4.13-napi-v7-win32-x64.tar.gz\n' +
npm WARN old lockfile 'npm ERR! prebuild-install warn install Request timed out\n' +
npm WARN old lockfile 'npm ERR! \n' +
npm WARN old lockfile 'npm ERR! =================================================================\n' +
npm WARN old lockfile 'npm ERR! Install from developer.nordicsemi.no failed.\n' +
npm WARN old lockfile 'npm ERR! \n' +
npm WARN old lockfile 'npm ERR! NOTE:\n' +
npm WARN old lockfile 'npm ERR! The prebuild-install module will use a different strategy for fetching prebuilt binaries and will try to download from Github instead if it finds a token in ~/.prebuild-installrc\n' +
npm WARN old lockfile 'npm ERR! Ensure that this token is not present by either deleting or temporarily moving it: ~/.prebuild-installrc\n' +
npm WARN old lockfile 'npm ERR! =================================================================\n' +
npm WARN old lockfile 'npm ERR! Error message was: Error: Command failed: npx prebuild-install -r napi -t 7 --verbose\n' +
npm WARN old lockfile 'npm ERR! npm WARN using --force Recommended protections disabled.\n' +
npm WARN old lockfile 'npm ERR! npm WARN using --force Recommended protections disabled.\n' +
npm WARN old lockfile 'npm ERR! prebuild-install info begin Prebuild-install version 7.1.1\n' +
npm WARN old lockfile 'npm ERR! prebuild-install info looking for local prebuild @ prebuilds\\nrf-device-lib-js-v0.4.13-napi-v7-win32-x64.tar.gz\n' +
npm WARN old lockfile 'npm ERR! prebuild-install info looking for cached prebuild @ C:\\Users\\Administrator\\AppData\\Local\\npm-cache\\_prebuilds\\596c67-nrf-device-lib-js-v0.4.13-napi-v7-win32-x64.tar.gz\n' +
npm WARN old lockfile 'npm ERR! prebuild-install http request GET https://developer.nordicsemi.com/.pc-tools/nrf-libs/nrf-device-lib-js/v0.4.13/nrf-device-lib-js-v0.4.13-napi-v7-win32-x64.tar.gz\n' +
npm WARN old lockfile 'npm ERR! prebuild-install warn install Request timed out\n' +
npm WARN old lockfile 'npm ERR! \n' +
npm WARN old lockfile 'npm ERR! Pre-building for versions: .\n' +
npm WARN old lockfile 'npm ERR! Done with error:\n' +
npm WARN old lockfile "npm ERR! Error: ENOENT: no such file or directory, open './include/nrfdl-js-version-autogen.h'\n" +
npm WARN old lockfile 'npm ERR! at Object.openSync (node:fs:585:3)\n' +
npm WARN old lockfile 'npm ERR! at Object.writeFileSync (node:fs:2157:35)\n' +
npm WARN old lockfile 'npm ERR! at create_version_header (C:\\Users\\Administrator\\AppData\\Local\\npm-cache\\_cacache\\tmp\\git-cloneOTG7x9\\node_modules\\@nordicsemiconductor\\nrf-device-lib-js\\do_prebuild.js:32:8)\n' +
npm WARN old lockfile 'npm ERR! at run_prebuild (C:\\Users\\Administrator\\AppData\\Local\\npm-cache\\_cacache\\tmp\\git-cloneOTG7x9\\node_modules\\@nordicsemiconductor\\nrf-device-lib-js\\do_prebuild.js:44:5)\n' +
npm WARN old lockfile 'npm ERR! at Object.<anonymous> (C:\\Users\\Administrator\\AppData\\Local\\npm-cache\\_cacache\\tmp\\git-cloneOTG7x9\\node_modules\\@nordicsemiconductor\\nrf-device-lib-js\\do_prebuild.js:446:5)\n' +
npm WARN old lockfile 'npm ERR! at Module._compile (node:internal/modules/cjs/loader:1103:14)\n' +
npm WARN old lockfile 'npm ERR! at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)\n' +
npm WARN old lockfile 'npm ERR! at Module.load (node:internal/modules/cjs/loader:981:32)\n' +
npm WARN old lockfile 'npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:822:12)\n' +
npm WARN old lockfile 'npm ERR! at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {\n' +
npm WARN old lockfile 'npm ERR! errno: -4058,\n' +
npm WARN old lockfile "npm ERR! syscall: 'open',\n" +
npm WARN old lockfile "npm ERR! code: 'ENOENT',\n" +
npm WARN old lockfile "npm ERR! path: './include/nrfdl-js-version-autogen.h'\n" +
npm WARN old lockfile 'npm ERR! }\n' +
npm WARN old lockfile '\n' +
npm WARN old lockfile 'npm ERR! A complete log of this run can be found in:\n' +
npm WARN old lockfile 'npm ERR! C:\\Users\\Administrator\\AppData\\Local\\npm-cache\\_logs\\2022-11-22T10_16_35_854Z-debug-0.log\n'
npm WARN old lockfile }
npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated @types/date-fns@2.6.0: This is a stub types definition for date-fns (https://github.com/date-fns/date-fns). date-fns provides its own type definitions, so you don't need @types/date-fns installed!
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.
npm WARN deprecated redux-devtools-extension@2.13.9: Package moved to @redux-devtools/extension.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated uuid@3.4.0: 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 request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated node-pre-gyp@0.15.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
added 2252 packages, and audited 2253 packages in 6m
271 packages are looking for funding
run `npm fund` for details
26 vulnerabilities (3 moderate, 22 high, 1 critical)
To address all issues, run:
npm audit fix
Run `npm audit` for details.
npm notice
npm notice New major version of npm available! 8.5.0 -> 9.1.2
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.1.2
npm notice Run npm install -g npm@9.1.2 to update!
npm notice
PS F:\download\pc-nrfconnect-ble>
3.编译项目,请看第二点文章中的编译内容,我这里编译的log如下:
PS F:\download\pc-nrfconnect-ble> npm run dev
> pc-nrfconnect-ble@4.0.2 dev
> webpack watch --mode development
Hash: fbf658d3a85ac09cd845
Version: webpack 4.46.0
Time: 30452ms
Built at: 2022/11/22 18:24:42
Asset Size Chunks Chunk Names
bundle.js 30.8 MiB main [emitted] main
nordic-publish.js 7.35 KiB [emitted]
Entrypoint main = bundle.js
[./node_modules/@babel/runtime/helpers/esm/extends.js] 527 bytes {main} [built]
[./node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js] 462 bytes {main} [built]
[./node_modules/pc-nrfconnect-shared/src/index.ts] 9.92 KiB {main} [built]
[./node_modules/react-bootstrap/esm/ProgressBar.js] 5.82 KiB {main} [built]
[./node_modules/semver/index.js] 2.57 KiB {main} [built]
[./src/config.ts] 742 bytes {main} [built]
[./src/downloadInstaller.ts] 3.34 KiB {main} [built]
[./src/index.tsx] 9.56 KiB {main} [built]
[./src/paths.ts] 2.83 KiB {main} [built]
[./src/run.ts] 2.15 KiB {main} [built]
[./src/style.css] 376 bytes {main} [built]
[@electron/remote] external "@electron/remote" 42 bytes {main} [built]
[fs] external "fs" 42 bytes {main} [built]
[path] external "path" 42 bytes {main} [built]
[react] external "react" 42 bytes {main} [built]
+ 1037 hidden modules
4.修改APP名称以及描述等内容:
5.运行nRF Connect for Desktop查看自己的APP:
到这里环境已经搭建好了!