- Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathprovision.ts
26 lines (23 loc) · 726 Bytes
/
provision.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import{IMPROV_BLE_SERVICE}from"./const";
importtype{LaunchButton}from"./launch-button";
import{fireEvent}from"./util";
exportconststartProvisioning=async(button: LaunchButton)=>{
import("./provision-dialog");
letdevice: BluetoothDevice|undefined;
try{
device=awaitnavigator.bluetooth.requestDevice({
filters: [{services: [IMPROV_BLE_SERVICE]}],
});
}catch(err){
console.error("Failed to get device",err);
}
if(!device){
return;
}
constel=document.createElement("improv-wifi-provision-dialog");
el.device=device;
el.stateUpdateCallback=(state)=>{
fireEvent(button,"state-changed",state);
};
document.body.appendChild(el);
};