@leonardojc/capacitor-ioboard 2.0.4 → 2.0.5

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.
@@ -182,29 +182,32 @@ public class CapacitorIoboardPlugin extends Plugin implements SerialConnectionMa
182
182
  result.put("firmware", parsedResponse.firmware);
183
183
  result.put("doorStatus", parsedResponse.doorStatus);
184
184
 
185
- // Interpret door status for user
186
- String doorStatusText;
187
- switch (parsedResponse.doorStatus) {
188
- case 0xFE:
189
- doorStatusText = "closed";
190
- break;
191
- case 0xFF:
192
- doorStatusText = "open";
193
- break;
194
- case 0x00:
195
- doorStatusText = "unknown";
196
- break;
197
- case 0x01:
198
- doorStatusText = "moving";
199
- break;
200
- default:
201
- doorStatusText = "custom";
202
- break;
185
+ // Parse door status bitmask (each bit represents a door)
186
+ // Bit 0 = Door 1, Bit 1 = Door 2, etc.
187
+ // 0 = closed, 1 = open
188
+ // Example: 0xF8 (11111000) = doors 1,2,3 closed, rest open
189
+ JSArray doorsArray = new JSArray();
190
+ for (int i = 0; i < 8; i++) {
191
+ boolean isOpen = ((parsedResponse.doorStatus & (1 << i)) != 0);
192
+ JSObject doorInfo = new JSObject();
193
+ doorInfo.put("doorNumber", i + 1);
194
+ doorInfo.put("isOpen", isOpen);
195
+ doorInfo.put("status", isOpen ? "open" : "closed");
196
+ doorsArray.put(doorInfo);
197
+ }
198
+ result.put("doors", doorsArray);
199
+
200
+ // Summary text
201
+ StringBuilder doorStatusText = new StringBuilder();
202
+ for (int i = 0; i < 8; i++) {
203
+ boolean isOpen = ((parsedResponse.doorStatus & (1 << i)) != 0);
204
+ if (i > 0) doorStatusText.append(", ");
205
+ doorStatusText.append("D").append(i + 1).append(":").append(isOpen ? "open" : "closed");
203
206
  }
204
- result.put("doorStatusText", doorStatusText);
207
+ result.put("doorStatusText", doorStatusText.toString());
205
208
 
206
- Log.i(TAG, String.format("✅ IOBoard Status - Firmware: %s, Door: 0x%02X (%s)",
207
- parsedResponse.firmware, parsedResponse.doorStatus, doorStatusText));
209
+ Log.i(TAG, String.format("✅ IOBoard Status - Firmware: %s, Door Status: 0x%02X (%s)",
210
+ parsedResponse.firmware, parsedResponse.doorStatus, doorStatusText.toString()));
208
211
 
209
212
  call.resolve(result);
210
213
 
@@ -78,11 +78,17 @@ export interface IOBoardResponse {
78
78
  message?: string;
79
79
  data?: any;
80
80
  }
81
+ export interface DoorInfo {
82
+ doorNumber: number;
83
+ isOpen: boolean;
84
+ status: 'open' | 'closed';
85
+ }
81
86
  export interface IOBoardStatusResponse extends IOBoardResponse {
82
87
  address?: number;
83
88
  firmware?: string;
84
89
  doorStatus?: number;
85
- doorStatusText?: 'closed' | 'open' | 'unknown' | 'moving' | 'custom';
90
+ doors?: DoorInfo[];
91
+ doorStatusText?: string;
86
92
  }
87
93
  export interface SerialConnectionOptions {
88
94
  portPath?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leonardojc/capacitor-ioboard",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "A comprehensive Capacitor plugin for IOBoard devices with integrated serial communication and complete MTC3P08L protocol support including OTA updates",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",