{"action":"created","issue":{"url":"https://api.github.com/repos/electron/electron/issues/7367","repository_url":"https://api.github.com/repos/electron/electron","labels_url":"https://api.github.com/repos/electron/electron/issues/7367/labels{/name}","comments_url":"https://api.github.com/repos/electron/electron/issues/7367/comments","events_url":"https://api.github.com/repos/electron/electron/issues/7367/events","html_url":"https://github.com/electron/electron/issues/7367","id":179617354,"number":7367,"title":"Electron && Bluetooth","user":{"login":"amrish7","id":1700689,"avatar_url":"https://avatars.githubusercontent.com/u/1700689?v=3","gravatar_id":"","url":"https://api.github.com/users/amrish7","html_url":"https://github.com/amrish7","followers_url":"https://api.github.com/users/amrish7/followers","following_url":"https://api.github.com/users/amrish7/following{/other_user}","gists_url":"https://api.github.com/users/amrish7/gists{/gist_id}","starred_url":"https://api.github.com/users/amrish7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amrish7/subscriptions","organizations_url":"https://api.github.com/users/amrish7/orgs","repos_url":"https://api.github.com/users/amrish7/repos","events_url":"https://api.github.com/users/amrish7/events{/privacy}","received_events_url":"https://api.github.com/users/amrish7/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-09-27T21:21:03Z","updated_at":"2016-09-28T08:05:22Z","closed_at":null,"body":"**Environment information**\r\n   * node `v 6.5.0`\r\n   * electron `v 1.4.1` (Chrome `v 53.0.2785.113`\r\n   * OS X `v 10.11.6`\r\n\r\n___\r\n\r\nIs there a tutorial/example on connecting and streaming data from a bluetooth device? It will be great if someone could point me in the right direction. I am having trouble connecting to a device paired to my mac.\r\n\r\nI want to connect to a bluetooth device (BLE and **non-BLE**) and stream and receive data. Here are the two things I have been trying\r\n\r\n## 1. bluetooth-serial-port\r\nThe following code works great as node App, but **not** in electron. I am not seeing a success/error response to my `btSerial.connect` API call. I have reached out to the module developers https://github.com/eelcocramer/node-bluetooth-serial-port/issues/116, but I also  wanted to run it by the Electron community\r\n\r\n```\r\nvar Bluetooth = require('bluetooth-serial-port');\r\nvar btSerial = new Bluetooth.BluetoothSerialPort();\r\n\r\nconst deviceEnum = (devs) => {\r\n    console.log(`${devs.length} BlueTooth device(s) are paired.`);\r\n    devs.forEach((dev) => {\r\n        console.log(`Paired with \"${dev.name}\"`);\r\n\r\n        if(dev.name.indexOf('<MY-DEVICE-NAME> ') === 0) {\r\n            console.log(`Trying to connect with ${dev.name}`);\r\n            btSerial.connect(dev.address, 1, () => {\r\n                console.log(`CONNECTED >>> `);\r\n            }, (e) => {\r\n                console.error(`ERROR ON CONNECTED ${e}`);\r\n            });\r\n        }\r\n    });\r\n};\r\nbtSerial.listPairedDevices(deviceEnum);\r\n```\r\n\r\nI have enabled web bluetooth flag in my `main.js` as well `app.commandLine.appendSwitch('enable-web-bluetooth', true);`\r\n\r\nI did not find https://github.com/electron/electron/issues/1943#issuecomment-146552554 helpful either (Unless I have missed something)\r\n\r\n## 2. Web Bluetooth API's\r\nI was not able to get the solution from https://github.com/electron/electron/issues/5565 and this [doc] (https://googlechrome.github.io/samples/web-bluetooth/device-info.html) to work either. \r\n\r\nHere is the code that I have and I am not getting a response back\r\n\r\n### main.js\r\n```\r\napp.commandLine.appendSwitch('enable-web-bluetooth', true);\r\n```\r\n\r\n### index.js\r\n```\r\nconsole.log(`>>>> navigator.bluetooth.requestDevice: ${navigator.bluetooth.requestDevice}`);\r\n    try {\r\n        const filters = [];\r\n        filters.push({namePrefix: 'MOB'});\r\n        console.log(`Using filters: ${JSON.stringify(filters)}`);\r\n        navigator.bluetooth.requestDevice({filters: filters})\r\n            .then(device => {\r\n                console.log('> Name:             ' + device.name);\r\n                console.log('> Id:               ' + device.id);\r\n                console.log('> UUIDs:            ' + device.uuids.join('\\n' + ' '.repeat(20)));\r\n                console.log('> Connected:        ' + device.gatt.connected);})\r\n            .catch(error => {\r\n                console.error('Argh! ' + error);\r\n            });\r\n    } catch(e) {\r\n        console.log('EXCEPTION> ' + e);\r\n    }\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/electron/electron/issues/comments/250099556","html_url":"https://github.com/electron/electron/issues/7367#issuecomment-250099556","issue_url":"https://api.github.com/repos/electron/electron/issues/7367","id":250099556,"user":{"login":"deepak1556","id":964386,"avatar_url":"https://avatars.githubusercontent.com/u/964386?v=3","gravatar_id":"","url":"https://api.github.com/users/deepak1556","html_url":"https://github.com/deepak1556","followers_url":"https://api.github.com/users/deepak1556/followers","following_url":"https://api.github.com/users/deepak1556/following{/other_user}","gists_url":"https://api.github.com/users/deepak1556/gists{/gist_id}","starred_url":"https://api.github.com/users/deepak1556/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deepak1556/subscriptions","organizations_url":"https://api.github.com/users/deepak1556/orgs","repos_url":"https://api.github.com/users/deepak1556/repos","events_url":"https://api.github.com/users/deepak1556/events{/privacy}","received_events_url":"https://api.github.com/users/deepak1556/received_events","type":"User","site_admin":false},"created_at":"2016-09-28T08:05:22Z","updated_at":"2016-09-28T08:05:22Z","body":"What is the error you are receiving when using the web bluetooth api and does the code work as expected on chrome ?\r\n\r\n> Do Electron's web bluetooth API's support non-Bluetooth LE devices?\r\n\r\nElectron does not implement the web bluetooth api, we reuse the implementation from chromium. So if it works with chrome then it should work here otherwise its a bug in Electron. Also webkit bluetooth implementation states they perform only LE  scan https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/bluetooth/README.md . I can verify that LE scan works fine with above code.\r\n\r\n```\r\n[8423:0928/130906:INFO:CONSOLE(11)] \">>>> navigator.bluetooth.requestDevice: function requestDevice() { [native code] }\", source: http://localhost:8000/index.html (11)\r\n[8423:0928/130906:INFO:CONSOLE(15)] \"Using filters: [{\"namePrefix\":\"OnePlus One\"}]\", source: http://localhost:8000/index.html (15)\r\n[8423:0928/130906:INFO:CONSOLE(28)] \"#### Electron Version: 1.4.1\", source: http://localhost:8000/index.html (28)\r\n[8423:0928/130906:INFO:CONSOLE(29)] \"#### Chrome Version: 53.0.2785.113\", source: http://localhost:8000/index.html (29)\r\n[8423:0928/130916:INFO:CONSOLE(18)] \"> Name:             OnePlus One\", source: http://localhost:8000/index.html (18)\r\n[8423:0928/130916:INFO:CONSOLE(19)] \"> Id:               3F/TCaINgSNxmtDXWT9Avg==\", source: http://localhost:8000/index.html (19)\r\n[8423:0928/130916:INFO:CONSOLE(20)] \"> UUIDs:            \", source: http://localhost:8000/index.html (20)\r\n[8423:0928/130916:INFO:CONSOLE(21)] \"> Connected:        false\", source: http://localhost:8000/index.html (21)\r\n```\r\n\r\n> Is `bluetooth-serial-port` compatible with Electron ?\r\n\r\nYes, the module is not specific to any runtime. "}}
{"actor":{"display_login":"deepak1556"}}