brilliantsole 0.0.46 → 0.0.49

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.
@@ -10,6 +10,7 @@ interface HasConnectionManager {
10
10
  }
11
11
  export interface NoblePeripheral extends noble.Peripheral, HasConnectionManager {
12
12
  scanner: NobleScanner;
13
+ shouldConnect?: boolean;
13
14
  }
14
15
  interface NobleService extends noble.Service, HasConnectionManager {
15
16
  name: BluetoothServiceName;
@@ -3266,7 +3266,7 @@ onBitmapCanvasSizeUpdate();
3266
3266
 
3267
3267
  const displayContainer = document.getElementById("display");
3268
3268
  device.addEventListener("connected", () => {
3269
- if (device.isDisplayAvailable) {
3269
+ if (!device.isDisplayAvailable) {
3270
3270
  displayContainer.setAttribute("hidden", "");
3271
3271
  } else {
3272
3272
  displayContainer.removeAttribute("hidden");
@@ -3274,7 +3274,7 @@ device.addEventListener("connected", () => {
3274
3274
  });
3275
3275
  const cameraContainer = document.getElementById("camera");
3276
3276
  device.addEventListener("connected", () => {
3277
- if (device.hasCamera) {
3277
+ if (!device.hasCamera) {
3278
3278
  cameraContainer.setAttribute("hidden", "");
3279
3279
  } else {
3280
3280
  cameraContainer.removeAttribute("hidden");
@@ -3282,7 +3282,7 @@ device.addEventListener("connected", () => {
3282
3282
  });
3283
3283
  const microphoneContainer = document.getElementById("microphone");
3284
3284
  device.addEventListener("connected", () => {
3285
- if (device.hasMicrophone) {
3285
+ if (!device.hasMicrophone) {
3286
3286
  microphoneContainer.setAttribute("hidden", "");
3287
3287
  } else {
3288
3288
  microphoneContainer.removeAttribute("hidden");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brilliantsole",
3
- "version": "0.0.46",
3
+ "version": "0.0.49",
4
4
  "description": "JavaScript SDK for BrilliantSole Smart Insoles",
5
5
  "main": "./build/brilliantsole.module.js",
6
6
  "module": "./build/brilliantsole.module.js",
@@ -40,6 +40,7 @@ export interface NoblePeripheral
40
40
  extends noble.Peripheral,
41
41
  HasConnectionManager {
42
42
  scanner: NobleScanner;
43
+ shouldConnect?: boolean;
43
44
  }
44
45
  interface NobleService extends noble.Service, HasConnectionManager {
45
46
  name: BluetoothServiceName;
@@ -76,9 +77,14 @@ class NobleConnectionManager extends BluetoothConnectionManager {
76
77
  if (!canConnect) {
77
78
  return false;
78
79
  }
79
- console.log("FUCK");
80
- await this.#noblePeripheral!.connectAsync();
81
- console.log("YEA");
80
+ if (isLinux) {
81
+ _console.log("setting noblePeripheral.shouldConnect");
82
+ this.#noblePeripheral!.shouldConnect = true;
83
+ } else {
84
+ _console.log("noblePeripheral.connectAsync");
85
+ await this.#noblePeripheral!.connectAsync();
86
+ _console.log("noblePeripheral.connectAsync done");
87
+ }
82
88
  return true;
83
89
  }
84
90
  async disconnect() {
@@ -86,7 +92,9 @@ class NobleConnectionManager extends BluetoothConnectionManager {
86
92
  if (!canContinue) {
87
93
  return false;
88
94
  }
95
+ _console.log("noblePeripheral.disconnectAsync");
89
96
  await this.#noblePeripheral!.disconnectAsync();
97
+ _console.log("noblePeripheral.disconnectAsync done");
90
98
  return true;
91
99
  }
92
100
 
@@ -154,6 +154,7 @@ abstract class BaseScanner {
154
154
  _console.log("already scanning");
155
155
  return false;
156
156
  }
157
+ _console.log("startScan");
157
158
  return true;
158
159
  // this.#assertIsAvailable();
159
160
  // this.#assertIsNotScanning();
@@ -163,6 +164,7 @@ abstract class BaseScanner {
163
164
  _console.log("already not scanning");
164
165
  return false;
165
166
  }
167
+ _console.log("stopScan");
166
168
  return true;
167
169
  //this.#assertIsScanning();
168
170
  }
@@ -19,6 +19,7 @@ let isSupported = false;
19
19
  let filterManually = true;
20
20
  const filterServiceUuid = (serviceUUIDs[0] as string).replaceAll("-", "");
21
21
 
22
+ let isLinux = false;
22
23
  /** NODE_START */
23
24
  import noble from "@abandonware/noble";
24
25
  import { DeviceTypes } from "../InformationManager.ts";
@@ -27,7 +28,8 @@ import { ClientConnectionType } from "../connection/BaseConnectionManager.ts";
27
28
  isSupported = true;
28
29
  import os from "os";
29
30
  const platform = os.platform();
30
- filterManually = platform == "linux";
31
+ isLinux = platform == "linux";
32
+ filterManually = isLinux;
31
33
  _console.log({ platform, filterManually, filterServiceUuid });
32
34
  /** NODE_END */
33
35
 
@@ -101,7 +103,8 @@ class NobleScanner extends BaseScanner {
101
103
  _console.log("onNobleStateChange", state);
102
104
  this.#nobleState = state;
103
105
  }
104
- #onNobleDiscover(noblePeripheral: NoblePeripheral) {
106
+ #isBusy = false;
107
+ async #onNobleDiscover(noblePeripheral: NoblePeripheral) {
105
108
  _console.log("advertisement", noblePeripheral.advertisement);
106
109
  if (filterManually) {
107
110
  const serviceUuid = noblePeripheral.advertisement.serviceUuids?.[0];
@@ -110,10 +113,26 @@ class NobleScanner extends BaseScanner {
110
113
  return;
111
114
  }
112
115
  }
116
+
113
117
  _console.log("onNobleDiscover", noblePeripheral.id);
114
118
  if (!this.#noblePeripherals[noblePeripheral.id]) {
115
119
  noblePeripheral.scanner = this;
116
120
  this.#noblePeripherals[noblePeripheral.id] = noblePeripheral;
121
+ } else {
122
+ const _noblePeripheral = this.#noblePeripherals[noblePeripheral.id];
123
+ if (
124
+ isLinux &&
125
+ _noblePeripheral.shouldConnect &&
126
+ !this.#isBusy &&
127
+ _noblePeripheral.state == "disconnected"
128
+ ) {
129
+ this.#isBusy = true;
130
+ _noblePeripheral.shouldConnect = false;
131
+ _console.log("noblePeripheral.connectAsync");
132
+ await _noblePeripheral.connectAsync();
133
+ _console.log("noblePeripheral.connectAsync done");
134
+ this.#isBusy = false;
135
+ }
117
136
  }
118
137
 
119
138
  _console.log("advertisement", noblePeripheral.advertisement);
@@ -184,6 +203,7 @@ class NobleScanner extends BaseScanner {
184
203
  if (!super.startScan()) {
185
204
  return false;
186
205
  }
206
+ _console.log("noble.startScan");
187
207
  noble.startScanningAsync(
188
208
  filterManually ? [] : (serviceUUIDs as string[]),
189
209
  true
@@ -194,6 +214,7 @@ class NobleScanner extends BaseScanner {
194
214
  if (!super.stopScan()) {
195
215
  return false;
196
216
  }
217
+ _console.log("noble.stopScan");
197
218
  noble.stopScanningAsync();
198
219
  return true;
199
220
  }
@@ -1,10 +0,0 @@
1
- import * as BS from "./BS.ts";
2
- declare global {
3
- var BS: typeof import("./BS.ts") | undefined;
4
- }
5
- declare const _default: typeof BS;
6
- export default _default;
7
- declare const _default_1: typeof BS;
8
- export default _default_1;
9
- /** BROWSER_END */
10
- export * from "./BS.ts";
@@ -1,23 +0,0 @@
1
- import BaseConnectionManager, { ConnectionType } from "./BaseConnectionManager.ts";
2
- import { ClientDeviceMessage } from "../server/ServerUtils.ts";
3
- export type SendWebSocketMessageCallback = (...messages: ClientDeviceMessage[]) => void;
4
- declare class WebSocketClientConnectionManager extends BaseConnectionManager {
5
- #private;
6
- static get isSupported(): boolean;
7
- static get type(): ConnectionType;
8
- get bluetoothId(): string;
9
- set bluetoothId(newBluetoothId: string);
10
- get isConnected(): boolean;
11
- set isConnected(newIsConnected: boolean);
12
- connect(): Promise<void>;
13
- disconnect(): Promise<void>;
14
- get canReconnect(): boolean;
15
- reconnect(): Promise<void>;
16
- sendWebSocketMessage: SendWebSocketMessageCallback;
17
- sendWebSocketConnectMessage: Function;
18
- sendWebSocketDisconnectMessage: Function;
19
- sendSmpMessage(data: ArrayBuffer): Promise<void>;
20
- sendTxData(data: ArrayBuffer): Promise<void>;
21
- onWebSocketMessage(dataView: DataView): void;
22
- }
23
- export default WebSocketClientConnectionManager;
@@ -1,12 +0,0 @@
1
- declare const BluetoothUUID: {
2
- /**
3
- * Converts a 16-bit or 32-bit UUID to a 128-bit UUID string
4
- */
5
- getService: (uuid: number | string) => string;
6
- getCharacteristic: (uuid: number | string) => string;
7
- getDescriptor: (uuid: number | string) => string;
8
- getCharacteristicName: (uuid: number | string) => string | null;
9
- getServiceName: (uuid: number | string) => string | null;
10
- getDescriptorName: (uuid: number | string) => string | null;
11
- };
12
- export { BluetoothUUID };
@@ -1,23 +0,0 @@
1
- import BaseConnectionManager, { ConnectionType } from "../BaseConnectionManager.ts";
2
- import { ClientDeviceMessage } from "../../server/ServerUtils.ts";
3
- export type SendClientMessageCallback = (...messages: ClientDeviceMessage[]) => void;
4
- declare class ClientConnectionManager extends BaseConnectionManager {
5
- #private;
6
- static get isSupported(): boolean;
7
- static get type(): ConnectionType;
8
- get bluetoothId(): string;
9
- set bluetoothId(newBluetoothId: string);
10
- get isConnected(): boolean;
11
- set isConnected(newIsConnected: boolean);
12
- connect(): Promise<void>;
13
- disconnect(): Promise<void>;
14
- get canReconnect(): boolean;
15
- reconnect(): Promise<void>;
16
- sendClientMessage: SendClientMessageCallback;
17
- sendClientConnectMessage: Function;
18
- sendClientDisconnectMessage: Function;
19
- sendSmpMessage(data: ArrayBuffer): Promise<void>;
20
- sendTxData(data: ArrayBuffer): Promise<void>;
21
- onClientMessage(dataView: DataView): void;
22
- }
23
- export default ClientConnectionManager;
@@ -1,23 +0,0 @@
1
- import BaseConnectionManager, { ConnectionType } from "../BaseConnectionManager.ts";
2
- import { ClientDeviceMessage } from "../../server/ServerUtils.ts";
3
- export type SendWebSocketMessageCallback = (...messages: ClientDeviceMessage[]) => void;
4
- declare class WebSocketClientConnectionManager extends BaseConnectionManager {
5
- #private;
6
- static get isSupported(): boolean;
7
- static get type(): ConnectionType;
8
- get bluetoothId(): string;
9
- set bluetoothId(newBluetoothId: string);
10
- get isConnected(): boolean;
11
- set isConnected(newIsConnected: boolean);
12
- connect(): Promise<void>;
13
- disconnect(): Promise<void>;
14
- get canReconnect(): boolean;
15
- reconnect(): Promise<void>;
16
- sendWebSocketMessage: SendWebSocketMessageCallback;
17
- sendWebSocketConnectMessage: Function;
18
- sendWebSocketDisconnectMessage: Function;
19
- sendSmpMessage(data: ArrayBuffer): Promise<void>;
20
- sendTxData(data: ArrayBuffer): Promise<void>;
21
- onWebSocketMessage(dataView: DataView): void;
22
- }
23
- export default WebSocketClientConnectionManager;
@@ -1,17 +0,0 @@
1
- import { DisplayBitmap } from "../DisplayManager.ts";
2
- import { DisplayContextState } from "./DisplayContextState.ts";
3
- export declare function quantizeImage(image: HTMLImageElement, width: number, height: number, numberOfColors: number): Promise<{
4
- blob: Blob;
5
- colors: string[];
6
- colorIndices: number[];
7
- }>;
8
- export declare function resizeAndQuantizeImage(image: HTMLImageElement, width: number, height: number, colors: string[]): Promise<{
9
- blob: Blob;
10
- colorIndices: number[];
11
- }>;
12
- export declare function imageToBitmap(image: HTMLImageElement, width: number, height: number, colors: string[], contextState: DisplayContextState, numberOfColors?: number): Promise<{
13
- blob: Blob;
14
- bitmap: DisplayBitmap;
15
- }>;
16
- export declare function getBitmapNumberOfBytes(bitmap: DisplayBitmap): number;
17
- export declare function assertValidBitmapPixels(bitmap: DisplayBitmap): void;
@@ -1,20 +0,0 @@
1
- import { DisplayContextCommandMessage } from "./DisplayContextCommand.ts";
2
- export type DisplaySprite = {
3
- width: number;
4
- height: number;
5
- displayCommandMessages: DisplayContextCommandMessage[];
6
- };
7
- export type DisplaySpriteSheetPalette = {
8
- colors: string[];
9
- opacities: number[];
10
- fillColorIndex: string;
11
- lineColorIndex: string;
12
- bitmapColorIndices: number[];
13
- };
14
- export type DisplaySpriteSheet = {
15
- name: string;
16
- palettes: DisplaySpriteSheetPalette[][];
17
- sprites: {
18
- [name: string]: DisplaySprite;
19
- };
20
- };
@@ -1,8 +0,0 @@
1
- import { DisplayContextCommand } from "./DisplayContextCommand.ts";
2
- export type ParseSvgOptions = {
3
- crop?: boolean;
4
- width?: number;
5
- height?: number;
6
- aspectRatio?: number;
7
- };
8
- export declare function svgToDisplayContextCommands(svgString: string, options?: ParseSvgOptions): DisplayContextCommand[];
@@ -1,9 +0,0 @@
1
- import { DisplayContextCommand } from "./DisplayContextCommand.ts";
2
- type ParseSvgOptions = {
3
- crop?: boolean;
4
- width?: number;
5
- height?: number;
6
- aspectRatio?: number;
7
- };
8
- export declare function svgToDisplayContextCommands(svgString: string, options?: ParseSvgOptions): DisplayContextCommand[];
9
- export {};