@sincpro/printer-expo 0.1.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +589 -415
  2. package/android/.editorconfig +20 -0
  3. package/android/README.md +103 -0
  4. package/android/build.gradle +36 -34
  5. package/android/libs/pdf/Bixolon_pdf.aar +0 -0
  6. package/android/libs/{jniLibs/x86_64/libbxl_common.so → sincpro-printer-sdk.aar} +0 -0
  7. package/android/src/main/java/sincpro/expo/printer/entrypoint/PrinterModule.kt +387 -0
  8. package/build/SincproPrinter.d.ts +191 -0
  9. package/build/SincproPrinter.d.ts.map +1 -0
  10. package/build/SincproPrinter.js +120 -0
  11. package/build/SincproPrinter.js.map +1 -0
  12. package/build/index.d.ts +11 -3
  13. package/build/index.d.ts.map +1 -1
  14. package/build/index.js +13 -3
  15. package/build/index.js.map +1 -1
  16. package/build/types/bluetooth.types.d.ts +19 -0
  17. package/build/types/bluetooth.types.d.ts.map +1 -0
  18. package/build/types/bluetooth.types.js +5 -0
  19. package/build/types/bluetooth.types.js.map +1 -0
  20. package/build/types/index.d.ts +7 -0
  21. package/build/types/index.d.ts.map +1 -0
  22. package/build/types/index.js +7 -0
  23. package/build/types/index.js.map +1 -0
  24. package/build/types/printer.types.d.ts +118 -0
  25. package/build/types/printer.types.d.ts.map +1 -0
  26. package/build/types/printer.types.js +5 -0
  27. package/build/types/printer.types.js.map +1 -0
  28. package/build/types/receipt.types.d.ts +96 -0
  29. package/build/types/receipt.types.d.ts.map +1 -0
  30. package/build/types/receipt.types.js +5 -0
  31. package/build/types/receipt.types.js.map +1 -0
  32. package/expo-module.config.json +2 -5
  33. package/package.json +6 -7
  34. package/android/libs/BixolonLabelPrinterLibrary_V2.0.9.jar +0 -0
  35. package/android/libs/jniLibs/arm64-v8a/libbxl_common.so +0 -0
  36. package/android/libs/jniLibs/armeabi-v7a/libbxl_common.so +0 -0
  37. package/android/libs/jniLibs/x86/libbxl_common.so +0 -0
  38. package/android/libs/libcommon_V1.4.0.jar +0 -0
  39. package/android/src/main/java/expo/sincpro/ExpoBixolonModule.kt +0 -271
  40. package/android/src/main/java/expo/sincpro/bixolon/BixolonQRPrinter.kt +0 -423
  41. package/android/src/main/java/expo/sincpro/managers/BluetoothManager.kt +0 -139
  42. package/android/src/main/java/expo/sincpro/managers/ConnectionManager.kt +0 -124
  43. package/android/src/main/java/expo/sincpro/managers/PermissionManager.kt +0 -122
  44. package/android/src/main/java/expo/sincpro/managers/PrinterManager.kt +0 -396
  45. package/android/src/main/jniLibs/arm64-v8a/libbxl_common.so +0 -0
  46. package/android/src/main/jniLibs/armeabi-v7a/libbxl_common.so +0 -0
  47. package/android/src/main/jniLibs/x86/libbxl_common.so +0 -0
  48. package/android/src/main/jniLibs/x86_64/libbxl_common.so +0 -0
  49. package/build/BixolonPrinter.d.ts +0 -4
  50. package/build/BixolonPrinter.d.ts.map +0 -1
  51. package/build/BixolonPrinter.js +0 -12
  52. package/build/BixolonPrinter.js.map +0 -1
  53. package/build/ExpoBixolon.types.d.ts +0 -45
  54. package/build/ExpoBixolon.types.d.ts.map +0 -1
  55. package/build/ExpoBixolon.types.js +0 -2
  56. package/build/ExpoBixolon.types.js.map +0 -1
  57. package/build/ExpoBixolonModule.d.ts +0 -24
  58. package/build/ExpoBixolonModule.d.ts.map +0 -1
  59. package/build/ExpoBixolonModule.js +0 -3
  60. package/build/ExpoBixolonModule.js.map +0 -1
  61. package/build/QrCodePrinter.d.ts +0 -45
  62. package/build/QrCodePrinter.d.ts.map +0 -1
  63. package/build/QrCodePrinter.js +0 -118
  64. package/build/QrCodePrinter.js.map +0 -1
  65. package/ios/ExpoBixolon.podspec +0 -29
  66. package/ios/ExpoBixolonModule.swift +0 -33
  67. package/ios/ExpoBixolonView.swift +0 -36
  68. package/src/BixolonPrinter.ts +0 -16
  69. package/src/ExpoBixolon.types.ts +0 -60
  70. package/src/ExpoBixolonModule.ts +0 -38
  71. package/src/QrCodePrinter.ts +0 -201
  72. package/src/index.ts +0 -3
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Receipt types for @sincpro/printer-expo
3
+ */
4
+ import type { FontSize, Alignment, BarcodeType } from './printer.types';
5
+ /**
6
+ * Receipt structure with header, body, and footer sections
7
+ */
8
+ export interface Receipt {
9
+ header?: ReceiptLine[];
10
+ body?: ReceiptLine[];
11
+ footer?: ReceiptLine[];
12
+ }
13
+ /**
14
+ * Receipt line types (discriminated union)
15
+ */
16
+ export type ReceiptLine = TextLine | KeyValueLine | QRLine | BarcodeLine | ImageLine | SeparatorLine | SpaceLine | ColumnsLine;
17
+ /**
18
+ * Text line
19
+ */
20
+ export interface TextLine {
21
+ type: 'text';
22
+ content: string;
23
+ fontSize?: FontSize;
24
+ bold?: boolean;
25
+ alignment?: Alignment;
26
+ }
27
+ /**
28
+ * Key-value pair line
29
+ */
30
+ export interface KeyValueLine {
31
+ type: 'keyValue';
32
+ key: string;
33
+ value: string;
34
+ fontSize?: FontSize;
35
+ bold?: boolean;
36
+ }
37
+ /**
38
+ * QR code line
39
+ */
40
+ export interface QRLine {
41
+ type: 'qr';
42
+ data: string;
43
+ size?: number;
44
+ alignment?: Alignment;
45
+ }
46
+ /**
47
+ * Barcode line
48
+ */
49
+ export interface BarcodeLine {
50
+ type: 'barcode';
51
+ data: string;
52
+ barcodeType?: BarcodeType;
53
+ height?: number;
54
+ alignment?: Alignment;
55
+ }
56
+ /**
57
+ * Image line (base64)
58
+ */
59
+ export interface ImageLine {
60
+ type: 'image';
61
+ base64: string;
62
+ alignment?: Alignment;
63
+ }
64
+ /**
65
+ * Separator line
66
+ */
67
+ export interface SeparatorLine {
68
+ type: 'separator';
69
+ char?: string;
70
+ length?: number;
71
+ }
72
+ /**
73
+ * Space/blank line
74
+ */
75
+ export interface SpaceLine {
76
+ type: 'space';
77
+ lines?: number;
78
+ }
79
+ /**
80
+ * Column definition
81
+ */
82
+ export interface Column {
83
+ text: string;
84
+ widthRatio?: number;
85
+ alignment?: Alignment;
86
+ }
87
+ /**
88
+ * Columns line (multiple columns in one row)
89
+ */
90
+ export interface ColumnsLine {
91
+ type: 'columns';
92
+ columns: Column[];
93
+ fontSize?: FontSize;
94
+ bold?: boolean;
95
+ }
96
+ //# sourceMappingURL=receipt.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receipt.types.d.ts","sourceRoot":"","sources":["../../src/types/receipt.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,YAAY,GACZ,MAAM,GACN,WAAW,GACX,SAAS,GACT,aAAa,GACb,SAAS,GACT,WAAW,CAAC;AAEhB;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Receipt types for @sincpro/printer-expo
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=receipt.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receipt.types.js","sourceRoot":"","sources":["../../src/types/receipt.types.ts"],"names":[],"mappings":"AAAA;;GAEG","sourcesContent":["/**\n * Receipt types for @sincpro/printer-expo\n */\n\nimport type { FontSize, Alignment, BarcodeType } from './printer.types';\n\n/**\n * Receipt structure with header, body, and footer sections\n */\nexport interface Receipt {\n header?: ReceiptLine[];\n body?: ReceiptLine[];\n footer?: ReceiptLine[];\n}\n\n/**\n * Receipt line types (discriminated union)\n */\nexport type ReceiptLine =\n | TextLine\n | KeyValueLine\n | QRLine\n | BarcodeLine\n | ImageLine\n | SeparatorLine\n | SpaceLine\n | ColumnsLine;\n\n/**\n * Text line\n */\nexport interface TextLine {\n type: 'text';\n content: string;\n fontSize?: FontSize;\n bold?: boolean;\n alignment?: Alignment;\n}\n\n/**\n * Key-value pair line\n */\nexport interface KeyValueLine {\n type: 'keyValue';\n key: string;\n value: string;\n fontSize?: FontSize;\n bold?: boolean;\n}\n\n/**\n * QR code line\n */\nexport interface QRLine {\n type: 'qr';\n data: string;\n size?: number;\n alignment?: Alignment;\n}\n\n/**\n * Barcode line\n */\nexport interface BarcodeLine {\n type: 'barcode';\n data: string;\n barcodeType?: BarcodeType;\n height?: number;\n alignment?: Alignment;\n}\n\n/**\n * Image line (base64)\n */\nexport interface ImageLine {\n type: 'image';\n base64: string;\n alignment?: Alignment;\n}\n\n/**\n * Separator line\n */\nexport interface SeparatorLine {\n type: 'separator';\n char?: string;\n length?: number;\n}\n\n/**\n * Space/blank line\n */\nexport interface SpaceLine {\n type: 'space';\n lines?: number;\n}\n\n/**\n * Column definition\n */\nexport interface Column {\n text: string;\n widthRatio?: number;\n alignment?: Alignment;\n}\n\n/**\n * Columns line (multiple columns in one row)\n */\nexport interface ColumnsLine {\n type: 'columns';\n columns: Column[];\n fontSize?: FontSize;\n bold?: boolean;\n}\n"]}
@@ -1,9 +1,6 @@
1
1
  {
2
- "platforms": ["apple", "android", "web"],
3
- "apple": {
4
- "modules": ["ExpoBixolonModule"]
5
- },
2
+ "platforms": ["android"],
6
3
  "android": {
7
- "modules": ["expo.sincpro.ExpoBixolonModule"]
4
+ "modules": ["sincpro.expo.printer.entrypoint.PrinterModule"]
8
5
  }
9
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sincpro/printer-expo",
3
- "version": "0.1.2",
3
+ "version": "1.0.1",
4
4
  "description": "Expo module for controlling Bixolon thermal printers with Bluetooth connectivity",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -11,6 +11,8 @@
11
11
  "lint": "expo-module lint",
12
12
  "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
13
13
  "format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,md}\"",
14
+ "format:kotlin": "ktlint --format \"android/**/*.kt\"",
15
+ "lint:kotlin": "ktlint \"android/**/*.kt\"",
14
16
  "test": "expo-module test",
15
17
  "prepare": "expo-module prepare",
16
18
  "prepublishOnly": "expo-module prepublishOnly",
@@ -24,8 +26,6 @@
24
26
  "files": [
25
27
  "build",
26
28
  "android",
27
- "ios",
28
- "src",
29
29
  "expo-module.config.json",
30
30
  "README.md",
31
31
  "LICENSE"
@@ -49,14 +49,13 @@
49
49
  "license": "MIT",
50
50
  "homepage": "https://github.com/Sincpro-SRL/expo_bixolon#readme",
51
51
  "devDependencies": {
52
- "@types/react": "~19.0.0",
53
- "expo": "~54.0.0",
52
+ "@types/react": "^18.0.0 || ^19.0.0",
54
53
  "expo-module-scripts": "^5.0.8",
55
54
  "prettier": "^3.7.4",
56
- "react-native": "0.79.1"
55
+ "typescript": "^5.3.0"
57
56
  },
58
57
  "peerDependencies": {
59
- "expo": "*",
58
+ "expo": ">=52.0.0",
60
59
  "react": "*",
61
60
  "react-native": "*"
62
61
  }
Binary file
@@ -1,271 +0,0 @@
1
- package expo.sincpro
2
-
3
- import android.util.Log
4
- import expo.modules.kotlin.modules.Module
5
- import expo.modules.kotlin.modules.ModuleDefinition
6
- import expo.sincpro.bixolon.BixolonQRPrinter
7
- import expo.sincpro.managers.BluetoothManager
8
- import expo.sincpro.managers.ConnectionManager
9
- import expo.sincpro.managers.PermissionManager
10
- import expo.sincpro.managers.PrinterManager
11
-
12
- class ExpoBixolonModule : Module() {
13
- private val TAG = "ExpoBixolonModule"
14
-
15
- private var bixolonQRPrinter: BixolonQRPrinter? = null
16
- private var bluetoothManager: BluetoothManager? = null
17
- private var connectionManager: ConnectionManager? = null
18
- private var printerManager: PrinterManager? = null
19
- private var permissionManager: PermissionManager? = null
20
-
21
- override fun definition() = ModuleDefinition {
22
- Name("ExpoBixolon")
23
-
24
- AsyncFunction("initializePrinter") {
25
- try {
26
- Log.d(TAG, "Initializing printer with Bixolon libraries")
27
-
28
- if (bixolonQRPrinter == null) {
29
- bixolonQRPrinter = BixolonQRPrinter(appContext.reactContext!!)
30
- connectionManager = ConnectionManager(bixolonQRPrinter!!)
31
- printerManager = PrinterManager(bixolonQRPrinter!!)
32
- }
33
-
34
- return@AsyncFunction connectionManager!!.initialize()
35
- } catch (e: Exception) {
36
- Log.e(TAG, "Error initializing printer: ${e.message}")
37
- throw e
38
- }
39
- }
40
-
41
- AsyncFunction("connectPrinter") { interfaceType: String, address: String, port: Int ->
42
- try {
43
- if (connectionManager == null || !connectionManager!!.isInitialized()) {
44
- throw Exception("Printer not initialized. Call initializePrinter() first.")
45
- }
46
-
47
- if (bluetoothManager == null) {
48
- bluetoothManager = BluetoothManager(appContext.reactContext!!)
49
- }
50
-
51
- return@AsyncFunction connectionManager!!.connect(interfaceType, address, port, bluetoothManager!!)
52
- } catch (e: Exception) {
53
- Log.e(TAG, "Error connecting to printer: ${e.message}")
54
- throw e
55
- }
56
- }
57
-
58
- AsyncFunction("disconnectPrinter") {
59
- try {
60
- if (connectionManager == null) {
61
- return@AsyncFunction true
62
- }
63
-
64
- return@AsyncFunction connectionManager!!.disconnect()
65
- } catch (e: Exception) {
66
- Log.e(TAG, "Error disconnecting from printer: ${e.message}")
67
- throw e
68
- }
69
- }
70
-
71
- AsyncFunction("executeCommand") { command: String ->
72
- try {
73
- if (connectionManager == null || !connectionManager!!.isConnected()) {
74
- throw Exception("Printer not connected")
75
- }
76
-
77
- return@AsyncFunction connectionManager!!.executeCommand(command)
78
- } catch (e: Exception) {
79
- Log.e(TAG, "Error executing command: ${e.message}")
80
- throw e
81
- }
82
- }
83
-
84
- AsyncFunction("testPlainText") { text: String ->
85
- try {
86
- if (connectionManager == null || !connectionManager!!.isConnected()) {
87
- throw Exception("Printer not connected")
88
- }
89
-
90
- return@AsyncFunction printerManager!!.printPlainText(text)
91
- } catch (e: Exception) {
92
- Log.e(TAG, "Error sending plain text: ${e.message}")
93
- throw e
94
- }
95
- }
96
-
97
- AsyncFunction("printInvoice") { invoiceText: String ->
98
- try {
99
- if (connectionManager == null || !connectionManager!!.isConnected()) {
100
- throw Exception("Printer not connected")
101
- }
102
-
103
- return@AsyncFunction printerManager!!.printInvoice(invoiceText)
104
- } catch (e: Exception) {
105
- Log.e(TAG, "Error printing invoice: ${e.message}")
106
- throw e
107
- }
108
- }
109
-
110
- AsyncFunction("printQRCode") { text: String, size: Int ->
111
- try {
112
- if (connectionManager == null || !connectionManager!!.isConnected()) {
113
- throw Exception("Printer not connected")
114
- }
115
-
116
- return@AsyncFunction printerManager!!.printQRCode(text, size)
117
- } catch (e: Exception) {
118
- Log.e(TAG, "Error printing QR code: ${e.message}")
119
- throw e
120
- }
121
- }
122
-
123
- AsyncFunction("printQRCodeAdvanced") {
124
- data: String,
125
- horizontalPosition: Int,
126
- verticalPosition: Int,
127
- model: String,
128
- eccLevel: String,
129
- size: Int,
130
- rotation: String
131
- ->
132
- try {
133
- if (connectionManager == null || !connectionManager!!.isConnected()) {
134
- throw Exception("Printer not connected")
135
- }
136
-
137
- return@AsyncFunction printerManager!!.printQRCodeAdvanced(data, size)
138
- } catch (e: Exception) {
139
- Log.e(TAG, "Error printing QR code: ${e.message}")
140
- throw e
141
- }
142
- }
143
-
144
- AsyncFunction("printFormattedText") { text: String, fontSize: Int? ->
145
- try {
146
- if (connectionManager == null || !connectionManager!!.isConnected()) {
147
- throw Exception("Printer not connected")
148
- }
149
-
150
- val actualFontSize = fontSize ?: 10
151
- return@AsyncFunction printerManager!!.printFormattedText(text, actualFontSize)
152
- } catch (e: Exception) {
153
- Log.e(TAG, "Error printing formatted text: ${e.message}")
154
- throw e
155
- }
156
- }
157
-
158
- AsyncFunction("printTextSimple") { text: String ->
159
- try {
160
- if (connectionManager == null || !connectionManager!!.isConnected()) {
161
- throw Exception("Printer not connected")
162
- }
163
-
164
- return@AsyncFunction printerManager!!.printTextSimple(text)
165
- } catch (e: Exception) {
166
- Log.e(TAG, "Error printing simple text: ${e.message}")
167
- throw e
168
- }
169
- }
170
-
171
- AsyncFunction("printTextInPages") { text: String ->
172
- try {
173
- if (connectionManager == null || !connectionManager!!.isConnected()) {
174
- throw Exception("Printer not connected")
175
- }
176
-
177
- return@AsyncFunction printerManager!!.printTextInPages(text)
178
- } catch (e: Exception) {
179
- Log.e(TAG, "Error printing text in pages: ${e.message}")
180
- throw e
181
- }
182
- }
183
-
184
-
185
- AsyncFunction("requestBluetoothPermissions") {
186
- try {
187
- if (permissionManager == null) {
188
- permissionManager = PermissionManager(appContext.reactContext!!)
189
- }
190
-
191
- return@AsyncFunction permissionManager!!.requestBluetoothPermissions(appContext.currentActivity)
192
- } catch (e: Exception) {
193
- Log.e(TAG, "Error requesting Bluetooth permissions: ${e.message}")
194
- return@AsyncFunction false
195
- }
196
- }
197
-
198
- AsyncFunction("checkBluetoothPermissions") {
199
- try {
200
- if (permissionManager == null) {
201
- permissionManager = PermissionManager(appContext.reactContext!!)
202
- }
203
-
204
- return@AsyncFunction permissionManager!!.checkBluetoothPermissions()
205
- } catch (e: Exception) {
206
- Log.e(TAG, "Error checking Bluetooth permissions: ${e.message}")
207
- throw e
208
- }
209
- }
210
-
211
- AsyncFunction("discoverBluetoothDevices") {
212
- try {
213
- if (bluetoothManager == null) {
214
- bluetoothManager = BluetoothManager(appContext.reactContext!!)
215
- }
216
-
217
- if (permissionManager == null) {
218
- permissionManager = PermissionManager(appContext.reactContext!!)
219
- }
220
-
221
- if (!permissionManager!!.hasRequiredPermissions()) {
222
- throw Exception("Required permissions not granted. Call requestBluetoothPermissions() first.")
223
- }
224
-
225
- return@AsyncFunction bluetoothManager!!.discoverBluetoothDevices()
226
- } catch (e: Exception) {
227
- Log.e(TAG, "Error discovering Bluetooth devices: ${e.message}")
228
- throw e
229
- }
230
- }
231
-
232
- AsyncFunction("startBluetoothDiscovery") {
233
- try {
234
- if (bluetoothManager == null) {
235
- bluetoothManager = BluetoothManager(appContext.reactContext!!)
236
- }
237
-
238
- return@AsyncFunction bluetoothManager!!.startBluetoothDiscovery()
239
- } catch (e: Exception) {
240
- Log.e(TAG, "Error starting Bluetooth discovery: ${e.message}")
241
- throw e
242
- }
243
- }
244
-
245
- AsyncFunction("stopBluetoothDiscovery") {
246
- try {
247
- if (bluetoothManager == null) {
248
- bluetoothManager = BluetoothManager(appContext.reactContext!!)
249
- }
250
-
251
- return@AsyncFunction bluetoothManager!!.stopBluetoothDiscovery()
252
- } catch (e: Exception) {
253
- Log.e(TAG, "Error stopping Bluetooth discovery: ${e.message}")
254
- throw e
255
- }
256
- }
257
-
258
- AsyncFunction("isBluetoothEnabled") {
259
- try {
260
- if (bluetoothManager == null) {
261
- bluetoothManager = BluetoothManager(appContext.reactContext!!)
262
- }
263
-
264
- return@AsyncFunction bluetoothManager!!.isBluetoothEnabled()
265
- } catch (e: Exception) {
266
- Log.e(TAG, "Error checking Bluetooth status: ${e.message}")
267
- throw e
268
- }
269
- }
270
- }
271
- }