Skip to content

Commit

Permalink
fix: Update soundcore-lib and tauri-backend types
Browse files Browse the repository at this point in the history
  • Loading branch information
gmallios committed Mar 3, 2024
1 parent a87267f commit b33f6d2
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 39 deletions.
86 changes: 59 additions & 27 deletions src/types/soundcore-lib.d.ts
Original file line number Diff line number Diff line change
@@ -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<SoundcoreFeatureFlags>;
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;
Expand All @@ -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",
}

41 changes: 29 additions & 12 deletions src/types/tauri-backend.d.ts
Original file line number Diff line number Diff line change
@@ -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 }
Expand All @@ -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",
Expand All @@ -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 };

0 comments on commit b33f6d2

Please sign in to comment.