web-bluetooth.idl (8461B)
1 // GENERATED CONTENT - DO NOT EDIT 2 // Content was automatically extracted by Reffy into webref 3 // (https://github.com/w3c/webref) 4 // Source: Web Bluetooth (https://webbluetoothcg.github.io/web-bluetooth/) 5 6 dictionary BluetoothDataFilterInit { 7 BufferSource dataPrefix; 8 BufferSource mask; 9 }; 10 11 dictionary BluetoothManufacturerDataFilterInit : BluetoothDataFilterInit { 12 required [EnforceRange] unsigned short companyIdentifier; 13 }; 14 15 dictionary BluetoothServiceDataFilterInit : BluetoothDataFilterInit { 16 required BluetoothServiceUUID service; 17 }; 18 19 dictionary BluetoothLEScanFilterInit { 20 sequence<BluetoothServiceUUID> services; 21 DOMString name; 22 DOMString namePrefix; 23 sequence<BluetoothManufacturerDataFilterInit> manufacturerData; 24 sequence<BluetoothServiceDataFilterInit> serviceData; 25 }; 26 27 dictionary RequestDeviceOptions { 28 sequence<BluetoothLEScanFilterInit> filters; 29 sequence<BluetoothLEScanFilterInit> exclusionFilters; 30 sequence<BluetoothServiceUUID> optionalServices = []; 31 sequence<unsigned short> optionalManufacturerData = []; 32 boolean acceptAllDevices = false; 33 }; 34 35 [Exposed=Window, SecureContext] 36 interface Bluetooth : EventTarget { 37 Promise<boolean> getAvailability(); 38 attribute EventHandler onavailabilitychanged; 39 [SameObject] 40 readonly attribute BluetoothDevice? referringDevice; 41 Promise<sequence<BluetoothDevice>> getDevices(); 42 Promise<BluetoothDevice> requestDevice(optional RequestDeviceOptions options = {}); 43 }; 44 45 Bluetooth includes BluetoothDeviceEventHandlers; 46 Bluetooth includes CharacteristicEventHandlers; 47 Bluetooth includes ServiceEventHandlers; 48 49 dictionary BluetoothPermissionDescriptor : PermissionDescriptor { 50 DOMString deviceId; 51 // These match RequestDeviceOptions. 52 sequence<BluetoothLEScanFilterInit> filters; 53 sequence<BluetoothServiceUUID> optionalServices = []; 54 sequence<unsigned short> optionalManufacturerData = []; 55 boolean acceptAllDevices = false; 56 }; 57 58 dictionary AllowedBluetoothDevice { 59 required DOMString deviceId; 60 required boolean mayUseGATT; 61 // An allowedServices of "all" means all services are allowed. 62 required (DOMString or sequence<UUID>) allowedServices; 63 required sequence<unsigned short> allowedManufacturerData; 64 }; 65 dictionary BluetoothPermissionStorage { 66 required sequence<AllowedBluetoothDevice> allowedDevices; 67 }; 68 69 [Exposed=Window] 70 interface BluetoothPermissionResult : PermissionStatus { 71 attribute FrozenArray<BluetoothDevice> devices; 72 }; 73 74 [ 75 Exposed=Window, 76 SecureContext 77 ] 78 interface ValueEvent : Event { 79 constructor(DOMString type, optional ValueEventInit initDict = {}); 80 readonly attribute any value; 81 }; 82 83 dictionary ValueEventInit : EventInit { 84 any value = null; 85 }; 86 87 [Exposed=Window, SecureContext] 88 interface BluetoothDevice : EventTarget { 89 readonly attribute DOMString id; 90 readonly attribute DOMString? name; 91 readonly attribute BluetoothRemoteGATTServer? gatt; 92 93 Promise<undefined> forget(); 94 Promise<undefined> watchAdvertisements( 95 optional WatchAdvertisementsOptions options = {}); 96 readonly attribute boolean watchingAdvertisements; 97 }; 98 BluetoothDevice includes BluetoothDeviceEventHandlers; 99 BluetoothDevice includes CharacteristicEventHandlers; 100 BluetoothDevice includes ServiceEventHandlers; 101 102 dictionary WatchAdvertisementsOptions { 103 AbortSignal signal; 104 }; 105 106 [Exposed=Window, SecureContext] 107 interface BluetoothManufacturerDataMap { 108 readonly maplike<unsigned short, DataView>; 109 }; 110 [Exposed=Window, SecureContext] 111 interface BluetoothServiceDataMap { 112 readonly maplike<UUID, DataView>; 113 }; 114 [ 115 Exposed=Window, 116 SecureContext 117 ] 118 interface BluetoothAdvertisingEvent : Event { 119 constructor(DOMString type, BluetoothAdvertisingEventInit init); 120 [SameObject] 121 readonly attribute BluetoothDevice device; 122 readonly attribute FrozenArray<UUID> uuids; 123 readonly attribute DOMString? name; 124 readonly attribute unsigned short? appearance; 125 readonly attribute byte? txPower; 126 readonly attribute byte? rssi; 127 [SameObject] 128 readonly attribute BluetoothManufacturerDataMap manufacturerData; 129 [SameObject] 130 readonly attribute BluetoothServiceDataMap serviceData; 131 }; 132 dictionary BluetoothAdvertisingEventInit : EventInit { 133 required BluetoothDevice device; 134 sequence<(DOMString or unsigned long)> uuids; 135 DOMString name; 136 unsigned short appearance; 137 byte txPower; 138 byte rssi; 139 BluetoothManufacturerDataMap manufacturerData; 140 BluetoothServiceDataMap serviceData; 141 }; 142 143 [Exposed=Window, SecureContext] 144 interface BluetoothRemoteGATTServer { 145 [SameObject] 146 readonly attribute BluetoothDevice device; 147 readonly attribute boolean connected; 148 Promise<BluetoothRemoteGATTServer> connect(); 149 undefined disconnect(); 150 Promise<BluetoothRemoteGATTService> getPrimaryService(BluetoothServiceUUID service); 151 Promise<sequence<BluetoothRemoteGATTService>> 152 getPrimaryServices(optional BluetoothServiceUUID service); 153 }; 154 155 [Exposed=Window, SecureContext] 156 interface BluetoothRemoteGATTService : EventTarget { 157 [SameObject] 158 readonly attribute BluetoothDevice device; 159 readonly attribute UUID uuid; 160 readonly attribute boolean isPrimary; 161 Promise<BluetoothRemoteGATTCharacteristic> 162 getCharacteristic(BluetoothCharacteristicUUID characteristic); 163 Promise<sequence<BluetoothRemoteGATTCharacteristic>> 164 getCharacteristics(optional BluetoothCharacteristicUUID characteristic); 165 Promise<BluetoothRemoteGATTService> 166 getIncludedService(BluetoothServiceUUID service); 167 Promise<sequence<BluetoothRemoteGATTService>> 168 getIncludedServices(optional BluetoothServiceUUID service); 169 }; 170 BluetoothRemoteGATTService includes CharacteristicEventHandlers; 171 BluetoothRemoteGATTService includes ServiceEventHandlers; 172 173 [Exposed=Window, SecureContext] 174 interface BluetoothRemoteGATTCharacteristic : EventTarget { 175 [SameObject] 176 readonly attribute BluetoothRemoteGATTService service; 177 readonly attribute UUID uuid; 178 readonly attribute BluetoothCharacteristicProperties properties; 179 readonly attribute DataView? value; 180 Promise<BluetoothRemoteGATTDescriptor> getDescriptor(BluetoothDescriptorUUID descriptor); 181 Promise<sequence<BluetoothRemoteGATTDescriptor>> 182 getDescriptors(optional BluetoothDescriptorUUID descriptor); 183 Promise<DataView> readValue(); 184 Promise<undefined> writeValue(BufferSource value); 185 Promise<undefined> writeValueWithResponse(BufferSource value); 186 Promise<undefined> writeValueWithoutResponse(BufferSource value); 187 Promise<BluetoothRemoteGATTCharacteristic> startNotifications(); 188 Promise<BluetoothRemoteGATTCharacteristic> stopNotifications(); 189 }; 190 BluetoothRemoteGATTCharacteristic includes CharacteristicEventHandlers; 191 192 [Exposed=Window, SecureContext] 193 interface BluetoothCharacteristicProperties { 194 readonly attribute boolean broadcast; 195 readonly attribute boolean read; 196 readonly attribute boolean writeWithoutResponse; 197 readonly attribute boolean write; 198 readonly attribute boolean notify; 199 readonly attribute boolean indicate; 200 readonly attribute boolean authenticatedSignedWrites; 201 readonly attribute boolean reliableWrite; 202 readonly attribute boolean writableAuxiliaries; 203 }; 204 205 [Exposed=Window, SecureContext] 206 interface BluetoothRemoteGATTDescriptor { 207 [SameObject] 208 readonly attribute BluetoothRemoteGATTCharacteristic characteristic; 209 readonly attribute UUID uuid; 210 readonly attribute DataView? value; 211 Promise<DataView> readValue(); 212 Promise<undefined> writeValue(BufferSource value); 213 }; 214 215 [SecureContext] 216 interface mixin CharacteristicEventHandlers { 217 attribute EventHandler oncharacteristicvaluechanged; 218 }; 219 220 [SecureContext] 221 interface mixin BluetoothDeviceEventHandlers { 222 attribute EventHandler onadvertisementreceived; 223 attribute EventHandler ongattserverdisconnected; 224 }; 225 226 [SecureContext] 227 interface mixin ServiceEventHandlers { 228 attribute EventHandler onserviceadded; 229 attribute EventHandler onservicechanged; 230 attribute EventHandler onserviceremoved; 231 }; 232 233 typedef DOMString UUID; 234 235 [Exposed=Window] 236 interface BluetoothUUID { 237 static UUID getService((DOMString or unsigned long) name); 238 static UUID getCharacteristic((DOMString or unsigned long) name); 239 static UUID getDescriptor((DOMString or unsigned long) name); 240 241 static UUID canonicalUUID([EnforceRange] unsigned long alias); 242 }; 243 244 typedef (DOMString or unsigned long) BluetoothServiceUUID; 245 typedef (DOMString or unsigned long) BluetoothCharacteristicUUID; 246 typedef (DOMString or unsigned long) BluetoothDescriptorUUID; 247 248 [SecureContext] 249 partial interface Navigator { 250 [SameObject] 251 readonly attribute Bluetooth bluetooth; 252 };