{"id":13481716,"url":"https://github.com/manekinekko/angular-web-bluetooth","last_synced_at":"2025-04-04T22:07:39.906Z","repository":{"id":52878559,"uuid":"77481400","full_name":"manekinekko/angular-web-bluetooth","owner":"manekinekko","description":"The missing Web Bluetooth module for Angular","archived":false,"fork":false,"pushed_at":"2024-02-12T14:36:26.000Z","size":6052,"stargazers_count":198,"open_issues_count":4,"forks_count":61,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-03-28T21:08:14.154Z","etag":null,"topics":["angular","bluetooth","bluetooth-le","bluetooth-low-energy","html5","iot","javascipt","javascript","nodejs","sensor","typescript","web-bluetooth"],"latest_commit_sha":null,"homepage":"https://manekinekko.github.io/angular-web-bluetooth/","language":"TypeScript","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/manekinekko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":"manekinekko"}},"created_at":"2016-12-27T20:40:08.000Z","updated_at":"2025-01-15T12:39:10.000Z","dependencies_parsed_at":"2024-06-18T19:51:23.881Z","dependency_job_id":"518743ed-1ee9-458b-9f84-40c198185ff6","html_url":"https://github.com/manekinekko/angular-web-bluetooth","commit_stats":null,"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manekinekko%2Fangular-web-bluetooth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manekinekko%2Fangular-web-bluetooth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manekinekko%2Fangular-web-bluetooth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manekinekko%2Fangular-web-bluetooth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manekinekko","download_url":"https://codeload.github.com/manekinekko/angular-web-bluetooth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256112,"owners_count":20909240,"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":["angular","bluetooth","bluetooth-le","bluetooth-low-energy","html5","iot","javascipt","javascript","nodejs","sensor","typescript","web-bluetooth"],"created_at":"2024-07-31T17:00:54.651Z","updated_at":"2025-04-04T22:07:39.880Z","avatar_url":"https://github.com/manekinekko.png","language":"TypeScript","funding_links":["https://github.com/sponsors/manekinekko"],"categories":["Uncategorized","Awesome Angular [![Awesome TipeIO](https://img.shields.io/badge/Awesome%20Angular-@TipeIO-6C6AE7.svg)](https://github.com/gdi2290/awesome-angular) [![Awesome devarchy.com](https://img.shields.io/badge/Awesome%20Angular-@devarchy.com-86BDC1.svg)](https://github.com/brillout/awesome-angular-components)"],"sub_categories":["Uncategorized","Angular \u003ca id=\"angular\"\u003e\u003c/a\u003e"],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://cloud.githubusercontent.com/assets/1699357/21510721/556f650c-cc97-11e6-8a69-ddd67eeeebb8.png\" width=\"250\" /\u003e\n\u003c/div\u003e\n\u003ch2 align=\"center\"\u003eThe missing Web Bluetooth module for Angular\u003c/h2\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://github.com/manekinekko/angular-web-bluetooth/workflows/Angular%20CI/badge.svg\"/\u003e\u003c/p\u003e\n\n## Install\n\n```\nnpm install -S @manekinekko/angular-web-bluetooth @types/web-bluetooth\n```\n\n\u003e Note: Make also sure the `@types/web-bluetooth` is installed correctly in your `node_modules`.\n\n## Getting started\n\n## 1) import the `WebBluetoothModule` module\n\n```typescript\nimport { NgModule } from '@angular/core';\nimport { WebBluetoothModule } from '@manekinekko/angular-web-bluetooth';\n\n@NgModule({\n  imports: [\n    //...,\n    WebBluetoothModule.forRoot({\n      enableTracing: true // or false, this will enable logs in the browser's console\n    })\n  ]\n  //...\n})\nexport class AppModule {}\n```\n\n## 2.a) use it in your service/component (the easiest way)\n\nHere is an annotated example using the `BluetoothCore` service:\n\n```javascript\nimport { Injectable } from '@angular/core';\nimport { BluetoothCore } from '@manekinekko/angular-web-bluetooth';\nimport { map } from 'rxjs/operators';\n\n@Injectable({\n  providedIn: 'root'\n})\nexport class BatteryLevelService {\n\n  constructor(public readonly ble: BluetoothCore) {}\n\n  getDevice() {\n    // call this method to get the connected device\n    return this.ble.getDevice$();\n  }\n\n  stream() {\n    // call this method to get a stream of values emitted by the device for a given characteristic\n    return this.ble.streamValues$().pipe(\n      map((value: DataView) =\u003e value.getInt8(0))\n    );\n  }\n\n  disconnectDevice() {\n    // call this method to disconnect from the device. This method will also stop clear all subscribed notifications\n    this.ble.disconnectDevice();\n  }\n\n  value() {\n    console.log('Getting Battery level...');\n\n    return this.ble\n      .value$({\n        service: 'battery_service',\n        characteristic: 'battery_level'\n      });\n  }\n\n}\n```\n\n\n## 2.b) use it in your service/component (the advanced way)\n\nHere is an annotated example using the `BluetoothCore` service:\n\n```javascript\nimport { Injectable } from '@angular/core';\nimport { map, mergeMap } from 'rxjs/operators';\nimport { BluetoothCore } from '@manekinekko/angular-web-bluetooth';\n\n@Injectable({\n  providedIn: 'root'\n})\nexport class BatteryLevelService {\n  static GATT_CHARACTERISTIC_BATTERY_LEVEL = 'battery_level';\n  static GATT_PRIMARY_SERVICE = 'battery_service';\n\n  constructor(public ble: BluetoothCore) {}\n\n  getDevice() {\n    // call this method to get the connected device\n    return this.ble.getDevice$();\n  }\n\n  stream() {\n    // call this method to get a stream of values emitted by the device\n    return this.ble.streamValues$().pipe(map((value: DataView) =\u003e value.getUint8(0)));\n  }\n\n  disconnectDevice() {\n    this.ble.disconnectDevice();\n  }\n\n  /**\n   * Get Battery Level GATT Characteristic value.\n   * This logic is specific to this service, this is why we can't abstract it elsewhere.\n   * The developer is free to provide any service, and characteristics they want.\n   *\n   * @return Emites the value of the requested service read from the device\n   */\n  value() {\n    console.log('Getting Battery level...');\n\n    return this.ble\n\n        // 1) call the discover method will trigger the discovery process (by the browser)\n        .discover$({\n          acceptAllDevices: true,\n          optionalServices: [BatteryLevelService.GATT_PRIMARY_SERVICE]\n        })\n        .pipe(\n\n          // 2) get that service\n          mergeMap((gatt: BluetoothRemoteGATTServer) =\u003e {\n            return this.ble.getPrimaryService$(gatt, BatteryLevelService.GATT_PRIMARY_SERVICE);\n          }),\n\n          // 3) get a specific characteristic on that service\n          mergeMap((primaryService: BluetoothRemoteGATTService) =\u003e {\n            return this.ble.getCharacteristic$(primaryService, BatteryLevelService.GATT_CHARACTERISTIC_BATTERY_LEVEL);\n          }),\n\n          // 4) ask for the value of that characteristic (will return a DataView)\n          mergeMap((characteristic: BluetoothRemoteGATTCharacteristic) =\u003e {\n            return this.ble.readValue$(characteristic);\n          }),\n\n          // 5) on that DataView, get the right value\n          map((value: DataView) =\u003e value.getUint8(0))\n        )\n  }\n}\n```\n\n## API documentation\n\nThe API documentation can be found here:  https://manekinekko.github.io/angular-web-bluetooth/\n\n## Need a starter?\n\n\u003cimg src=\"src/assets/screenshot.png\"/\u003e\n\nThis project serves also as a starter. Run the following command:\n\n```bash\nnpm start\n```\n\n## Blog post\n\nCheckout my full [blog post on dev.to](https://dev.to/angular/the-web-bluetooth-module-for-angular-314b) about how to use this package in your app.\n\n## Have a PR?\n\nAll contributions are welcome. Here are few [open issues](https://github.com/manekinekko/angular-web-bluetooth/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) that I need help with ;)\n\n# License\n\nThe MIT License (MIT) Copyright (c) 2017 - Wassim CHEGHAM\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanekinekko%2Fangular-web-bluetooth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanekinekko%2Fangular-web-bluetooth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanekinekko%2Fangular-web-bluetooth/lists"}