@m430/capacitor-label-printer 0.1.0

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 (150) hide show
  1. package/API.md +218 -0
  2. package/LICENSE +21 -0
  3. package/M430CapacitorLabelPrinter.podspec +21 -0
  4. package/README.md +190 -0
  5. package/android/build.gradle +46 -0
  6. package/android/libs/.gitkeep +1 -0
  7. package/android/libs/fat-generic-tspl-bluetooth-classic-0.1.16-GA.jar +0 -0
  8. package/android/src/main/AndroidManifest.xml +12 -0
  9. package/android/src/main/java/com/m430/capacitor/labelprinter/.gitkeep +1 -0
  10. package/android/src/main/java/com/m430/capacitor/labelprinter/AndroidPrinterManager.java +132 -0
  11. package/android/src/main/java/com/m430/capacitor/labelprinter/AndroidStatusMapper.java +54 -0
  12. package/android/src/main/java/com/m430/capacitor/labelprinter/LabelPrinterPlugin.java +273 -0
  13. package/android/src/main/java/com/m430/capacitor/labelprinter/VendorAndroidDeviceCatalog.java +81 -0
  14. package/android/src/main/java/com/m430/capacitor/labelprinter/VendorAndroidPrinterSession.java +189 -0
  15. package/capacitor-label-printer.podspec +21 -0
  16. package/dist/docs.json +443 -0
  17. package/dist/esm/cpcl/builder.d.ts +10 -0
  18. package/dist/esm/cpcl/builder.js +35 -0
  19. package/dist/esm/definitions.d.ts +107 -0
  20. package/dist/esm/definitions.js +1 -0
  21. package/dist/esm/errors.d.ts +1 -0
  22. package/dist/esm/errors.js +1 -0
  23. package/dist/esm/index.d.ts +9 -0
  24. package/dist/esm/index.js +11 -0
  25. package/dist/esm/tspl/builder.d.ts +13 -0
  26. package/dist/esm/tspl/builder.js +45 -0
  27. package/dist/esm/tspl/helpers.d.ts +2 -0
  28. package/dist/esm/tspl/helpers.js +6 -0
  29. package/dist/esm/types.d.ts +12 -0
  30. package/dist/esm/types.js +1 -0
  31. package/dist/esm/web.d.ts +21 -0
  32. package/dist/esm/web.js +34 -0
  33. package/dist/plugin.cjs.js +143 -0
  34. package/dist/plugin.cjs.js.map +1 -0
  35. package/dist/plugin.js +136 -0
  36. package/dist/plugin.js.map +1 -0
  37. package/ios/Plugin/.gitkeep +1 -0
  38. package/ios/Plugin/IOSPrinterManager.swift +230 -0
  39. package/ios/Plugin/IOSStatusMapper.swift +57 -0
  40. package/ios/Plugin/LabelPrinterPlugin.swift +141 -0
  41. package/ios/VendorFrameworks/.gitkeep +1 -0
  42. package/ios/VendorFrameworks/adapter.framework/Headers/BasedOtherConnectedDevice.h +17 -0
  43. package/ios/VendorFrameworks/adapter.framework/Headers/ConnectedDevice.h +213 -0
  44. package/ios/VendorFrameworks/adapter.framework/Headers/IPRTBlueToothBaseDef.h +22 -0
  45. package/ios/VendorFrameworks/adapter.framework/Headers/KeepStateConnectedDevice.h +18 -0
  46. package/ios/VendorFrameworks/adapter.framework/Headers/QueueConfig.h +18 -0
  47. package/ios/VendorFrameworks/adapter.framework/Headers/ReadOptions.h +22 -0
  48. package/ios/VendorFrameworks/adapter.framework/Headers/WroteReporter.h +23 -0
  49. package/ios/VendorFrameworks/adapter.framework/Headers/adapter.h +18 -0
  50. package/ios/VendorFrameworks/adapter.framework/Info.plist +0 -0
  51. package/ios/VendorFrameworks/adapter.framework/Modules/module.modulemap +6 -0
  52. package/ios/VendorFrameworks/adapter.framework/adapter +0 -0
  53. package/ios/VendorFrameworks/appleble.framework/Frameworks/adapter.framework/Info.plist +0 -0
  54. package/ios/VendorFrameworks/appleble.framework/Frameworks/adapter.framework/_CodeSignature/CodeResources +101 -0
  55. package/ios/VendorFrameworks/appleble.framework/Frameworks/adapter.framework/adapter +0 -0
  56. package/ios/VendorFrameworks/appleble.framework/Frameworks/ibridge.framework/Frameworks/adapter.framework/Info.plist +0 -0
  57. package/ios/VendorFrameworks/appleble.framework/Frameworks/ibridge.framework/Frameworks/adapter.framework/adapter +0 -0
  58. package/ios/VendorFrameworks/appleble.framework/Frameworks/ibridge.framework/Info.plist +0 -0
  59. package/ios/VendorFrameworks/appleble.framework/Frameworks/ibridge.framework/_CodeSignature/CodeResources +132 -0
  60. package/ios/VendorFrameworks/appleble.framework/Frameworks/ibridge.framework/ibridge +0 -0
  61. package/ios/VendorFrameworks/appleble.framework/Headers/AppleBle.h +25 -0
  62. package/ios/VendorFrameworks/appleble.framework/Info.plist +0 -0
  63. package/ios/VendorFrameworks/appleble.framework/Modules/module.modulemap +6 -0
  64. package/ios/VendorFrameworks/appleble.framework/_CodeSignature/CodeResources +252 -0
  65. package/ios/VendorFrameworks/appleble.framework/appleble +0 -0
  66. package/ios/VendorFrameworks/father.framework/Frameworks/adapter.framework/Info.plist +0 -0
  67. package/ios/VendorFrameworks/father.framework/Frameworks/adapter.framework/adapter +0 -0
  68. package/ios/VendorFrameworks/father.framework/Headers/Appendat.h +28 -0
  69. package/ios/VendorFrameworks/father.framework/Headers/Arg.h +22 -0
  70. package/ios/VendorFrameworks/father.framework/Headers/BasicBatteryVolumeArg.h +16 -0
  71. package/ios/VendorFrameworks/father.framework/Headers/BinaryCommand.h +17 -0
  72. package/ios/VendorFrameworks/father.framework/Headers/CPCLCommand.h +10 -0
  73. package/ios/VendorFrameworks/father.framework/Headers/CallbackData.h +26 -0
  74. package/ios/VendorFrameworks/father.framework/Headers/Checker.h +16 -0
  75. package/ios/VendorFrameworks/father.framework/Headers/Command.h +25 -0
  76. package/ios/VendorFrameworks/father.framework/Headers/CommandClause.h +33 -0
  77. package/ios/VendorFrameworks/father.framework/Headers/Commander.h +31 -0
  78. package/ios/VendorFrameworks/father.framework/Headers/DataWriteOperation.h +42 -0
  79. package/ios/VendorFrameworks/father.framework/Headers/DefaultCommand.h +16 -0
  80. package/ios/VendorFrameworks/father.framework/Headers/EasyArg.h +16 -0
  81. package/ios/VendorFrameworks/father.framework/Headers/FastBinary.h +20 -0
  82. package/ios/VendorFrameworks/father.framework/Headers/HexOutput.h +19 -0
  83. package/ios/VendorFrameworks/father.framework/Headers/IDataWriteCallback.h +25 -0
  84. package/ios/VendorFrameworks/father.framework/Headers/Lifecycle.h +21 -0
  85. package/ios/VendorFrameworks/father.framework/Headers/NewLineArg.h +15 -0
  86. package/ios/VendorFrameworks/father.framework/Headers/OnlyBinaryHeaderArg.h +15 -0
  87. package/ios/VendorFrameworks/father.framework/Headers/OnlyTextHeaderArg.h +16 -0
  88. package/ios/VendorFrameworks/father.framework/Headers/PImageTool.h +22 -0
  89. package/ios/VendorFrameworks/father.framework/Headers/PReplaceKit.h +16 -0
  90. package/ios/VendorFrameworks/father.framework/Headers/PSDK.h +60 -0
  91. package/ios/VendorFrameworks/father.framework/Headers/PVariableKit.h +18 -0
  92. package/ios/VendorFrameworks/father.framework/Headers/PsdkConst.h +33 -0
  93. package/ios/VendorFrameworks/father.framework/Headers/Raw.h +22 -0
  94. package/ios/VendorFrameworks/father.framework/Headers/SimpleCheck.h +16 -0
  95. package/ios/VendorFrameworks/father.framework/Headers/SingleCommand.h +32 -0
  96. package/ios/VendorFrameworks/father.framework/Headers/TSPLCommand.h +10 -0
  97. package/ios/VendorFrameworks/father.framework/Headers/WriteControl.h +12 -0
  98. package/ios/VendorFrameworks/father.framework/Headers/WriteOptions.h +28 -0
  99. package/ios/VendorFrameworks/father.framework/Headers/father.h +21 -0
  100. package/ios/VendorFrameworks/father.framework/Info.plist +0 -0
  101. package/ios/VendorFrameworks/father.framework/Modules/module.modulemap +6 -0
  102. package/ios/VendorFrameworks/father.framework/father +0 -0
  103. package/ios/VendorFrameworks/tspl.framework/Frameworks/father.framework/Frameworks/adapter.framework/Info.plist +0 -0
  104. package/ios/VendorFrameworks/tspl.framework/Frameworks/father.framework/Frameworks/adapter.framework/adapter +0 -0
  105. package/ios/VendorFrameworks/tspl.framework/Frameworks/father.framework/Info.plist +0 -0
  106. package/ios/VendorFrameworks/tspl.framework/Frameworks/father.framework/father +0 -0
  107. package/ios/VendorFrameworks/tspl.framework/Headers/BasicTSPL.h +146 -0
  108. package/ios/VendorFrameworks/tspl.framework/Headers/BasicTSPLArg.h +17 -0
  109. package/ios/VendorFrameworks/tspl.framework/Headers/GenericTSPL.h +16 -0
  110. package/ios/VendorFrameworks/tspl.framework/Headers/TBar.h +30 -0
  111. package/ios/VendorFrameworks/tspl.framework/Headers/TBarCode.h +54 -0
  112. package/ios/VendorFrameworks/tspl.framework/Headers/TBatteryVolume.h +19 -0
  113. package/ios/VendorFrameworks/tspl.framework/Headers/TBox.h +32 -0
  114. package/ios/VendorFrameworks/tspl.framework/Headers/TCircle.h +26 -0
  115. package/ios/VendorFrameworks/tspl.framework/Headers/TCleanBmpFlash.h +20 -0
  116. package/ios/VendorFrameworks/tspl.framework/Headers/TClear.h +20 -0
  117. package/ios/VendorFrameworks/tspl.framework/Headers/TCut.h +21 -0
  118. package/ios/VendorFrameworks/tspl.framework/Headers/TDensity.h +21 -0
  119. package/ios/VendorFrameworks/tspl.framework/Headers/TDirection.h +51 -0
  120. package/ios/VendorFrameworks/tspl.framework/Headers/TDmatrix.h +29 -0
  121. package/ios/VendorFrameworks/tspl.framework/Headers/TDownloadBmpFlash.h +16 -0
  122. package/ios/VendorFrameworks/tspl.framework/Headers/TGap.h +21 -0
  123. package/ios/VendorFrameworks/tspl.framework/Headers/TImage.h +36 -0
  124. package/ios/VendorFrameworks/tspl.framework/Headers/TLine.h +34 -0
  125. package/ios/VendorFrameworks/tspl.framework/Headers/TMddle.h +16 -0
  126. package/ios/VendorFrameworks/tspl.framework/Headers/TPage.h +22 -0
  127. package/ios/VendorFrameworks/tspl.framework/Headers/TPrint.h +21 -0
  128. package/ios/VendorFrameworks/tspl.framework/Headers/TQRCode.h +35 -0
  129. package/ios/VendorFrameworks/tspl.framework/Headers/TReadState.h +16 -0
  130. package/ios/VendorFrameworks/tspl.framework/Headers/TReverse.h +27 -0
  131. package/ios/VendorFrameworks/tspl.framework/Headers/TSN.h +19 -0
  132. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLCodeType.h +53 -0
  133. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLCorrectLevel.h +21 -0
  134. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLFont.h +83 -0
  135. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLImageMode.h +30 -0
  136. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLLineMode.h +37 -0
  137. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLLineType.h +21 -0
  138. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLOutDirection.h +27 -0
  139. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLRotation.h +36 -0
  140. package/ios/VendorFrameworks/tspl.framework/Headers/TSPLShowType.h +36 -0
  141. package/ios/VendorFrameworks/tspl.framework/Headers/TSPL_.h +18 -0
  142. package/ios/VendorFrameworks/tspl.framework/Headers/TSpeed.h +20 -0
  143. package/ios/VendorFrameworks/tspl.framework/Headers/TText.h +38 -0
  144. package/ios/VendorFrameworks/tspl.framework/Headers/TTextBox.h +44 -0
  145. package/ios/VendorFrameworks/tspl.framework/Headers/TVersion.h +19 -0
  146. package/ios/VendorFrameworks/tspl.framework/Headers/tspl.h +45 -0
  147. package/ios/VendorFrameworks/tspl.framework/Info.plist +0 -0
  148. package/ios/VendorFrameworks/tspl.framework/Modules/module.modulemap +6 -0
  149. package/ios/VendorFrameworks/tspl.framework/tspl +0 -0
  150. package/package.json +95 -0
@@ -0,0 +1,141 @@
1
+ import Foundation
2
+ import Capacitor
3
+ import CoreBluetooth
4
+ import UIKit
5
+
6
+ @objc(LabelPrinterPlugin)
7
+ public class LabelPrinterPlugin: CAPPlugin {
8
+ private let manager = IOSPrinterManager()
9
+
10
+ @objc func isSupported(_ call: CAPPluginCall) {
11
+ call.resolve(["supported": true])
12
+ }
13
+
14
+ @objc override public func checkPermissions(_ call: CAPPluginCall) {
15
+ call.resolve(buildPermissionResult(for: bluetoothAuthorization))
16
+ }
17
+
18
+ @objc func ensurePermissions(_ call: CAPPluginCall) {
19
+ let authorization = bluetoothAuthorization
20
+ if authorization == .notDetermined {
21
+ call.resolve([
22
+ "granted": true,
23
+ "canPrompt": true,
24
+ "shouldOpenSettings": false,
25
+ "permissions": [
26
+ "bluetooth": "prompt"
27
+ ]
28
+ ])
29
+ return
30
+ }
31
+
32
+ call.resolve(buildPermissionResult(for: authorization))
33
+ }
34
+
35
+ @objc func discoverDevices(_ call: CAPPluginCall) {
36
+ let prefixes = call.getArray("namePrefixes", String.self) ?? []
37
+ let timeoutMs = call.getDouble("timeout") ?? 2000
38
+ call.resolve(["devices": manager.discoverDevices(namePrefixes: prefixes, timeoutMs: timeoutMs)])
39
+ }
40
+
41
+ @objc func connect(_ call: CAPPluginCall) {
42
+ guard let deviceId = call.getString("deviceId") else {
43
+ call.reject("deviceId is required")
44
+ return
45
+ }
46
+
47
+ do {
48
+ try manager.connect(deviceId: deviceId)
49
+ call.resolve()
50
+ } catch {
51
+ call.reject(error.localizedDescription)
52
+ }
53
+ }
54
+
55
+ @objc func disconnect(_ call: CAPPluginCall) {
56
+ manager.disconnect()
57
+ call.resolve()
58
+ }
59
+
60
+ @objc func getConnectionState(_ call: CAPPluginCall) {
61
+ call.resolve(manager.getConnectionState())
62
+ }
63
+
64
+ @objc func print(_ call: CAPPluginCall) {
65
+ do {
66
+ try manager.print(payload: call.getString("payload", ""), copies: call.getInt("copies", 1))
67
+ call.resolve()
68
+ } catch {
69
+ call.reject(error.localizedDescription)
70
+ }
71
+ }
72
+
73
+ @objc func getStatus(_ call: CAPPluginCall) {
74
+ call.resolve(manager.getStatus())
75
+ }
76
+
77
+ @objc func openAppSettings(_ call: CAPPluginCall) {
78
+ guard let url = URL(string: UIApplication.openSettingsURLString) else {
79
+ call.reject("unable to create app settings url")
80
+ return
81
+ }
82
+
83
+ DispatchQueue.main.async {
84
+ UIApplication.shared.open(url) { success in
85
+ if success {
86
+ call.resolve()
87
+ return
88
+ }
89
+
90
+ call.reject("unable to open app settings")
91
+ }
92
+ }
93
+ }
94
+
95
+ private var bluetoothAuthorization: CBManagerAuthorization {
96
+ if #available(iOS 13.0, *) {
97
+ return CBManager.authorization
98
+ }
99
+
100
+ return .allowedAlways
101
+ }
102
+
103
+ private func buildPermissionResult(for authorization: CBManagerAuthorization) -> [String: Any] {
104
+ let permissionState: String
105
+ let granted: Bool
106
+ let canPrompt: Bool
107
+ let shouldOpenSettings: Bool
108
+
109
+ switch authorization {
110
+ case .allowedAlways:
111
+ permissionState = "granted"
112
+ granted = true
113
+ canPrompt = false
114
+ shouldOpenSettings = false
115
+ case .notDetermined:
116
+ permissionState = "prompt"
117
+ granted = false
118
+ canPrompt = true
119
+ shouldOpenSettings = false
120
+ case .denied, .restricted:
121
+ permissionState = "denied"
122
+ granted = false
123
+ canPrompt = false
124
+ shouldOpenSettings = true
125
+ @unknown default:
126
+ permissionState = "prompt"
127
+ granted = false
128
+ canPrompt = true
129
+ shouldOpenSettings = false
130
+ }
131
+
132
+ return [
133
+ "granted": granted,
134
+ "canPrompt": canPrompt,
135
+ "shouldOpenSettings": shouldOpenSettings,
136
+ "permissions": [
137
+ "bluetooth": permissionState
138
+ ]
139
+ ]
140
+ }
141
+ }
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,17 @@
1
+ //
2
+ // BasedOtherConnectedDevice.h
3
+ // adapter
4
+ //
5
+ // Created by IPRT on 2022/11/10.
6
+ //
7
+
8
+ #import <adapter/ConnectedDevice.h>
9
+
10
+ NS_ASSUME_NONNULL_BEGIN
11
+
12
+ @interface BasedOtherConnectedDevice : ConnectedDevice
13
+ @property (nonatomic , readonly) BasedOtherConnectedDevice *(^connectedDevice)(ConnectedDevice *device);
14
+
15
+ @end
16
+
17
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,213 @@
1
+ //
2
+ // ConnectedDevice.h
3
+ // adapter
4
+ //
5
+ // Created by IPRT on 2022/10/24.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <CoreBluetooth/CoreBluetooth.h>
10
+ #import <CoreBluetooth/CBCharacteristic.h>
11
+ #import <adapter/ReadOptions.h>
12
+ #import <adapter/IPRTBlueToothBaseDef.h>
13
+ #import <adapter/WroteReporter.h>
14
+
15
+ NS_ASSUME_NONNULL_BEGIN
16
+ typedef enum _printResult {
17
+ printResultSuccessful,//打印成功
18
+ printResultFailed,//打印失败
19
+ printResultInvalidDevice,
20
+ printResultUnknow
21
+ }printResult;
22
+ typedef enum _printStatus{
23
+ printResultCoverOpen,//纸舱盖打开
24
+ printResultNoPaper,//缺纸
25
+ printResultOverHeat,//打印头过热
26
+ printResultPrinting,//打印中
27
+ printResultBatteryLow,//低电压
28
+ printResultOk,//正常
29
+ }printStatus;
30
+ @protocol ConnectedDeviceDelegate <NSObject>
31
+
32
+ /**
33
+ * 打印机数据接收
34
+ * @param revData 接收到的数据
35
+ * 备注:在未进行查询动作的情况下:
36
+ * 若打印最后发送了【printerPosition】则打印成功后会收到OK,不成功收到RE
37
+ * 若打印最后未发送【printerPosition】则发送成功后会收到0xAA,不成功无返回
38
+ */
39
+ - (void)bleDataReceived:(NSData *)revData;
40
+ /**
41
+ * 搜索到打印机设备
42
+ * @param peripheral CBCentralManager通过扫描、连接的外围设备
43
+ * @param RSSI 设备信号强度
44
+ */
45
+ - (void)bleDidDiscoverDevies:(CBPeripheral *)peripheral RSSI:(nullable NSNumber *)RSSI;
46
+
47
+ /**
48
+ * 打印机连接成功
49
+ * @param peripheral CBCentralManager通过扫描、连接的外围设备
50
+ */
51
+ - (void)bleDidConnectPeripheral:(CBPeripheral *)peripheral;
52
+
53
+ @optional
54
+ /**
55
+ *打印结束回调
56
+ */
57
+ -(void)bleDidFinishPrint:(printResult)result;
58
+ -(void)printResultFailed;
59
+ /**
60
+ *查询打印机状态回调
61
+ */
62
+ -(void)blePrinterStatus:(printStatus)status;
63
+
64
+ - (void)didServicesFound:(nonnull CBPeripheral *)peripheral services:(nullable NSArray<CBService *> *)services;
65
+ /**
66
+ * 搜索到打印机设备
67
+ * @param peripheral CBCentralManager通过扫描、连接的外围设备
68
+ * @param RSSI 设备信号强度
69
+ */
70
+
71
+ - (void)bleDidDiscoverDevies: (CBPeripheral *)peripheral advertisementData:(id)advertisementData RSSI:(nullable NSNumber *)RSSI;
72
+ /**
73
+ * 打印机连接失败
74
+ * @param peripheral CBCentralManager通过扫描、连接的外围设备
75
+ * @param error 错误信息
76
+ */
77
+ - (void)bleDidFailToConnectPeripheral:(CBPeripheral *)peripheral error:(nullable NSError *)error;
78
+
79
+ /**
80
+ * 打印机断开连接
81
+ * @param peripheral CBCentralManager通过扫描、连接的外围设备
82
+ * @param error 错误信息
83
+ */
84
+ - (void)bleDidDisconnectPeripheral:(CBPeripheral *)peripheral error:(nullable NSError *)error;
85
+ /**
86
+ * 蓝牙打开
87
+ */
88
+ - (void)bleBTOpen;
89
+ /**
90
+ * 蓝牙断开
91
+ */
92
+ - (void)bleBTClose;
93
+ /**
94
+ * 蓝牙异常断开
95
+ */
96
+ - (void)bleAbnormalDisconnection;
97
+ /**
98
+ * 蓝牙开始升级
99
+ */
100
+ - (void)startUpdateBt;
101
+ /**
102
+ * 蓝牙升级失败
103
+ */
104
+ - (void)updateBtFail;
105
+ /**
106
+ * 蓝牙升级进度
107
+ * @param progress 进度值
108
+ */
109
+ - (void)updateBtProgress:(int)progress;
110
+ /**
111
+ * 蓝牙升级结束
112
+ */
113
+ - (void)updateBtFinish;
114
+
115
+ /**
116
+ * 打印机开始升级
117
+ */
118
+ - (void)startUpdatePrinter;
119
+ /**
120
+ * 打印机升级失败
121
+ */
122
+ - (void)updatePrinterFail;
123
+ /**
124
+ * 打印机升级进度
125
+ * @param progress 进度值
126
+ */
127
+ - (void)updatePrinterProgress:(int)progress;
128
+ /**
129
+ * 打印机升级结束
130
+ */
131
+ - (void)updatePrinterFinish;
132
+ /**
133
+ * 打印机自动返回缺纸
134
+ */
135
+ - (void) onPrinterOutPaperAuto;
136
+ /**
137
+ * 打印机自动返回开盖
138
+ */
139
+ - (void) onPrinterOpenCoverAuto;
140
+ /**
141
+ * 打印机自动返回过热
142
+ */
143
+ - (void) onPrinterOverHeatAuto;
144
+ /**
145
+ * 打印机自动返回低电压
146
+ */
147
+ - (void) onPrinterLowValAuto;
148
+ /**
149
+ * 打印机开启服务
150
+ * @param result YES:开启成功 NO:开启失败
151
+ */
152
+ - (void)didStart:(BOOL)result;
153
+
154
+ @end
155
+
156
+ @interface ConnectedDevice : NSObject
157
+
158
+ @property (nonatomic,assign)_Nullable id<ConnectedDeviceDelegate> delegate;
159
+ /**
160
+ * 获取设备名称
161
+ */
162
+ -(NSString *)deviceName;
163
+ /**
164
+ * 写入数据
165
+ * @param data 数据
166
+ */
167
+ -(void)write:(NSData *)data;
168
+ /**
169
+ * 读取数据
170
+ * @param options options
171
+ */
172
+ -(void)read:(ReadOptions *)options ;
173
+ /**
174
+ * 获取连接状态
175
+ */
176
+ -(ConnectionState)connectionState;
177
+ /**
178
+ * 获取实例
179
+ */
180
+ + (ConnectedDevice *)sharedInstance;
181
+ /**
182
+ * 开始扫描打印机设备
183
+ */
184
+ -(void)startScanPrinters;
185
+ /**
186
+ * 停止扫描打印机设备
187
+ */
188
+ -(void)stopScanPrinters;
189
+ /**
190
+ * 连接设备
191
+ * @param peripheral 外设
192
+ */
193
+ - (void)connect:(CBPeripheral*)peripheral;
194
+ /**
195
+ * 断开连接
196
+ * @param peripheral 外设
197
+ */
198
+ - (void)disconnect:(CBPeripheral*)peripheral;
199
+ - (void)disconnect;
200
+ /**
201
+ * 启动服务
202
+ * @param serviceUUIDString 服务 uuid
203
+ * @param peripheral 外设
204
+ */
205
+ - (BOOL)start:(NSString *)serviceUUIDString on:(CBPeripheral *)peripheral;
206
+ -(NSString *)getNowTimeTimestamp;
207
+
208
+ @end
209
+
210
+ @interface NoneConnectedDevice : ConnectedDevice
211
+
212
+ @end
213
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,22 @@
1
+ //
2
+ // IPRTBlueToothBaseDef.h
3
+ // adapter
4
+ //
5
+ // Created by IPRT on 2022/10/25.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+
10
+
11
+ typedef void (^ReceivedData)(NSData *revData, NSError *error);
12
+
13
+ /**
14
+ * 连接状态
15
+ */
16
+ typedef NS_ENUM (NSUInteger , ConnectionState){
17
+ /// 已连接
18
+ CONNECTED,
19
+ /// 未连接
20
+ DISCONNECT
21
+ };
22
+
@@ -0,0 +1,18 @@
1
+ //
2
+ // KeepStateConnectedDevice.h
3
+ // adapter
4
+ //
5
+ // Created by IPRT on 2022/11/10.
6
+ //
7
+
8
+ #import "BasedOtherConnectedDevice.h"
9
+ #import "QueueConfig.h"
10
+ NS_ASSUME_NONNULL_BEGIN
11
+
12
+ @interface KeepStateConnectedDevice : BasedOtherConnectedDevice
13
+ -(instancetype)initWithConfig:(QueueConfig *)config :(ConnectedDevice *)connectedDevice;
14
+ -(ConnectedDevice *)raw;
15
+ -(void)disconnect;
16
+ @end
17
+
18
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,18 @@
1
+ //
2
+ // QueueConfig.h
3
+ // adapter
4
+ //
5
+ // Created by IPRT on 2022/11/11.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+
10
+ NS_ASSUME_NONNULL_BEGIN
11
+
12
+ @interface QueueConfig : NSObject
13
+ -(QueueConfig *)def;
14
+ @property (nonatomic , assign) BOOL enable;
15
+ @property (nonatomic , assign) int interval;
16
+ @end
17
+
18
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,22 @@
1
+ //
2
+ // ReadOptions.h
3
+ // adapter
4
+ //
5
+ // Created by IPRT on 2022/10/24.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import "IPRTBlueToothBaseDef.h"
10
+
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ @interface ReadOptions : NSObject
14
+
15
+ @property(nonatomic, readonly) ReadOptions *(^timeout)(int time);
16
+ @property(nonatomic, copy) ReceivedData callBack;
17
+ - (ReadOptions *)def;
18
+ - (int)getTimeout;
19
+
20
+ @end
21
+
22
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,23 @@
1
+ //
2
+ // WroteReporter.h
3
+ // adapter
4
+ //
5
+ // Created by IPRT on 2022/10/24.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+
10
+ NS_ASSUME_NONNULL_BEGIN
11
+
12
+ @interface WroteReporter : NSObject
13
+ @property (nonatomic , readonly)WroteReporter *(^ok)(BOOL isOk);
14
+ @property (nonatomic , readonly)WroteReporter *(^binary)(NSData * br);
15
+ @property (nonatomic , readonly)WroteReporter *(^exception)(NSException *error);
16
+ @property (nonatomic , readonly)WroteReporter *(^controlExit)(BOOL controlExit);
17
+ -(BOOL)getIsOk;
18
+ -(NSData *)getBinary;
19
+ -(NSException *)getException;
20
+ -(BOOL)getIsControlExit;
21
+ @end
22
+
23
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,18 @@
1
+ //
2
+ // adapter.h
3
+ // adapter
4
+ //
5
+ // Created by aiyin on 2022/10/30.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <adapter/KeepStateConnectedDevice.h>
10
+ //! Project version number for adapter.
11
+ FOUNDATION_EXPORT double adapterVersionNumber;
12
+
13
+ //! Project version string for adapter.
14
+ FOUNDATION_EXPORT const unsigned char adapterVersionString[];
15
+
16
+ // In this header, you should import all the public headers of your framework using statements like #import <adapter/PublicHeader.h>
17
+
18
+
@@ -0,0 +1,6 @@
1
+ framework module adapter {
2
+ umbrella header "adapter.h"
3
+
4
+ export *
5
+ module * { export * }
6
+ }
@@ -0,0 +1,101 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>files</key>
6
+ <dict>
7
+ <key>Info.plist</key>
8
+ <data>
9
+ TAVyv2vEIAmPJAQ/p+c45neerAc=
10
+ </data>
11
+ </dict>
12
+ <key>files2</key>
13
+ <dict/>
14
+ <key>rules</key>
15
+ <dict>
16
+ <key>^.*</key>
17
+ <true/>
18
+ <key>^.*\.lproj/</key>
19
+ <dict>
20
+ <key>optional</key>
21
+ <true/>
22
+ <key>weight</key>
23
+ <real>1000</real>
24
+ </dict>
25
+ <key>^.*\.lproj/locversion.plist$</key>
26
+ <dict>
27
+ <key>omit</key>
28
+ <true/>
29
+ <key>weight</key>
30
+ <real>1100</real>
31
+ </dict>
32
+ <key>^Base\.lproj/</key>
33
+ <dict>
34
+ <key>weight</key>
35
+ <real>1010</real>
36
+ </dict>
37
+ <key>^version.plist$</key>
38
+ <true/>
39
+ </dict>
40
+ <key>rules2</key>
41
+ <dict>
42
+ <key>.*\.dSYM($|/)</key>
43
+ <dict>
44
+ <key>weight</key>
45
+ <real>11</real>
46
+ </dict>
47
+ <key>^(.*/)?\.DS_Store$</key>
48
+ <dict>
49
+ <key>omit</key>
50
+ <true/>
51
+ <key>weight</key>
52
+ <real>2000</real>
53
+ </dict>
54
+ <key>^.*</key>
55
+ <true/>
56
+ <key>^.*\.lproj/</key>
57
+ <dict>
58
+ <key>optional</key>
59
+ <true/>
60
+ <key>weight</key>
61
+ <real>1000</real>
62
+ </dict>
63
+ <key>^.*\.lproj/locversion.plist$</key>
64
+ <dict>
65
+ <key>omit</key>
66
+ <true/>
67
+ <key>weight</key>
68
+ <real>1100</real>
69
+ </dict>
70
+ <key>^Base\.lproj/</key>
71
+ <dict>
72
+ <key>weight</key>
73
+ <real>1010</real>
74
+ </dict>
75
+ <key>^Info\.plist$</key>
76
+ <dict>
77
+ <key>omit</key>
78
+ <true/>
79
+ <key>weight</key>
80
+ <real>20</real>
81
+ </dict>
82
+ <key>^PkgInfo$</key>
83
+ <dict>
84
+ <key>omit</key>
85
+ <true/>
86
+ <key>weight</key>
87
+ <real>20</real>
88
+ </dict>
89
+ <key>^embedded\.provisionprofile$</key>
90
+ <dict>
91
+ <key>weight</key>
92
+ <real>20</real>
93
+ </dict>
94
+ <key>^version\.plist$</key>
95
+ <dict>
96
+ <key>weight</key>
97
+ <real>20</real>
98
+ </dict>
99
+ </dict>
100
+ </dict>
101
+ </plist>