Skip to content

Commit

Permalink
chore: test refreshGatt
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteZhang1024 committed Jul 30, 2024
1 parent 00d819a commit ec599e2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions src/BleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,23 @@ export class BleManager {
return new Device(nativeDevice, this)
}

async discoverAllServicesAndCharacteristicsForDeviceForceRefresh(
deviceIdentifier: DeviceId,
transactionId: ?TransactionId
): Promise<Device> {
if (!transactionId) {
transactionId = this._nextUniqueID()
}
const nativeDevice = await this._callPromise(
BleModule.discoverAllServicesAndCharacteristicsForDeviceForceRefresh(deviceIdentifier, transactionId)
)
return new Device(nativeDevice, this)
}

async refreshGatt(deviceIdentifier: DeviceId): Promise<Boolean> {
return await this._callPromise(BleModule.refreshGatt(deviceIdentifier))
}

// Mark: Service and characteristic getters --------------------------------------------------------------------------

/**
Expand Down

0 comments on commit ec599e2

Please sign in to comment.