incyclist-devices 1.4.0 → 1.4.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.
@@ -575,8 +575,6 @@ class AntProtocol extends DeviceProtocol_1.default {
575
575
  const channel = channelsUsed + idx;
576
576
  const { sensor } = i;
577
577
  i.device.setChannel(channel);
578
- if (process.env.DEBUG)
579
- console.log('~~~~Ant: attach', channel, i.device.getID());
580
578
  sensor.attach(channel, i.device.getID());
581
579
  this.sensors.attached.push(i);
582
580
  });
@@ -156,7 +156,7 @@ class DaumClassicProtocol extends DeviceProtocol_1.default {
156
156
  return;
157
157
  scan.scanning = true;
158
158
  return device.check()
159
- .then(() => {
159
+ .then(() => __awaiter(this, void 0, void 0, function* () {
160
160
  if (this.state.stopScanning)
161
161
  return;
162
162
  const { onDeviceFound, onScanFinished, id } = opts;
@@ -166,10 +166,16 @@ class DaumClassicProtocol extends DeviceProtocol_1.default {
166
166
  if (onScanFinished) {
167
167
  onScanFinished(id);
168
168
  }
169
+ try {
170
+ yield device.getBike().saveClose();
171
+ }
172
+ catch (err) {
173
+ this.logger.logEvent({ message: 'scanCommand warning: Could not close port', error: err.message });
174
+ }
169
175
  clearInterval(scan.iv);
170
176
  scan.iv = undefined;
171
177
  scan.scanning = false;
172
- })
178
+ }))
173
179
  .catch(() => {
174
180
  scan.scanning = false;
175
181
  });
@@ -1,4 +1,4 @@
1
- export declare function getCockpit(c: any): "Cardio" | "Fitness" | "Vita De Luxe" | "8008" | "8080" | "Therapie" | "8008 TRS Pro" | "8008 TRS3" | "Unknown";
1
+ export declare function getCockpit(c: any): "Cardio" | "Fitness" | "Vita De Luxe" | "8008" | "8008 TRS" | "8080" | "Therapie" | "8008 TRS Pro" | "8008 TRS3" | "Unknown";
2
2
  export declare function getBikeType(type: any): 1 | 0;
3
3
  export declare function getAge(birthday: any): number;
4
4
  export declare function getGender(sex: any): 1 | 2;
@@ -11,6 +11,8 @@ function getCockpit(c) {
11
11
  return "Vita De Luxe";
12
12
  case 40:
13
13
  return "8008";
14
+ case 0x2A:
15
+ return "8008 TRS";
14
16
  case 50:
15
17
  return "8080";
16
18
  case 60:
@@ -177,7 +177,7 @@ class DaumPremiumProtocol extends DeviceProtocol_1.default {
177
177
  return;
178
178
  scan.scanning = true;
179
179
  device.check()
180
- .then(() => {
180
+ .then(() => __awaiter(this, void 0, void 0, function* () {
181
181
  if (this.state.stopScanning)
182
182
  return;
183
183
  const { onDeviceFound, onScanFinished, id } = opts;
@@ -187,10 +187,16 @@ class DaumPremiumProtocol extends DeviceProtocol_1.default {
187
187
  if (onScanFinished) {
188
188
  onScanFinished(id);
189
189
  }
190
+ try {
191
+ yield device.getBike().saveClose();
192
+ }
193
+ catch (err) {
194
+ this.logger.logEvent({ message: 'scanCommand warning: Could not close port', error: err.message });
195
+ }
190
196
  clearInterval(scan.iv);
191
197
  scan.iv = undefined;
192
198
  scan.scanning = false;
193
- })
199
+ }))
194
200
  .catch(() => {
195
201
  scan.scanning = false;
196
202
  });
@@ -166,21 +166,18 @@ class Daum8i {
166
166
  const tTimeout = Date.now() + TIMEOUT_START;
167
167
  const iv = setInterval(() => {
168
168
  if (this.state.error !== undefined) {
169
- console.log('~~ -> error');
170
169
  clearInterval(iv);
171
170
  this.forceClose();
172
171
  reject(this.state.error);
173
172
  this.state = { opened: false, closed: true, busy: false };
174
173
  }
175
174
  else if (this.isConnected()) {
176
- console.log('~~ -> connected');
177
175
  this.state.connecting = false;
178
176
  resolve(true);
179
177
  clearInterval(iv);
180
178
  }
181
179
  else {
182
180
  if (Date.now() > tTimeout) {
183
- console.log('~~ -> timeout');
184
181
  this.state.connecting = false;
185
182
  this.forceClose();
186
183
  clearInterval(iv);
@@ -281,7 +278,6 @@ class Daum8i {
281
278
  });
282
279
  }
283
280
  forceClose(updateState = false) {
284
- console.log('~~~ forceClose', updateState);
285
281
  const sp = this.sp;
286
282
  if (!this.sp)
287
283
  return;
@@ -38,18 +38,15 @@ class TcpSocketPort {
38
38
  });
39
39
  }
40
40
  this.logger.logEvent({ message: 'opening', id: this.id, retry });
41
- console.log('~~opening socket', this.id);
42
41
  this.socket.connect(this.port, this.host);
43
42
  }
44
43
  catch (err) {
45
44
  this.logger.logEvent({ message: 'opening error', id: this.id, error: err.message, stack: err.stack });
46
- console.log('~~open socket error', this.id, err);
47
45
  this.emit('error', err);
48
46
  }
49
47
  }
50
48
  close() {
51
49
  this.logger.logEvent({ message: 'closing', id: this.id });
52
- console.log('~~closing socket', this.id);
53
50
  this.isOpen = false;
54
51
  this.isClosed = true;
55
52
  try {
@@ -67,7 +64,6 @@ class TcpSocketPort {
67
64
  if (this.isOpen)
68
65
  return;
69
66
  this.logger.logEvent({ message: 'timeout', id: this.id });
70
- console.log('~~socket timeout', this.id);
71
67
  try {
72
68
  this.socket.end();
73
69
  }
@@ -78,14 +74,12 @@ class TcpSocketPort {
78
74
  }
79
75
  onConnect() {
80
76
  this.logger.logEvent({ message: 'connected', id: this.id });
81
- console.log('~~socket connected', this.id);
82
77
  this.isOpen = true;
83
78
  this.isClosed = false;
84
79
  this.emit('open');
85
80
  }
86
81
  onError(err) {
87
82
  this.logger.logEvent({ message: 'error', error: err.message });
88
- console.log('~~socket error', this.id, err);
89
83
  if (this.callbacks['error'])
90
84
  this.callbacks['error'](err);
91
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "dependencies": {
5
5
  "@serialport/parser-byte-length": "^9.0.1",
6
6
  "@serialport/parser-delimiter": "^9.0.1",