@onekeyfe/hd-transport-electron 1.2.0-alpha.165 → 1.2.0-alpha.167
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.
|
@@ -32,7 +32,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
32
32
|
|
|
33
33
|
function initNobleBleSupport(webContents) {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const { setupNobleBleHandlers } = yield Promise.resolve().then(function () { return require('./noble-ble-handler-
|
|
35
|
+
const { setupNobleBleHandlers } = yield Promise.resolve().then(function () { return require('./noble-ble-handler-ed9148f1.js'); });
|
|
36
36
|
setupNobleBleHandlers(webContents);
|
|
37
37
|
});
|
|
38
38
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-d4b61656.js');
|
|
4
4
|
var hdShared = require('@onekeyfe/hd-shared');
|
|
5
5
|
var pRetry = require('p-retry');
|
|
6
6
|
|
|
@@ -545,6 +545,7 @@ function attemptWindowsWriteUntilPaired(deviceId, doGetWriteCharacteristic, payl
|
|
|
545
545
|
});
|
|
546
546
|
}
|
|
547
547
|
function transmitHexDataToDevice(deviceId, hexData, options) {
|
|
548
|
+
var _a;
|
|
548
549
|
return index.__awaiter(this, void 0, void 0, function* () {
|
|
549
550
|
const characteristics = deviceCharacteristics.get(deviceId);
|
|
550
551
|
const peripheral = connectedDevices.get(deviceId);
|
|
@@ -556,6 +557,14 @@ function transmitHexDataToDevice(deviceId, hexData, options) {
|
|
|
556
557
|
const doGetWriteCharacteristic = () => { var _a; return (_a = deviceCharacteristics.get(deviceId)) === null || _a === void 0 ? void 0 : _a.write; };
|
|
557
558
|
const packetCapacity = resolveBlePacketCapacity(peripheral.mtu, BLE_PACKET_SIZE_MAXIMUM, BLE_PACKET_SIZE_FALLBACK);
|
|
558
559
|
const pacingDelayMs = resolveNobleBleWritePacingDelay(options);
|
|
560
|
+
logger === null || logger === void 0 ? void 0 : logger.info('[NobleBLE] Write frame', {
|
|
561
|
+
deviceId,
|
|
562
|
+
bytes: toBuffer.length,
|
|
563
|
+
head: toBuffer.subarray(0, 8).toString('hex'),
|
|
564
|
+
packetCapacity,
|
|
565
|
+
mtu: (_a = peripheral.mtu) !== null && _a !== void 0 ? _a : null,
|
|
566
|
+
pacingDelayMs,
|
|
567
|
+
});
|
|
559
568
|
if (!IS_WINDOWS || pairedDevices.has(deviceId)) {
|
|
560
569
|
const writeCharacteristic = doGetWriteCharacteristic();
|
|
561
570
|
if (!writeCharacteristic) {
|
|
@@ -1302,6 +1311,11 @@ function subscribeNotifications(deviceId, callback) {
|
|
|
1302
1311
|
timeoutBehavior: 'reject',
|
|
1303
1312
|
});
|
|
1304
1313
|
notifyCharacteristic.on('data', (data) => {
|
|
1314
|
+
logger === null || logger === void 0 ? void 0 : logger.debug('[NobleBLE] Notify frame', {
|
|
1315
|
+
deviceId,
|
|
1316
|
+
bytes: data.length,
|
|
1317
|
+
head: data.subarray(0, 8).toString('hex'),
|
|
1318
|
+
});
|
|
1305
1319
|
if (!pairedDevices.has(deviceId)) {
|
|
1306
1320
|
pairedDevices.add(deviceId);
|
|
1307
1321
|
logger === null || logger === void 0 ? void 0 : logger.info('[NobleBLE] Device paired successfully', { deviceId });
|
|
@@ -1310,9 +1324,14 @@ function subscribeNotifications(deviceId, callback) {
|
|
|
1310
1324
|
});
|
|
1311
1325
|
});
|
|
1312
1326
|
}
|
|
1327
|
+
const subscribeStartedAt = Date.now();
|
|
1313
1328
|
try {
|
|
1314
1329
|
yield rebuildAppSubscription(deviceId, notifyCharacteristic);
|
|
1315
1330
|
subscribedDevices.set(deviceId, true);
|
|
1331
|
+
logger === null || logger === void 0 ? void 0 : logger.info('[NobleBLE] Notification subscription active', {
|
|
1332
|
+
deviceId,
|
|
1333
|
+
ms: Date.now() - subscribeStartedAt,
|
|
1334
|
+
});
|
|
1316
1335
|
}
|
|
1317
1336
|
finally {
|
|
1318
1337
|
subscriptionOperations.set(deviceId, 'idle');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noble-ble-handler.d.ts","sourceRoot":"","sources":["../src/noble-ble-handler.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAA+B,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAoFhE,wBAAgB,+BAA+B,CAAC,OAAO,CAAC,EAAE,oBAAoB,UAI7E;
|
|
1
|
+
{"version":3,"file":"noble-ble-handler.d.ts","sourceRoot":"","sources":["../src/noble-ble-handler.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAA+B,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAoFhE,wBAAgB,+BAA+B,CAAC,OAAO,CAAC,EAAE,oBAAoB,UAI7E;AAutDD,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAkMpE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-electron",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.167",
|
|
4
4
|
"author": "OneKey",
|
|
5
5
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"electron-log": ">=4.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-core": "1.2.0-alpha.
|
|
29
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
30
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
28
|
+
"@onekeyfe/hd-core": "1.2.0-alpha.167",
|
|
29
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.167",
|
|
30
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.167",
|
|
31
31
|
"@stoprocent/noble": "2.3.16",
|
|
32
32
|
"p-retry": "^4.6.2"
|
|
33
33
|
},
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"electron": "^25.0.0",
|
|
37
37
|
"typescript": "^5.3.3"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "aa450044aaef7519d647a1857a38ac3d4e306475"
|
|
40
40
|
}
|
package/src/noble-ble-handler.ts
CHANGED
|
@@ -733,6 +733,17 @@ async function transmitHexDataToDevice(
|
|
|
733
733
|
);
|
|
734
734
|
const pacingDelayMs = resolveNobleBleWritePacingDelay(options);
|
|
735
735
|
|
|
736
|
+
// Diagnostics: the frame header alone (report id + magic + message type +
|
|
737
|
+
// length) identifies which protocol frame went out, without logging payload.
|
|
738
|
+
logger?.info('[NobleBLE] Write frame', {
|
|
739
|
+
deviceId,
|
|
740
|
+
bytes: toBuffer.length,
|
|
741
|
+
head: toBuffer.subarray(0, 8).toString('hex'),
|
|
742
|
+
packetCapacity,
|
|
743
|
+
mtu: peripheral.mtu ?? null,
|
|
744
|
+
pacingDelayMs,
|
|
745
|
+
});
|
|
746
|
+
|
|
736
747
|
if (!IS_WINDOWS || pairedDevices.has(deviceId)) {
|
|
737
748
|
// macOS / Linux or already paired on Windows: direct write
|
|
738
749
|
const writeCharacteristic = doGetWriteCharacteristic();
|
|
@@ -1830,6 +1841,11 @@ async function subscribeNotifications(
|
|
|
1830
1841
|
});
|
|
1831
1842
|
|
|
1832
1843
|
notifyCharacteristic.on('data', (data: Buffer) => {
|
|
1844
|
+
logger?.debug('[NobleBLE] Notify frame', {
|
|
1845
|
+
deviceId,
|
|
1846
|
+
bytes: data.length,
|
|
1847
|
+
head: data.subarray(0, 8).toString('hex'),
|
|
1848
|
+
});
|
|
1833
1849
|
// Windows BLE pairing detection: receiving any data means device is paired
|
|
1834
1850
|
if (!pairedDevices.has(deviceId)) {
|
|
1835
1851
|
pairedDevices.add(deviceId);
|
|
@@ -1840,9 +1856,14 @@ async function subscribeNotifications(
|
|
|
1840
1856
|
});
|
|
1841
1857
|
}
|
|
1842
1858
|
|
|
1859
|
+
const subscribeStartedAt = Date.now();
|
|
1843
1860
|
try {
|
|
1844
1861
|
await rebuildAppSubscription(deviceId, notifyCharacteristic);
|
|
1845
1862
|
subscribedDevices.set(deviceId, true);
|
|
1863
|
+
logger?.info('[NobleBLE] Notification subscription active', {
|
|
1864
|
+
deviceId,
|
|
1865
|
+
ms: Date.now() - subscribeStartedAt,
|
|
1866
|
+
});
|
|
1846
1867
|
} finally {
|
|
1847
1868
|
// 🔒 CRITICAL: Always clear operation state (even on error)
|
|
1848
1869
|
subscriptionOperations.set(deviceId, 'idle');
|