{"id":13527501,"url":"https://github.com/lsongdev/node-bluetooth","last_synced_at":"2025-04-09T20:15:11.827Z","repository":{"id":65411361,"uuid":"62123303","full_name":"lsongdev/node-bluetooth","owner":"lsongdev","description":":large_blue_diamond:😬Bluetooth serial port communication for Node.js","archived":false,"fork":false,"pushed_at":"2023-06-22T10:41:44.000Z","size":71,"stargazers_count":199,"open_issues_count":27,"forks_count":55,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-09T20:15:06.370Z","etag":null,"topics":["bluetooth","iot-device","node-bluetooth","serialport"],"latest_commit_sha":null,"homepage":"https://npmjs.org/node-bluetooth","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lsongdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-28T08:22:47.000Z","updated_at":"2025-02-27T12:46:52.000Z","dependencies_parsed_at":"2024-06-11T19:19:24.820Z","dependency_job_id":null,"html_url":"https://github.com/lsongdev/node-bluetooth","commit_stats":{"total_commits":15,"total_committers":5,"mean_commits":3.0,"dds":0.4666666666666667,"last_synced_commit":"53f9412964c4a4ca7705bb593912827f128e3869"},"previous_names":["lsongdev/node-bluetooth","song940/node-bluetooth"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fnode-bluetooth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fnode-bluetooth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fnode-bluetooth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fnode-bluetooth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lsongdev","download_url":"https://codeload.github.com/lsongdev/node-bluetooth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103872,"owners_count":21048245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bluetooth","iot-device","node-bluetooth","serialport"],"created_at":"2024-08-01T06:01:49.426Z","updated_at":"2025-04-09T20:15:11.796Z","avatar_url":"https://github.com/lsongdev.png","language":"C++","readme":"## node-bluetooth ![NPM version](https://img.shields.io/npm/v/node-bluetooth.svg?style=flat)\n\nBluetooth serial port communication for Node.js\n\n\n### Requirements\n\n**This package require `node-gyp` installed .**\n\n#### Linux\n\nYou'll need libbluetooth-dev. On Ubuntu/Debian : ``` $ sudo apt-get install libbluetooth-dev```\n\n### Installation\n\n```bash\n$ npm install node-bluetooth --save\n```\n\n### Example\n\n#### create device\n```js\nconst bluetooth = require('node-bluetooth');\n\n// create bluetooth device instance\nconst device = new bluetooth.DeviceINQ();\n```\n\n#### list already paired devices\n```js\ndevice.listPairedDevices(console.log);\n```\nwill output\n```js\n➜  node-bluetooth git:(master) ✗ node example/index.js\n[ { name: 'Lsong’s Trackpad',\n    address: 'd0-a6-37-f1-e7-87',\n    services: [ [Object], [Object] ] },\n  { name: 'Lsong’s iPhone',\n    address: 'dc-2b-2a-82-76-29',\n    services: [ [Object], [Object], [Object], [Object] ] },\n  { name: 'Lsong’s Keyboard',\n    address: '60-c5-47-19-d3-76',\n    services: [ [Object], [Object] ] } ]\n```\n\n\n#### find devices\n\n```js\ndevice\n.on('finished',  console.log.bind(console, 'finished'))\n.on('found', function found(address, name){\n  console.log('Found: ' + address + ' with name ' + name);\n}).scan();\n```\n\nwill output\n\n```\n➜  node-bluetooth git:(master) ✗ node example/index.js\nFound: 22-22-a3-0d-63-09 with name Meizu MX4 Pro\nFound: dc-2b-2a-82-76-29 with name Lsong's iPhone\nFound: 38-bc-1a-37-2d-d4 with name MEIZU MX5\nfinished\n```\n\nfind serial port channel\n\n```js\ndevice.findSerialPortChannel(address, function(channel){\n  console.log('Found RFCOMM channel for serial port on %s: ', name, channel);\n\n  // make bluetooth connect to remote device\n  bluetooth.connect(address, channel, function(err, connection){\n    if(err) return console.error(err);\n    connection.write(new Buffer('Hello!', 'utf-8'), () =\u003e {\n      console.log(\"wrote\");\n    });\n  });\n\n});\n```\n\ncreate connection to device, read and write\n\n```js\n// make bluetooth connect to remote device\nbluetooth.connect(address, channel, function(err, connection){\n  if(err) return console.error(err);\n\n  connection.on('data', (buffer) =\u003e {\n    console.log('received message:', buffer.toString());\n  });\n\n  connection.write(new Buffer('Hello!', 'utf-8'), () =\u003e {\n    console.log(\"wrote\");\n  });\n});\n```\n\n### API\n\n- [bluetooth.Connection](#Connection)\n- [bluetooth.DeviceINQ](#DeviceINQ)\n- [bluetooth.connect](#connect)\n\n### Contributing\n- Fork this Repo first\n- Clone your Repo\n- Install dependencies by `$ npm install`\n- Checkout a feature branch\n- Feel free to add your features\n- Make sure your features are fully tested\n- Publish your local branch, Open a pull request\n- Enjoy hacking \u003c3\n\n### MIT license\nCopyright (c) 2016 lsong\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \u0026quot;Software\u0026quot;), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \u0026quot;AS IS\u0026quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n---\n","funding_links":[],"categories":["Repository","C++"],"sub_categories":["Hardware"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsongdev%2Fnode-bluetooth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flsongdev%2Fnode-bluetooth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsongdev%2Fnode-bluetooth/lists"}