incyclist-devices 2.4.10 → 2.4.11

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.
@@ -157,31 +157,38 @@ class BleZwiftPlaySensor extends sensor_1.TBleSensor {
157
157
  }
158
158
  initHubService() {
159
159
  return __awaiter(this, arguments, void 0, function* (setSimulation = true) {
160
- var _a;
161
160
  if (!this.isHubServiceActive && this.initHubServicePromise !== undefined) {
162
161
  yield this.initHubServicePromise;
163
162
  }
163
+ const subscribe = () => __awaiter(this, void 0, void 0, function* () {
164
+ var _a;
165
+ if (!this.isHubServiceSubscribed) {
166
+ this.logEvent({ message: 'subscribe to hub service characteristics' });
167
+ this.subscribePromise = (_a = this.subscribePromise) !== null && _a !== void 0 ? _a : this.subscribe();
168
+ const subscribed = yield this.subscribePromise;
169
+ this.subscribePromise = undefined;
170
+ this.isHubServiceSubscribed = subscribed;
171
+ if (!subscribed)
172
+ return false;
173
+ this.logEvent({ message: 'subscribed to hub service characteristics' });
174
+ }
175
+ });
176
+ const pair = () => __awaiter(this, void 0, void 0, function* () {
177
+ if (!this.isHubServicePaired) {
178
+ this.logEvent({ message: 'pair hub service' });
179
+ this.pairPromise = this.pair();
180
+ const paired = yield this.pairPromise;
181
+ this.pairPromise = undefined;
182
+ if (!paired)
183
+ return false;
184
+ }
185
+ });
164
186
  if (this.isHubServiceActive)
165
187
  return true;
166
188
  this.logEvent({ message: 'init hub service', paired: this.isHubPairConfirmed, subscribed: this.isHubServiceSubscribed });
167
- if (!this.isHubServicePaired) {
168
- this.logEvent({ message: 'pair hub service' });
169
- this.pairPromise = this.pair();
170
- const paired = yield this.pairPromise;
171
- this.pairPromise = undefined;
172
- if (!paired)
173
- return false;
174
- }
175
- if (!this.isHubServiceSubscribed) {
176
- this.logEvent({ message: 'subscribe to hub service characteristics' });
177
- this.subscribePromise = (_a = this.subscribePromise) !== null && _a !== void 0 ? _a : this.subscribe();
178
- const subscribed = yield this.subscribePromise;
179
- this.subscribePromise = undefined;
180
- this.isHubServiceSubscribed = subscribed;
181
- if (!subscribed)
182
- return false;
183
- this.logEvent({ message: 'subscribed to hub service characteristics' });
184
- }
189
+ yield subscribe();
190
+ yield pair();
191
+ yield subscribe();
185
192
  this.initHubServicePromise = new Promise((done) => {
186
193
  this.logEvent({ message: 'send hub init message' });
187
194
  let timeout = setTimeout(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "2.4.10",
3
+ "version": "2.4.11",
4
4
  "dependencies": {
5
5
  "@protobuf-ts/runtime": "^2.11.1",
6
6
  "@serialport/bindings-interface": "^1.2.2",