react-native-beidou 1.0.8 → 1.1.2

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.
Files changed (26) hide show
  1. package/BeiDouAIDLTestPage.tsx +505 -19
  2. package/LogManager.ts +4 -0
  3. package/README.md +108 -63
  4. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  5. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  7. package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
  8. package/android/.idea/caches/deviceStreaming.xml +993 -0
  9. package/android/build.gradle +9 -9
  10. package/android/src/main/AndroidManifest.xml +2 -0
  11. package/android/src/main/java/com/fxzs.rnbeidou/BeiDouBluetoothModule.java +195 -217
  12. package/android/src/main/java/com/fxzs.rnbeidou/BeidouAidlHelper.java +643 -0
  13. package/index.ts +223 -89
  14. package/ios/BeiDouBluetoothModule.m +26 -1
  15. package/ios/BeidouBluetooth.framework/BeidouBluetooth +0 -0
  16. package/ios/BeidouBluetooth.framework/FMDB.bundle/Info.plist +0 -0
  17. package/ios/BeidouBluetooth.framework/FMDB.bundle/PrivacyInfo.xcprivacy +14 -0
  18. package/ios/BeidouBluetooth.framework/Headers/BDTLocationService.h +24 -0
  19. package/ios/BeidouBluetooth.framework/Headers/BeidouBluetooth.h +3 -1
  20. package/ios/BeidouBluetooth.framework/Info.plist +0 -0
  21. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeDirectory +0 -0
  22. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeRequirements-1 +0 -0
  23. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeResources +49 -4
  24. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeSignature +0 -0
  25. package/package.json +2 -1
  26. package/react-native-beidou.podspec +26 -0
package/index.ts CHANGED
@@ -31,9 +31,17 @@ export type BluetoothStatus = 'NotSupported' | 'NO' | 'OK';
31
31
 
32
32
  // ================== 北斗AIDL服务相关类型定义 ==================
33
33
  export interface BDStatusResponse {
34
+ slotId?: number;
34
35
  code: number;
35
36
  statusMsg: string;
36
37
  msgQuotaRemain: number;
38
+ userOpenStatus: number;
39
+ }
40
+
41
+ export interface BDAuthResult {
42
+ slotId: number;
43
+ code: number;
44
+ statusMsg: string | null;
37
45
  }
38
46
 
39
47
  export interface BDMsgEncryptResponse {
@@ -41,6 +49,7 @@ export interface BDMsgEncryptResponse {
41
49
  statusMsg: string;
42
50
  data: number[]; // byte array as number array
43
51
  sendMobile: string;
52
+ len: number;
44
53
  }
45
54
 
46
55
  export interface BDMsgDecryptResponse {
@@ -51,9 +60,11 @@ export interface BDMsgDecryptResponse {
51
60
  }
52
61
 
53
62
  export interface BDMsgEphemerisFileDLResponse {
63
+ slotId: number;
54
64
  code: number;
55
65
  statusMsg: string;
56
66
  ephemerisZipFile: number[]; // byte array as number array
67
+ ephemerisZipFileName: string | null;
57
68
  version: string;
58
69
  }
59
70
 
@@ -76,60 +87,17 @@ export interface MessageInfo {
76
87
  timestamp: number;
77
88
  }
78
89
 
79
- // ================== 蓝牙模块接口定义 ==================
80
- interface BeiDouBluetoothModuleType {
81
- // 原有蓝牙相关方法
82
- getAllConversations(): Promise<string>; // 更新为Promise版本
83
- startScanForService(callback: (res: number) => void): void;
84
- stopScanning(): void;
85
- getDiscoveredDevices(): Promise<string>; // JSON string of BlueDeviceInfoEntity[]
86
- connectToDeviceFromCloudDeviceNO(deviceNO: string, a: number): Promise<'ok' | 'fail'>;
87
- getAndroidNetWorkInfo(callback: (netWorkInfo: NetworkInfo) => void): void;
88
- checkBlueToothPermission(callback: (status: BluetoothPermissionStatus) => void): void;
89
- shouldShowBlueToothPermissionRationale(params: string, callback: (status: BluetoothPermissionRationaleStatus) => void): void;
90
- initializeBluetooth(callback: (status: BluetoothStatus) => void): void;
91
- generateRandom16BytesString(): string;
92
- writeData(randomString: string, deviceNo: string, command: number, attrType: number, callback: (result: number) => void): void;
93
-
94
- // 新增的iOS兼容方法
95
- writeInfo(base64Payload: string | null, deviceNO: string, command: number, opCode: number, attrType: number, encrypted: boolean): Promise<WriteInfoResponse>;
96
- insertMsg(phone: string, content: string, timestamp: number, isSend: boolean): void;
97
- getMessagesForPhone(phone: string, page: number, pageSize: number, callback: (result: string) => void): void;
98
- setBLEKey(bleKey: string): Promise<number>;
99
-
100
- // 原有方法保持兼容
101
- writeValueInfo(randomString: string, deviceNo: string, command: number, attrType: number, value: number, callback: (result: any) => void): void;
102
- disConnectWithDeviceUUID(deviceNo: string): Promise<number>;
103
- fetchCurrentWifiName(callback: (wifiName: string) => void): void;
104
-
105
- // 北斗AIDL服务绑定方法
106
- bindBeidouServiceMethod(packageName: string, actionName: string): Promise<boolean>;
107
- unbindBeidouServiceMethod(): Promise<boolean>;
108
-
109
- // 北斗AIDL服务方法 (需要在Java端实现)
110
- BDAuthenticate(): Promise<boolean>;
111
- getBDMsgStatus(): Promise<BDStatusResponse>;
112
- checkValidatedKey(): Promise<number>;
113
- commonBDMsgEncrypt(receiveList: string[], inputMsg: string): Promise<BDMsgEncryptResponse>;
114
- positionBDMsgEncrypt(receiveList: string[], inputMsg: string, longitude: number, latitude: number): Promise<BDMsgEncryptResponse>;
115
- BDMailboxQueryEncrypt(): Promise<BDMsgEncryptResponse>;
116
- BDMsgDecrypt(msg: number[], len: number): Promise<BDMsgDecryptResponse>;
117
- DLEphemerisFile(type: string, version: string): Promise<BDMsgEphemerisFileDLResponse>;
118
-
119
- // 位置
120
- getGpsLocation(): Promise<{
121
- latitude: number;
122
- longitude: number;
123
- provider: string;
124
- accuracy: number;
125
- timestamp: number;
126
- } | null>;
127
-
128
- // 日志管理相关方法
129
- configureLogger(enableFileLog: boolean, enableConsoleLog: boolean, maxFileSize: number, maxFileCount: number, encryptionKey: string | null): Promise<boolean>;
130
- getLogStats(): Promise<string>;
131
- clearAllLogs(): Promise<boolean>;
132
- writeLog(level: string, tag: string, message: string): Promise<boolean>;
90
+ export interface SimCardInfo {
91
+ subscriptionId: number;
92
+ simSlotIndex: number;
93
+ carrierName: string | null;
94
+ displayName: string | null;
95
+ countryIso: string | null;
96
+ mcc: number;
97
+ mnc: number;
98
+ isEmbedded: boolean;
99
+ isOpportunistic: boolean;
100
+ number: string | null;
133
101
  }
134
102
 
135
103
  // ================== 导出的便利方法 ==================
@@ -195,6 +163,14 @@ export const getDiscoveredDevicesArray = async (): Promise<BlueDeviceInfo[]> =>
195
163
  }
196
164
  };
197
165
 
166
+ /**
167
+ * 获取当前设备的SIM卡列表
168
+ */
169
+ export const getSimCardList = async (): Promise<SimCardInfo[]> => {
170
+ const list = await BeiDouBluetoothModule.getSimCardList();
171
+ return list ?? [];
172
+ };
173
+
198
174
  /**
199
175
  * 绑定北斗AIDL服务
200
176
  * @param packageName 北斗服务的包名
@@ -214,72 +190,159 @@ export const unbindBeiDouService = async (): Promise<boolean> => {
214
190
  /**
215
191
  * 北斗服务鉴权
216
192
  */
217
- export const authenticateBeiDou = async (): Promise<boolean> => {
218
- return await BeiDouBluetoothModule.BDAuthenticate();
193
+ export const authenticateBeiDou = async (slotId: number = 0): Promise<BDAuthResult> => {
194
+ return await BeiDouBluetoothModule.BDAuthenticate(slotId);
219
195
  };
220
196
 
221
197
  /**
222
198
  * 查询北斗用户开通状态及额度
223
199
  */
224
- export const getBeiDouStatus = async (): Promise<BDStatusResponse> => {
225
- return await BeiDouBluetoothModule.getBDMsgStatus();
200
+ export const getBeiDouStatus = async (slotId: number = 0): Promise<BDStatusResponse> => {
201
+ return await BeiDouBluetoothModule.getBDMsgStatus(slotId);
226
202
  };
227
203
 
228
204
  /**
229
205
  * 检查北斗密钥状态
230
206
  */
231
- export const checkBeiDouKey = async (): Promise<number> => {
232
- return await BeiDouBluetoothModule.checkValidatedKey();
207
+ export const checkBeiDouKey = async (slotId: number = 0): Promise<number> => {
208
+ return await BeiDouBluetoothModule.checkValidatedKey(slotId);
233
209
  };
234
210
 
235
211
  /**
236
212
  * 通用北斗报文编码加密
237
213
  */
238
214
  export const encryptCommonBeiDouMessage = async (
215
+ slotId: number = 0,
216
+ speedType: string = '0',
239
217
  receiveList: string[],
240
218
  inputMsg: string
241
- ): Promise<BDMsgEncryptResponse> => {
242
- return await BeiDouBluetoothModule.commonBDMsgEncrypt(receiveList, inputMsg);
243
- };
219
+ ): Promise<BDMsgEncryptResponse[]> => BeiDouBluetoothModule.commonBDMsgEncrypt(slotId, speedType, receiveList, inputMsg);
244
220
 
245
221
  /**
246
222
  * 位置信息北斗报文编码加密
247
223
  */
248
224
  export const encryptPositionBeiDouMessage = async (
225
+ slotId: number = 0,
226
+ speedType: string = '0',
249
227
  receiveList: string[],
250
228
  inputMsg: string,
251
229
  longitude: number,
252
230
  latitude: number
253
- ): Promise<BDMsgEncryptResponse> => {
254
- return await BeiDouBluetoothModule.positionBDMsgEncrypt(receiveList, inputMsg, longitude, latitude);
255
- };
231
+ ): Promise<BDMsgEncryptResponse[]> =>
232
+ BeiDouBluetoothModule.positionBDMsgEncrypt(slotId, speedType, receiveList, inputMsg, longitude, latitude);
233
+
234
+ export const encryptCommonEmergencyBeiDouMessage = async (
235
+ slotId: number = 0,
236
+ speedType: string = '0',
237
+ receiveList: string[],
238
+ inputMsg: string
239
+ ): Promise<BDMsgEncryptResponse[]> =>
240
+ BeiDouBluetoothModule.commonEmergencyBDMsgEncrypt(slotId, speedType, receiveList, inputMsg);
241
+
242
+ export const encryptPositionEmergencyBeiDouMessage = async (
243
+ slotId: number = 0,
244
+ speedType: string = '0',
245
+ receiveList: string[],
246
+ inputMsg: string,
247
+ longitude: number,
248
+ latitude: number
249
+ ): Promise<BDMsgEncryptResponse[]> =>
250
+ BeiDouBluetoothModule.positionEmergencyBDMsgEncrypt(slotId, speedType, receiveList, inputMsg, longitude, latitude);
251
+
252
+ export const encryptCommonRichMediaBeiDouMessage = async (
253
+ slotId: number = 0,
254
+ speedType: string = '0',
255
+ receiveList: string[],
256
+ msgType: string,
257
+ inputRichMediaData: number[]
258
+ ): Promise<BDMsgEncryptResponse[]> =>
259
+ BeiDouBluetoothModule.commonRichMediaBDMsgEncrypt(slotId, speedType, receiveList, msgType, inputRichMediaData);
260
+
261
+ export const encryptPositionRichMediaBeiDouMessage = async (
262
+ slotId: number = 0,
263
+ speedType: string = '0',
264
+ receiveList: string[],
265
+ msgType: string,
266
+ inputRichMediaData: number[],
267
+ longitude: number,
268
+ latitude: number
269
+ ): Promise<BDMsgEncryptResponse[]> =>
270
+ BeiDouBluetoothModule.positionRichMediaBDMsgEncrypt(
271
+ slotId,
272
+ speedType,
273
+ receiveList,
274
+ msgType,
275
+ inputRichMediaData,
276
+ longitude,
277
+ latitude
278
+ );
279
+
280
+ export const encryptCommonRichMediaAndTextBeiDouMessage = async (
281
+ slotId: number = 0,
282
+ speedType: string = '0',
283
+ receiveList: string[],
284
+ text: string,
285
+ msgType: string,
286
+ inputRichMediaData: number[]
287
+ ): Promise<BDMsgEncryptResponse[]> =>
288
+ BeiDouBluetoothModule.commonRichMediaAndTextBDMsgEncrypt(
289
+ slotId,
290
+ speedType,
291
+ receiveList,
292
+ text,
293
+ msgType,
294
+ inputRichMediaData
295
+ );
296
+
297
+ export const encryptPositionRichMediaAndTextBeiDouMessage = async (
298
+ slotId: number = 0,
299
+ speedType: string = '0',
300
+ receiveList: string[],
301
+ text: string,
302
+ msgType: string,
303
+ inputRichMediaData: number[],
304
+ longitude: number,
305
+ latitude: number
306
+ ): Promise<BDMsgEncryptResponse[]> =>
307
+ BeiDouBluetoothModule.positionRichMediaAndTextBDMsgEncrypt(
308
+ slotId,
309
+ speedType,
310
+ receiveList,
311
+ text,
312
+ msgType,
313
+ inputRichMediaData,
314
+ longitude,
315
+ latitude
316
+ );
256
317
 
257
318
  /**
258
319
  * 北斗信箱查询请求加密
259
320
  */
260
- export const encryptBeiDouMailboxQuery = async (): Promise<BDMsgEncryptResponse> => {
261
- return await BeiDouBluetoothModule.BDMailboxQueryEncrypt();
262
- };
321
+ export const encryptBeiDouMailboxQuery = async (slotId: number = 0): Promise<BDMsgEncryptResponse> =>
322
+ BeiDouBluetoothModule.BDMailboxQueryEncrypt(slotId);
323
+
324
+ export const encryptEmergencyBeiDouMailboxQuery = async (
325
+ slotId: number = 0,
326
+ replyMobile: string
327
+ ): Promise<BDMsgEncryptResponse> => BeiDouBluetoothModule.EmergencyBDMailboxQueryEncrypt(slotId, replyMobile);
263
328
 
264
329
  /**
265
330
  * 北斗报文解密
266
331
  */
267
332
  export const decryptBeiDouMessage = async (
333
+ slotId: number = 0,
268
334
  msg: number[],
269
335
  len: number
270
- ): Promise<BDMsgDecryptResponse> => {
271
- return await BeiDouBluetoothModule.BDMsgDecrypt(msg, len);
272
- };
336
+ ): Promise<BDMsgDecryptResponse> => BeiDouBluetoothModule.BDMsgDecrypt(slotId, msg, len);
273
337
 
274
338
  /**
275
339
  * 下载北斗星历文件
276
340
  */
277
341
  export const downloadEphemerisFile = async (
342
+ slotId: number = 0,
278
343
  type: string,
279
344
  version: string
280
- ): Promise<BDMsgEphemerisFileDLResponse> => {
281
- return await BeiDouBluetoothModule.DLEphemerisFile(type, version);
282
- };
345
+ ): Promise<BDMsgEphemerisFileDLResponse> => BeiDouBluetoothModule.DLEphemerisFile(slotId, type, version);
283
346
 
284
347
  // ================== 新增iOS兼容方法的便利函数 ==================
285
348
 
@@ -356,8 +419,6 @@ export const setBeiDouBLEKey = async (bleKey: string): Promise<boolean> => {
356
419
  }
357
420
  };
358
421
 
359
- // export default BeiDouBluetoothModule as BeiDouBluetoothModuleType;
360
-
361
422
  export const BeiDouModule = {
362
423
  // 蓝牙相关
363
424
  bluetooth: {
@@ -387,6 +448,7 @@ export const BeiDouModule = {
387
448
  checkBluetoothPermission,
388
449
  initializeBluetooth,
389
450
  fetchCurrentWifiName,
451
+ getSimCardList,
390
452
  getGpsLocation: (): Promise<{
391
453
  latitude: number;
392
454
  longitude: number;
@@ -403,14 +465,78 @@ export const BeiDouModule = {
403
465
  unbindService: unbindBeiDouService,
404
466
 
405
467
  // 核心功能
406
- authenticate: authenticateBeiDou,
407
- getStatus: getBeiDouStatus,
408
- checkKey: checkBeiDouKey,
409
- encryptCommonMessage: encryptCommonBeiDouMessage,
410
- encryptPositionMessage: encryptPositionBeiDouMessage,
411
- encryptMailboxQuery: encryptBeiDouMailboxQuery,
412
- decryptMessage: decryptBeiDouMessage,
413
- downloadEphemeris: downloadEphemerisFile,
468
+ authenticate: (slotId: number = 0) => authenticateBeiDou(slotId),
469
+ getStatus: (slotId: number = 0) => getBeiDouStatus(slotId),
470
+ checkKey: (slotId: number = 0) => checkBeiDouKey(slotId),
471
+ encryptCommonMessage: (
472
+ slotId: number,
473
+ speedType: string,
474
+ receiveList: string[],
475
+ inputMsg: string
476
+ ) => encryptCommonBeiDouMessage(slotId, speedType, receiveList, inputMsg),
477
+ encryptPositionMessage: (
478
+ slotId: number,
479
+ speedType: string,
480
+ receiveList: string[],
481
+ inputMsg: string,
482
+ longitude: number,
483
+ latitude: number
484
+ ) => encryptPositionBeiDouMessage(slotId, speedType, receiveList, inputMsg, longitude, latitude),
485
+ encryptCommonEmergencyMessage: (
486
+ slotId: number,
487
+ speedType: string,
488
+ receiveList: string[],
489
+ inputMsg: string
490
+ ) => encryptCommonEmergencyBeiDouMessage(slotId, speedType, receiveList, inputMsg),
491
+ encryptPositionEmergencyMessage: (
492
+ slotId: number,
493
+ speedType: string,
494
+ receiveList: string[],
495
+ inputMsg: string,
496
+ longitude: number,
497
+ latitude: number
498
+ ) => encryptPositionEmergencyBeiDouMessage(slotId, speedType, receiveList, inputMsg, longitude, latitude),
499
+ encryptCommonRichMediaMessage: (
500
+ slotId: number,
501
+ speedType: string,
502
+ receiveList: string[],
503
+ msgType: string,
504
+ data: number[]
505
+ ) => encryptCommonRichMediaBeiDouMessage(slotId, speedType, receiveList, msgType, data),
506
+ encryptPositionRichMediaMessage: (
507
+ slotId: number,
508
+ speedType: string,
509
+ receiveList: string[],
510
+ msgType: string,
511
+ data: number[],
512
+ longitude: number,
513
+ latitude: number
514
+ ) => encryptPositionRichMediaBeiDouMessage(slotId, speedType, receiveList, msgType, data, longitude, latitude),
515
+ encryptCommonRichMediaAndTextMessage: (
516
+ slotId: number,
517
+ speedType: string,
518
+ receiveList: string[],
519
+ text: string,
520
+ msgType: string,
521
+ data: number[]
522
+ ) => encryptCommonRichMediaAndTextBeiDouMessage(slotId, speedType, receiveList, text, msgType, data),
523
+ encryptPositionRichMediaAndTextMessage: (
524
+ slotId: number,
525
+ speedType: string,
526
+ receiveList: string[],
527
+ text: string,
528
+ msgType: string,
529
+ data: number[],
530
+ longitude: number,
531
+ latitude: number
532
+ ) =>
533
+ encryptPositionRichMediaAndTextBeiDouMessage(slotId, speedType, receiveList, text, msgType, data, longitude, latitude),
534
+ encryptMailboxQuery: (slotId: number = 0) => encryptBeiDouMailboxQuery(slotId),
535
+ encryptEmergencyMailboxQuery: (replyMobile: string, slotId: number = 0) =>
536
+ encryptEmergencyBeiDouMailboxQuery(slotId, replyMobile),
537
+ decryptMessage: (msg: number[], len: number, slotId: number = 0) => decryptBeiDouMessage(slotId, msg, len),
538
+ downloadEphemeris: (type: string, version: string, slotId: number = 0) =>
539
+ downloadEphemerisFile(slotId, type, version),
414
540
  },
415
541
 
416
542
  // 所有原生方法的原名导出
@@ -436,6 +562,7 @@ export const BeiDouModule = {
436
562
  insertMsg: insertBeiDouMessage,
437
563
  getMessagesForPhone: getMessagesForPhoneNumber,
438
564
  setBLEKey: BeiDouBluetoothModule.setBLEKey,
565
+ getSimCardList: BeiDouBluetoothModule.getSimCardList,
439
566
 
440
567
  // 北斗AIDL服务绑定方法
441
568
  bindBeidouServiceMethod: BeiDouBluetoothModule.bindBeidouServiceMethod,
@@ -447,7 +574,14 @@ export const BeiDouModule = {
447
574
  checkValidatedKey: BeiDouBluetoothModule.checkValidatedKey,
448
575
  commonBDMsgEncrypt: BeiDouBluetoothModule.commonBDMsgEncrypt,
449
576
  positionBDMsgEncrypt: BeiDouBluetoothModule.positionBDMsgEncrypt,
577
+ commonEmergencyBDMsgEncrypt: BeiDouBluetoothModule.commonEmergencyBDMsgEncrypt,
578
+ positionEmergencyBDMsgEncrypt: BeiDouBluetoothModule.positionEmergencyBDMsgEncrypt,
579
+ commonRichMediaBDMsgEncrypt: BeiDouBluetoothModule.commonRichMediaBDMsgEncrypt,
580
+ positionRichMediaBDMsgEncrypt: BeiDouBluetoothModule.positionRichMediaBDMsgEncrypt,
581
+ commonRichMediaAndTextBDMsgEncrypt: BeiDouBluetoothModule.commonRichMediaAndTextBDMsgEncrypt,
582
+ positionRichMediaAndTextBDMsgEncrypt: BeiDouBluetoothModule.positionRichMediaAndTextBDMsgEncrypt,
450
583
  BDMailboxQueryEncrypt: BeiDouBluetoothModule.BDMailboxQueryEncrypt,
584
+ EmergencyBDMailboxQueryEncrypt: BeiDouBluetoothModule.EmergencyBDMailboxQueryEncrypt,
451
585
  BDMsgDecrypt: BeiDouBluetoothModule.BDMsgDecrypt,
452
586
  DLEphemerisFile: BeiDouBluetoothModule.DLEphemerisFile,
453
587
  getGpsLocation: (): Promise<{
@@ -464,10 +598,9 @@ export default BeiDouModule;
464
598
  export { default as Compass } from './Compass';
465
599
 
466
600
  // 导出日志管理功能
467
- export {
468
- BeiDouLogManager,
469
- BeiDouLogger,
470
- LogConfig,
601
+ export {
602
+ BeiDouLogManager,
603
+ BeiDouLogger,
471
604
  LogLevel,
472
605
  logVerbose,
473
606
  logDebug,
@@ -476,5 +609,6 @@ export {
476
609
  logError,
477
610
  setupGlobalLogInterception
478
611
  } from './LogManager';
612
+ export type { LogConfig } from './LogManager';
479
613
 
480
614
 
@@ -93,7 +93,7 @@ RCT_EXPORT_METHOD(getDiscoveredDevices:(RCTPromiseResolveBlock)resolve rejecter:
93
93
 
94
94
  /// 连接蓝牙设备
95
95
  /// - Parameter resolve: 连接成功回调
96
- /// - Parameter reject: 连接失败回调 0:连接失败 3:用户拒绝授权 4:系统蓝牙开关关闭
96
+ /// - Parameter reject: 连接失败回调 0:连 接失败 3:用户拒绝授权 4:系统蓝牙开关关闭
97
97
  RCT_EXPORT_METHOD(connectToDeviceFromCloudDeviceNO:(NSString *)deviceNO
98
98
  timeout:(nonnull NSNumber *)second
99
99
  resolve:(RCTPromiseResolveBlock)resolve
@@ -420,5 +420,30 @@ RCT_EXPORT_METHOD(initializeBluetooth:(RCTResponseSenderBlock)callBack){
420
420
  }];
421
421
  }
422
422
 
423
+ RCT_REMAP_METHOD(getGpsLocation,
424
+ resolver:(RCTPromiseResolveBlock)resolve
425
+ rejecter:(RCTPromiseRejectBlock)reject)
426
+ {
427
+ // 确保在主线程执行
428
+ dispatch_async(dispatch_get_main_queue(), ^{
429
+ [[BDTLocationService shared] getCurrentLocationWithCompletion:^(double latitude, double longitude, NSError *error) {
430
+ if (error) {
431
+ // 获取位置失败,返回 null
432
+ resolve([NSNull null]);
433
+ } else {
434
+ // 获取位置成功,构建返回对象
435
+ NSDictionary *locationData = @{
436
+ @"latitude": @(latitude),
437
+ @"longitude": @(longitude),
438
+ @"provider": @"gps", // iOS 中定位来源
439
+ @"accuracy": @(0.0), // 如果需要精度信息,需要在 LocationService 中获取
440
+ @"timestamp": @([[NSDate date] timeIntervalSince1970] * 1000) // 毫秒时间戳
441
+ };
442
+ resolve(locationData);
443
+ }
444
+ }];
445
+ });
446
+ }
447
+
423
448
 
424
449
  @end
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>NSPrivacyTracking</key>
6
+ <false/>
7
+ <key>NSPrivacyTrackingDomains</key>
8
+ <array/>
9
+ <key>NSPrivacyCollectedDataTypes</key>
10
+ <array/>
11
+ <key>NSPrivacyAccessedAPITypes</key>
12
+ <array/>
13
+ </dict>
14
+ </plist>
@@ -0,0 +1,24 @@
1
+ //
2
+ // BDTLocationService.h
3
+ // BeidouBluetooth
4
+ //
5
+ // Created by 董建伟 on 2025/11/5.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <CoreLocation/CoreLocation.h>
10
+
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ typedef void (^LocationCompletionBlock)(double latitude, double longitude, NSError * _Nullable error);
14
+
15
+ @interface BDTLocationService : NSObject
16
+
17
+ + (instancetype)shared;
18
+
19
+ // 获取一次经纬度
20
+ - (void)getCurrentLocationWithCompletion:(LocationCompletionBlock)completion;
21
+
22
+ @end
23
+
24
+ NS_ASSUME_NONNULL_END
@@ -2,7 +2,7 @@
2
2
  // BeidouBluetooth.h
3
3
  // BeidouBluetooth
4
4
  //
5
- // Created by 董建伟 on 2025/8/12.
5
+ // Created by 董建伟 on 2025/11/4.
6
6
  //
7
7
 
8
8
  #import <Foundation/Foundation.h>
@@ -15,7 +15,9 @@ FOUNDATION_EXPORT const unsigned char BeidouBluetoothVersionString[];
15
15
 
16
16
  // In this header, you should import all the public headers of your framework using statements like #import <BeidouBluetooth/PublicHeader.h>
17
17
 
18
+
18
19
  #import <BeidouBluetooth/BDTBluetoothManager.h>
19
20
  #import <BeidouBluetooth/BDTDataPacketBuilder.h>
20
21
  #import <BeidouBluetooth/BDTChatDBManager.h>
22
+ #import <BeidouBluetooth/BDTLocationService.h>
21
23
 
@@ -4,6 +4,14 @@
4
4
  <dict>
5
5
  <key>files</key>
6
6
  <dict>
7
+ <key>FMDB.bundle/Info.plist</key>
8
+ <data>
9
+ fQm/OgDmwDzxKX8rvFINy7CJkJ4=
10
+ </data>
11
+ <key>FMDB.bundle/PrivacyInfo.xcprivacy</key>
12
+ <data>
13
+ ucg9pita0v8d353x3NuGfxweQYU=
14
+ </data>
7
15
  <key>Headers/BDTBluetoothManager.h</key>
8
16
  <data>
9
17
  Mke3zeUQy40YfFrfW2gJ82VfWV4=
@@ -16,13 +24,17 @@
16
24
  <data>
17
25
  M2mub8VwH6cd3mT+Cmj6jU/wxfs=
18
26
  </data>
27
+ <key>Headers/BDTLocationService.h</key>
28
+ <data>
29
+ RzN/dKza3l/TAtgAS9ZuWVtxszs=
30
+ </data>
19
31
  <key>Headers/BeidouBluetooth.h</key>
20
32
  <data>
21
- GT//uw00ZbbeeNIbQ1sZNM1rENU=
33
+ pjIaMEI7NmkpW/V7pIaOIcpW/8E=
22
34
  </data>
23
35
  <key>Info.plist</key>
24
36
  <data>
25
- DR5ddGL6XEMpus+lIMmzGrdLRFQ=
37
+ XA4b0GI82DRY0I4G277GU6YcIDc=
26
38
  </data>
27
39
  <key>Modules/module.modulemap</key>
28
40
  <data>
@@ -31,6 +43,28 @@
31
43
  </dict>
32
44
  <key>files2</key>
33
45
  <dict>
46
+ <key>FMDB.bundle/Info.plist</key>
47
+ <dict>
48
+ <key>hash</key>
49
+ <data>
50
+ fQm/OgDmwDzxKX8rvFINy7CJkJ4=
51
+ </data>
52
+ <key>hash2</key>
53
+ <data>
54
+ BeV82aZzyEQ+5IJExHzOKtyngMdCpF/kTedm1V+R9cA=
55
+ </data>
56
+ </dict>
57
+ <key>FMDB.bundle/PrivacyInfo.xcprivacy</key>
58
+ <dict>
59
+ <key>hash</key>
60
+ <data>
61
+ ucg9pita0v8d353x3NuGfxweQYU=
62
+ </data>
63
+ <key>hash2</key>
64
+ <data>
65
+ Uh6274Qwdz5cAQ4YOP6d2PpdYre3bRzqjX2NqtyxROI=
66
+ </data>
67
+ </dict>
34
68
  <key>Headers/BDTBluetoothManager.h</key>
35
69
  <dict>
36
70
  <key>hash</key>
@@ -64,15 +98,26 @@
64
98
  HDzbJwP03m263UzurGCq5CnM2RmRkmJAvzRPsKAmZ9U=
65
99
  </data>
66
100
  </dict>
101
+ <key>Headers/BDTLocationService.h</key>
102
+ <dict>
103
+ <key>hash</key>
104
+ <data>
105
+ RzN/dKza3l/TAtgAS9ZuWVtxszs=
106
+ </data>
107
+ <key>hash2</key>
108
+ <data>
109
+ H3MgmiqqbNExoGreVNN3gPO81RCdL/r1NmAFF12PG4c=
110
+ </data>
111
+ </dict>
67
112
  <key>Headers/BeidouBluetooth.h</key>
68
113
  <dict>
69
114
  <key>hash</key>
70
115
  <data>
71
- GT//uw00ZbbeeNIbQ1sZNM1rENU=
116
+ pjIaMEI7NmkpW/V7pIaOIcpW/8E=
72
117
  </data>
73
118
  <key>hash2</key>
74
119
  <data>
75
- 9KnESYsMN0jIa0J3X3LKKHNDT/8mnHWXbXdWEShMazo=
120
+ 7B/Mf1b1ApHkKh4ojqs364EJalW6lo6L8V3Bmv1gnvs=
76
121
  </data>
77
122
  </dict>
78
123
  <key>Modules/module.modulemap</key>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-beidou",
3
- "version": "1.0.8",
3
+ "version": "1.1.2",
4
4
  "description": "A React Native module for BeiDou Bluetooth communication.",
5
5
  "main": "index.ts",
6
6
  "types": "index.ts",
@@ -15,6 +15,7 @@
15
15
  "react-native.config.js",
16
16
  "BeiDouAIDLTestPage.tsx",
17
17
  "TestPage.ts",
18
+ "react-native-beidou.podspec",
18
19
  "LogManager.ts"
19
20
  ],
20
21
  "keywords": [