{"id":16149768,"url":"https://github.com/robotastic/able","last_synced_at":"2025-04-06T22:17:35.072Z","repository":{"id":66958036,"uuid":"42771076","full_name":"robotastic/able","owner":"robotastic","description":"BLENO + NOBLE = Fun","archived":false,"fork":false,"pushed_at":"2015-10-11T12:29:41.000Z","size":600,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T02:43:27.877Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robotastic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-19T11:57:10.000Z","updated_at":"2015-09-20T19:51:57.000Z","dependencies_parsed_at":"2023-02-28T02:45:58.365Z","dependency_job_id":null,"html_url":"https://github.com/robotastic/able","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotastic%2Fable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotastic%2Fable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotastic%2Fable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotastic%2Fable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robotastic","download_url":"https://codeload.github.com/robotastic/able/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557748,"owners_count":20958047,"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":[],"created_at":"2024-10-10T00:45:00.354Z","updated_at":"2025-04-06T22:17:35.043Z","avatar_url":"https://github.com/robotastic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# noble\n\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sandeepmistry/noble?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nA Node.js BLE (Bluetooth Low Energy) central module.\n\nWant to implement a peripheral? Checkout [bleno](https://github.com/sandeepmistry/bleno)\n\n__Note:__ Mac OS X, Linux and Windows are currently the only supported OSes. Other platforms may be developed later on.\n\n## Prerequisites\n\n### OS X\n\n * install [Xcode](https://itunes.apple.com/ca/app/xcode/id497799835?mt=12)\n\n### Linux (Ubuntu)\n\n * Kernel version 3.6 or above\n * ```libbluetooth-dev```\n\n#### Ubuntu/Debian/Raspbian\n\n```sh\nsudo apt-get install bluetooth bluez-utils libbluetooth-dev libudev-dev\n```\n\n#### Fedora / Other-RPM based\n\n```sh\nsudo yum install bluez bluez-libs bluez-libs-devel\n```\n\n#### Intel Edison\n\nSee [Configure Intel Edison for Bluetooth LE (Smart) Development](http://rexstjohn.com/configure-intel-edison-for-bluetooth-le-smart-development/)\n\n### Windows\n\n * [node-gyp requirements for Windows](https://github.com/TooTallNate/node-gyp#installation)\n   * Python 2.7\n   * Visual Studio ([Express](https://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx))\n * [node-bluetooth-hci-socket prerequisites](https://github.com/sandeepmistry/node-bluetooth-hci-socket#windows)\n   * Compatible Bluetooth 4.0 USB adapter\n   * [WinUSB](https://msdn.microsoft.com/en-ca/library/windows/hardware/ff540196(v=vs.85).aspx) driver setup for Bluetooth 4.0 USB adapter, using [Zadig tool](http://zadig.akeo.ie/)\n\n## Install\n\n```sh\nnpm install noble\n```\n\n## Usage\n\n```javascript\nvar noble = require('noble');\n```\n\n### Actions\n\n#### Start scanning\n\n```javascript\nnoble.startScanning(); // any service UUID, no duplicates\n\n\nnoble.startScanning([], true); // any service UUID, allow duplicates\n\n\nvar serviceUUIDs = [\"\u003cservice UUID 1\u003e\", ...]; // default: [] =\u003e all\nvar allowDuplicates = \u003cfalse|true\u003e; // default: false\n\nnoble.startScanning(serviceUUIDs, allowDuplicates[, callback(error)]); // particular UUID's\n```\n\n__NOTE:__ ```noble.state``` must be ```poweredOn``` before scanning is started. ```noble.on('stateChange', callback(state));``` can be used register for state change events.\n\n#### Stop scanning\n\n```javascript\nnoble.stopScanning();\n```\n\n#### Peripheral\n\n##### Connect\n\n```javascript\nperipheral.connect([callback(error)]);\n```\n\n##### Disconnect or cancel pending connection\n\n```javascript\nperipheral.disconnect([callback(error)]);\n```\n\n##### Update RSSI\n\n```javascript\nperipheral.updateRssi([callback(error, rssi)]);\n```\n\n##### Discover services\n\n```javascript\nperipheral.discoverServices(); // any service UUID\n\nvar serviceUUIDs = [\"\u003cservice UUID 1\u003e\", ...];\nperipheral.discoverServices(serviceUUIDs[, callback(error, services)]); // particular UUID's\n```\n\n##### Discover all services and characteristics\n\n```javascript\nperipheral.discoverAllServicesAndCharacteristics([callback(error, services, characteristics));\n```\n\n##### Discover some services and characteristics\n\n```javascript\nvar serviceUUIDs = [\"\u003cservice UUID 1\u003e\", ...];\nvar characteristicUUIDs = [\"\u003ccharacteristic UUID 1\u003e\", ...];\nperipheral.discoverSomeServicesAndCharacteristics(serviceUUIDs, characteristicUUIDs, [callback(error, services, characteristics));\n```\n#### Service\n\n##### Discover included services\n\n```javascript\nservice.discoverIncludedServices(); // any service UUID\n\nvar serviceUUIDs = [\"\u003cservice UUID 1\u003e\", ...];\nservice.discoverIncludedServices(serviceUUIDs[, callback(error, includedServiceUuids)]); // particular UUID's\n```\n\n##### Discover characteristics\n\n```javascript\nservice.discoverCharacteristics() // any characteristic UUID\n\nvar characteristicUUIDs = [\"\u003ccharacteristic UUID 1\u003e\", ...];\nservice.discoverCharacteristics(characteristicUUIDs[, callback(error, characteristics)]); // particular UUID's\n```\n\n#### Characteristic\n\n##### Read\n\n```javascript\ncharacteristic.read([callback(error, data)]);\n```\n\n##### Write\n\n```javascript\ncharacteristic.write(data, notify[, callback(error)]); // data is a buffer, notify is true|false\n```\n\n##### Broadcast\n\n```javascript\ncharacteristic.broadcast(broadcast[, callback(error)]); // broadcast is true|false\n```\n\n##### Notify\n\n```javascript\ncharacteristic.notify(notify[, callback(error)]); // notify is true|false\n```\n\n  * allows notification to trigger `'data'` event\n  * use for characteristics with notify or indicate properties\n\n##### Discover descriptors\n\n```javascript\ncharacteristic.discoverDescriptors([callback(error, descriptors)]);\n```\n\n##### Read value\n\n```javascript\ndescriptor.readValue([callback(error, data)]);\n```\n\n##### Write value\n\n```javascript\ndescriptor.writeValue(data[, callback(error)]); // data is a buffer\n```\n\n#### Handle\n\n##### Read\n\n```javascript\nperipheral.readHandle(handle, callback(error, data));\n```\n\n##### Write\n\n```javascript\nperipheral.writeHandle(handle, data, withoutResponse, callback(error));\n```\n\n### Events\n\n#### Adapter state change\n\n```javascript\nstate = \u003c\"unknown\" | \"resetting\" | \"unsupported\" | \"unauthorized\" | \"poweredOff\" | \"poweredOn\"\u003e\n\nnoble.on('stateChange', callback(state));\n```\n\n#### Scan started:\n\n```javascript\nnoble.on('scanStart', callback);\n```\n\n#### Scan stopped\n\n```javascript\nnoble.on('scanStop', callback);\n```\n\n#### Peripheral discovered\n\n```javascript\nperipheral = {\n  id: \"\u003cid\u003e\",\n  address: \"\u003cBT address\"\u003e, // Bluetooth Address of device, or 'unknown' if not known\n  addressType: \"\u003cBT address type\u003e\", // Bluetooth Address type (public, random), or 'unknown' if not known\n  connectable: \u003cconnectable\u003e, // true or false, or undefined if not known\n  advertisement: {\n    localName: \"\u003cname\u003e\",\n    txPowerLevel: \u003cint\u003e,\n    serviceUuids: [\"\u003cservice UUID\u003e\", ...],\n    manufacturerData: \u003cBuffer\u003e,\n    serviceData: [\n        {\n            uuid: \"\u003cservice UUID\u003e\"\n            data: \u003cBuffer\u003e\n        },\n        ...\n    ]\n  },\n  rssi: \u003crssi\u003e\n};\n\nnoble.on('discover', callback(peripheral));\n```\n\n#### Warnings\n\n```javascript\nnoble.on('warning', callback(message));\n```\n\n#### Peripheral\n\n##### Connected\n\n```javascript\nperipheral.on('connect', callback);\n```\n\n##### Disconnected:\n\n```javascript\nperipheral.on('disconnect', callback);\n```\n\n##### RSSI update\n\n```javascript\nperipheral.on('rssiUpdate', callback(rssi));\n```\n\n##### Services discovered\n\n```javascript\nperipheral.on('servicesDiscover', callback(services));\n```\n\n#### Service\n\n##### Included services discovered\n\n```javascript\nservice.on('includedServicesDiscover', callback(includedServiceUuids));\n```\n\n##### Characteristics discovered\n\n```javascript\ncharacteristic = {\n  uuid: \"\u003cuuid\u003e\",\n   // properties: 'broadcast', 'read', 'writeWithoutResponse', 'write', 'notify', 'indicate', 'authenticatedSignedWrites', 'extendedProperties'\n  properties: [...]\n};\n\nservice.on('characteristicsDiscover', callback(characteristics));\n```\n\n#### Characteristic\n\n##### Data\n\nEmitted when characteristic read has completed, result of ```characteristic.read(...)``` or characteristic value has been updated by peripheral via notification or indication - after having been enabled with ```notify(true[, callback(error)])```.\n\n```javascript\ncharacteristic.on('data', callback(data, isNotification));\n\ncharacteristic.on('read', callback(data, isNotification)); // legacy\n```\n\n##### Write\n\nEmitted when characteristic write has completed, result of ```characteristic.write(...)```.\n\n```javascript\ncharacteristic.on('write', withoutResponse, callback());\n```\n\n##### Broadcast\n\nEmitted when characteristic broadcast state changes, result of ```characteristic.broadcast(...)```.\n\n```javascript\ncharacteristic.on('broadcast', callback(state));\n```\n\n##### Notify\n\nEmitted when characteristic notification state changes, result of ```characteristic.notify(...)```.\n\n```javascript\ncharacteristic.on('notify', callback(state));\n```\n\n##### Descriptors discovered\n\n```javascript\ndescriptor = {\n  uuid: '\u003cuuid\u003e'\n};\n\ncharacteristic.on('descriptorsDiscover', callback(descriptors));\n```\n\n#### Descriptor\n\n##### Value read\n\n```javascript\ndescriptor.on('valueRead', data);\n```\n\n##### Value write\n\n```javascript\ndescriptor.on('valueWrite');\n```\n\n## Running on Linux\n\n### Running without root/sudo\n\nRun the following command:\n\n```sh\nsudo setcap cap_net_raw+eip $(eval readlink -f `which node`)\n```\n\nThis grants the ```node``` binary ```cap_net_raw``` privileges, so it can start/stop BLE advertising.\n\n__Note:__ The above command requires ```setcap``` to be installed, it can be installed using the following:\n\n * apt: ```sudo apt-get install libcap2-bin```\n * yum: ```su -c \\'yum install libcap2-bin\\'```\n\n### Multiple Adapters\n\n```hci0``` is used by default to override set the ```NOBLE_HCI_DEVICE_ID``` environment variable to the interface number.\n\nExample, specify ```hci1```:\n\n```sh\nsudo NOBLE_HCI_DEVICE_ID=1 node \u003cyour file\u003e.js\n```\n\n### Reporting all HCI events\n\nBy default noble waits for both the advertisement data and scan response data for each Bluetooth address. If your device does not use scan response the following enviroment variable can be used to bypass it.\n\n\n```sh\nsudo NOBLE_REPORT_ALL_HCI_EVENTS=1 node \u003cyour file\u003e.js\n```\n\n## Useful Links\n\n * [Bluetooth Development Portal](http://developer.bluetooth.org)\n   * [GATT Specifications](http://developer.bluetooth.org/gatt/Pages/default.aspx)\n * [Bluetooth: ATT and GATT](http://epx.com.br/artigos/bluetooth_gatt.php)\n\n## License\n\nCopyright (C) 2015 Sandeep Mistry \u003csandeep.mistry@gmail.com\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n[![Analytics](https://ga-beacon.appspot.com/UA-56089547-1/sandeepmistry/noble?pixel)](https://github.com/igrigorik/ga-beacon)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobotastic%2Fable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobotastic%2Fable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobotastic%2Fable/lists"}