Html5如何監聽藍牙(可結合JS或者PHP實作),有沒有哪位親知道具體的實作方法!!!
uj5u.com熱心網友回復:
作者:林友昂鏈接:https://www.zhihu.com/question/30884733/answer/104715177
來源:知乎
著作權歸作者所有,轉載請聯系作者獲得授權。
以下是以上鏈接介紹的簡單列子
Here is a very simple example, showing a button:
<button id="the-button">Try it</button>
…and the following JavaScript:
const button = document.querySelector('#the-button');
button.addEventListener('click', function() {
navigator.bluetooth.requestDevice({
filters: [{
services: ['battery_service']
}]
}).then(device => {
console.log('Got device:', device.name);
console.log('id:', device.id);
});
});
As mentioned earlier, the method navigator.bluetooth.requestDevice() can only be called in response to a user action like a button click. This method calls up a dialog box showing the list of available BLE devices matching the query filter. In our case, the filter we have set pertains to BLE devices which expose a so-called “GATT service” called battery_service. We’ll find out more about GATT services in the next section.
可試下
uj5u.com熱心網友回復:
怎么匹配,是搜到附近所有的藍牙嗎?uj5u.com熱心網友回復:

研究一下!
uj5u.com熱心網友回復:
uj5u.com熱心網友回復:
解決了嗎?我的需求是設備要通過藍牙向手機app發送資料,不知道咋整,還無從下手,不知道用不用連接,還是直接監聽轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/45459.html
標籤:HTML5
上一篇:React和Vue怎么選
下一篇:關于彈窗問題
