kaios-types
    Preparing search index...

    Interface BluetoothGattServer

    bluetooth

    interface BluetoothGattServer {
        onattributereadreq: EventHandler;
        onattributewritereq: EventHandler;
        onconnectionstatechanged: EventHandler;
        services: BluetoothGattService[];
        addEventListener(
            type: string,
            callback: EventListenerOrEventListenerObject | null,
            options?: boolean | AddEventListenerOptions,
        ): void;
        addService(service: BluetoothGattService): Promise<void>;
        connect(address: string): Promise<void>;
        disconnect(address: string): Promise<void>;
        dispatchEvent(event: Event): boolean;
        notifyCharacteristicChanged(
            address: string,
            characteristic: BluetoothGattCharacteristic,
            confirm: boolean,
        ): Promise<void>;
        removeEventListener(
            type: string,
            callback: EventListenerOrEventListenerObject | null,
            options?: boolean | EventListenerOptions,
        ): void;
        removeService(service: BluetoothGattService): Promise<void>;
        sendResponse(
            address: string,
            status: number,
            requestId: number,
        ): Promise<void>;
        startAdvertising(advData?: BluetoothAdvertisingData): Promise<void>;
        stopAdvertising(): Promise<void>;
    }

    Hierarchy

    • EventTarget
      • BluetoothGattServer
    Index

    Properties

    onattributereadreq: EventHandler

    Fired when a read request for an attribute is received.

    onattributewritereq: EventHandler

    Fired when a write request for an attribute is received.

    onconnectionstatechanged: EventHandler

    Fired when the connection state changes.

    Methods

    • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | AddEventListenerOptions

      Returns void

    • Connects to a remote device.

      Parameters

      • address: string

        The address of the remote device.

      Returns Promise<void>

    • Disconnects from a remote device.

      Parameters

      • address: string

        The address of the remote device.

      Returns Promise<void>

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.

      MDN Reference

      Parameters

      • event: Event

      Returns boolean

    • Notifies a client that a characteristic value has changed.

      Parameters

      • address: string

        The address of the client.

      • characteristic: BluetoothGattCharacteristic

        The characteristic that changed.

      • confirm: boolean

        Whether the client should confirm the notification (indication).

      Returns Promise<void>

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | EventListenerOptions

      Returns void

    • Sends a response to a read or write request.

      Parameters

      • address: string

        The address of the client.

      • status: number

        The status of the operation.

      • requestId: number

        The request ID.

      Returns Promise<void>