node-libcec 1.0.4 → 1.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.
@@ -102,9 +102,23 @@ const timeout = setTimeout(() => {
102
102
 
103
103
  let opened = false;
104
104
  try {
105
+ // First try auto-detect
105
106
  opened = adapter.open();
106
107
  clearTimeout(timeout);
107
- console.log(` OK: open() returned ${opened} in ${Date.now() - openStart}ms`);
108
+ console.log(` open() with auto-detect returned ${opened} in ${Date.now() - openStart}ms`);
109
+
110
+ // If auto-detect failed, try explicit port
111
+ if (!opened) {
112
+ console.log(' Trying explicit port from detected adapters...');
113
+ const adapters = native.CECAdapter.detectAdapters();
114
+ if (adapters.length > 0) {
115
+ const port = adapters[0].comPath;
116
+ console.log(` Trying open('${port}')...`);
117
+ const openStart2 = Date.now();
118
+ opened = adapter.open(port);
119
+ console.log(` open('${port}') returned ${opened} in ${Date.now() - openStart2}ms`);
120
+ }
121
+ }
108
122
  } catch (e) {
109
123
  clearTimeout(timeout);
110
124
  console.error(` FAILED: open() threw after ${Date.now() - openStart}ms`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-libcec",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Node.js bindings for libcec - control CEC devices over HDMI",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",