UNPKG

@openhps/sphero

Version:

Open Hybrid Positioning System - Sphero component

108 lines (107 loc) 3.88 kB
/// <reference types="web-bluetooth" /> import { DriveFlag, ICommandWithRaw } from '../commands/types'; import { Stance, APIVersion } from './types'; export interface IReExport { a: Stance; b: DriveFlag; } export declare const commandsType: { api: { echo: () => ICommandWithRaw; }; driving: { drive: (speed: number, heading: number, flags: DriveFlag[]) => ICommandWithRaw; driveAsRc: (heading: number, speed: number) => ICommandWithRaw; }; power: { batteryVoltage: () => ICommandWithRaw; sleep: () => ICommandWithRaw; something2: () => ICommandWithRaw; something3: () => ICommandWithRaw; something4: () => ICommandWithRaw; wake: () => ICommandWithRaw; }; somethingApi: { something5: () => ICommandWithRaw; }; systemInfo: { appVersion: () => ICommandWithRaw; something: () => ICommandWithRaw; something6: () => ICommandWithRaw; something7: () => ICommandWithRaw; }; userIo: { allLEDsRaw: (payload: number[]) => ICommandWithRaw; setBackLedIntensity: (i: number) => ICommandWithRaw; setMainLedBlueIntensity: (b: number) => ICommandWithRaw; setMainLedColor: (r: number, g: number, b: number) => ICommandWithRaw; setMainLedGreenIntensity: (g: number) => ICommandWithRaw; setMainLedRedIntensity: (r: number) => ICommandWithRaw; playAudioFile: (idx: number) => ICommandWithRaw; turnDome: (angle: Uint8Array) => ICommandWithRaw; setStance: (stance: Stance) => ICommandWithRaw; playAnimation: (animation: number) => ICommandWithRaw; }; sensor: { enableCollisionAsync: () => ICommandWithRaw; configureCollision: (xThreshold: number, yThreshold: number, xSpeed: number, ySpeed: number, deadTime: number, method?: number) => ICommandWithRaw; sensorMask: (sensorRawValue: number, streamingRate: number) => ICommandWithRaw; sensorMaskExtended: (mask: number) => ICommandWithRaw; }; }; export declare const decodeType: { add(byte: number): number | void; }; export interface IQueuePayload { command: ICommandWithRaw; characteristic?: BluetoothRemoteGATTCharacteristic; } export declare enum Event { onCollision = "onCollision", onSensor = "onSensor" } export declare class Core { protected maxVoltage: number; protected minVoltage: number; protected apiVersion: APIVersion; protected commands: typeof commandsType; private peripheral; private server; private apiV2Characteristic?; private dfuControlCharacteristic?; private subsCharacteristic?; private antiDoSCharacteristic?; private decoder; private started; private queue; private eventsListeners; private sensorMask; constructor(p: BluetoothDevice); batteryVoltage(): Promise<number>; batteryLevel(): Promise<number>; wake(): Promise<IQueuePayload>; sleep(): Promise<IQueuePayload>; start(): Promise<void>; appVersion(): Promise<{ major: number; minor: number; }>; on(eventName: Event, handler: (command: ICommandWithRaw) => void): void; destroy(): void; configureSensorStream(interval?: number): Promise<void>; enableCollisionDetection(): Promise<IQueuePayload>; configureCollisionDetection(xThreshold?: number, yThreshold?: number, xSpeed?: number, ySpeed?: number, deadTime?: number, method?: number): Promise<IQueuePayload>; protected queueCommand(command: ICommandWithRaw): Promise<IQueuePayload>; private init; private onExecute; private match; private bindServices; private bindListeners; private onPacketRead; private eventHandler; private handleCollision; private handleSensorUpdate; private onApiRead; private onDFUControlNotify; private write; }