@onekeyfe/hd-transport-react-native 0.1.11 → 0.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,IAAI,aAAa,EAC3B,MAAM,EAEN,cAAc,EAEf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAiC,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAkB,QAAQ,EAA6B,MAAM,qBAAqB,CAAC;AAa1F,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAmBjE,MAAM,CAAC,OAAO,OAAO,uBAAuB;IAC1C,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IAEzC,SAAS,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAEnE,UAAU,UAAS;IAEnB,OAAO,UAAS;IAEhB,WAAW,SAAQ;IAEnB,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;gBAE5B,OAAO,EAAE,gBAAgB;IAIrC,IAAI;IAEJ,SAAS,CAAC,UAAU,EAAE,GAAG;IAMzB,MAAM;IAIN,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;IAYjC,SAAS;IAsET,OAAO,CAAC,KAAK,EAAE,eAAe;;;IA+JpC,sBAAsB,CAAC,cAAc,EAAE,cAAc;IA4D/C,OAAO,CAAC,IAAI,EAAE,MAAM;IAcpB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IA+EpE,IAAI;IAIJ,MAAM;CAOP"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,IAAI,aAAa,EAC3B,MAAM,EAEN,cAAc,EAEf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAiC,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAEL,QAAQ,EAKT,MAAM,qBAAqB,CAAC;AAa7B,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAqBjE,MAAM,CAAC,OAAO,OAAO,uBAAuB;IAC1C,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IAEzC,SAAS,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAEnE,UAAU,UAAS;IAEnB,OAAO,UAAS;IAEhB,WAAW,SAAQ;IAEnB,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;gBAE5B,OAAO,EAAE,gBAAgB;IAKrC,IAAI;IAEJ,SAAS,CAAC,UAAU,EAAE,GAAG;IAMzB,MAAM;IAIN,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;IAYjC,SAAS;IAoET,OAAO,CAAC,KAAK,EAAE,eAAe;;;IA+JpC,sBAAsB,CAAC,cAAc,EAAE,cAAc;IA4D/C,OAAO,CAAC,IAAI,EAAE,MAAM;IAcpB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IA+EpE,IAAI;IAIJ,MAAM;CAOP"}
package/dist/index.js CHANGED
@@ -166,6 +166,7 @@ class BleTransport {
166
166
 
167
167
  const { check, buildBuffers, receiveOne, parseConfigure } = transport__default["default"];
168
168
  const transportCache = {};
169
+ const Log = hdShared.initLog('@onekey/hd-ble-sdk');
169
170
  let connectOptions = {
170
171
  requestMTU: 512,
171
172
  timeout: 3000,
@@ -187,6 +188,7 @@ class ReactNativeBleTransport {
187
188
  this.scanTimeout = 3000;
188
189
  this.runPromise = null;
189
190
  this.scanTimeout = (_a = options.scanTimeout) !== null && _a !== void 0 ? _a : 3000;
191
+ hdShared.enableLog(true);
190
192
  }
191
193
  init() { }
192
194
  configure(signedData) {
@@ -212,7 +214,7 @@ class ReactNativeBleTransport {
212
214
  yield subscribeBleOn(blePlxManager);
213
215
  }
214
216
  catch (error) {
215
- console.log('subscribeBleOn error: ', error);
217
+ Log.debug('subscribeBleOn error: ', error);
216
218
  reject(error);
217
219
  return;
218
220
  }
@@ -221,8 +223,8 @@ class ReactNativeBleTransport {
221
223
  }, (error, device) => {
222
224
  var _a, _b;
223
225
  if (error) {
224
- console.log('ble scan manager: ', blePlxManager);
225
- console.log('ble scan error: ', error);
226
+ Log.debug('ble scan manager: ', blePlxManager);
227
+ Log.debug('ble scan error: ', error);
226
228
  if ([reactNativeBlePlx.BleErrorCode.BluetoothPoweredOff, reactNativeBlePlx.BleErrorCode.BluetoothInUnknownState].includes(error.errorCode)) {
227
229
  reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BlePermissionError));
228
230
  }
@@ -235,16 +237,16 @@ class ReactNativeBleTransport {
235
237
  return;
236
238
  }
237
239
  if (isOnekeyDevice((_b = device === null || device === void 0 ? void 0 : device.name) !== null && _b !== void 0 ? _b : null, device === null || device === void 0 ? void 0 : device.id)) {
238
- console.log('search device start ======================');
240
+ Log.debug('search device start ======================');
239
241
  const { name, localName, id } = device !== null && device !== void 0 ? device : {};
240
- console.log(`device name: ${name !== null && name !== void 0 ? name : ''}\nlocalName: ${localName !== null && localName !== void 0 ? localName : ''}\nid: ${id !== null && id !== void 0 ? id : ''}`);
242
+ Log.debug(`device name: ${name !== null && name !== void 0 ? name : ''}\nlocalName: ${localName !== null && localName !== void 0 ? localName : ''}\nid: ${id !== null && id !== void 0 ? id : ''}`);
241
243
  addDevice(device);
242
- console.log('search device end ======================\n');
244
+ Log.debug('search device end ======================\n');
243
245
  }
244
246
  });
245
247
  getConnectedDeviceIds(getBluetoothServiceUuids()).then(devices => {
246
248
  for (const device of devices) {
247
- console.log('search connected peripheral: ', device.id);
249
+ Log.debug('search connected peripheral: ', device.id);
248
250
  addDevice(device);
249
251
  }
250
252
  });
@@ -269,7 +271,7 @@ class ReactNativeBleTransport {
269
271
  }
270
272
  let device = null;
271
273
  if (transportCache[uuid]) {
272
- console.log('@onekey/hd-ble-sdk transport not be released, will release: ', uuid);
274
+ Log.debug('transport not be released, will release: ', uuid);
273
275
  yield this.release(uuid);
274
276
  }
275
277
  const blePlxManager = yield this.getPlxManager();
@@ -277,7 +279,7 @@ class ReactNativeBleTransport {
277
279
  yield subscribeBleOn(blePlxManager);
278
280
  }
279
281
  catch (error) {
280
- console.log('subscribeBleOn error: ', error);
282
+ Log.debug('subscribeBleOn error: ', error);
281
283
  throw error;
282
284
  }
283
285
  if (!device) {
@@ -287,16 +289,16 @@ class ReactNativeBleTransport {
287
289
  if (!device) {
288
290
  const connectedDevice = yield blePlxManager.connectedDevices(getBluetoothServiceUuids());
289
291
  const deviceFilter = connectedDevice.filter(device => device.id === uuid);
290
- console.log(`found connected device count: ${deviceFilter.length}`);
292
+ Log.debug(`found connected device count: ${deviceFilter.length}`);
291
293
  [device] = deviceFilter;
292
294
  }
293
295
  if (!device) {
294
- console.log('try to connect to device: ', uuid);
296
+ Log.debug('try to connect to device: ', uuid);
295
297
  try {
296
298
  device = yield blePlxManager.connectToDevice(uuid, connectOptions);
297
299
  }
298
300
  catch (e) {
299
- console.log('try to connect to device has error: ', e);
301
+ Log.debug('try to connect to device has error: ', e);
300
302
  if (e.errorCode === reactNativeBlePlx.BleErrorCode.DeviceMTUChangeFailed ||
301
303
  e.errorCode === reactNativeBlePlx.BleErrorCode.OperationCancelled) {
302
304
  connectOptions = {};
@@ -311,12 +313,12 @@ class ReactNativeBleTransport {
311
313
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleConnectedError, 'unable to connect to device');
312
314
  }
313
315
  if (!(yield device.isConnected())) {
314
- console.log('not connected, try to connect to device: ', uuid);
316
+ Log.debug('not connected, try to connect to device: ', uuid);
315
317
  try {
316
318
  yield device.connect(connectOptions);
317
319
  }
318
320
  catch (e) {
319
- console.log('try to connect to device has error: ', e);
321
+ Log.debug('try to connect to device has error: ', e);
320
322
  if (e.errorCode === reactNativeBlePlx.BleErrorCode.DeviceMTUChangeFailed ||
321
323
  e.errorCode === reactNativeBlePlx.BleErrorCode.OperationCancelled) {
322
324
  connectOptions = {};
@@ -331,7 +333,7 @@ class ReactNativeBleTransport {
331
333
  const bondedDevices = yield getBondedDevices();
332
334
  const hasBonded = !!bondedDevices.find(bondedDevice => bondedDevice.id === (device === null || device === void 0 ? void 0 : device.id));
333
335
  if (!hasBonded) {
334
- throw hdShared.ERRORS.TypedError('device is not bonded');
336
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleDeviceNotBonded, 'device is not bonded');
335
337
  }
336
338
  }
337
339
  yield device.discoverAllServicesAndCharacteristics();
@@ -345,7 +347,7 @@ class ReactNativeBleTransport {
345
347
  break;
346
348
  }
347
349
  catch (e) {
348
- console.log(e);
350
+ Log.error(e);
349
351
  }
350
352
  }
351
353
  }
@@ -385,7 +387,7 @@ class ReactNativeBleTransport {
385
387
  transport.nofitySubscription = this._monitorCharacteristic(transport.notifyCharacteristic);
386
388
  transportCache[uuid] = transport;
387
389
  const disconnectSubscription = device.onDisconnected(() => {
388
- console.log('device disconnect: ', device === null || device === void 0 ? void 0 : device.id);
390
+ Log.debug('device disconnect: ', device === null || device === void 0 ? void 0 : device.id);
389
391
  this.release(uuid);
390
392
  disconnectSubscription === null || disconnectSubscription === void 0 ? void 0 : disconnectSubscription.remove();
391
393
  });
@@ -398,10 +400,10 @@ class ReactNativeBleTransport {
398
400
  const subscription = characteristic.monitor((error, c) => {
399
401
  var _a, _b, _c;
400
402
  if (error) {
401
- console.log(`error monitor ${characteristic.uuid}, deviceId: ${characteristic.deviceID}: ${error}`);
403
+ Log.debug(`error monitor ${characteristic.uuid}, deviceId: ${characteristic.deviceID}: ${error}`);
402
404
  if (this.runPromise) {
403
405
  this.runPromise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleCharacteristicNotifyError, (_a = error.reason) !== null && _a !== void 0 ? _a : error.message));
404
- console.log('@onekey/hd-ble-sdk: monitor notify error, and has unreleased Promise');
406
+ Log.debug(': monitor notify error, and has unreleased Promise');
405
407
  }
406
408
  return;
407
409
  }
@@ -425,12 +427,12 @@ class ReactNativeBleTransport {
425
427
  }
426
428
  }
427
429
  catch (error) {
428
- console.log('monitor data error: ', error);
430
+ Log.debug('monitor data error: ', error);
429
431
  (_c = this.runPromise) === null || _c === void 0 ? void 0 : _c.reject(error);
430
432
  }
431
433
  });
432
434
  return () => {
433
- console.log('remove characteristic monitor: ', characteristic.uuid);
435
+ Log.debug('remove characteristic monitor: ', characteristic.uuid);
434
436
  subscription.remove();
435
437
  };
436
438
  }
@@ -465,7 +467,7 @@ class ReactNativeBleTransport {
465
467
  }
466
468
  this.runPromise = hdShared.createDeferred();
467
469
  const messages = this._messages;
468
- console.log('transport-react-native', 'call-', ' name: ', name, ' data: ', data);
470
+ Log.debug('transport-react-native', 'call-', ' name: ', name, ' data: ', data);
469
471
  const buffers = buildBuffers(messages, name, data);
470
472
  if (name === 'FirmwareUpload') {
471
473
  const packetCapacity = reactNative.Platform.OS === 'ios' ? IOS_PACKET_LENGTH : ANDROID_PACKET_LENGTH;
@@ -477,14 +479,14 @@ class ReactNativeBleTransport {
477
479
  index += 1;
478
480
  if (chunk.offset === packetCapacity || index >= buffers.length) {
479
481
  chunk.reset();
480
- console.log('@onekey/hd-ble-sdk send more packet hex strting: ', chunk.toString('hex'));
482
+ Log.debug('send more packet hex strting: ', chunk.toString('hex'));
481
483
  try {
482
484
  yield transport.writeCharacteristic.writeWithoutResponse(chunk.toString('base64'));
483
485
  chunk = ByteBuffer__default["default"].allocate(packetCapacity);
484
486
  }
485
487
  catch (e) {
486
488
  this.runPromise = null;
487
- console.log('writeCharacteristic write error: ', e);
489
+ Log.error('writeCharacteristic write error: ', e);
488
490
  return;
489
491
  }
490
492
  }
@@ -493,7 +495,7 @@ class ReactNativeBleTransport {
493
495
  else {
494
496
  for (const o of buffers) {
495
497
  const outData = o.toString('base64');
496
- console.log('@onekey/hd-ble-sdk send hex strting: ', o.toString('hex'));
498
+ Log.debug('send hex strting: ', o.toString('hex'));
497
499
  try {
498
500
  yield transport.writeCharacteristic.writeWithoutResponse(outData);
499
501
  }
@@ -502,7 +504,7 @@ class ReactNativeBleTransport {
502
504
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleDeviceNotBonded);
503
505
  }
504
506
  this.runPromise = null;
505
- console.log('writeCharacteristic write error: ', e);
507
+ Log.debug('writeCharacteristic write error: ', e);
506
508
  return;
507
509
  }
508
510
  }
@@ -512,12 +514,12 @@ class ReactNativeBleTransport {
512
514
  if (typeof response !== 'string') {
513
515
  throw new Error('Returning data is not string.');
514
516
  }
515
- console.log('@onekey/hd-ble-sdk receive data: ', response);
517
+ Log.debug('receive data: ', response);
516
518
  const jsonData = receiveOne(messages, response);
517
519
  return check.call(jsonData);
518
520
  }
519
521
  catch (e) {
520
- console.log('call error: ', e);
522
+ Log.error('call error: ', e);
521
523
  return e;
522
524
  }
523
525
  finally {
@@ -529,7 +531,7 @@ class ReactNativeBleTransport {
529
531
  this.stopped = true;
530
532
  }
531
533
  cancel() {
532
- console.log('transport-react-native canceled');
534
+ Log.debug('transport-react-native canceled');
533
535
  if (this.runPromise) ;
534
536
  this.runPromise = null;
535
537
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-react-native",
3
- "version": "0.1.11",
3
+ "version": "0.1.14",
4
4
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -20,10 +20,10 @@
20
20
  "lint:fix": "eslint . --fix"
21
21
  },
22
22
  "dependencies": {
23
- "@onekeyfe/hd-shared": "^0.1.11",
24
- "@onekeyfe/hd-transport": "^0.1.11",
23
+ "@onekeyfe/hd-shared": "^0.1.14",
24
+ "@onekeyfe/hd-transport": "^0.1.14",
25
25
  "react-native-ble-manager": "^8.1.0",
26
26
  "react-native-ble-plx": "^2.0.3"
27
27
  },
28
- "gitHead": "4a71d9d0de15a8179cac16565be09f1c601ddfd5"
28
+ "gitHead": "216fee1795067013da0d68f4fc25f583509bb509"
29
29
  }
package/src/index.ts CHANGED
@@ -9,7 +9,14 @@ import {
9
9
  } from 'react-native-ble-plx';
10
10
  import ByteBuffer from 'bytebuffer';
11
11
  import transport, { COMMON_HEADER_SIZE } from '@onekeyfe/hd-transport';
12
- import { createDeferred, Deferred, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
12
+ import {
13
+ createDeferred,
14
+ Deferred,
15
+ ERRORS,
16
+ HardwareErrorCode,
17
+ enableLog,
18
+ initLog,
19
+ } from '@onekeyfe/hd-shared';
13
20
  import { initializeBleManager, getConnectedDeviceIds, getBondedDevices } from './BleManager';
14
21
  import { subscribeBleOn } from './subscribeBleOn';
15
22
  import {
@@ -28,6 +35,8 @@ const { check, buildBuffers, receiveOne, parseConfigure } = transport;
28
35
 
29
36
  const transportCache: Record<string, any> = {};
30
37
 
38
+ const Log = initLog('@onekey/hd-ble-sdk');
39
+
31
40
  let connectOptions: Record<string, unknown> = {
32
41
  requestMTU: 512,
33
42
  timeout: 3000,
@@ -56,6 +65,7 @@ export default class ReactNativeBleTransport {
56
65
 
57
66
  constructor(options: TransportOptions) {
58
67
  this.scanTimeout = options.scanTimeout ?? 3000;
68
+ enableLog(true);
59
69
  }
60
70
 
61
71
  init() {}
@@ -90,7 +100,7 @@ export default class ReactNativeBleTransport {
90
100
  try {
91
101
  await subscribeBleOn(blePlxManager);
92
102
  } catch (error) {
93
- console.log('subscribeBleOn error: ', error);
103
+ Log.debug('subscribeBleOn error: ', error);
94
104
  reject(error);
95
105
  return;
96
106
  }
@@ -102,8 +112,8 @@ export default class ReactNativeBleTransport {
102
112
  },
103
113
  (error, device) => {
104
114
  if (error) {
105
- console.log('ble scan manager: ', blePlxManager);
106
- console.log('ble scan error: ', error);
115
+ Log.debug('ble scan manager: ', blePlxManager);
116
+ Log.debug('ble scan error: ', error);
107
117
  if (
108
118
  [BleErrorCode.BluetoothPoweredOff, BleErrorCode.BluetoothInUnknownState].includes(
109
119
  error.errorCode
@@ -119,22 +129,20 @@ export default class ReactNativeBleTransport {
119
129
  }
120
130
 
121
131
  if (isOnekeyDevice(device?.name ?? null, device?.id)) {
122
- console.log('search device start ======================');
132
+ Log.debug('search device start ======================');
123
133
 
124
134
  const { name, localName, id } = device ?? {};
125
- console.log(
126
- `device name: ${name ?? ''}\nlocalName: ${localName ?? ''}\nid: ${id ?? ''}`
127
- );
135
+ Log.debug(`device name: ${name ?? ''}\nlocalName: ${localName ?? ''}\nid: ${id ?? ''}`);
128
136
  addDevice(device as unknown as Device);
129
137
 
130
- console.log('search device end ======================\n');
138
+ Log.debug('search device end ======================\n');
131
139
  }
132
140
  }
133
141
  );
134
142
 
135
143
  getConnectedDeviceIds(getBluetoothServiceUuids()).then(devices => {
136
144
  for (const device of devices) {
137
- console.log('search connected peripheral: ', device.id);
145
+ Log.debug('search connected peripheral: ', device.id);
138
146
  addDevice(device as unknown as Device);
139
147
  }
140
148
  });
@@ -166,7 +174,7 @@ export default class ReactNativeBleTransport {
166
174
  * If the transport is not released due to an exception operation
167
175
  * it will be handled again here
168
176
  */
169
- console.log('@onekey/hd-ble-sdk transport not be released, will release: ', uuid);
177
+ Log.debug('transport not be released, will release: ', uuid);
170
178
  await this.release(uuid);
171
179
  }
172
180
 
@@ -174,7 +182,7 @@ export default class ReactNativeBleTransport {
174
182
  try {
175
183
  await subscribeBleOn(blePlxManager);
176
184
  } catch (error) {
177
- console.log('subscribeBleOn error: ', error);
185
+ Log.debug('subscribeBleOn error: ', error);
178
186
  throw error;
179
187
  }
180
188
 
@@ -186,16 +194,16 @@ export default class ReactNativeBleTransport {
186
194
  if (!device) {
187
195
  const connectedDevice = await blePlxManager.connectedDevices(getBluetoothServiceUuids());
188
196
  const deviceFilter = connectedDevice.filter(device => device.id === uuid);
189
- console.log(`found connected device count: ${deviceFilter.length}`);
197
+ Log.debug(`found connected device count: ${deviceFilter.length}`);
190
198
  [device] = deviceFilter;
191
199
  }
192
200
 
193
201
  if (!device) {
194
- console.log('try to connect to device: ', uuid);
202
+ Log.debug('try to connect to device: ', uuid);
195
203
  try {
196
204
  device = await blePlxManager.connectToDevice(uuid, connectOptions);
197
205
  } catch (e) {
198
- console.log('try to connect to device has error: ', e);
206
+ Log.debug('try to connect to device has error: ', e);
199
207
  if (
200
208
  e.errorCode === BleErrorCode.DeviceMTUChangeFailed ||
201
209
  e.errorCode === BleErrorCode.OperationCancelled
@@ -213,12 +221,12 @@ export default class ReactNativeBleTransport {
213
221
  }
214
222
 
215
223
  if (!(await device.isConnected())) {
216
- console.log('not connected, try to connect to device: ', uuid);
224
+ Log.debug('not connected, try to connect to device: ', uuid);
217
225
 
218
226
  try {
219
227
  await device.connect(connectOptions);
220
228
  } catch (e) {
221
- console.log('try to connect to device has error: ', e);
229
+ Log.debug('try to connect to device has error: ', e);
222
230
  if (
223
231
  e.errorCode === BleErrorCode.DeviceMTUChangeFailed ||
224
232
  e.errorCode === BleErrorCode.OperationCancelled
@@ -236,7 +244,7 @@ export default class ReactNativeBleTransport {
236
244
  const bondedDevices = await getBondedDevices();
237
245
  const hasBonded = !!bondedDevices.find(bondedDevice => bondedDevice.id === device?.id);
238
246
  if (!hasBonded) {
239
- throw ERRORS.TypedError('device is not bonded');
247
+ throw ERRORS.TypedError(HardwareErrorCode.BleDeviceNotBonded, 'device is not bonded');
240
248
  }
241
249
  }
242
250
 
@@ -251,7 +259,7 @@ export default class ReactNativeBleTransport {
251
259
  infos = getInfosForServiceUuid(serviceUuid, 'classic');
252
260
  break;
253
261
  } catch (e) {
254
- console.log(e);
262
+ Log.error(e);
255
263
  }
256
264
  }
257
265
  }
@@ -303,7 +311,7 @@ export default class ReactNativeBleTransport {
303
311
  transportCache[uuid] = transport;
304
312
 
305
313
  const disconnectSubscription = device.onDisconnected(() => {
306
- console.log('device disconnect: ', device?.id);
314
+ Log.debug('device disconnect: ', device?.id);
307
315
  this.release(uuid);
308
316
  disconnectSubscription?.remove();
309
317
  });
@@ -316,7 +324,7 @@ export default class ReactNativeBleTransport {
316
324
  let buffer: any[] = [];
317
325
  const subscription = characteristic.monitor((error, c) => {
318
326
  if (error) {
319
- console.log(
327
+ Log.debug(
320
328
  `error monitor ${characteristic.uuid}, deviceId: ${characteristic.deviceID}: ${
321
329
  error as unknown as string
322
330
  }`
@@ -328,7 +336,7 @@ export default class ReactNativeBleTransport {
328
336
  error.reason ?? error.message
329
337
  )
330
338
  );
331
- console.log('@onekey/hd-ble-sdk: monitor notify error, and has unreleased Promise');
339
+ Log.debug(': monitor notify error, and has unreleased Promise');
332
340
  }
333
341
  return;
334
342
  }
@@ -360,13 +368,13 @@ export default class ReactNativeBleTransport {
360
368
  this.runPromise?.resolve(value.toString('hex'));
361
369
  }
362
370
  } catch (error) {
363
- console.log('monitor data error: ', error);
371
+ Log.debug('monitor data error: ', error);
364
372
  this.runPromise?.reject(error);
365
373
  }
366
374
  });
367
375
 
368
376
  return () => {
369
- console.log('remove characteristic monitor: ', characteristic.uuid);
377
+ Log.debug('remove characteristic monitor: ', characteristic.uuid);
370
378
  subscription.remove();
371
379
  };
372
380
  }
@@ -405,7 +413,7 @@ export default class ReactNativeBleTransport {
405
413
 
406
414
  this.runPromise = createDeferred();
407
415
  const messages = this._messages;
408
- console.log('transport-react-native', 'call-', ' name: ', name, ' data: ', data);
416
+ Log.debug('transport-react-native', 'call-', ' name: ', name, ' data: ', data);
409
417
  const buffers = buildBuffers(messages, name, data);
410
418
 
411
419
  if (name === 'FirmwareUpload') {
@@ -418,13 +426,13 @@ export default class ReactNativeBleTransport {
418
426
  index += 1;
419
427
  if (chunk.offset === packetCapacity || index >= buffers.length) {
420
428
  chunk.reset();
421
- console.log('@onekey/hd-ble-sdk send more packet hex strting: ', chunk.toString('hex'));
429
+ Log.debug('send more packet hex strting: ', chunk.toString('hex'));
422
430
  try {
423
431
  await transport.writeCharacteristic.writeWithoutResponse(chunk.toString('base64'));
424
432
  chunk = ByteBuffer.allocate(packetCapacity);
425
433
  } catch (e) {
426
434
  this.runPromise = null;
427
- console.log('writeCharacteristic write error: ', e);
435
+ Log.error('writeCharacteristic write error: ', e);
428
436
  return;
429
437
  }
430
438
  }
@@ -432,7 +440,7 @@ export default class ReactNativeBleTransport {
432
440
  } else {
433
441
  for (const o of buffers) {
434
442
  const outData = o.toString('base64');
435
- console.log('@onekey/hd-ble-sdk send hex strting: ', o.toString('hex'));
443
+ Log.debug('send hex strting: ', o.toString('hex'));
436
444
  try {
437
445
  await transport.writeCharacteristic.writeWithoutResponse(outData);
438
446
  } catch (e) {
@@ -440,7 +448,7 @@ export default class ReactNativeBleTransport {
440
448
  throw ERRORS.TypedError(HardwareErrorCode.BleDeviceNotBonded);
441
449
  }
442
450
  this.runPromise = null;
443
- console.log('writeCharacteristic write error: ', e);
451
+ Log.debug('writeCharacteristic write error: ', e);
444
452
  return;
445
453
  }
446
454
  }
@@ -453,11 +461,11 @@ export default class ReactNativeBleTransport {
453
461
  throw new Error('Returning data is not string.');
454
462
  }
455
463
 
456
- console.log('@onekey/hd-ble-sdk receive data: ', response);
464
+ Log.debug('receive data: ', response);
457
465
  const jsonData = receiveOne(messages, response);
458
466
  return check.call(jsonData);
459
467
  } catch (e) {
460
- console.log('call error: ', e);
468
+ Log.error('call error: ', e);
461
469
  return e;
462
470
  } finally {
463
471
  this.runPromise = null;
@@ -469,7 +477,7 @@ export default class ReactNativeBleTransport {
469
477
  }
470
478
 
471
479
  cancel() {
472
- console.log('transport-react-native canceled');
480
+ Log.debug('transport-react-native canceled');
473
481
  if (this.runPromise) {
474
482
  // this.runPromise.reject(new Error('Transport_CallCanceled'));
475
483
  }