incyclist-services 1.7.69 → 1.7.70

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.
@@ -261,7 +261,15 @@ let ActivityRideService = (() => {
261
261
  catch {
262
262
  }
263
263
  if (showLog) {
264
- this.logEvent({ message: 'Dashboard update', items: info.map(i => `${i.title}:${i.data[0]?.value ?? ''}:${i.data[1]?.value ?? ''}${i.data[1]?.label ? '(' + i.data[1]?.label + ')' : ''}`).join('|') });
264
+ const getLog = (i) => {
265
+ let health = '';
266
+ if (i.dataState === 'amber')
267
+ health = '[A]';
268
+ if (i.dataState === 'red')
269
+ health = '[R]';
270
+ return `${i.title}${health}:${i.data[0]?.value ?? ''}:${i.data[1]?.value ?? ''}${i.data[1]?.label ? '(' + i.data[1]?.label + ')' : ''}`;
271
+ };
272
+ this.logEvent({ message: 'Dashboard update', items: info.map(getLog).join('|') });
265
273
  }
266
274
  return info;
267
275
  }
@@ -691,7 +691,7 @@ let DeviceRideService = (() => {
691
691
  const tsLastData = this.getLastDataTS(ai);
692
692
  const isPaused = ai.adapter.isPaused();
693
693
  const prevStatus = ai.dataStatus;
694
- if (isPaused || !tsLastData || ai.isRestarting) {
694
+ if (isPaused || !tsLastData) {
695
695
  this.setLastDataTS(ai, tsNow);
696
696
  ai.dataStatus = 'green';
697
697
  return;
@@ -715,6 +715,7 @@ let DeviceRideService = (() => {
715
715
  if (ai.dataStatus !== prevStatus) {
716
716
  const { enabledCapabilities } = this.getEnabledCapabilities(ai);
717
717
  this.emit('health', ai.udid, ai.dataStatus, enabledCapabilities);
718
+ this.logEvent({ message: 'device health status changed', device: ai.adapter.getUniqueName(), udid: ai.udid, healthState: ai.dataStatus });
718
719
  }
719
720
  };
720
721
  if (ai.ivToCheck) {
@@ -752,16 +753,22 @@ let DeviceRideService = (() => {
752
753
  }
753
754
  }
754
755
  async prepareReconnect(unhealthy) {
755
- this.logEvent({ message: 'prepareReconnect', device: unhealthy.adapter.getUniqueName(), udid: unhealthy.udid, noDataSince: (Date.now() - unhealthy.tsLastData), tsLastData: unhealthy.tsLastData, isRestarting: unhealthy.isRestarting });
756
+ const tsLastData = this.getLastDataTS(unhealthy);
757
+ const tsLastDataStr = new Date(tsLastData).toISOString();
758
+ const tsNow = Date.now();
759
+ this.logEvent({ message: 'prepareReconnect', device: unhealthy.adapter.getUniqueName(), udid: unhealthy.udid, noDataSince: (tsNow - tsLastData), tsLastData: tsLastDataStr, isRestarting: unhealthy.isRestarting });
756
760
  if (unhealthy.isRestarting) {
757
- this.logEvent({ message: 'skipped reconnect - device already restarting', device: unhealthy.adapter.getUniqueName(), udid: unhealthy.udid, noDataSince: (Date.now() - unhealthy.tsLastData), tsLastData: unhealthy.tsLastData });
761
+ this.logEvent({ message: 'skipped reconnect - device already restarting', device: unhealthy.adapter.getUniqueName(), udid: unhealthy.udid, noDataSince: (tsNow - tsLastData), tsLastData: tsLastDataStr });
758
762
  return;
759
763
  }
760
764
  unhealthy.isRestarting = true;
765
+ unhealthy.isHealthy = false;
761
766
  const ifName = unhealthy.adapter.getInterface();
762
767
  const adapters = this.rideAdapters?.filter(ai => ai.adapter.getInterface() === ifName);
763
- const stillHealthy = adapters.filter(ai => ai.isHealthy === undefined || ai.isHealthy);
764
- this.logEvent({ message: 'reconnect confirmed', device: unhealthy.adapter.getUniqueName(), udid: unhealthy.udid, noDataSince: (Date.now() - unhealthy.tsLastData), tsLastData: unhealthy.tsLastData, stillHealthy: stillHealthy?.length, onSameInterface: adapters.length });
768
+ const stillHealthy = adapters.filter(ai => ai.isHealthy === undefined || ai.isHealthy === true);
769
+ this.logEvent({ message: 'reconnect confirmed', device: unhealthy.adapter.getUniqueName(), udid: unhealthy.udid,
770
+ noDataSince: (tsNow - tsLastData),
771
+ tsLastData: tsLastDataStr, stillHealthy: stillHealthy?.length, onSameInterface: adapters.length });
765
772
  try {
766
773
  if (!stillHealthy?.length && adapters.length > 1 && ifName !== 'ble') {
767
774
  await this.reconnectInterface(ifName, adapters);
@@ -792,6 +799,13 @@ let DeviceRideService = (() => {
792
799
  this.reconnectBusy = false;
793
800
  return;
794
801
  }
802
+ const restarting = adapters.filter(ai => ai.isRestarting) ?? [];
803
+ if (restarting.length) {
804
+ this.logEvent({ message: 'interrupt restarts', interface: ifName });
805
+ for (const ai of restarting) {
806
+ await this.stopDuringInterfaceRestart(ai);
807
+ }
808
+ }
795
809
  this.logEvent({ message: 'restart interface', interface: ifName });
796
810
  let stopRequested = false;
797
811
  this.once('stop-ride', () => { stopRequested = true; });
@@ -878,6 +892,7 @@ let DeviceRideService = (() => {
878
892
  catch (err) {
879
893
  this.logError(err, 'stopDuringInterfaceRestart');
880
894
  }
895
+ unhealthy.isRestarting = false;
881
896
  }
882
897
  async reconnectSingle(unhealthy) {
883
898
  unhealthy.isRestarting = true;
@@ -255,7 +255,15 @@ let ActivityRideService = (() => {
255
255
  catch {
256
256
  }
257
257
  if (showLog) {
258
- this.logEvent({ message: 'Dashboard update', items: info.map(i => `${i.title}:${i.data[0]?.value ?? ''}:${i.data[1]?.value ?? ''}${i.data[1]?.label ? '(' + i.data[1]?.label + ')' : ''}`).join('|') });
258
+ const getLog = (i) => {
259
+ let health = '';
260
+ if (i.dataState === 'amber')
261
+ health = '[A]';
262
+ if (i.dataState === 'red')
263
+ health = '[R]';
264
+ return `${i.title}${health}:${i.data[0]?.value ?? ''}:${i.data[1]?.value ?? ''}${i.data[1]?.label ? '(' + i.data[1]?.label + ')' : ''}`;
265
+ };
266
+ this.logEvent({ message: 'Dashboard update', items: info.map(getLog).join('|') });
259
267
  }
260
268
  return info;
261
269
  }
@@ -685,7 +685,7 @@ let DeviceRideService = (() => {
685
685
  const tsLastData = this.getLastDataTS(ai);
686
686
  const isPaused = ai.adapter.isPaused();
687
687
  const prevStatus = ai.dataStatus;
688
- if (isPaused || !tsLastData || ai.isRestarting) {
688
+ if (isPaused || !tsLastData) {
689
689
  this.setLastDataTS(ai, tsNow);
690
690
  ai.dataStatus = 'green';
691
691
  return;
@@ -709,6 +709,7 @@ let DeviceRideService = (() => {
709
709
  if (ai.dataStatus !== prevStatus) {
710
710
  const { enabledCapabilities } = this.getEnabledCapabilities(ai);
711
711
  this.emit('health', ai.udid, ai.dataStatus, enabledCapabilities);
712
+ this.logEvent({ message: 'device health status changed', device: ai.adapter.getUniqueName(), udid: ai.udid, healthState: ai.dataStatus });
712
713
  }
713
714
  };
714
715
  if (ai.ivToCheck) {
@@ -746,16 +747,22 @@ let DeviceRideService = (() => {
746
747
  }
747
748
  }
748
749
  async prepareReconnect(unhealthy) {
749
- this.logEvent({ message: 'prepareReconnect', device: unhealthy.adapter.getUniqueName(), udid: unhealthy.udid, noDataSince: (Date.now() - unhealthy.tsLastData), tsLastData: unhealthy.tsLastData, isRestarting: unhealthy.isRestarting });
750
+ const tsLastData = this.getLastDataTS(unhealthy);
751
+ const tsLastDataStr = new Date(tsLastData).toISOString();
752
+ const tsNow = Date.now();
753
+ this.logEvent({ message: 'prepareReconnect', device: unhealthy.adapter.getUniqueName(), udid: unhealthy.udid, noDataSince: (tsNow - tsLastData), tsLastData: tsLastDataStr, isRestarting: unhealthy.isRestarting });
750
754
  if (unhealthy.isRestarting) {
751
- this.logEvent({ message: 'skipped reconnect - device already restarting', device: unhealthy.adapter.getUniqueName(), udid: unhealthy.udid, noDataSince: (Date.now() - unhealthy.tsLastData), tsLastData: unhealthy.tsLastData });
755
+ this.logEvent({ message: 'skipped reconnect - device already restarting', device: unhealthy.adapter.getUniqueName(), udid: unhealthy.udid, noDataSince: (tsNow - tsLastData), tsLastData: tsLastDataStr });
752
756
  return;
753
757
  }
754
758
  unhealthy.isRestarting = true;
759
+ unhealthy.isHealthy = false;
755
760
  const ifName = unhealthy.adapter.getInterface();
756
761
  const adapters = this.rideAdapters?.filter(ai => ai.adapter.getInterface() === ifName);
757
- const stillHealthy = adapters.filter(ai => ai.isHealthy === undefined || ai.isHealthy);
758
- this.logEvent({ message: 'reconnect confirmed', device: unhealthy.adapter.getUniqueName(), udid: unhealthy.udid, noDataSince: (Date.now() - unhealthy.tsLastData), tsLastData: unhealthy.tsLastData, stillHealthy: stillHealthy?.length, onSameInterface: adapters.length });
762
+ const stillHealthy = adapters.filter(ai => ai.isHealthy === undefined || ai.isHealthy === true);
763
+ this.logEvent({ message: 'reconnect confirmed', device: unhealthy.adapter.getUniqueName(), udid: unhealthy.udid,
764
+ noDataSince: (tsNow - tsLastData),
765
+ tsLastData: tsLastDataStr, stillHealthy: stillHealthy?.length, onSameInterface: adapters.length });
759
766
  try {
760
767
  if (!stillHealthy?.length && adapters.length > 1 && ifName !== 'ble') {
761
768
  await this.reconnectInterface(ifName, adapters);
@@ -786,6 +793,13 @@ let DeviceRideService = (() => {
786
793
  this.reconnectBusy = false;
787
794
  return;
788
795
  }
796
+ const restarting = adapters.filter(ai => ai.isRestarting) ?? [];
797
+ if (restarting.length) {
798
+ this.logEvent({ message: 'interrupt restarts', interface: ifName });
799
+ for (const ai of restarting) {
800
+ await this.stopDuringInterfaceRestart(ai);
801
+ }
802
+ }
789
803
  this.logEvent({ message: 'restart interface', interface: ifName });
790
804
  let stopRequested = false;
791
805
  this.once('stop-ride', () => { stopRequested = true; });
@@ -872,6 +886,7 @@ let DeviceRideService = (() => {
872
886
  catch (err) {
873
887
  this.logError(err, 'stopDuringInterfaceRestart');
874
888
  }
889
+ unhealthy.isRestarting = false;
875
890
  }
876
891
  async reconnectSingle(unhealthy) {
877
892
  unhealthy.isRestarting = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-services",
3
- "version": "1.7.69",
3
+ "version": "1.7.70",
4
4
  "peerDependencies": {
5
5
  "gd-eventlog": "^0.1.27"
6
6
  },