Skip to content

Commit

Permalink
fix: added timeout argument to interface and android
Browse files Browse the repository at this point in the history
  • Loading branch information
mhochsto committed Feb 19, 2025
1 parent 0a422a5 commit 1e85705
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ class AbrevvaBleModule(reactContext: ReactApplicationContext) :
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
fun startNotifications(options: ReadableMap, promise: Promise) {
val deviceId = options.getString("deviceId") ?: ""
var timeout: Long = 10000
try {
timeout = options.getDouble("timeout").toLong()
} catch (_: Exception) {
}
val characteristic =
getCharacteristic(options, promise)
?: return promise.reject(Exception("startNotifications(): bad characteristic"))
Expand All @@ -321,7 +326,9 @@ class AbrevvaBleModule(reactContext: ReactApplicationContext) :

ret.putString("value", bytesToString(data))
reactApplicationContext.emitDeviceEvent(key, ret)
})
},
timeout
)
if (success) {
val ret = Arguments.createMap()
ret.putString("value", "success")
Expand Down
2 changes: 2 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export class AbrevvaBleModule implements AbrevvaBLEInterface {
deviceId: string,
service: string,
characteristic: string,
timeout: number,
callback: (event: StringResult) => void,
): Promise<void> {
const key = `notification|${deviceId}|${service}|${characteristic}`.toLowerCase();
Expand All @@ -273,6 +274,7 @@ export class AbrevvaBleModule implements AbrevvaBLEInterface {
deviceId: deviceId,
service: service,
characteristic: characteristic,
timeout: timeout,
}),
);
}
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export interface AbrevvaBLEInterface {
deviceId: string,
service: string,
characteristic: string,
timeout: number,
callback: (event: StringResult) => void,
): Promise<void>;
stopNotifications(deviceId: string, service: string, characteristic: string): Promise<void>;
Expand Down

0 comments on commit 1e85705

Please sign in to comment.