Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,6 @@ object Unified {
}
}

/**
* Request a GATT write to the DSM TX characteristic of the given device.
* Returns true if the async flow was successfully started.
*/
@Keep @JvmStatic fun requestGattWrite(deviceAddress: String, transactionData: ByteArray): Boolean {
return UnifiedBleBridge.requestGattWrite(deviceAddress, transactionData)
}

/**
* Start BLE pairing in advertiser role using the instance-bound service.
* Returns false if BLE service is not initialized.
Expand All @@ -192,8 +184,8 @@ object Unified {
}

// ---------- Event notifications ----------
@Keep @JvmStatic fun bleNotifyConnectionState(address: String, connected: Boolean) {
UnifiedNativeApi.bleNotifyConnectionState(address, connected)
@Keep @JvmStatic fun bleNotifyLink(deviceId: ByteArray, address: String, up: Boolean) {
UnifiedNativeApi.bleNotifyLink(deviceId, address, up)
}

/**
Expand Down Expand Up @@ -290,18 +282,16 @@ object Unified {

/**
* Process raw protobuf bytes read from the GATT identity characteristic.
* Rust decodes BleIdentityCharValue, dispatches identity events, and returns
* BleGattIdentityReadResult with the write-back envelope.
* Rust decodes BleIdentityCharValue, decides by the contact's device id whether
* the link re-anchors a paired contact or starts pairing, and returns
* BleGattIdentityReadResult (with the write-back envelope when pairing starts).
* expectedDeviceId names the appliance a reach is connecting for (empty when the
* link is not a reach); any other peer is reported not established and nothing
* about it is recorded.
* Kotlin MUST NOT split or interpret identity bytes.
*/
@Keep @JvmStatic fun processGattIdentityRead(bleAddress: String, rawProtoBytes: ByteArray): ByteArray =
UnifiedNativeApi.processGattIdentityRead(bleAddress, rawProtoBytes)
/**
* Observe raw protobuf bytes read from the GATT identity characteristic for an already-paired peer.
* Rust re-anchors the peer identity and updates persistence without sending write-back pairing data.
*/
@Keep @JvmStatic fun observeGattIdentityRead(bleAddress: String, rawProtoBytes: ByteArray): ByteArray =
UnifiedNativeApi.observeGattIdentityRead(bleAddress, rawProtoBytes)
@Keep @JvmStatic fun processGattIdentityRead(bleAddress: String, rawProtoBytes: ByteArray, expectedDeviceId: ByteArray): ByteArray =
UnifiedNativeApi.processGattIdentityRead(bleAddress, rawProtoBytes, expectedDeviceId)

@Keep @JvmStatic fun createTransactionErrorEnvelope(address: String, code: Int, message: String): ByteArray? =
UnifiedNativeApi.createTransactionErrorEnvelope(address, code, message)
Expand Down Expand Up @@ -380,36 +370,32 @@ object Unified {
UnifiedNativeApi.identityReadResultGetSuccess(responseProto)

/** Extract write_back_envelope bytes from a BleGattIdentityReadResult proto. */
@Keep @JvmStatic fun identityReadResultExtractWriteBack(responseProto: ByteArray): ByteArray =
@Keep @JvmStatic fun identityReadResultExtractWriteBack(responseProto: ByteArray): ByteArray? =
UnifiedNativeApi.identityReadResultExtractWriteBack(responseProto)

/** Extract peer_device_id (32 bytes) from a BleGattIdentityReadResult proto. */
@Keep @JvmStatic fun identityReadResultExtractPeerDeviceId(responseProto: ByteArray): ByteArray =
@Keep @JvmStatic fun identityReadResultExtractPeerDeviceId(responseProto: ByteArray): ByteArray? =
UnifiedNativeApi.identityReadResultExtractPeerDeviceId(responseProto)

/** Extract peer_genesis_hash (32 bytes) from a BleGattIdentityReadResult proto. */
@Keep @JvmStatic fun identityReadResultExtractPeerGenesisHash(responseProto: ByteArray): ByteArray =
@Keep @JvmStatic fun identityReadResultExtractPeerGenesisHash(responseProto: ByteArray): ByteArray? =
UnifiedNativeApi.identityReadResultExtractPeerGenesisHash(responseProto)

/**
* Called after bilateral prepare succeeds.
* deviceAddress: BLE MAC address of recipient
* chunks: Array of byte arrays, each containing a protobuf BleChunk
* Returns true if async send was successfully initiated.
* Send one message's chunks to the appliance deviceId (invoked by Rust). The
* device id routes: only a link whose identity is anchored to it carries the
* message; with none, the transport reaches for it, trying addressHint (where
* it was last seen, possibly empty) first. False is "not delivered now" — the
* SDK's frame stays owed.
*/
@Keep @JvmStatic fun sendBleChunks(deviceAddress: String, chunks: Array<ByteArray>): Boolean =
UnifiedNativeApi.sendBleChunks(deviceAddress, chunks)
@Keep @JvmStatic fun requestGattWriteChunks(deviceId: ByteArray, addressHint: String, chunks: Array<ByteArray>): Boolean {
return UnifiedBleBridge.requestGattWriteChunks(deviceId, addressHint, chunks)
}

/**
* Optimized multi-chunk writer invoked by JNI (sendBleChunks) after chunk diagnostics.
* Reuses / establishes a SINGLE GATT connection and writes all provided BleChunk protobuf
* messages sequentially, advancing only after onCharacteristicWrite callbacks succeed.
* Falls back to per-chunk failure envelope on first error.
* Send a reply on the link, at deviceAddress, that the frame it answers
* arrived on. Nothing reconnects for it.
*/
@Keep @JvmStatic fun requestGattWriteChunks(deviceAddress: String, chunks: Array<ByteArray>): Boolean {
return UnifiedBleBridge.requestGattWriteChunks(deviceAddress, chunks)
}

@Keep @JvmStatic fun dispatchRustBleFollowUp(deviceAddress: String, chunks: Array<ByteArray>, useReliableWrite: Boolean): Boolean {
return UnifiedBleBridge.dispatchRustFollowUp(deviceAddress, chunks, useReliableWrite)
}
Expand Down Expand Up @@ -448,8 +434,6 @@ object Unified {
* Resolve the persisted peer identity for a BLE address.
* Returns 64 bytes ordered as [device_id(32)][genesis_hash(32)], or empty if unknown.
*/
@Keep @JvmStatic fun resolvePeerIdentityForBleAddressBin(address: String): ByteArray =
UnifiedNativeApi.resolvePeerIdentityForBleAddressBin(address)
@Keep @JvmStatic fun isRejectEnvelope(envelopeBytes: ByteArray): ByteArray =
UnifiedNativeApi.isRejectEnvelope(envelopeBytes)
@Keep @JvmStatic fun isErrorEnvelope(envelopeBytes: ByteArray): Int =
Expand Down Expand Up @@ -481,15 +465,11 @@ object Unified {
counterpartyDeviceId
)

// ---------- BLE diagnostics + retry helpers (non-external; pure-Kotlin wrappers) ----------
// ---------- BLE diagnostics helpers (non-external; pure-Kotlin wrappers) ----------
@Keep @JvmStatic fun getBleStats(deviceAddress: String): ByteArray {
return UnifiedBleBridge.getBleStats(deviceAddress)
}

@Keep @JvmStatic fun retryLastBleTransaction(deviceAddress: String): Boolean {
return UnifiedBleBridge.retryLastBleTransaction(deviceAddress)
}

// ---------- Bluetooth pairing status API ----------

/**
Expand Down
Loading
Loading