incyclist-devices 2.0.8 → 2.0.9

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.
@@ -188,6 +188,10 @@ class DaumAdapterBase extends adapter_1.SerialIncyclistDevice {
188
188
  if (!this.logger)
189
189
  return;
190
190
  this.logger.logEvent(event);
191
+ const w = global.window;
192
+ if (w === null || w === void 0 ? void 0 : w.DEVICE_DEBUG) {
193
+ console.log('~~~ Serial', event);
194
+ }
191
195
  }
192
196
  stop() {
193
197
  if (this.stopped)
@@ -82,9 +82,9 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
82
82
  if (this.isStopped())
83
83
  return false;
84
84
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
85
- this.logger.logEvent({ message: "checking device", port: this.getPort() });
85
+ this.logEvent({ message: "checking device", port: this.getPort() });
86
86
  const iv = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
87
- this.logger.logEvent({ message: "checking device failed", port: this.getPort(), reason: 'timeout' });
87
+ this.logEvent({ message: "checking device failed", port: this.getPort(), reason: 'timeout' });
88
88
  resolve(false);
89
89
  }), 5000);
90
90
  try {
@@ -92,6 +92,7 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
92
92
  if (!connected) {
93
93
  clearTimeout(iv);
94
94
  resolve(false);
95
+ return;
95
96
  }
96
97
  const address = (yield this.bike.getAddress()) || {};
97
98
  info.bikeNo = address.bike;
@@ -101,11 +102,11 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
101
102
  this.setName('Daum ' + info.cockpit);
102
103
  this.setID(info.serialNo);
103
104
  clearTimeout(iv);
104
- this.logger.logEvent({ message: "checking device success", port: this.getPort(), info });
105
+ this.logEvent({ message: "checking device success", port: this.getPort(), info });
105
106
  resolve(true);
106
107
  }
107
108
  catch (err) {
108
- this.logger.logEvent({ message: "checking device failed", port: this.getPort(), reason: err.message || err });
109
+ this.logEvent({ message: "checking device failed", port: this.getPort(), reason: err.message || err });
109
110
  resolve(false);
110
111
  }
111
112
  }));
@@ -133,7 +134,7 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
133
134
  }
134
135
  startRide(props = {}) {
135
136
  return __awaiter(this, void 0, void 0, function* () {
136
- this.logger.logEvent({ message: 'relaunch of device' });
137
+ this.logEvent({ message: 'relaunch of device' });
137
138
  try {
138
139
  yield this.launch(props, true);
139
140
  return true;
@@ -146,7 +147,7 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
146
147
  }
147
148
  start(props = {}) {
148
149
  return __awaiter(this, void 0, void 0, function* () {
149
- this.logger.logEvent({ message: 'initial start of device' });
150
+ this.logEvent({ message: 'initial start of device' });
150
151
  try {
151
152
  yield this.launch(props, false);
152
153
  return true;
@@ -172,11 +173,11 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
172
173
  }
173
174
  catch (_a) { }
174
175
  }
175
- this.logger.logEvent({ message: 'start result: success' });
176
+ this.logEvent({ message: 'start result: success' });
176
177
  return true;
177
178
  }
178
179
  catch (err) {
179
- this.logger.logEvent({ message: 'start result: error', error: err.message });
180
+ this.logEvent({ message: 'start result: error', error: err.message });
180
181
  throw new Error(`could not start device, reason:${err.message}`);
181
182
  }
182
183
  });
@@ -190,9 +191,12 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
190
191
  let startState = {};
191
192
  return (0, utils_1.runWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
192
193
  try {
193
- this.logger.logEvent({ message: 'start attempt', isRelaunch, isConnected: this.bike.isConnected() });
194
- if (!isRelaunch && !this.bike.isConnected())
195
- yield this.connect();
194
+ this.logEvent({ message: 'start attempt', isRelaunch, isConnected: this.bike.isConnected() });
195
+ if (!isRelaunch && !this.bike.isConnected()) {
196
+ const connected = yield this.connect();
197
+ if (!connected)
198
+ throw new Error('Could not connect');
199
+ }
196
200
  yield this.getBike().resetDevice();
197
201
  if (!startState.setProg) {
198
202
  yield this.getBike().setProg(0);
@@ -228,7 +232,7 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
228
232
  return data;
229
233
  }
230
234
  catch (err) {
231
- this.logger.logEvent({ message: 'start attempt failed', error: err.message });
235
+ this.logEvent({ message: 'start attempt failed', error: err.message });
232
236
  if (startState.checkRunData) {
233
237
  startState = {};
234
238
  }
@@ -60,6 +60,10 @@ class Daum8008 {
60
60
  logEvent(e) {
61
61
  if (!this.isLoggingPaused)
62
62
  this.logger.logEvent(e);
63
+ const w = global.window;
64
+ if (w === null || w === void 0 ? void 0 : w.DEVICE_DEBUG) {
65
+ console.log('~~~ DaumClassic', e);
66
+ }
63
67
  }
64
68
  connect() {
65
69
  return __awaiter(this, void 0, void 0, function* () {
@@ -67,8 +71,10 @@ class Daum8008 {
67
71
  return true;
68
72
  }
69
73
  try {
74
+ this.logEvent({ message: 'connect attempt', port: this.portName });
70
75
  const port = yield this.serial.openPort(this.portName);
71
76
  if (port !== null) {
77
+ this.logEvent({ message: 'connect success', port: this.portName });
72
78
  this.connected = true;
73
79
  this.sp = port;
74
80
  this.sp.on('close', this.onPortClose.bind(this));
@@ -76,10 +82,12 @@ class Daum8008 {
76
82
  return true;
77
83
  }
78
84
  else {
85
+ this.logEvent({ message: 'connect failure' });
79
86
  return false;
80
87
  }
81
88
  }
82
- catch (_a) {
89
+ catch (err) {
90
+ this.logEvent({ message: 'connect failure', reason: err.message });
83
91
  return false;
84
92
  }
85
93
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "dependencies": {
5
5
  "@serialport/bindings-interface": "^1.2.2",
6
6
  "@serialport/parser-byte-length": "^9.0.1",