diff --git a/src/types/soundcore-lib.d.ts b/src/types/soundcore-lib.d.ts index 8371f47..b82ace8 100644 --- a/src/types/soundcore-lib.d.ts +++ b/src/types/soundcore-lib.d.ts @@ -1,13 +1,71 @@ /* - Generated by typeshare 1.0.0 + Generated by typeshare 1.7.0 */ +/** This is a generalized version of the state for all devices */ +export interface SoundcoreDeviceState { + featureFlags: BitFlags; + battery: Battery; + soundMode: SoundMode; + serial?: SerialNumber; + fw?: FirmwareVer; + drcFw?: FirmwareVer; + hostDevice?: number; + twsStatus?: TwsStatus; + buttonModel?: ButtonModel; + sideTone?: SideTone; + hearidEqPreset?: number; + wearDetection?: WearDetection; + hearId?: HearID; + ageRange?: AgeRange; +} + +export interface BluetoothAdrr { + address: [number, number, number, number, number, number]; +} + +export enum SupportedModels { + A3027 = "A3027", + A3028 = "A3028", + A3029 = "A3029", + A3040 = "A3040", + A3930 = "A3930", + A3931 = "A3931", + A3935 = "A3935", + A3951 = "A3951", +} + +/** A discovered BLE device. The DiscoveredDevice can be upgraded to a SoundcoreBLEDevice. */ +export interface DiscoveredDevice { + /** The BLE device descriptor. */ + descriptor: BLEDeviceDescriptor; + /** The model of the device, resolved using the device's advertised name. */ + model?: SupportedModels; +} + export interface DeviceInfo { left_fw: string; right_fw: string; sn: string; } +export interface BatteryLevel { + left: number; + right: number; +} + +export interface BatteryCharging { + left: boolean; + right: boolean; +} + +export interface ANCProfile { + option: number; + anc_option: number; + transparency_option: number; + anc_custom: number; +} + export interface DeviceStatus { host_device: number; tws_status: boolean; @@ -26,29 +84,3 @@ export interface DeviceStatus { right_hearid_customdata: EQWave; } -export interface BatteryCharging { - left: boolean; - right: boolean; -} - -export interface BatteryLevel { - left: number; - right: number; -} - -export interface ANCProfile { - option: number; - anc_option: number; - transparency_option: number; - anc_custom: number; -} - -export enum SupportedModels { - A3027 = "A3027", - A3028 = "A3028", - A3029 = "A3029", - A3040 = "A3040", - A3935 = "A3935", - A3951 = "A3951", -} - diff --git a/src/types/tauri-backend.d.ts b/src/types/tauri-backend.d.ts index 66c4708..357f2d1 100644 --- a/src/types/tauri-backend.d.ts +++ b/src/types/tauri-backend.d.ts @@ -1,24 +1,18 @@ /* - Generated by typeshare 1.0.0 + Generated by typeshare 1.7.0 */ +export interface NewStateResponse { + addr: BluetoothAdrr; + state: SoundcoreDeviceState; +} + export interface BthScanResult { name: string; address: string; is_connected: boolean; } -export interface NewTrayDeviceStatus { - is_connected: boolean; - charging: BatteryCharging; - level: BatteryLevel; - anc_mode: ANCModes; -} - -export interface DeviceFeatures { - profiles: SupportedANCProfiles[]; -} - export type ANCModes = | { mode: "NormalMode", value?: undefined } | { mode: "AncTransportMode", value?: undefined } @@ -28,6 +22,13 @@ export type ANCModes = | { mode: "TransparencyFullyTransparentMode", value?: undefined } | { mode: "TransparencyVocalMode", value?: undefined }; +export interface NewTrayDeviceStatus { + is_connected: boolean; + charging: BatteryCharging; + level: BatteryLevel; + anc_mode: ANCModes; +} + export enum SupportedANCProfiles { Normal = "Normal", AncTransportMode = "AncTransportMode", @@ -38,3 +39,19 @@ export enum SupportedANCProfiles { TransparencyVocalMode = "TransparencyVocalMode", } +export interface DeviceFeatures { + profiles: SupportedANCProfiles[]; +} + +export type BridgeCommand = + | { command: "scan", payload?: undefined } + | { command: "connect", payload: DiscoveredDevice } + | { command: "disconnect", payload: BluetoothAdrr }; + +export type BridgeResponse = + | { kind: "scanResult", payload: DiscoveredDevice[] } + | { kind: "connectionEstablished", payload: BluetoothAdrr } + | { kind: "newState", payload: NewStateResponse } + | { kind: "disconnected", payload: BluetoothAdrr } + | { kind: "error", payload: string }; +