diff --git a/android/build.gradle b/android/build.gradle index fa21ce9..14cae36 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -51,6 +51,6 @@ repositories { dependencies { implementation 'androidx.core:core-ktx:1.7.0' implementation "com.facebook.react:react-native:+" - implementation 'com.github.OneKeyHQ:MultiPlatformBleAdapter:4e98f6fb0b9b59f0082fbfeea612dd0a5fb9db88' + implementation 'com.github.bytezhang1024:MultiPlatformBleAdapter:96399204ff' testImplementation 'junit:junit:4.13.2' } \ No newline at end of file diff --git a/android/src/main/java/com/polidea/reactnativeble/BleClientManager.java b/android/src/main/java/com/polidea/reactnativeble/BleClientManager.java index e4105b1..6a6eadc 100644 --- a/android/src/main/java/com/polidea/reactnativeble/BleClientManager.java +++ b/android/src/main/java/com/polidea/reactnativeble/BleClientManager.java @@ -275,6 +275,21 @@ public void discoverAllServicesAndCharacteristicsForDevice(String deviceId, fina data -> safePromise.resolve(deviceConverter.toJSObject(data)), error -> safePromise.reject(null, errorConverter.toJs(error))); } + @ReactMethod + public void discoverAllServicesAndCharacteristicsForDeviceForceRefresh(String deviceId, final String transactionId,final Promise promise) { + final SafePromise safePromise = new SafePromise(promise); + bleAdapter.discoverAllServicesAndCharacteristicsForDevice(deviceId, transactionId, true, + data -> safePromise.resolve(deviceConverter.toJSObject(data)), error -> safePromise.reject(null, errorConverter.toJs(error))); + } + + + @ReactMethod + public void refreshGatt(String deviceId, final Promise promise) { + final SafePromise safePromise = new SafePromise(promise); + bleAdapter.refreshGatt(deviceId, + data -> safePromise.resolve(data), error -> safePromise.reject(null, errorConverter.toJs(error))); + } + // Mark: Service and characteristic getters ---------------------------------------------------- @ReactMethod @@ -634,7 +649,7 @@ public void writeDescriptor(final int descriptorIdentifier, @ReactMethod public void addListener(String eventName) { - // Keep: Required for RN built in Event Emitter Calls. + // Keep: Required for RN built in Event Emitter Calls. } @ReactMethod diff --git a/src/BleManager.js b/src/BleManager.js index 92b1eab..3a5e981 100644 --- a/src/BleManager.js +++ b/src/BleManager.js @@ -529,6 +529,23 @@ export class BleManager { return new Device(nativeDevice, this) } + async discoverAllServicesAndCharacteristicsForDeviceForceRefresh( + deviceIdentifier: DeviceId, + transactionId: ?TransactionId + ): Promise { + if (!transactionId) { + transactionId = this._nextUniqueID() + } + const nativeDevice = await this._callPromise( + BleModule.discoverAllServicesAndCharacteristicsForDeviceForceRefresh(deviceIdentifier, transactionId) + ) + return new Device(nativeDevice, this) + } + + async refreshGatt(deviceIdentifier: DeviceId): Promise { + return await this._callPromise(BleModule.refreshGatt(deviceIdentifier)) + } + // Mark: Service and characteristic getters -------------------------------------------------------------------------- /**