/** * (c) 2023, Center for Computational Thinking and Design at Aarhus University and contributors * * SPDX-License-Identifier: MIT */ import { BackgroundErrorData, ConnectionStatusChange, DeviceConnection } from "../device.js"; import { Logging } from "../logging.js"; import { AccelerometerData, ButtonData } from "../service-events.js"; import { MicrobitUSBConnection } from "../usb/connection.js"; export interface MicrobitRadioBridgeConnectionOptions { logging?: Logging; } /** * A connection to a remote micro:bit via a USB-connected micro:bit running * radio bridge firmware. Sensor data is relayed over a serial protocol. * * @experimental This connection type has limited service support compared to * direct Bluetooth connections: * * - `accelerometerdatachanged`, `buttonachanged`, `buttonbchanged` events * are supported. * - `flash` is not supported. */ export interface MicrobitRadioBridgeConnection extends DeviceConnection { readonly type: "radio-bridge"; addEventListener(type: "status", listener: (data: ConnectionStatusChange) => void): void; addEventListener(type: "backgrounderror", listener: (data: BackgroundErrorData) => void): void; addEventListener(type: "beforerequestdevice", listener: () => void): void; addEventListener(type: "afterrequestdevice", listener: () => void): void; addEventListener(type: "flash", listener: () => void): void; addEventListener(type: "accelerometerdatachanged", listener: (data: AccelerometerData) => void): void; addEventListener(type: "buttonachanged" | "buttonbchanged", listener: (data: ButtonData) => void): void; removeEventListener(type: "status", listener: (data: ConnectionStatusChange) => void): void; removeEventListener(type: "backgrounderror", listener: (data: BackgroundErrorData) => void): void; removeEventListener(type: "beforerequestdevice", listener: () => void): void; removeEventListener(type: "afterrequestdevice", listener: () => void): void; removeEventListener(type: "flash", listener: () => void): void; removeEventListener(type: "accelerometerdatachanged", listener: (data: AccelerometerData) => void): void; removeEventListener(type: "buttonachanged" | "buttonbchanged", listener: (data: ButtonData) => void): void; /** * Sets remote device. * * @param deviceId The device id of remote micro:bit. */ setRemoteDeviceId(deviceId: number): void; } /** * A radio bridge connection factory. * * @experimental See {@link MicrobitRadioBridgeConnection} for limitations. */ export declare const createRadioBridgeConnection: (delegate: MicrobitUSBConnection, options?: MicrobitRadioBridgeConnectionOptions) => MicrobitRadioBridgeConnection;