BluetoothUUID: phương thức tĩnh getService()

Khả dụng hạn chế

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Phương thức tĩnh getService() của giao diện BluetoothUUID trả về một UUID đại diện cho một service đã đăng ký khi truyền vào tên hoặc bí danh UUID 16 bit hay 32 bit.

Cú pháp

js
BluetoothUUID.getService(name)

Tham số

name

Một chuỗi chứa tên của service.

Giá trị trả về

Một UUID 128 bit.

Ngoại lệ

TypeError

Được ném ra nếu name không xuất hiện trong registry.

Ví dụ

Trong ví dụ sau, UUID đại diện cho service có tên device_information được trả về và in ra console.

js
let result = BluetoothUUID.getService("device_information");
console.log(result); // "0000180a-0000-1000-8000-00805f9b34fb"

Thông số kỹ thuật

Thông số kỹ thuật
Web Bluetooth
# dom-bluetoothuuid-getservice

Tương thích trình duyệt