@onekeyfe/hardware-cli 1.2.0-alpha.12 → 1.2.0-alpha.14

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.
@@ -16,7 +16,6 @@ const CONNECTION_TIMEOUT = 8000;
16
16
  const SERVICE_DISCOVERY_TIMEOUT = 10000;
17
17
  const BLE_CLEANUP_TIMEOUT = 100;
18
18
  const BLE_PACKET_SIZE = 192;
19
- const BLE_WRITE_DELAY = 5;
20
19
  const BLE_ENCRYPTION_ERROR_PATTERNS = [/encryption is insufficient/i, /insufficient encryption/i];
21
20
  let noble = null;
22
21
  let nobleReadyPromise = null;
@@ -360,9 +359,6 @@ function createNobleBlePlugin() {
360
359
  for (let offset = 0; offset < buffer.length; offset += BLE_PACKET_SIZE) {
361
360
  const chunk = buffer.subarray(offset, Math.min(offset + BLE_PACKET_SIZE, buffer.length));
362
361
  await writeCharacteristic(characteristics.write, chunk, true);
363
- if (offset + BLE_PACKET_SIZE < buffer.length) {
364
- await (0, hd_shared_1.wait)(BLE_WRITE_DELAY);
365
- }
366
362
  }
367
363
  },
368
364
  async receive(uuid) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hardware-cli",
3
- "version": "1.2.0-alpha.12",
3
+ "version": "1.2.0-alpha.14",
4
4
  "description": "OneKey hardware wallet CLI for testing device communication",
5
5
  "author": "OneKey",
6
6
  "license": "Apache-2.0",
@@ -30,12 +30,12 @@
30
30
  "test": "jest"
31
31
  },
32
32
  "dependencies": {
33
- "@onekeyfe/hd-common-connect-sdk": "1.2.0-alpha.12",
34
- "@onekeyfe/hd-core": "1.2.0-alpha.12",
35
- "@onekeyfe/hd-shared": "1.2.0-alpha.12",
36
- "@onekeyfe/hd-transport-usb": "1.2.0-alpha.12",
33
+ "@onekeyfe/hd-common-connect-sdk": "1.2.0-alpha.14",
34
+ "@onekeyfe/hd-core": "1.2.0-alpha.14",
35
+ "@onekeyfe/hd-shared": "1.2.0-alpha.14",
36
+ "@onekeyfe/hd-transport-usb": "1.2.0-alpha.14",
37
37
  "@stoprocent/noble": "2.3.16",
38
38
  "commander": "^12.0.0"
39
39
  },
40
- "gitHead": "3601e8003c96a2a4ca7856e865d16f48c0c5b758"
40
+ "gitHead": "c1edaed6435fb6049c7516c64b298ee62519e797"
41
41
  }
@@ -140,4 +140,35 @@ describe('Noble BLE plugin notification routing', () => {
140
140
  true,
141
141
  ]);
142
142
  });
143
+
144
+ test('does not add a fixed delay between 192-byte writes', async () => {
145
+ const device = createPeripheral('device-a');
146
+ const noble = new EventEmitter() as EventEmitter & {
147
+ state: string;
148
+ startScanning: jest.Mock;
149
+ stopScanning: jest.Mock;
150
+ };
151
+ const wait = jest.fn(() => Promise.resolve());
152
+ noble.state = 'poweredOn';
153
+ noble.startScanning = jest.fn((_services, _duplicates, callback) => {
154
+ callback?.();
155
+ noble.emit('discover', device.peripheral);
156
+ });
157
+ noble.stopScanning = jest.fn(callback => callback?.());
158
+ jest.doMock('@stoprocent/noble', () => noble);
159
+ jest.doMock('@onekeyfe/hd-shared', () => ({
160
+ ...jest.requireActual('@onekeyfe/hd-shared'),
161
+ wait,
162
+ }));
163
+
164
+ const { createNobleBlePlugin } = await import('../transports/nobleBlePlugin');
165
+ const plugin = createNobleBlePlugin();
166
+ await plugin.init();
167
+ await plugin.connect('device-a');
168
+
169
+ await plugin.send('device-a', 'aa'.repeat(193));
170
+
171
+ expect(device.write.write).toHaveBeenCalledTimes(2);
172
+ expect(wait).not.toHaveBeenCalled();
173
+ });
143
174
  });
@@ -3,7 +3,6 @@ import {
3
3
  HardwareErrorCode,
4
4
  ONEKEY_SERVICE_UUID,
5
5
  isOnekeyDevice,
6
- wait,
7
6
  } from '@onekeyfe/hd-shared';
8
7
 
9
8
  import type { LowLevelDevice, LowlevelTransportSharedPlugin } from '@onekeyfe/hd-transport';
@@ -54,7 +53,6 @@ const CONNECTION_TIMEOUT = 8_000;
54
53
  const SERVICE_DISCOVERY_TIMEOUT = 10_000;
55
54
  const BLE_CLEANUP_TIMEOUT = 100;
56
55
  const BLE_PACKET_SIZE = 192;
57
- const BLE_WRITE_DELAY = 5;
58
56
  const BLE_ENCRYPTION_ERROR_PATTERNS = [/encryption is insufficient/i, /insufficient encryption/i];
59
57
 
60
58
  let noble: NobleModule | null = null;
@@ -468,9 +466,6 @@ export function createNobleBlePlugin(): LowlevelTransportSharedPlugin {
468
466
  for (let offset = 0; offset < buffer.length; offset += BLE_PACKET_SIZE) {
469
467
  const chunk = buffer.subarray(offset, Math.min(offset + BLE_PACKET_SIZE, buffer.length));
470
468
  await writeCharacteristic(characteristics.write, chunk, true);
471
- if (offset + BLE_PACKET_SIZE < buffer.length) {
472
- await wait(BLE_WRITE_DELAY);
473
- }
474
469
  }
475
470
  },
476
471