-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Etch support is only in JVM, but the helper utils are in common
- Loading branch information
Showing
28 changed files
with
51 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions
29
core/src/jvmTest/kotlin/io/bimmergestalt/idriveconnectkit/RHMIUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
import de.bmw.idrive.BMWRemoting | ||
import de.bmw.idrive.BMWRemotingServer | ||
import java.io.InputStream | ||
import java.security.MessageDigest | ||
|
||
object RHMIUtils { | ||
fun BMWRemotingServer.rhmi_setResourceCached(handle: Int, type: BMWRemoting.RHMIResourceType, data: InputStream?): Boolean { | ||
data ?: return false | ||
val bytes = data.readBytes() | ||
return rhmi_setResourceCached(handle, type, bytes) | ||
} | ||
|
||
fun BMWRemotingServer.rhmi_setResourceCached(handle: Int, type: BMWRemoting.RHMIResourceType, data: ByteArray?): Boolean { | ||
data ?: return false | ||
val hash = md5sum(data) | ||
val cached = rhmi_checkResource(hash, handle, data.size, "", type) | ||
if (!cached) { | ||
rhmi_setResource(handle, data, type) | ||
} | ||
return cached | ||
} | ||
|
||
fun md5sum(data: ByteArray): ByteArray { | ||
val hasher = MessageDigest.getInstance("MD5") | ||
hasher.update(data) | ||
return hasher.digest() | ||
} | ||
} |
File renamed without changes.