CodePudding user response:
Author: Lin YouangLink: https://www.zhihu.com/question/30884733/answer/104715177
Source: zhihu
Copyright owned by the author, reproduced please contact the author for authorization,
The following is a simple example above link to introduce
Here is a very simple example, showing a button:
... And the following JavaScript:
Const button=document. QuerySelector (' # the - button ');
Button. The addEventListener (' click ', function () {
The navigator. Bluetooth. RequestDevice ({
Filters: [{
Services: [' battery_service]
}]
}). Then (device=& gt; {
The console. The log (' Got device: ', device. Name);
The console. The log (' id: 'device. The id);
});
});
As mentioned earlier, the method the 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 the 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 the GATT services in the next section.
Can try
CodePudding user response:
How to match, is all search to the nearby bluetooth?CodePudding user response:

Look at!
CodePudding user response:

CodePudding user response:
The solution? My demand is devices to send data via bluetooth to the mobile phone app, don't know what to do, also do not know how to start, I don't know use connection, or directly to monitor