@onekeyfe/hd-transport-react-native 1.2.2-alpha.116 → 1.2.2-alpha.118
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/dist/index.d.ts +13 -59
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +91 -179
- package/package.json +5 -5
- package/src/__tests__/connectTimeout.test.ts +18 -38
- package/src/__tests__/protocolV2Link.test.ts +255 -298
- package/src/index.ts +135 -330
package/dist/index.d.ts
CHANGED
|
@@ -75,27 +75,15 @@ declare function getProtocolV2BleTuning(): {
|
|
|
75
75
|
androidPacketLength: number;
|
|
76
76
|
};
|
|
77
77
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* an aborted discovery) the stack runs its own discovery first and only executes the MTU
|
|
81
|
-
* request after it; single passes on a Pro 2 at MTU 23 measured 1.7-4.8s and a refresh
|
|
82
|
-
* plus restart 7.7s, so the bound has to sit well above those. An exchange the stack holds
|
|
83
|
-
* as already in progress never completes, so a longer bound costs nothing on that link.
|
|
78
|
+
* With no cached GATT table the stack runs its own discovery (up to ~8s) before the MTU
|
|
79
|
+
* exchange, so the bound sits above that; a stuck exchange never completes.
|
|
84
80
|
*/
|
|
85
81
|
declare const ANDROID_MTU_EXCHANGE_TIMEOUT_MS = 12000;
|
|
86
82
|
/**
|
|
87
|
-
* Android keeps an LE link
|
|
88
|
-
*
|
|
89
|
-
* A reconnect inside that window attaches to the same link. The only connectivity signal
|
|
90
|
-
* reachable from here, BluetoothManager.getConnectedDevices(GATT), is built from the
|
|
91
|
-
* per-app GATT client registry rather than the LE link: it empties the moment this client
|
|
92
|
-
* closes on phones with no resident GATT server, and stays populated for the life of the
|
|
93
|
-
* link on phones that have one. So an unusable link is held for at least the quiet period
|
|
94
|
-
* (past the idle timer), and additionally until that registry no longer lists the device,
|
|
95
|
-
* within the overall bound.
|
|
83
|
+
* Android keeps an LE link, with per-link ATT state such as a pending MTU exchange, for its
|
|
84
|
+
* 4s GATT link idle timer after the last client closes; a reconnect inside it reuses the link.
|
|
96
85
|
*/
|
|
97
86
|
declare const ANDROID_LINK_DROP_QUIET_MS = 5000;
|
|
98
|
-
declare const ANDROID_LINK_DROP_TIMEOUT_MS = 8000;
|
|
99
87
|
/**
|
|
100
88
|
* JS backstop for connect. The native adapter applies its own 3s budget, but it
|
|
101
89
|
* schedules that timeout on its serial queue, so a busy queue (e.g. right after a
|
|
@@ -157,25 +145,10 @@ declare class ReactNativeBleTransport {
|
|
|
157
145
|
private confirmedProtocolV2;
|
|
158
146
|
/** Consecutive detections that failed while trusting sessionProtocols. */
|
|
159
147
|
private protocolReprobeFailures;
|
|
160
|
-
/** Endpoints whose last detection got no answer
|
|
148
|
+
/** Endpoints whose last detection got no answer; 'woken' once their Initialize wake is spent. */
|
|
161
149
|
private silentDetections;
|
|
162
|
-
/**
|
|
163
|
-
* Android endpoints whose cached GATT table is suspect and must be rediscovered on the
|
|
164
|
-
* next connect. The cache is no longer refreshed on every connect, so a missing OneKey
|
|
165
|
-
* service or characteristic marks the endpoint instead.
|
|
166
|
-
*/
|
|
150
|
+
/** Android endpoints whose cached GATT table is suspect; the next connect refreshes it. */
|
|
167
151
|
private androidGattCacheRefreshes;
|
|
168
|
-
/** Instance copies of the Android timing bounds so tests can shorten real-time waits. */
|
|
169
|
-
androidMtuExchangeTimeoutMs: number;
|
|
170
|
-
androidLinkDropQuietMs: number;
|
|
171
|
-
androidLinkDropTimeoutMs: number;
|
|
172
|
-
/**
|
|
173
|
-
* Endpoints already sent a Protocol V1 wake. The wake starts a fresh wallet session
|
|
174
|
-
* on the device, and a failed detection tears the link down and reconnects on every
|
|
175
|
-
* poll, so neither set is cleared on teardown: one wake is spent per endpoint until a
|
|
176
|
-
* detection succeeds, which re-arms it for the next time the device sleeps.
|
|
177
|
-
*/
|
|
178
|
-
private protocolWakeAttempts;
|
|
179
152
|
/**
|
|
180
153
|
* Native encryption/pairing failures seen before Protocol V2 probe starts.
|
|
181
154
|
* Pro2/Neo GATT connect can succeed on a stale iOS bond; the CCCD write then
|
|
@@ -236,20 +209,12 @@ declare class ReactNativeBleTransport {
|
|
|
236
209
|
private runLifecycleOperation;
|
|
237
210
|
cancel(): Promise<void>;
|
|
238
211
|
/**
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
* mid-flight stays marked in progress for the whole LE link. A link that already negotiated
|
|
242
|
-
* an MTU answers at once with the recorded value.
|
|
212
|
+
* Android: request the MTU with nothing queued ahead and never close the client while it is
|
|
213
|
+
* outstanding; a link that times out or stays at MTU 23 is dropped.
|
|
243
214
|
*/
|
|
244
215
|
private negotiateAndroidMtu;
|
|
245
|
-
/**
|
|
246
|
-
* Abandon an Android LE link whose per-link GATT state is unusable. Closing the GATT
|
|
247
|
-
* client alone keeps the link up for the stack's idle timer, and Core's retry arrives
|
|
248
|
-
* inside that window, so this holds for at least ANDROID_LINK_DROP_QUIET_MS and until the
|
|
249
|
-
* GATT registry no longer lists the device, capped at ANDROID_LINK_DROP_TIMEOUT_MS.
|
|
250
|
-
*/
|
|
216
|
+
/** Close the client and wait out the link idle timer so the next connect gets a fresh link. */
|
|
251
217
|
private dropAndroidLink;
|
|
252
|
-
private resolveCharacteristicsForAcquire;
|
|
253
218
|
/** Run a native connect under the JS backstop budget. */
|
|
254
219
|
private connectWithTimeout;
|
|
255
220
|
/** Resolve the complete GATT shape under a budget so acquire() always settles. */
|
|
@@ -285,20 +250,9 @@ declare class ReactNativeBleTransport {
|
|
|
285
250
|
private getActiveProtocol;
|
|
286
251
|
private detectProtocol;
|
|
287
252
|
/**
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
* sits in the screensaver loop, whose host-message filter accepts only Initialize and
|
|
292
|
-
* the *Ack messages. GetFeatures and Ping are dropped there without a reply, so no
|
|
293
|
-
* amount of probing can bring the device back.
|
|
294
|
-
*
|
|
295
|
-
* Initialize is the one message that breaks that loop, but it also starts a fresh
|
|
296
|
-
* wallet session, which is why it is not the probe itself — a bare Initialize on every
|
|
297
|
-
* acquire would drop a hidden-wallet session before Core can restore it. Requiring a
|
|
298
|
-
* fully silent previous detection keeps it to devices with no session left to protect.
|
|
299
|
-
*
|
|
300
|
-
* The firmware consumes the wake to leave its loop and does not reliably answer it, so
|
|
301
|
-
* the result is ignored: the probes that follow are what decide the protocol.
|
|
253
|
+
* A sleeping Classic drops GetFeatures/Ping and only leaves its screensaver on Initialize, which
|
|
254
|
+
* resets the wallet session, so it is sent once after a fully silent detection. The firmware does
|
|
255
|
+
* not reliably answer it, so its timeout must not drop the link.
|
|
302
256
|
*/
|
|
303
257
|
private wakeSilentProtocolV1Device;
|
|
304
258
|
private resetProbeStateAfterProtocolProbe;
|
|
@@ -324,4 +278,4 @@ declare class ReactNativeBleTransport {
|
|
|
324
278
|
getProtocolType(path: string): ProtocolType | undefined;
|
|
325
279
|
}
|
|
326
280
|
|
|
327
|
-
export { ANDROID_LINK_DROP_QUIET_MS,
|
|
281
|
+
export { ANDROID_LINK_DROP_QUIET_MS, ANDROID_MTU_EXCHANGE_TIMEOUT_MS, BLE_CONNECT_TIMEOUT_MANAGER_RESET_THRESHOLD, BLE_CONNECT_TIMEOUT_MS, BLE_GATT_SETUP_TIMEOUT_MS, BLE_NATIVE_TEARDOWN_TIMEOUT_MS, BLE_SETUP_WEDGED_MESSAGE, BLE_WRITE_PACKET_TIMEOUT_MS, BLE_WRITE_TIMEOUT_MANAGER_RESET_THRESHOLD, IOneKeyDevice, PROTOCOL_REPROBE_FALLBACK_ATTEMPTS, ProtocolV2BleTuning, configureProtocolV2BleTuning, ReactNativeBleTransport as default, getFirmwareUploadWriteRetryType, getProtocolV2BleTuning, resetProtocolV2BleTuning };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAGL,UAAU,IAAI,aAAa,EAG5B,MAAM,sBAA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