Skip to content

Commit e1bcc75

Browse files
committed
feat: add read card records
1 parent 17333a2 commit e1bcc75

File tree

13 files changed

+687
-39
lines changed

13 files changed

+687
-39
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.pos
2+
3+
import com.facebook.react.bridge.*
4+
import com.pos.byte_stuff.ByteConvertReactNativeUtil
5+
import com.pos.byte_stuff.ByteConvertStringUtil
6+
import java.nio.charset.StandardCharsets
7+
8+
class ByteUtilsModule(reactContext: ReactApplicationContext) :
9+
ReactContextBaseJavaModule(reactContext) {
10+
11+
override fun getName(): String {
12+
return ByteUtilsModule.NAME
13+
}
14+
15+
@ReactMethod
16+
fun stringToByteArray(str: String, promise: Promise) {
17+
val bytes = ByteConvertStringUtil.stringToByteArray(str)
18+
promise.resolve(ByteConvertReactNativeUtil.byteArrayToReadableArray(bytes))
19+
}
20+
21+
@ReactMethod
22+
fun bytesFromString(str: String, promise: Promise) {
23+
val bytes = str.toByteArray(StandardCharsets.UTF_8);
24+
promise.resolve(ByteConvertReactNativeUtil.byteArrayToReadableArray(bytes))
25+
}
26+
27+
@ReactMethod
28+
fun bytesToHexString(array: ReadableArray, promise: Promise) {
29+
val bytes = ByteConvertReactNativeUtil.readableArrayToByteArray(array)
30+
val hexString = ByteConvertStringUtil.bytesToHexString(bytes)
31+
promise.resolve(hexString)
32+
}
33+
34+
companion object {
35+
const val NAME = "ByteUtils"
36+
}
37+
}

android/src/main/java/com/pos/Card.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ abstract class Card {
1111

1212
abstract fun init(promise: Promise)
1313

14+
abstract fun readRecordsFromCard(promise: Promise)
15+
1416
// call open before anything else if no other promises are running
1517
abstract fun writeToCard(apdu: ReadableArray, promise: Promise)
1618

0 commit comments

Comments
 (0)