@neurosity/sdk 6.0.0-next.11
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.
- package/LICENSE +21 -0
- package/README.md +46 -0
- package/dist/browser/neurosity.iife.js +48736 -0
- package/dist/browser/neurosity.js +672 -0
- package/dist/browser/neurosity.js.map +1 -0
- package/dist/cjs/Notion.d.ts +619 -0
- package/dist/cjs/Notion.js +1291 -0
- package/dist/cjs/api/bluetooth/BluetoothClient.d.ts +59 -0
- package/dist/cjs/api/bluetooth/BluetoothClient.js +287 -0
- package/dist/cjs/api/bluetooth/BluetoothTransport.d.ts +32 -0
- package/dist/cjs/api/bluetooth/BluetoothTransport.js +2 -0
- package/dist/cjs/api/bluetooth/constants.d.ts +4 -0
- package/dist/cjs/api/bluetooth/constants.js +9 -0
- package/dist/cjs/api/bluetooth/index.d.ts +4 -0
- package/dist/cjs/api/bluetooth/index.js +20 -0
- package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.d.ts +65 -0
- package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.js +386 -0
- package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.d.ts +63 -0
- package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.js +11 -0
- package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +180 -0
- package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.js +10 -0
- package/dist/cjs/api/bluetooth/types/index.d.ts +31 -0
- package/dist/cjs/api/bluetooth/types/index.js +22 -0
- package/dist/cjs/api/bluetooth/utils/create6DigitPin.d.ts +1 -0
- package/dist/cjs/api/bluetooth/utils/create6DigitPin.js +8 -0
- package/dist/cjs/api/bluetooth/utils/csvBufferToEpoch.d.ts +11 -0
- package/dist/cjs/api/bluetooth/utils/csvBufferToEpoch.js +36 -0
- package/dist/cjs/api/bluetooth/utils/encoding.d.ts +3 -0
- package/dist/cjs/api/bluetooth/utils/encoding.js +22 -0
- package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.d.ts +2 -0
- package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.js +23 -0
- package/dist/cjs/api/bluetooth/utils/stitch.d.ts +5 -0
- package/dist/cjs/api/bluetooth/utils/stitch.js +22 -0
- package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.d.ts +47 -0
- package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.js +412 -0
- package/dist/cjs/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +1 -0
- package/dist/cjs/api/bluetooth/web/isMaybeWebWorkerContext.js +8 -0
- package/dist/cjs/api/bluetooth/web/isWebBluetoothSupported.d.ts +1 -0
- package/dist/cjs/api/bluetooth/web/isWebBluetoothSupported.js +11 -0
- package/dist/cjs/api/firebase/FirebaseApp.d.ts +20 -0
- package/dist/cjs/api/firebase/FirebaseApp.js +70 -0
- package/dist/cjs/api/firebase/FirebaseDevice.d.ts +68 -0
- package/dist/cjs/api/firebase/FirebaseDevice.js +146 -0
- package/dist/cjs/api/firebase/FirebaseUser.d.ts +53 -0
- package/dist/cjs/api/firebase/FirebaseUser.js +434 -0
- package/dist/cjs/api/firebase/config.d.ts +8 -0
- package/dist/cjs/api/firebase/config.js +11 -0
- package/dist/cjs/api/firebase/deviceStore.d.ts +26 -0
- package/dist/cjs/api/firebase/deviceStore.js +191 -0
- package/dist/cjs/api/firebase/index.d.ts +3 -0
- package/dist/cjs/api/firebase/index.js +19 -0
- package/dist/cjs/api/https/config.d.ts +1 -0
- package/dist/cjs/api/https/config.js +4 -0
- package/dist/cjs/api/https/createOAuthURL.d.ts +3 -0
- package/dist/cjs/api/https/createOAuthURL.js +18 -0
- package/dist/cjs/api/https/getOAuthToken.d.ts +3 -0
- package/dist/cjs/api/https/getOAuthToken.js +34 -0
- package/dist/cjs/api/https/utils.d.ts +2 -0
- package/dist/cjs/api/https/utils.js +13 -0
- package/dist/cjs/api/index.d.ts +108 -0
- package/dist/cjs/api/index.js +306 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/skills/NotionOnDevice.d.ts +7 -0
- package/dist/cjs/skills/NotionOnDevice.js +25 -0
- package/dist/cjs/skills/createSkill.d.ts +7 -0
- package/dist/cjs/skills/createSkill.js +40 -0
- package/dist/cjs/skills/index.d.ts +2 -0
- package/dist/cjs/skills/index.js +18 -0
- package/dist/cjs/subscriptions/SubscriptionManager.d.ts +11 -0
- package/dist/cjs/subscriptions/SubscriptionManager.js +27 -0
- package/dist/cjs/timesync/Timesync.d.ts +20 -0
- package/dist/cjs/timesync/Timesync.js +78 -0
- package/dist/cjs/timesync/index.d.ts +1 -0
- package/dist/cjs/timesync/index.js +17 -0
- package/dist/cjs/types/accelerometer.d.ts +10 -0
- package/dist/cjs/types/accelerometer.js +2 -0
- package/dist/cjs/types/actions.d.ts +16 -0
- package/dist/cjs/types/actions.js +2 -0
- package/dist/cjs/types/awareness.d.ts +1 -0
- package/dist/cjs/types/awareness.js +2 -0
- package/dist/cjs/types/brainwaves.d.ts +26 -0
- package/dist/cjs/types/brainwaves.js +2 -0
- package/dist/cjs/types/calm.d.ts +6 -0
- package/dist/cjs/types/calm.js +2 -0
- package/dist/cjs/types/client.d.ts +22 -0
- package/dist/cjs/types/client.js +2 -0
- package/dist/cjs/types/credentials.d.ts +12 -0
- package/dist/cjs/types/credentials.js +2 -0
- package/dist/cjs/types/deviceInfo.d.ts +18 -0
- package/dist/cjs/types/deviceInfo.js +2 -0
- package/dist/cjs/types/epoch.d.ts +12 -0
- package/dist/cjs/types/epoch.js +2 -0
- package/dist/cjs/types/experiment.d.ts +9 -0
- package/dist/cjs/types/experiment.js +2 -0
- package/dist/cjs/types/focus.d.ts +6 -0
- package/dist/cjs/types/focus.js +2 -0
- package/dist/cjs/types/hapticEffects.d.ts +125 -0
- package/dist/cjs/types/hapticEffects.js +2 -0
- package/dist/cjs/types/kinesis.d.ts +6 -0
- package/dist/cjs/types/kinesis.js +2 -0
- package/dist/cjs/types/marker.d.ts +7 -0
- package/dist/cjs/types/marker.js +2 -0
- package/dist/cjs/types/metrics.d.ts +21 -0
- package/dist/cjs/types/metrics.js +2 -0
- package/dist/cjs/types/oauth.d.ts +20 -0
- package/dist/cjs/types/oauth.js +2 -0
- package/dist/cjs/types/options.d.ts +51 -0
- package/dist/cjs/types/options.js +2 -0
- package/dist/cjs/types/sample.d.ts +15 -0
- package/dist/cjs/types/sample.js +2 -0
- package/dist/cjs/types/settings.d.ts +13 -0
- package/dist/cjs/types/settings.js +2 -0
- package/dist/cjs/types/signalQuality.d.ts +13 -0
- package/dist/cjs/types/signalQuality.js +2 -0
- package/dist/cjs/types/skill.d.ts +68 -0
- package/dist/cjs/types/skill.js +2 -0
- package/dist/cjs/types/status.d.ts +26 -0
- package/dist/cjs/types/status.js +22 -0
- package/dist/cjs/types/streaming.d.ts +15 -0
- package/dist/cjs/types/streaming.js +20 -0
- package/dist/cjs/types/subscriptions.d.ts +23 -0
- package/dist/cjs/types/subscriptions.js +2 -0
- package/dist/cjs/types/training.d.ts +19 -0
- package/dist/cjs/types/training.js +2 -0
- package/dist/cjs/types/user.d.ts +12 -0
- package/dist/cjs/types/user.js +2 -0
- package/dist/cjs/utils/errors.d.ts +5 -0
- package/dist/cjs/utils/errors.js +17 -0
- package/dist/cjs/utils/filterInternalKeys.d.ts +3 -0
- package/dist/cjs/utils/filterInternalKeys.js +21 -0
- package/dist/cjs/utils/hapticEffects.d.ts +123 -0
- package/dist/cjs/utils/hapticEffects.js +130 -0
- package/dist/cjs/utils/heartbeat.d.ts +4 -0
- package/dist/cjs/utils/heartbeat.js +34 -0
- package/dist/cjs/utils/is-node.d.ts +1 -0
- package/dist/cjs/utils/is-node.js +9 -0
- package/dist/cjs/utils/metrics.d.ts +1 -0
- package/dist/cjs/utils/metrics.js +56 -0
- package/dist/cjs/utils/oauth.d.ts +9 -0
- package/dist/cjs/utils/oauth.js +92 -0
- package/dist/cjs/utils/pick.d.ts +1 -0
- package/dist/cjs/utils/pick.js +5 -0
- package/dist/cjs/utils/pipes.d.ts +46 -0
- package/dist/cjs/utils/pipes.js +71 -0
- package/dist/cjs/utils/platform.d.ts +30 -0
- package/dist/cjs/utils/platform.js +47 -0
- package/dist/cjs/utils/subscription.d.ts +6 -0
- package/dist/cjs/utils/subscription.js +55 -0
- package/dist/cjs/utils/transferDevice.d.ts +9 -0
- package/dist/cjs/utils/transferDevice.js +2 -0
- package/dist/cjs/utils/whileOnline.d.ts +8 -0
- package/dist/cjs/utils/whileOnline.js +15 -0
- package/dist/electron/index.js +92 -0
- package/dist/electron/index.js.map +1 -0
- package/dist/esm/Notion.d.ts +619 -0
- package/dist/esm/Notion.js +1260 -0
- package/dist/esm/api/bluetooth/BluetoothClient.d.ts +59 -0
- package/dist/esm/api/bluetooth/BluetoothClient.js +283 -0
- package/dist/esm/api/bluetooth/BluetoothTransport.d.ts +32 -0
- package/dist/esm/api/bluetooth/BluetoothTransport.js +1 -0
- package/dist/esm/api/bluetooth/constants.d.ts +4 -0
- package/dist/esm/api/bluetooth/constants.js +6 -0
- package/dist/esm/api/bluetooth/index.d.ts +4 -0
- package/dist/esm/api/bluetooth/index.js +4 -0
- package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.d.ts +65 -0
- package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.js +382 -0
- package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.d.ts +63 -0
- package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.js +8 -0
- package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +180 -0
- package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.js +9 -0
- package/dist/esm/api/bluetooth/types/index.d.ts +31 -0
- package/dist/esm/api/bluetooth/types/index.js +19 -0
- package/dist/esm/api/bluetooth/utils/create6DigitPin.d.ts +1 -0
- package/dist/esm/api/bluetooth/utils/create6DigitPin.js +4 -0
- package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.d.ts +11 -0
- package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.js +31 -0
- package/dist/esm/api/bluetooth/utils/encoding.d.ts +3 -0
- package/dist/esm/api/bluetooth/utils/encoding.js +17 -0
- package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.d.ts +2 -0
- package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.js +16 -0
- package/dist/esm/api/bluetooth/utils/stitch.d.ts +5 -0
- package/dist/esm/api/bluetooth/utils/stitch.js +18 -0
- package/dist/esm/api/bluetooth/web/WebBluetoothTransport.d.ts +47 -0
- package/dist/esm/api/bluetooth/web/WebBluetoothTransport.js +408 -0
- package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +1 -0
- package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.js +4 -0
- package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.d.ts +1 -0
- package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.js +7 -0
- package/dist/esm/api/firebase/FirebaseApp.d.ts +20 -0
- package/dist/esm/api/firebase/FirebaseApp.js +63 -0
- package/dist/esm/api/firebase/FirebaseDevice.d.ts +68 -0
- package/dist/esm/api/firebase/FirebaseDevice.js +139 -0
- package/dist/esm/api/firebase/FirebaseUser.d.ts +53 -0
- package/dist/esm/api/firebase/FirebaseUser.js +426 -0
- package/dist/esm/api/firebase/config.d.ts +8 -0
- package/dist/esm/api/firebase/config.js +8 -0
- package/dist/esm/api/firebase/deviceStore.d.ts +26 -0
- package/dist/esm/api/firebase/deviceStore.js +184 -0
- package/dist/esm/api/firebase/index.d.ts +3 -0
- package/dist/esm/api/firebase/index.js +3 -0
- package/dist/esm/api/https/config.d.ts +1 -0
- package/dist/esm/api/https/config.js +1 -0
- package/dist/esm/api/https/createOAuthURL.d.ts +3 -0
- package/dist/esm/api/https/createOAuthURL.js +11 -0
- package/dist/esm/api/https/getOAuthToken.d.ts +3 -0
- package/dist/esm/api/https/getOAuthToken.js +27 -0
- package/dist/esm/api/https/utils.d.ts +2 -0
- package/dist/esm/api/https/utils.js +9 -0
- package/dist/esm/api/index.d.ts +108 -0
- package/dist/esm/api/index.js +299 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/neurosity.mjs +48722 -0
- package/dist/esm/skills/NotionOnDevice.d.ts +7 -0
- package/dist/esm/skills/NotionOnDevice.js +21 -0
- package/dist/esm/skills/createSkill.d.ts +7 -0
- package/dist/esm/skills/createSkill.js +36 -0
- package/dist/esm/skills/index.d.ts +2 -0
- package/dist/esm/skills/index.js +2 -0
- package/dist/esm/subscriptions/SubscriptionManager.d.ts +11 -0
- package/dist/esm/subscriptions/SubscriptionManager.js +23 -0
- package/dist/esm/timesync/Timesync.d.ts +20 -0
- package/dist/esm/timesync/Timesync.js +71 -0
- package/dist/esm/timesync/index.d.ts +1 -0
- package/dist/esm/timesync/index.js +1 -0
- package/dist/esm/types/accelerometer.d.ts +10 -0
- package/dist/esm/types/accelerometer.js +1 -0
- package/dist/esm/types/actions.d.ts +16 -0
- package/dist/esm/types/actions.js +1 -0
- package/dist/esm/types/awareness.d.ts +1 -0
- package/dist/esm/types/awareness.js +1 -0
- package/dist/esm/types/brainwaves.d.ts +26 -0
- package/dist/esm/types/brainwaves.js +1 -0
- package/dist/esm/types/calm.d.ts +6 -0
- package/dist/esm/types/calm.js +1 -0
- package/dist/esm/types/client.d.ts +22 -0
- package/dist/esm/types/client.js +1 -0
- package/dist/esm/types/credentials.d.ts +12 -0
- package/dist/esm/types/credentials.js +1 -0
- package/dist/esm/types/deviceInfo.d.ts +18 -0
- package/dist/esm/types/deviceInfo.js +1 -0
- package/dist/esm/types/epoch.d.ts +12 -0
- package/dist/esm/types/epoch.js +1 -0
- package/dist/esm/types/experiment.d.ts +9 -0
- package/dist/esm/types/experiment.js +1 -0
- package/dist/esm/types/focus.d.ts +6 -0
- package/dist/esm/types/focus.js +1 -0
- package/dist/esm/types/hapticEffects.d.ts +125 -0
- package/dist/esm/types/hapticEffects.js +1 -0
- package/dist/esm/types/kinesis.d.ts +6 -0
- package/dist/esm/types/kinesis.js +1 -0
- package/dist/esm/types/marker.d.ts +7 -0
- package/dist/esm/types/marker.js +1 -0
- package/dist/esm/types/metrics.d.ts +21 -0
- package/dist/esm/types/metrics.js +1 -0
- package/dist/esm/types/oauth.d.ts +20 -0
- package/dist/esm/types/oauth.js +1 -0
- package/dist/esm/types/options.d.ts +51 -0
- package/dist/esm/types/options.js +1 -0
- package/dist/esm/types/sample.d.ts +15 -0
- package/dist/esm/types/sample.js +1 -0
- package/dist/esm/types/settings.d.ts +13 -0
- package/dist/esm/types/settings.js +1 -0
- package/dist/esm/types/signalQuality.d.ts +13 -0
- package/dist/esm/types/signalQuality.js +1 -0
- package/dist/esm/types/skill.d.ts +68 -0
- package/dist/esm/types/skill.js +1 -0
- package/dist/esm/types/status.d.ts +26 -0
- package/dist/esm/types/status.js +19 -0
- package/dist/esm/types/streaming.d.ts +15 -0
- package/dist/esm/types/streaming.js +17 -0
- package/dist/esm/types/subscriptions.d.ts +23 -0
- package/dist/esm/types/subscriptions.js +1 -0
- package/dist/esm/types/training.d.ts +19 -0
- package/dist/esm/types/training.js +1 -0
- package/dist/esm/types/user.d.ts +12 -0
- package/dist/esm/types/user.js +1 -0
- package/dist/esm/utils/errors.d.ts +5 -0
- package/dist/esm/utils/errors.js +11 -0
- package/dist/esm/utils/filterInternalKeys.d.ts +3 -0
- package/dist/esm/utils/filterInternalKeys.js +17 -0
- package/dist/esm/utils/hapticEffects.d.ts +123 -0
- package/dist/esm/utils/hapticEffects.js +125 -0
- package/dist/esm/utils/heartbeat.d.ts +4 -0
- package/dist/esm/utils/heartbeat.js +29 -0
- package/dist/esm/utils/is-node.d.ts +1 -0
- package/dist/esm/utils/is-node.js +5 -0
- package/dist/esm/utils/metrics.d.ts +1 -0
- package/dist/esm/utils/metrics.js +52 -0
- package/dist/esm/utils/oauth.d.ts +9 -0
- package/dist/esm/utils/oauth.js +64 -0
- package/dist/esm/utils/pick.d.ts +1 -0
- package/dist/esm/utils/pick.js +1 -0
- package/dist/esm/utils/pipes.d.ts +46 -0
- package/dist/esm/utils/pipes.js +65 -0
- package/dist/esm/utils/platform.d.ts +30 -0
- package/dist/esm/utils/platform.js +41 -0
- package/dist/esm/utils/subscription.d.ts +6 -0
- package/dist/esm/utils/subscription.js +24 -0
- package/dist/esm/utils/transferDevice.d.ts +9 -0
- package/dist/esm/utils/transferDevice.js +1 -0
- package/dist/esm/utils/whileOnline.d.ts +8 -0
- package/dist/esm/utils/whileOnline.js +11 -0
- package/dist/examples/auth.html +32 -0
- package/dist/examples/cloud.html +17 -0
- package/dist/examples/index.html +1 -0
- package/dist/examples/neurosity.iife.js +48736 -0
- package/dist/examples/neurosity.js +672 -0
- package/dist/examples/neurosity.mjs +48722 -0
- package/dist/examples/training.html +49 -0
- package/package.json +78 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { ReplaySubject } from "rxjs";
|
|
3
|
+
import { WebBluetoothTransport } from "./web/WebBluetoothTransport";
|
|
4
|
+
import { ReactNativeTransport } from "./react-native/ReactNativeTransport";
|
|
5
|
+
import { DeviceInfo } from "../../types/deviceInfo";
|
|
6
|
+
import { Action } from "../../types/actions";
|
|
7
|
+
import { Epoch } from "../../types/epoch";
|
|
8
|
+
import { BLUETOOTH_CONNECTION } from "./types";
|
|
9
|
+
import { DeviceNicknameOrPeripheral } from "./BluetoothTransport";
|
|
10
|
+
import { Peripheral } from "./react-native/types/BleManagerTypes";
|
|
11
|
+
export declare type BluetoothTransport = WebBluetoothTransport | ReactNativeTransport;
|
|
12
|
+
declare type IsAuthenticated = boolean;
|
|
13
|
+
declare type ExpiresIn = number;
|
|
14
|
+
declare type IsAuthenticatedResponse = [IsAuthenticated, ExpiresIn];
|
|
15
|
+
declare type CreateBluetoothToken = () => Promise<string>;
|
|
16
|
+
declare type Options = {
|
|
17
|
+
transport: BluetoothTransport;
|
|
18
|
+
selectedDevice$: Observable<DeviceInfo>;
|
|
19
|
+
createBluetoothToken: CreateBluetoothToken;
|
|
20
|
+
};
|
|
21
|
+
export declare class BluetoothClient {
|
|
22
|
+
transport: BluetoothTransport;
|
|
23
|
+
deviceInfo: DeviceInfo;
|
|
24
|
+
selectedDevice$: ReplaySubject<DeviceInfo>;
|
|
25
|
+
isAuthenticated$: ReplaySubject<boolean>;
|
|
26
|
+
constructor(options: Options);
|
|
27
|
+
_autoAuthenticate(createBluetoothToken: CreateBluetoothToken): Observable<IsAuthenticatedResponse>;
|
|
28
|
+
_hasBluetoothSupport(): Promise<boolean>;
|
|
29
|
+
authenticate(token: string): Promise<IsAuthenticatedResponse>;
|
|
30
|
+
isAuthenticated(): Promise<IsAuthenticatedResponse>;
|
|
31
|
+
scan(options?: any): Observable<Peripheral[]>;
|
|
32
|
+
connect(deviceNicknameORPeripheral?: DeviceNicknameOrPeripheral): Promise<void>;
|
|
33
|
+
disconnect(): Promise<void>;
|
|
34
|
+
connection(): Observable<BLUETOOTH_CONNECTION>;
|
|
35
|
+
logs(): Observable<string>;
|
|
36
|
+
getDeviceId(): Promise<string>;
|
|
37
|
+
_withAuthentication<T>(getter: () => Promise<T>): Promise<T>;
|
|
38
|
+
_subscribeWhileAuthenticated(characteristicName: string): Observable<any>;
|
|
39
|
+
focus(): Observable<any>;
|
|
40
|
+
calm(): Observable<any>;
|
|
41
|
+
accelerometer(): Observable<any>;
|
|
42
|
+
brainwaves(label: string): Observable<Epoch | any>;
|
|
43
|
+
signalQuality(): Observable<any>;
|
|
44
|
+
addMarker(label: string): Promise<void>;
|
|
45
|
+
getInfo(): Promise<DeviceInfo>;
|
|
46
|
+
status(): Observable<any>;
|
|
47
|
+
dispatchAction(action: Action): Promise<any>;
|
|
48
|
+
settings(): Observable<any>;
|
|
49
|
+
haptics(effects: any): Promise<any>;
|
|
50
|
+
get wifi(): {
|
|
51
|
+
nearbyNetworks: () => Observable<any>;
|
|
52
|
+
connections: () => Observable<any>;
|
|
53
|
+
connect: (ssid: string, password?: string) => Promise<any>;
|
|
54
|
+
forgetConnection: (ssid: string) => Promise<any>;
|
|
55
|
+
reset: () => Promise<any>;
|
|
56
|
+
speedTest: () => Promise<any>;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BluetoothClient = void 0;
|
|
13
|
+
const rxjs_1 = require("rxjs");
|
|
14
|
+
const rxjs_2 = require("rxjs");
|
|
15
|
+
const operators_1 = require("rxjs/operators");
|
|
16
|
+
const operators_2 = require("rxjs/operators");
|
|
17
|
+
const WebBluetoothTransport_1 = require("./web/WebBluetoothTransport");
|
|
18
|
+
const ReactNativeTransport_1 = require("./react-native/ReactNativeTransport");
|
|
19
|
+
const csvBufferToEpoch_1 = require("./utils/csvBufferToEpoch");
|
|
20
|
+
const types_1 = require("./types");
|
|
21
|
+
const osHasBluetoothSupport_1 = require("./utils/osHasBluetoothSupport");
|
|
22
|
+
class BluetoothClient {
|
|
23
|
+
constructor(options) {
|
|
24
|
+
this.selectedDevice$ = new rxjs_2.ReplaySubject(1);
|
|
25
|
+
this.isAuthenticated$ = new rxjs_2.ReplaySubject(1);
|
|
26
|
+
const { transport, selectedDevice$, createBluetoothToken } = options !== null && options !== void 0 ? options : {};
|
|
27
|
+
if (!transport) {
|
|
28
|
+
throw new Error(`No bluetooth transport provided.`);
|
|
29
|
+
}
|
|
30
|
+
this.transport = transport;
|
|
31
|
+
// Pass events to the internal selectedDevice$ if selectedDevice$ is passed via options
|
|
32
|
+
if (selectedDevice$) {
|
|
33
|
+
selectedDevice$.subscribe(this.selectedDevice$);
|
|
34
|
+
}
|
|
35
|
+
// Auto Connect
|
|
36
|
+
this.transport._autoConnect(this.selectedDevice$).subscribe({
|
|
37
|
+
error: (error) => {
|
|
38
|
+
var _a;
|
|
39
|
+
this.transport.addLog(`Auto connect: error -> ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
// Auto authentication
|
|
43
|
+
if (typeof createBluetoothToken === "function") {
|
|
44
|
+
this.transport.addLog("Auto authentication enabled");
|
|
45
|
+
this._autoAuthenticate(createBluetoothToken).subscribe();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.transport.addLog("Auto authentication not enabled");
|
|
49
|
+
}
|
|
50
|
+
// Auto manage action notifications
|
|
51
|
+
this.transport._autoToggleActionNotifications(this.selectedDevice$);
|
|
52
|
+
}
|
|
53
|
+
_autoAuthenticate(createBluetoothToken) {
|
|
54
|
+
const REAUTHENTICATE_INTERVAL = 3600000; // 1 hour
|
|
55
|
+
const reauthenticateInterval$ = (0, rxjs_1.timer)(0, REAUTHENTICATE_INTERVAL).pipe((0, operators_1.tap)(() => {
|
|
56
|
+
this.transport.addLog(`Auto authentication in progress...`);
|
|
57
|
+
}));
|
|
58
|
+
return this.selectedDevice$.pipe((0, operators_1.switchMap)((selectedDevice) => !(0, osHasBluetoothSupport_1.osHasBluetoothSupport)(selectedDevice)
|
|
59
|
+
? rxjs_2.EMPTY
|
|
60
|
+
: this.connection().pipe((0, operators_1.switchMap)((connection) => connection === types_1.BLUETOOTH_CONNECTION.CONNECTED
|
|
61
|
+
? reauthenticateInterval$
|
|
62
|
+
: rxjs_2.EMPTY), (0, operators_1.switchMap)(() => __awaiter(this, void 0, void 0, function* () { return yield this.isAuthenticated(); })), (0, operators_1.tap)(([isAuthenticated]) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
if (!isAuthenticated) {
|
|
64
|
+
const token = yield createBluetoothToken();
|
|
65
|
+
yield this.authenticate(token);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.transport.addLog(`Already authenticated`);
|
|
69
|
+
}
|
|
70
|
+
})))));
|
|
71
|
+
}
|
|
72
|
+
_hasBluetoothSupport() {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const selectedDevice = yield (0, rxjs_1.firstValueFrom)(this.selectedDevice$);
|
|
75
|
+
return (0, osHasBluetoothSupport_1.osHasBluetoothSupport)(selectedDevice);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
authenticate(token) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const hasBluetoothSupport = yield this._hasBluetoothSupport();
|
|
81
|
+
if (!hasBluetoothSupport) {
|
|
82
|
+
const errorMessage = `authenticate method: The OS version does not support Bluetooth.`;
|
|
83
|
+
this.transport.addLog(errorMessage);
|
|
84
|
+
return Promise.reject(errorMessage);
|
|
85
|
+
}
|
|
86
|
+
yield this.transport.writeCharacteristic("auth", token);
|
|
87
|
+
const isAuthenticatedResponse = yield this.isAuthenticated();
|
|
88
|
+
const [isAuthenticated] = isAuthenticatedResponse;
|
|
89
|
+
this.transport.addLog(`Authentication ${isAuthenticated ? "succeeded" : "failed"}`);
|
|
90
|
+
this.isAuthenticated$.next(isAuthenticated);
|
|
91
|
+
return isAuthenticatedResponse;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
isAuthenticated() {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
const [isAuthenticated, expiresIn] = yield this.transport.readCharacteristic("auth", true);
|
|
97
|
+
this.isAuthenticated$.next(isAuthenticated);
|
|
98
|
+
return [isAuthenticated, expiresIn];
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
// Method for React Native only
|
|
102
|
+
scan(options) {
|
|
103
|
+
if (this.transport instanceof ReactNativeTransport_1.ReactNativeTransport) {
|
|
104
|
+
return this.transport.scan(options);
|
|
105
|
+
}
|
|
106
|
+
if (this.transport instanceof WebBluetoothTransport_1.WebBluetoothTransport) {
|
|
107
|
+
throw new Error(`scan method is compatibly with the React Native transport only`);
|
|
108
|
+
}
|
|
109
|
+
throw new Error(`unknown transport`);
|
|
110
|
+
}
|
|
111
|
+
// Argument for React Native only
|
|
112
|
+
connect(deviceNicknameORPeripheral) {
|
|
113
|
+
if (this.transport instanceof ReactNativeTransport_1.ReactNativeTransport) {
|
|
114
|
+
return this.transport.connect(deviceNicknameORPeripheral);
|
|
115
|
+
}
|
|
116
|
+
if (this.transport instanceof WebBluetoothTransport_1.WebBluetoothTransport) {
|
|
117
|
+
return deviceNicknameORPeripheral
|
|
118
|
+
? this.transport.connect(deviceNicknameORPeripheral)
|
|
119
|
+
: this.transport.connect();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
disconnect() {
|
|
123
|
+
return this.transport.disconnect();
|
|
124
|
+
}
|
|
125
|
+
connection() {
|
|
126
|
+
return this.transport.connection();
|
|
127
|
+
}
|
|
128
|
+
logs() {
|
|
129
|
+
return this.transport.logs$.asObservable();
|
|
130
|
+
}
|
|
131
|
+
getDeviceId() {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
// This is a public characteristic and does not require authentication
|
|
134
|
+
return this.transport.readCharacteristic("deviceId");
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
_withAuthentication(getter) {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
// First check if the OS supports Bluetooth before checking if the device is authenticated
|
|
140
|
+
const hasBluetoothSupport = yield this._hasBluetoothSupport();
|
|
141
|
+
if (!hasBluetoothSupport) {
|
|
142
|
+
const errorMessage = `The OS version does not support Bluetooth.`;
|
|
143
|
+
this.transport.addLog(errorMessage);
|
|
144
|
+
return Promise.reject(errorMessage);
|
|
145
|
+
}
|
|
146
|
+
const isAuthenticated = yield (0, rxjs_1.firstValueFrom)(this.isAuthenticated$);
|
|
147
|
+
if (!isAuthenticated) {
|
|
148
|
+
const errorMessage = `Authentication required.`;
|
|
149
|
+
this.transport.addLog(errorMessage);
|
|
150
|
+
return Promise.reject(errorMessage);
|
|
151
|
+
}
|
|
152
|
+
return yield getter();
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
_subscribeWhileAuthenticated(characteristicName) {
|
|
156
|
+
return this.selectedDevice$.pipe((0, operators_1.switchMap)((selectedDevice) => !(0, osHasBluetoothSupport_1.osHasBluetoothSupport)(selectedDevice)
|
|
157
|
+
? rxjs_2.EMPTY
|
|
158
|
+
: this.isAuthenticated$.pipe((0, operators_2.distinctUntilChanged)(), (0, operators_1.switchMap)((isAuthenticated) => isAuthenticated
|
|
159
|
+
? this.transport.subscribeToCharacteristic({
|
|
160
|
+
characteristicName
|
|
161
|
+
})
|
|
162
|
+
: rxjs_2.EMPTY))));
|
|
163
|
+
}
|
|
164
|
+
focus() {
|
|
165
|
+
return this._subscribeWhileAuthenticated("focus");
|
|
166
|
+
}
|
|
167
|
+
calm() {
|
|
168
|
+
return this._subscribeWhileAuthenticated("calm");
|
|
169
|
+
}
|
|
170
|
+
accelerometer() {
|
|
171
|
+
return this._subscribeWhileAuthenticated("accelerometer");
|
|
172
|
+
}
|
|
173
|
+
brainwaves(label) {
|
|
174
|
+
switch (label) {
|
|
175
|
+
case "raw":
|
|
176
|
+
case "rawUnfiltered":
|
|
177
|
+
return (0, rxjs_1.defer)(() => this.getInfo()).pipe((0, operators_1.switchMap)((deviceInfo) => this._subscribeWhileAuthenticated(label).pipe((0, csvBufferToEpoch_1.csvBufferToEpoch)(deviceInfo))));
|
|
178
|
+
default:
|
|
179
|
+
return this._subscribeWhileAuthenticated(label);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
signalQuality() {
|
|
183
|
+
return this._subscribeWhileAuthenticated("signalQuality");
|
|
184
|
+
}
|
|
185
|
+
addMarker(label) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
yield this.dispatchAction({
|
|
188
|
+
action: "marker",
|
|
189
|
+
command: "add",
|
|
190
|
+
message: {
|
|
191
|
+
timestamp: Date.now(),
|
|
192
|
+
label
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
getInfo() {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
199
|
+
return yield this._withAuthentication(() => (0, rxjs_1.firstValueFrom)(this.transport.subscribeToCharacteristic({
|
|
200
|
+
characteristicName: "deviceInfo"
|
|
201
|
+
})));
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
// Tested
|
|
205
|
+
status() {
|
|
206
|
+
return this._subscribeWhileAuthenticated("status");
|
|
207
|
+
}
|
|
208
|
+
dispatchAction(action) {
|
|
209
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
return yield this._withAuthentication(() => this.transport.dispatchAction({
|
|
211
|
+
characteristicName: "actions",
|
|
212
|
+
action
|
|
213
|
+
}));
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
settings() {
|
|
217
|
+
return this._subscribeWhileAuthenticated("settings");
|
|
218
|
+
}
|
|
219
|
+
haptics(effects) {
|
|
220
|
+
const metric = "haptics";
|
|
221
|
+
return this.dispatchAction({
|
|
222
|
+
action: metric,
|
|
223
|
+
command: "queue",
|
|
224
|
+
responseRequired: true,
|
|
225
|
+
responseTimeout: 4000,
|
|
226
|
+
// @TODO: implement validation logic as per SDK
|
|
227
|
+
message: { effects }
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
get wifi() {
|
|
231
|
+
return {
|
|
232
|
+
nearbyNetworks: () => this._subscribeWhileAuthenticated("wifiNearbyNetworks"),
|
|
233
|
+
connections: () => this._subscribeWhileAuthenticated("wifiConnections"),
|
|
234
|
+
connect: (ssid, password) => {
|
|
235
|
+
if (!ssid) {
|
|
236
|
+
return Promise.reject(`Missing ssid`);
|
|
237
|
+
}
|
|
238
|
+
return this.dispatchAction({
|
|
239
|
+
action: "wifi",
|
|
240
|
+
command: "connect",
|
|
241
|
+
responseRequired: true,
|
|
242
|
+
responseTimeout: 1000 * 60 * 2,
|
|
243
|
+
message: {
|
|
244
|
+
ssid,
|
|
245
|
+
password: password !== null && password !== void 0 ? password : null
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
},
|
|
249
|
+
forgetConnection: (ssid) => {
|
|
250
|
+
if (!ssid) {
|
|
251
|
+
return Promise.reject(`Missing ssid`);
|
|
252
|
+
}
|
|
253
|
+
return this.dispatchAction({
|
|
254
|
+
action: "wifi",
|
|
255
|
+
command: "forget-connection",
|
|
256
|
+
responseRequired: true,
|
|
257
|
+
responseTimeout: 1000 * 15,
|
|
258
|
+
message: {
|
|
259
|
+
ssid
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
},
|
|
263
|
+
reset: () => {
|
|
264
|
+
return this.dispatchAction({
|
|
265
|
+
action: "wifi",
|
|
266
|
+
command: "reset",
|
|
267
|
+
responseRequired: true,
|
|
268
|
+
responseTimeout: 1000 * 30,
|
|
269
|
+
message: {
|
|
270
|
+
// without this, the action will resolve as soon as the
|
|
271
|
+
// action is received by the OS
|
|
272
|
+
respondOnSuccess: true
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
},
|
|
276
|
+
speedTest: () => {
|
|
277
|
+
return this.dispatchAction({
|
|
278
|
+
action: "wifi",
|
|
279
|
+
command: "speed-test",
|
|
280
|
+
responseRequired: true,
|
|
281
|
+
responseTimeout: 1000 * 60 * 1 // 1 minute
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
exports.BluetoothClient = BluetoothClient;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Observable, Subject } from "rxjs";
|
|
2
|
+
import { BLUETOOTH_CONNECTION, TRANSPORT_TYPE } from "./types";
|
|
3
|
+
import { Action } from "../../types/actions";
|
|
4
|
+
import { DeviceInfo } from "../../types/deviceInfo";
|
|
5
|
+
import { Peripheral } from "./react-native/types/BleManagerTypes";
|
|
6
|
+
export declare type DeviceNicknameOrPeripheral = string | Peripheral;
|
|
7
|
+
/**
|
|
8
|
+
* @hidden
|
|
9
|
+
*/
|
|
10
|
+
export interface BluetoothTransport {
|
|
11
|
+
type: TRANSPORT_TYPE;
|
|
12
|
+
connect(deviceNicknameORPeripheral?: DeviceNicknameOrPeripheral): Promise<void>;
|
|
13
|
+
_autoConnect(selectedDevice$: Observable<DeviceInfo>): Observable<void>;
|
|
14
|
+
disconnect(): Promise<void>;
|
|
15
|
+
connection(): Observable<BLUETOOTH_CONNECTION>;
|
|
16
|
+
requestDevice?(): any;
|
|
17
|
+
addLog: (log: string) => void;
|
|
18
|
+
logs$: Subject<string>;
|
|
19
|
+
scan?(options?: {
|
|
20
|
+
seconds?: number;
|
|
21
|
+
}): Observable<Peripheral[]>;
|
|
22
|
+
subscribeToCharacteristic(args: {
|
|
23
|
+
characteristicName: string;
|
|
24
|
+
manageNotifications?: boolean;
|
|
25
|
+
}): Observable<any>;
|
|
26
|
+
readCharacteristic(characteristicName: string, parse?: boolean): Promise<any>;
|
|
27
|
+
writeCharacteristic(characteristicName: string, data: string): Promise<void>;
|
|
28
|
+
dispatchAction(args: {
|
|
29
|
+
characteristicName: string;
|
|
30
|
+
action: Action;
|
|
31
|
+
}): Promise<any>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CHARACTERISTIC_UUIDS_TO_NAMES = exports.DEFAULT_ACTION_RESPONSE_TIMEOUT = exports.REACT_NATIVE_MAX_BYTE_SIZE = exports.ANDROID_MAX_MTU = void 0;
|
|
4
|
+
const ipk_1 = require("@neurosity/ipk");
|
|
5
|
+
exports.ANDROID_MAX_MTU = 512;
|
|
6
|
+
exports.REACT_NATIVE_MAX_BYTE_SIZE = 512; // the default is 20
|
|
7
|
+
exports.DEFAULT_ACTION_RESPONSE_TIMEOUT = 1000 * 60; // 1 minute
|
|
8
|
+
// Reverse BLUETOOTH_CHARACTERISTICS key/values for easy lookup
|
|
9
|
+
exports.CHARACTERISTIC_UUIDS_TO_NAMES = Object.fromEntries(Object.entries(ipk_1.BLUETOOTH_CHARACTERISTICS).map((entries) => entries.reverse()));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./BluetoothClient"), exports);
|
|
18
|
+
__exportStar(require("./web/WebBluetoothTransport"), exports);
|
|
19
|
+
__exportStar(require("./react-native/ReactNativeTransport"), exports);
|
|
20
|
+
__exportStar(require("./utils/osHasBluetoothSupport"), exports);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { BehaviorSubject, ReplaySubject } from "rxjs";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
import { BluetoothTransport } from "../BluetoothTransport";
|
|
4
|
+
import { ActionOptions, SubscribeOptions } from "../types";
|
|
5
|
+
import { TRANSPORT_TYPE, BLUETOOTH_CONNECTION } from "../types";
|
|
6
|
+
import { BleManager } from "./types/BleManagerTypes";
|
|
7
|
+
import { Peripheral } from "./types/BleManagerTypes";
|
|
8
|
+
import { NativeEventEmitter } from "./types/ReactNativeTypes";
|
|
9
|
+
import { PlatformOSType } from "./types/ReactNativeTypes";
|
|
10
|
+
import { DeviceInfo } from "../../../types/deviceInfo";
|
|
11
|
+
declare type Characteristic = {
|
|
12
|
+
characteristicUUID: string;
|
|
13
|
+
serviceUUID: string;
|
|
14
|
+
peripheralId: string;
|
|
15
|
+
};
|
|
16
|
+
declare type CharacteristicsByName = {
|
|
17
|
+
[name: string]: Characteristic;
|
|
18
|
+
};
|
|
19
|
+
declare type Options = {
|
|
20
|
+
BleManager: BleManager;
|
|
21
|
+
bleManagerEmitter: NativeEventEmitter;
|
|
22
|
+
platform: PlatformOSType;
|
|
23
|
+
};
|
|
24
|
+
declare type BleManagerEvents = {
|
|
25
|
+
stopScan$: Observable<void>;
|
|
26
|
+
discoverPeripheral$: Observable<Peripheral>;
|
|
27
|
+
connectPeripheral$: Observable<void>;
|
|
28
|
+
disconnectPeripheral$: Observable<void>;
|
|
29
|
+
didUpdateValueForCharacteristic$: Observable<any>;
|
|
30
|
+
};
|
|
31
|
+
export declare class ReactNativeTransport implements BluetoothTransport {
|
|
32
|
+
type: TRANSPORT_TYPE;
|
|
33
|
+
BleManager: BleManager;
|
|
34
|
+
bleManagerEmitter: NativeEventEmitter;
|
|
35
|
+
platform: PlatformOSType;
|
|
36
|
+
bleEvents: BleManagerEvents;
|
|
37
|
+
device: Peripheral;
|
|
38
|
+
characteristicsByName: CharacteristicsByName;
|
|
39
|
+
connection$: BehaviorSubject<BLUETOOTH_CONNECTION>;
|
|
40
|
+
pendingActions$: BehaviorSubject<any[]>;
|
|
41
|
+
logs$: ReplaySubject<string>;
|
|
42
|
+
onDisconnected$: Observable<void>;
|
|
43
|
+
connectionStream$: Observable<BLUETOOTH_CONNECTION>;
|
|
44
|
+
constructor(options: Options);
|
|
45
|
+
addLog(log: string): void;
|
|
46
|
+
isConnected(): boolean;
|
|
47
|
+
_autoConnect(selectedDevice$: Observable<DeviceInfo>): Observable<void>;
|
|
48
|
+
connection(): Observable<BLUETOOTH_CONNECTION>;
|
|
49
|
+
_fromEvent(eventName: string): Observable<any>;
|
|
50
|
+
scan(options?: {
|
|
51
|
+
seconds?: number;
|
|
52
|
+
once?: boolean;
|
|
53
|
+
}): Observable<Peripheral[]>;
|
|
54
|
+
connect(peripheral: Peripheral): Promise<void>;
|
|
55
|
+
disconnect(): Promise<void>;
|
|
56
|
+
getCharacteristicByName(characteristicName: string): Characteristic;
|
|
57
|
+
subscribeToCharacteristic({ characteristicName, manageNotifications }: SubscribeOptions): Observable<any>;
|
|
58
|
+
readCharacteristic(characteristicName: string, parse?: boolean): Promise<any>;
|
|
59
|
+
writeCharacteristic(characteristicName: string, data: string): Promise<void>;
|
|
60
|
+
_addPendingAction(actionId: number): void;
|
|
61
|
+
_removePendingAction(actionId: number): void;
|
|
62
|
+
_autoToggleActionNotifications(selectedDevice$: Observable<DeviceInfo>): Promise<void>;
|
|
63
|
+
dispatchAction({ characteristicName, action }: ActionOptions): Promise<any>;
|
|
64
|
+
}
|
|
65
|
+
export {};
|