react-native-flic2 2.0.0-alpha.39 → 2.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,81 +1,164 @@
1
- import type { CodegenTypes } from 'react-native';
2
- import type { MultiplyEvent, ManagerStateChangeEvent, ScanStatusChangeEvent, ButtonEvent, FlicButton, TriggerModeType, LatencyModeType } from './NativeFlic2';
3
- export declare function multiply(a: number, b: number): number;
4
- export declare const onMultiply: CodegenTypes.EventEmitter<MultiplyEvent>;
5
- export declare function initialize(background: boolean): Promise<{
6
- success: boolean;
7
- message: string;
8
- }>;
9
- export declare function getButtons(): Promise<FlicButton[]>;
10
- export declare function scanForButtons(): Promise<{
11
- success: boolean;
12
- message: string;
13
- }>;
14
- export declare function stopScan(): Promise<{
15
- success: boolean;
16
- message: string;
17
- }>;
18
- export declare function forgetButton(uuid: string): Promise<{
19
- success: boolean;
20
- message: string;
21
- }>;
22
- export declare function connectAllKnownButtons(): Promise<{
23
- success: boolean;
24
- message: string;
25
- }>;
26
- export declare function disconnectAllKnownButtons(): Promise<{
27
- success: boolean;
28
- message: string;
29
- }>;
30
- export declare function forgetAllButtons(): Promise<{
31
- success: boolean;
32
- message: string;
33
- }>;
34
- export declare function isScanning(): Promise<boolean>;
35
- export declare function connectButton(uuid: string): Promise<{
36
- success: boolean;
37
- message: string;
38
- }>;
39
- export declare function disconnectButton(uuid: string): Promise<{
40
- success: boolean;
41
- message: string;
42
- }>;
43
- /**
44
- * Sets the trigger mode for a button.
45
- *
46
- * @platform iOS
47
- * @param uuid - Button UUID
48
- * @param mode - Trigger mode (0-3)
49
- * @returns Promise that resolves on iOS, rejects with NOT_SUPPORTED_ON_ANDROID on Android
50
- *
51
- * **Note:** This feature is only available on iOS. On Android, this will reject due to
52
- * limitations in the Android Flic2 library v1.1.0+.
53
- */
54
- export declare function setTriggerMode(uuid: string, mode: TriggerModeType): Promise<{
55
- success: boolean;
56
- message: string;
57
- }>;
58
- /**
59
- * Sets the latency mode for a button.
60
- *
61
- * @platform iOS
62
- * @param uuid - Button UUID
63
- * @param mode - Latency mode (0-1)
64
- * @returns Promise that resolves on iOS, rejects with NOT_SUPPORTED_ON_ANDROID on Android
65
- *
66
- * **Note:** This feature is only available on iOS. On Android, this will reject due to
67
- * limitations in the Android Flic2 library v1.1.0+.
68
- */
69
- export declare function setLatencyMode(uuid: string, mode: LatencyModeType): Promise<{
70
- success: boolean;
71
- message: string;
72
- }>;
73
- export declare function setNickname(uuid: string, nickname: string): Promise<{
74
- success: boolean;
75
- message: string;
76
- }>;
77
- export declare const onManagerStateChange: CodegenTypes.EventEmitter<ManagerStateChangeEvent>;
78
- export declare const onScanStatusChange: CodegenTypes.EventEmitter<ScanStatusChangeEvent>;
79
- export declare const onButtonEvent: CodegenTypes.EventEmitter<ButtonEvent>;
80
- export type { MultiplyEvent, ManagerStateChangeEvent, ScanStatusChangeEvent, ButtonEvent, FlicButton, FlicManagerState, FlicButtonState, FlicTriggerMode, FlicLatencyMode, FlicScannerEvent, TriggerModeType, LatencyModeType, } from './NativeFlic2';
1
+ import { TypedEmitter } from './lib/typedEventEmitter';
2
+ import { type ButtonEvent, type FlicButton, type LatencyModeType, type ManagerStateChangeEvent, type ScanStatusChangeEvent, type TriggerModeType } from './NativeFlic2';
3
+ declare class Flic2 {
4
+ private isFlic2ManagerInitialized;
5
+ eventEmitter: TypedEmitter<{
6
+ buttonEvent: (event: ButtonEvent) => void;
7
+ managerStateChange: (event: ManagerStateChangeEvent) => void;
8
+ scanStatusChange: (event: ScanStatusChangeEvent) => void;
9
+ }>;
10
+ /**
11
+ * Constructor.
12
+ *
13
+ * @class
14
+ * @version 2.0.0
15
+ */
16
+ constructor();
17
+ /**
18
+ * Initialize the Flic2 manager.
19
+ *
20
+ * @returns A promise that resolves when the Flic2 manager is initialized.
21
+ */
22
+ initialize(): Promise<void>;
23
+ /**
24
+ * Scan for buttons.
25
+ *
26
+ * @returns A promise that resolves when the scan is started. Events will be emitted for the scan process.
27
+ */
28
+ startScan(): Promise<void>;
29
+ /**
30
+ * Stop the scan.
31
+ *
32
+ * @returns A promise that resolves when the scan is stopped.
33
+ */
34
+ stopScan(): Promise<void>;
35
+ /**
36
+ * Called when the Flic2 manager is initialized.
37
+ */
38
+ onInitialized(): void;
39
+ /**
40
+ * Check if the Flic2 manager is initialized.
41
+ *
42
+ * @returns True if the Flic2 manager is initialized, false otherwise.
43
+ */
44
+ isInitialized(): boolean;
45
+ /**
46
+ * Connect all known buttons.
47
+ *
48
+ * @returns A promise that resolves when the all known buttons are connected.
49
+ */
50
+ connectAllKnownButtons(): Promise<void>;
51
+ /**
52
+ * Disconnect all known buttons.
53
+ *
54
+ * @returns A promise that resolves when the all known buttons are disconnected.
55
+ */
56
+ disconnectAllKnownButtons(): Promise<void>;
57
+ /**
58
+ * Forget all buttons.
59
+ *
60
+ * @returns A promise that resolves when the all buttons are forgotten.
61
+ */
62
+ forgetAllButtons(): Promise<void>;
63
+ /**
64
+ * Check if a scan is currently running.
65
+ *
66
+ * @returns A promise that resolves to true if scanning, false otherwise.
67
+ */
68
+ isScanning(): Promise<boolean>;
69
+ /**
70
+ * Forget a specific button by UUID.
71
+ *
72
+ * @param uuid - The UUID of the button to forget.
73
+ * @returns A promise that resolves when the button is forgotten.
74
+ */
75
+ forgetButton(uuid: string): Promise<void>;
76
+ /**
77
+ * Connect a button.
78
+ *
79
+ * @param uuid - The UUID of the button to connect.
80
+ * @returns A promise that resolves with the button when the connection is initiated.
81
+ */
82
+ buttonConnect(uuid: string): Promise<FlicButton>;
83
+ /**
84
+ * Disconnect a button.
85
+ *
86
+ * @param uuid - The UUID of the button to disconnect.
87
+ * @returns A promise that resolves with the button when the disconnection is initiated.
88
+ */
89
+ buttonDisconnect(uuid: string): Promise<FlicButton>;
90
+ /**
91
+ * Set the trigger mode of a button.
92
+ *
93
+ * @param uuid - The UUID of the button to set the trigger mode of.
94
+ * @param mode - The trigger mode to set.
95
+ * @returns A promise that resolves with the button when the trigger mode is set.
96
+ */
97
+ buttonSetTriggerMode(uuid: string, mode: TriggerModeType): Promise<FlicButton>;
98
+ /**
99
+ * Set the latency mode of a button.
100
+ *
101
+ * @param uuid - The UUID of the button to set the latency mode of.
102
+ * @param mode - The latency mode to set.
103
+ * @returns A promise that resolves with the button when the latency mode is set.
104
+ */
105
+ buttonSetLatencyMode(uuid: string, mode: LatencyModeType): Promise<FlicButton>;
106
+ /**
107
+ * Set the nickname of a button.
108
+ *
109
+ * @param uuid - The UUID of the button to set the nickname of.
110
+ * @param nickname - The nickname to set.
111
+ * @returns A promise that resolves with the button when the nickname is set.
112
+ */
113
+ buttonSetNickname(uuid: string, nickname: string): Promise<FlicButton>;
114
+ /**
115
+ * Get all buttons.
116
+ *
117
+ * @returns A promise that resolves with an array of FlicButton instances.
118
+ */
119
+ getButtons(): Promise<FlicButton[]>;
120
+ /**
121
+ * Get a button by UUID.
122
+ *
123
+ * @param uuid - The UUID of the button to get.
124
+ * @returns A promise that resolves with the FlicButton instance or null if the button is not found.
125
+ */
126
+ getButton(uuid: string): Promise<FlicButton | null>;
127
+ /**
128
+ * Get the battery health status of a button.
129
+ *
130
+ * @param uuid - The UUID of the button to check.
131
+ * @returns A promise that resolves to true if battery is OK (voltage > 2.65V), false otherwise.
132
+ * @throws Error if the button is not found.
133
+ */
134
+ getBatteryHealth(uuid: string): Promise<boolean>;
135
+ /**
136
+ * Check if battery voltage is OK based on the 2.65V threshold.
137
+ *
138
+ * @param voltage - The battery voltage in volts.
139
+ * @returns True if voltage is above 2.65V (battery is OK), false otherwise.
140
+ */
141
+ private isBatteryVoltageOk;
142
+ /**
143
+ * Called when a button event is received from the native side.
144
+ *
145
+ * @param event - The button event.
146
+ */
147
+ private onNativeButtonEvent;
148
+ /**
149
+ * Called when a manager state change event is received from the native side.
150
+ *
151
+ * @param event - The manager state change event.
152
+ */
153
+ private onNativeManagerStateChange;
154
+ /**
155
+ * Called when a scan status change event is received from the native side.
156
+ *
157
+ * @param event - The scan status change event.
158
+ */
159
+ private onNativeScanStatusChange;
160
+ }
161
+ declare const _default: Flic2;
162
+ export default _default;
163
+ export type * from './NativeFlic2';
81
164
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EACvB,qBAAqB,EACrB,WAAW,EACX,UAAU,EACV,eAAe,EACf,eAAe,EAChB,MAAM,eAAe,CAAC;AAKvB,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,eAAO,MAAM,UAAU,EACK,YAAY,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;AAIrE,wBAAgB,UAAU,CACxB,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAEhD;AAED,wBAAgB,UAAU,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAElD;AAED,wBAAgB,cAAc,IAAI,OAAO,CAAC;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAED;AAED,wBAAgB,QAAQ,IAAI,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAEzE;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAEhD;AAED,wBAAgB,sBAAsB,IAAI,OAAO,CAAC;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CAC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args: any[]) => void>;
2
+ export declare class TypedEmitter<E extends EventMap> {
3
+ private listeners;
4
+ on<K extends keyof E>(event: K, fn: E[K]): {
5
+ remove: () => void;
6
+ };
7
+ off<K extends keyof E>(event: K, fn: E[K]): this;
8
+ once<K extends keyof E>(event: K, fn: E[K]): {
9
+ remove: () => void;
10
+ };
11
+ emit<K extends keyof E>(event: K, ...args: Parameters<E[K]>): boolean;
12
+ clear(): this;
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=typedEventEmitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedEventEmitter.d.ts","sourceRoot":"","sources":["../../../../src/lib/typedEventEmitter.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,CAAC;AAEzD,qBAAa,YAAY,CAAC,CAAC,SAAS,QAAQ;IAE1C,OAAO,CAAC,SAAS,CAAsC;IAEvD,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG;QAAE,MAAM,EAAE,MAAM,IAAI,CAAA;KAAE;IASjE,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAOhD,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG;QAAE,MAAM,EAAE,MAAM,IAAI,CAAA;KAAE;IAanE,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO;IAoBrE,KAAK,IAAI,IAAI;CAOd"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "react-native-flic2",
3
- "version": "2.0.0-alpha.39",
3
+ "version": "2.0.0-beta.10",
4
4
  "description": "React Native Flic plugin made with the Flic2 SDK (unofficial)",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
- "source": "./src/index.tsx",
9
+ "source": "./src/index.ts",
10
10
  "types": "./lib/typescript/src/index.d.ts",
11
11
  "default": "./lib/module/index.js"
12
12
  },
@@ -57,35 +57,35 @@
57
57
  "registry": "https://registry.npmjs.org/"
58
58
  },
59
59
  "devDependencies": {
60
- "@eslint/compat": "^1.3.2",
61
- "@eslint/eslintrc": "^3.3.1",
62
- "@eslint/js": "^9.35.0",
63
- "@evilmartians/lefthook": "^1.12.3",
60
+ "@eslint/compat": "1.3.2",
61
+ "@eslint/eslintrc": "3.3.1",
62
+ "@eslint/js": "9.35.0",
63
+ "@evilmartians/lefthook": "1.12.3",
64
64
  "@react-native-community/cli": "20.0.1",
65
65
  "@react-native/babel-preset": "0.81.1",
66
- "@react-native/eslint-config": "^0.81.1",
67
- "@release-it/conventional-changelog": "^10.0.1",
68
- "@types/react": "^19.1.0",
69
- "@typescript-eslint/eslint-plugin": "^8.46.2",
70
- "@typescript-eslint/parser": "^8.46.2",
71
- "del-cli": "^6.0.0",
72
- "eslint": "^8.57.1",
73
- "eslint-config-prettier": "^10.1.8",
74
- "eslint-plugin-ft-flow": "^3.0.11",
75
- "eslint-plugin-jest": "^29.0.1",
76
- "eslint-plugin-prettier": "^5.5.4",
77
- "eslint-plugin-react-native": "^5.0.0",
78
- "prettier": "^3.6.2",
66
+ "@react-native/eslint-config": "0.81.1",
67
+ "@release-it/conventional-changelog": "10.0.1",
68
+ "@types/react": "19.1.0",
69
+ "@typescript-eslint/eslint-plugin": "8.46.2",
70
+ "@typescript-eslint/parser": "8.46.2",
71
+ "del-cli": "6.0.0",
72
+ "eslint": "8.57.1",
73
+ "eslint-config-prettier": "10.1.8",
74
+ "eslint-plugin-ft-flow": "3.0.11",
75
+ "eslint-plugin-jest": "29.0.1",
76
+ "eslint-plugin-prettier": "5.5.4",
77
+ "eslint-plugin-react-native": "5.0.0",
78
+ "prettier": "3.6.2",
79
79
  "react": "19.1.0",
80
80
  "react-native": "0.81.1",
81
- "react-native-builder-bob": "^0.40.13",
82
- "release-it": "^19.0.4",
83
- "turbo": "^2.5.6",
84
- "typescript": "^5.9.2"
81
+ "react-native-builder-bob": "0.40.13",
82
+ "release-it": "19.0.4",
83
+ "turbo": "2.5.6",
84
+ "typescript": "5.9.2"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "react": "*",
88
- "react-native": "*"
88
+ "react-native": ">=0.81.0"
89
89
  },
90
90
  "release-it": {
91
91
  "git": {
@@ -136,7 +136,7 @@
136
136
  "type": "modules",
137
137
  "jsSrcsDir": "src",
138
138
  "android": {
139
- "javaPackageName": "com.flic2"
139
+ "javaPackageName": "nl.xguard.flic2"
140
140
  }
141
141
  },
142
142
  "create-react-native-library": {
@@ -6,12 +6,6 @@ import {
6
6
 
7
7
  // MARK: - Event Types
8
8
 
9
- export type MultiplyEvent = {
10
- a: number;
11
- b: number;
12
- result: number;
13
- };
14
-
15
9
  export type ManagerStateChangeEvent = {
16
10
  event: 'restored' | 'stateChanged';
17
11
  state?: number;
@@ -19,31 +13,62 @@ export type ManagerStateChangeEvent = {
19
13
  message?: string;
20
14
  };
21
15
 
16
+ export enum ScanResult {
17
+ SUCCESS = 0,
18
+ ALREADY_RUNNING = 1,
19
+ BLUETOOTH_NOT_ACTIVATED = 2,
20
+ UNKNOWN = 3,
21
+ NO_PUBLIC_BUTTON_DISCOVERED = 4,
22
+ ALREADY_CONNECTED_TO_ANOTHER_DEVICE = 5,
23
+ CONNECTION_TIMEOUT = 6,
24
+ INVALID_VERIFIER = 7,
25
+ BLE_PAIRING_FAILED_PREVIOUS_PAIRING_ALREADY_EXISTING = 8,
26
+ BLE_PAIRING_FAILED_USER_CANCELED = 9,
27
+ BLE_PAIRING_FAILED_UNKNOWN_REASON = 10,
28
+ APP_CREDENTIALS_DONT_MATCH = 11,
29
+ USER_CANCELED = 12,
30
+ INVALID_BLUETOOTH_ADDRESS = 13,
31
+ GENUINE_CHECK_FAILED = 14,
32
+ TOO_MANY_APPS = 15,
33
+ COULD_NOT_SET_BLUETOOTH_NOTIFY = 16,
34
+ COULD_NOT_DISCOVER_BLUETOOTH_SERVICES = 17,
35
+ BUTTON_DISCONNECTED_DURING_VERIFICATION = 18,
36
+ FAILED_TO_ESTABLISH = 19,
37
+ CONNECTION_LIMIT_REACHED = 20,
38
+ NOT_IN_PUBLIC_MODE = 21,
39
+ }
40
+
41
+ export type ScanStatus = 'started' | 'completion';
42
+
22
43
  export type ScanStatusChangeEvent = {
23
- event: number;
24
- eventName: string;
44
+ event: ScanStatus;
45
+ eventName: ScanStatus;
46
+ result?: ScanResult;
25
47
  };
26
48
 
49
+ export type ButtonEventName =
50
+ | 'discovered'
51
+ | 'connected'
52
+ | 'ready'
53
+ | 'disconnected'
54
+ | 'connectionFailed'
55
+ | 'buttonDown'
56
+ | 'buttonUp'
57
+ | 'click'
58
+ | 'doubleClick'
59
+ | 'hold'
60
+ | 'unpaired'
61
+ | 'batteryUpdate'
62
+ | 'nicknameUpdate';
63
+
27
64
  export type ButtonEvent = {
28
65
  uuid: string;
29
- event:
30
- | 'discovered'
31
- | 'connected'
32
- | 'ready'
33
- | 'disconnected'
34
- | 'connectionFailed'
35
- | 'buttonDown'
36
- | 'buttonUp'
37
- | 'click'
38
- | 'doubleClick'
39
- | 'hold'
40
- | 'unpaired'
41
- | 'batteryUpdate'
42
- | 'nicknameUpdate';
66
+ event: ButtonEventName;
43
67
  queued?: boolean;
44
68
  age?: number;
45
- voltage?: number;
46
69
  nickname?: string;
70
+ voltage?: number;
71
+ batteryVoltageOk?: boolean;
47
72
  error?: {
48
73
  code: number;
49
74
  message: string;
@@ -99,12 +124,6 @@ export type FlicTriggerMode =
99
124
 
100
125
  export type FlicLatencyMode = 'normal' | 'low';
101
126
 
102
- export type FlicScannerEvent =
103
- | 'discovered'
104
- | 'connected'
105
- | 'verified'
106
- | 'verificationFailed';
107
-
108
127
  // MARK: - Mode Types
109
128
 
110
129
  export type TriggerModeType = 0 | 1 | 2 | 3;
@@ -113,40 +132,36 @@ export type LatencyModeType = 0 | 1;
113
132
  // MARK: - Spec Interface
114
133
 
115
134
  export interface Spec extends TurboModule {
116
- // Keep multiply example
117
- multiply(a: number, b: number): number;
118
- readonly onMultiply: CodegenTypes.EventEmitter<MultiplyEvent>;
119
-
120
135
  // Manager methods
121
136
  initialize(
122
137
  background: boolean
123
- ): Promise<{ success: boolean; message: string }>;
138
+ ): Promise<void>;
124
139
  getButtons(): Promise<FlicButton[]>;
125
- scanForButtons(): Promise<{ success: boolean; message: string }>;
126
- stopScan(): Promise<{ success: boolean; message: string }>;
127
- forgetButton(uuid: string): Promise<{ success: boolean; message: string }>;
128
- connectAllKnownButtons(): Promise<{ success: boolean; message: string }>;
129
- disconnectAllKnownButtons(): Promise<{ success: boolean; message: string }>;
130
- forgetAllButtons(): Promise<{ success: boolean; message: string }>;
140
+ scanForButtons(): Promise<void>;
141
+ stopScan(): Promise<void>;
142
+ forgetButton(uuid: string): Promise<void>;
143
+ connectAllKnownButtons(): Promise<void>;
144
+ disconnectAllKnownButtons(): Promise<void>;
145
+ forgetAllButtons(): Promise<void>;
131
146
  isScanning(): Promise<boolean>;
132
147
 
133
148
  // Button methods
134
- connectButton(uuid: string): Promise<{ success: boolean; message: string }>;
149
+ connectButton(uuid: string): Promise<FlicButton>;
135
150
  disconnectButton(
136
151
  uuid: string
137
- ): Promise<{ success: boolean; message: string }>;
152
+ ): Promise<FlicButton>;
138
153
  setTriggerMode(
139
154
  uuid: string,
140
- mode: TriggerModeType
141
- ): Promise<{ success: boolean; message: string }>;
155
+ mode: number
156
+ ): Promise<FlicButton>;
142
157
  setLatencyMode(
143
158
  uuid: string,
144
- mode: LatencyModeType
145
- ): Promise<{ success: boolean; message: string }>;
159
+ mode: number
160
+ ): Promise<FlicButton>;
146
161
  setNickname(
147
162
  uuid: string,
148
163
  nickname: string
149
- ): Promise<{ success: boolean; message: string }>;
164
+ ): Promise<FlicButton>;
150
165
 
151
166
  // Event emitters
152
167
  readonly onManagerStateChange: CodegenTypes.EventEmitter<ManagerStateChangeEvent>;