@homebridge/hap-nodejs 2.2.4-beta.3 → 2.2.4-beta.4
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.
- package/dist/lib/Accessory.d.ts +24 -3
- package/dist/lib/Accessory.d.ts.map +1 -1
- package/dist/lib/Accessory.js +127 -149
- package/dist/lib/Accessory.js.map +1 -1
- package/dist/lib/Advertiser.d.ts +1 -0
- package/dist/lib/Advertiser.d.ts.map +1 -1
- package/dist/lib/Advertiser.js +52 -25
- package/dist/lib/Advertiser.js.map +1 -1
- package/dist/lib/Characteristic.d.ts +14 -1
- package/dist/lib/Characteristic.d.ts.map +1 -1
- package/dist/lib/Characteristic.js +32 -19
- package/dist/lib/Characteristic.js.map +1 -1
- package/dist/lib/HAPServer.d.ts +17 -0
- package/dist/lib/HAPServer.d.ts.map +1 -1
- package/dist/lib/HAPServer.js +74 -4
- package/dist/lib/HAPServer.js.map +1 -1
- package/dist/lib/Service.d.ts.map +1 -1
- package/dist/lib/Service.js +2 -0
- package/dist/lib/Service.js.map +1 -1
- package/dist/lib/camera/RTPProxy.d.ts.map +1 -1
- package/dist/lib/camera/RTPProxy.js +14 -0
- package/dist/lib/camera/RTPProxy.js.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.d.ts +1 -0
- package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.js +65 -23
- package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.d.ts.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.js +22 -4
- package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
- package/dist/lib/controller/RemoteController.d.ts.map +1 -1
- package/dist/lib/controller/RemoteController.js +35 -13
- package/dist/lib/controller/RemoteController.js.map +1 -1
- package/dist/lib/datastream/DataStreamParser.d.ts +14 -0
- package/dist/lib/datastream/DataStreamParser.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamParser.js +37 -6
- package/dist/lib/datastream/DataStreamParser.js.map +1 -1
- package/dist/lib/datastream/DataStreamServer.d.ts +8 -0
- package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamServer.js +44 -5
- package/dist/lib/datastream/DataStreamServer.js.map +1 -1
- package/dist/lib/model/ControllerStorage.d.ts +7 -0
- package/dist/lib/model/ControllerStorage.d.ts.map +1 -1
- package/dist/lib/model/ControllerStorage.js +31 -0
- package/dist/lib/model/ControllerStorage.js.map +1 -1
- package/dist/lib/util/checkName.d.ts.map +1 -1
- package/dist/lib/util/checkName.js +2 -1
- package/dist/lib/util/checkName.js.map +1 -1
- package/dist/lib/util/color-utils.d.ts.map +1 -1
- package/dist/lib/util/color-utils.js +7 -5
- package/dist/lib/util/color-utils.js.map +1 -1
- package/dist/lib/util/eventedhttp.d.ts +42 -0
- package/dist/lib/util/eventedhttp.d.ts.map +1 -1
- package/dist/lib/util/eventedhttp.js +114 -9
- package/dist/lib/util/eventedhttp.js.map +1 -1
- package/dist/lib/util/hapCrypto.d.ts.map +1 -1
- package/dist/lib/util/hapCrypto.js +5 -1
- package/dist/lib/util/hapCrypto.js.map +1 -1
- package/dist/lib/util/request-util.d.ts +9 -0
- package/dist/lib/util/request-util.d.ts.map +1 -1
- package/dist/lib/util/request-util.js +20 -0
- package/dist/lib/util/request-util.js.map +1 -1
- package/dist/lib/util/tlv.d.ts.map +1 -1
- package/dist/lib/util/tlv.js +6 -0
- package/dist/lib/util/tlv.js.map +1 -1
- package/dist/lib/util/uuid.d.ts +2 -2
- package/package.json +4 -4
package/dist/lib/Accessory.d.ts
CHANGED
|
@@ -233,9 +233,8 @@ export declare const enum AccessoryEventTypes {
|
|
|
233
233
|
/**
|
|
234
234
|
* Emitted when an iOS device wishes for this Accessory to identify itself. If `paired` is false, then
|
|
235
235
|
* this device is currently browsing for Accessories in the system-provided "Add Accessory" screen. If
|
|
236
|
-
* `paired` is true, then this is a device that has already paired with us
|
|
237
|
-
*
|
|
238
|
-
* `getService(Service.AccessoryInformation).getCharacteristic(Characteristic.Identify).on('set', ...)`
|
|
236
|
+
* `paired` is true, then this is a device that has already paired with us, and wrote `true` to the `Identify` Characteristic
|
|
237
|
+
* of the `AccessoryInformation` service (after any handlers a plugin set up on that characteristic were called).
|
|
239
238
|
* You must call the callback for identification to be successful.
|
|
240
239
|
*/
|
|
241
240
|
IDENTIFY = "identify",
|
|
@@ -354,6 +353,16 @@ export declare class Accessory extends EventEmitter {
|
|
|
354
353
|
private permsQuarantined;
|
|
355
354
|
constructor(displayName: string, UUID: string);
|
|
356
355
|
private identificationRequest;
|
|
356
|
+
/**
|
|
357
|
+
* A paired device wishes for us to identify ourselves by writing `true` to the `Identify` characteristic (as opposed
|
|
358
|
+
* to an unpaired device - that case is handled by the HAPServer 'identify' event). This is handled here rather than
|
|
359
|
+
* by a `set` listener on the characteristic, so a plugin's own handlers on it don't compete with ours.
|
|
360
|
+
*/
|
|
361
|
+
private isIdentifyCharacteristic;
|
|
362
|
+
/**
|
|
363
|
+
* @returns a promise resolving once the identification is done, rejecting with the {@link HAPStatus} to answer otherwise.
|
|
364
|
+
*/
|
|
365
|
+
private handlePairedIdentify;
|
|
357
366
|
/**
|
|
358
367
|
* Add the given service instance to the Accessory.
|
|
359
368
|
*
|
|
@@ -499,6 +508,18 @@ export declare class Accessory extends EventEmitter {
|
|
|
499
508
|
private handleListPairings;
|
|
500
509
|
private handleAccessories;
|
|
501
510
|
private handleGetCharacteristics;
|
|
511
|
+
/**
|
|
512
|
+
* Runs the handler for every characteristic of a `/characteristics` read or write request, and answers once all of them settled.
|
|
513
|
+
* A handler still running after {@link TIMEOUT_WARNING} is reported as slow. Once {@link TIMEOUT_AFTER_WARNING} more passed, the
|
|
514
|
+
* request is answered without waiting any longer: every characteristic still missing is reported as timed out and answered with
|
|
515
|
+
* {@link HAPStatus.OPERATION_TIMED_OUT}.
|
|
516
|
+
*
|
|
517
|
+
* @param ids - The requested characteristics.
|
|
518
|
+
* @param operation - Whether this is a read or a write, for the warnings and the log.
|
|
519
|
+
* @param handle - Handles a single requested characteristic.
|
|
520
|
+
* @param respond - Called exactly once, with the results in the order they settled, or with the error answering the whole request.
|
|
521
|
+
*/
|
|
522
|
+
private handleCharacteristicRequests;
|
|
502
523
|
private handleCharacteristicRead;
|
|
503
524
|
private handleSetCharacteristics;
|
|
504
525
|
private handleCharacteristicWrite;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accessory.d.ts","sourceRoot":"","sources":["../../src/lib/Accessory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,
|
|
1
|
+
{"version":3,"file":"Accessory.d.ts","sourceRoot":"","sources":["../../src/lib/Accessory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAML,eAAe,EACf,UAAU,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,QAAQ,EAKR,YAAY,EACZ,QAAQ,EACT,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAA8F,MAAM,cAAc,CAAC;AAEtI,OAAO,EAGL,cAAc,EAKf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,UAAU,EACV,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EAErB,MAAM,cAAc,CAAC;AACtB,OAAO,EAKL,SAAS,EAWV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAmB,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,2BAA2B,EAAqB,SAAS,EAAE,MAAM,WAAW,CAAC;AAelH;;;;GAIG;AACH,0BAAkB,UAAU;IAE1B,KAA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,CAAC,MAAM,CAAC,qBAAqB;IAapC,OAAO,CAAC,MAAM,CAAC,eAAe;CAoE/B"}
|
package/dist/lib/Accessory.js
CHANGED
|
@@ -17,6 +17,8 @@ const ControllerStorage_1 = require("./model/ControllerStorage");
|
|
|
17
17
|
const IdentifierCache_1 = require("./model/IdentifierCache");
|
|
18
18
|
const Service_1 = require("./Service");
|
|
19
19
|
const clone_1 = require("./util/clone");
|
|
20
|
+
const hapStatusError_1 = require("./util/hapStatusError");
|
|
21
|
+
const once_1 = require("./util/once");
|
|
20
22
|
const request_util_1 = require("./util/request-util");
|
|
21
23
|
const uuid = tslib_1.__importStar(require("./util/uuid"));
|
|
22
24
|
const uuid_1 = require("./util/uuid");
|
|
@@ -127,9 +129,8 @@ var AccessoryEventTypes;
|
|
|
127
129
|
/**
|
|
128
130
|
* Emitted when an iOS device wishes for this Accessory to identify itself. If `paired` is false, then
|
|
129
131
|
* this device is currently browsing for Accessories in the system-provided "Add Accessory" screen. If
|
|
130
|
-
* `paired` is true, then this is a device that has already paired with us
|
|
131
|
-
*
|
|
132
|
-
* `getService(Service.AccessoryInformation).getCharacteristic(Characteristic.Identify).on('set', ...)`
|
|
132
|
+
* `paired` is true, then this is a device that has already paired with us, and wrote `true` to the `Identify` Characteristic
|
|
133
|
+
* of the `AccessoryInformation` service (after any handlers a plugin set up on that characteristic were called).
|
|
133
134
|
* You must call the callback for identification to be successful.
|
|
134
135
|
*/
|
|
135
136
|
AccessoryEventTypes["IDENTIFY"] = "identify";
|
|
@@ -245,16 +246,6 @@ class Accessory extends events_1.EventEmitter {
|
|
|
245
246
|
(0, checkName_1.checkName)(this.displayName, "Name", displayName);
|
|
246
247
|
this.addService(Service_1.Service.AccessoryInformation)
|
|
247
248
|
.setCharacteristic(Characteristic_1.Characteristic.Name, displayName);
|
|
248
|
-
// sign up for when iOS attempts to "set" the `Identify` characteristic - this means a paired device wishes
|
|
249
|
-
// for us to identify ourselves (as opposed to an unpaired device - that case is handled by HAPServer 'identify' event)
|
|
250
|
-
this.getService(Service_1.Service.AccessoryInformation)
|
|
251
|
-
.getCharacteristic(Characteristic_1.Characteristic.Identify)
|
|
252
|
-
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
253
|
-
if (value) {
|
|
254
|
-
const paired = true;
|
|
255
|
-
this.identificationRequest(paired, callback);
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
249
|
}
|
|
259
250
|
identificationRequest(paired, callback) {
|
|
260
251
|
debug("[%s] Identification request", this.displayName);
|
|
@@ -268,6 +259,43 @@ class Accessory extends events_1.EventEmitter {
|
|
|
268
259
|
callback();
|
|
269
260
|
}
|
|
270
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* A paired device wishes for us to identify ourselves by writing `true` to the `Identify` characteristic (as opposed
|
|
264
|
+
* to an unpaired device - that case is handled by the HAPServer 'identify' event). This is handled here rather than
|
|
265
|
+
* by a `set` listener on the characteristic, so a plugin's own handlers on it don't compete with ours.
|
|
266
|
+
*/
|
|
267
|
+
isIdentifyCharacteristic(characteristic) {
|
|
268
|
+
return characteristic.UUID === Characteristic_1.Characteristic.Identify.UUID
|
|
269
|
+
&& !!this.getService(Service_1.Service.AccessoryInformation)?.characteristics.includes(characteristic);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* @returns a promise resolving once the identification is done, rejecting with the {@link HAPStatus} to answer otherwise.
|
|
273
|
+
*/
|
|
274
|
+
handlePairedIdentify(characteristic) {
|
|
275
|
+
return new Promise((resolve, reject) => {
|
|
276
|
+
try {
|
|
277
|
+
this.identificationRequest(true, (0, once_1.once)((error) => {
|
|
278
|
+
if (!error) {
|
|
279
|
+
resolve();
|
|
280
|
+
}
|
|
281
|
+
else if (typeof error === "number") {
|
|
282
|
+
reject(new hapStatusError_1.HapStatusError(error).hapStatus);
|
|
283
|
+
}
|
|
284
|
+
else if (error instanceof hapStatusError_1.HapStatusError) {
|
|
285
|
+
reject(error.hapStatus);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
debug("[%s] Received error from identify handler %s", this.displayName, error.stack);
|
|
289
|
+
reject((0, request_util_1.extractHAPStatusFromError)(error));
|
|
290
|
+
}
|
|
291
|
+
}));
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
this.sendCharacteristicWarning(characteristic, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, `Unhandled error thrown inside identify handler: ${error?.message}`);
|
|
295
|
+
reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
271
299
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
272
300
|
addService(serviceParam, ...constructorArgs) {
|
|
273
301
|
// service might be a constructor like `Service.AccessoryInformation` instead of an instance
|
|
@@ -407,10 +435,17 @@ class Accessory extends events_1.EventEmitter {
|
|
|
407
435
|
throw new Error("Cannot find the bridged Accessory to remove.");
|
|
408
436
|
}
|
|
409
437
|
this.bridgedAccessories.splice(accessoryIndex, 1);
|
|
438
|
+
if (this._server && accessory.aid != null) {
|
|
439
|
+
// connected clients stay subscribed to the removed accessory's ids, which a replacement under the same UUID gets again
|
|
440
|
+
for (const iid of this._server.disableEventNotificationsForAccessory(accessory.aid)) {
|
|
441
|
+
accessory.getCharacteristicByIID(iid)?.unsubscribe();
|
|
442
|
+
}
|
|
443
|
+
}
|
|
410
444
|
accessory.bridged = false;
|
|
411
445
|
accessory.bridge = undefined;
|
|
412
446
|
accessory.permsQuarantined = false; // a later bridge starts from a clean slate and re-evaluates the accessory itself
|
|
413
447
|
accessory.removeAllListeners();
|
|
448
|
+
this.controllerStorage.unlinkAccessory(accessory);
|
|
414
449
|
if (!deferUpdate) {
|
|
415
450
|
this.enqueueConfigurationUpdate();
|
|
416
451
|
}
|
|
@@ -1043,7 +1078,7 @@ class Accessory extends events_1.EventEmitter {
|
|
|
1043
1078
|
}
|
|
1044
1079
|
const existingKey = this._accessoryInfo.getClientPublicKey(username);
|
|
1045
1080
|
if (existingKey) {
|
|
1046
|
-
if (existingKey.
|
|
1081
|
+
if (!existingKey.equals(publicKey)) {
|
|
1047
1082
|
callback(1 /* TLVErrorCode.UNKNOWN */);
|
|
1048
1083
|
return;
|
|
1049
1084
|
}
|
|
@@ -1105,81 +1140,92 @@ class Accessory extends events_1.EventEmitter {
|
|
|
1105
1140
|
});
|
|
1106
1141
|
}
|
|
1107
1142
|
handleGetCharacteristics(connection, request, callback) {
|
|
1143
|
+
this.handleCharacteristicRequests(request.ids, "read", id => this.handleCharacteristicRead(connection, id, request), (error, characteristics) => callback(error, characteristics && { characteristics }));
|
|
1144
|
+
}
|
|
1145
|
+
/**
|
|
1146
|
+
* Runs the handler for every characteristic of a `/characteristics` read or write request, and answers once all of them settled.
|
|
1147
|
+
* A handler still running after {@link TIMEOUT_WARNING} is reported as slow. Once {@link TIMEOUT_AFTER_WARNING} more passed, the
|
|
1148
|
+
* request is answered without waiting any longer: every characteristic still missing is reported as timed out and answered with
|
|
1149
|
+
* {@link HAPStatus.OPERATION_TIMED_OUT}.
|
|
1150
|
+
*
|
|
1151
|
+
* @param ids - The requested characteristics.
|
|
1152
|
+
* @param operation - Whether this is a read or a write, for the warnings and the log.
|
|
1153
|
+
* @param handle - Handles a single requested characteristic.
|
|
1154
|
+
* @param respond - Called exactly once, with the results in the order they settled, or with the error answering the whole request.
|
|
1155
|
+
*/
|
|
1156
|
+
handleCharacteristicRequests(ids, operation, handle, respond) {
|
|
1157
|
+
// both result types have a member which carries nothing but the status
|
|
1158
|
+
const statusOnly = (status) => ({ status });
|
|
1108
1159
|
const characteristics = [];
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1111
|
-
if (missingCharacteristics.size !== request.ids.length) {
|
|
1160
|
+
const missingCharacteristics = new Map(ids.map(id => [`${id.aid}.${id.iid}`, id]));
|
|
1161
|
+
if (missingCharacteristics.size !== ids.length) {
|
|
1112
1162
|
// if those sizes differ, we have duplicates and can't properly handle that
|
|
1113
|
-
|
|
1163
|
+
respond({ httpCode: 422 /* HAPHTTPCode.UNPROCESSABLE_ENTITY */, status: -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */ });
|
|
1114
1164
|
return;
|
|
1115
1165
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
const
|
|
1166
|
+
if (ids.length === 0) {
|
|
1167
|
+
respond(undefined, characteristics); // nothing to wait for
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
const warnMissing = (slow) => {
|
|
1171
|
+
for (const id of missingCharacteristics.values()) {
|
|
1172
|
+
const accessory = this.getAccessoryByAID(id.aid);
|
|
1173
|
+
const characteristic = accessory?.getCharacteristicByIID(id.iid);
|
|
1123
1174
|
if (!accessory || !characteristic) {
|
|
1124
1175
|
continue;
|
|
1125
1176
|
}
|
|
1126
|
-
|
|
1127
|
-
|
|
1177
|
+
const type = operation === "read"
|
|
1178
|
+
? (slow ? "slow-read" /* CharacteristicWarningType.SLOW_READ */ : "timeout-read" /* CharacteristicWarningType.TIMEOUT_READ */)
|
|
1179
|
+
: (slow ? "slow-write" /* CharacteristicWarningType.SLOW_WRITE */ : "timeout-write" /* CharacteristicWarningType.TIMEOUT_WRITE */);
|
|
1180
|
+
const message = slow
|
|
1181
|
+
? "was slow to respond!"
|
|
1182
|
+
: "didn't respond at all!. Please check that you properly call the callback!";
|
|
1183
|
+
accessory.sendCharacteristicWarning(characteristic, type, `The ${operation} handler for the characteristic '${characteristic.displayName}' on the accessory '${accessory.displayName}' ${message}`);
|
|
1184
|
+
if (!slow) {
|
|
1185
|
+
characteristics.push({
|
|
1186
|
+
aid: id.aid,
|
|
1187
|
+
iid: id.iid,
|
|
1188
|
+
...statusOnly(-70408 /* HAPStatus.OPERATION_TIMED_OUT */),
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1128
1191
|
}
|
|
1192
|
+
};
|
|
1193
|
+
let timeout = setTimeout(() => {
|
|
1194
|
+
warnMissing(true);
|
|
1129
1195
|
// after a total of 10s we do no longer wait for a request to appear and just return status code timeout
|
|
1130
1196
|
timeout = setTimeout(() => {
|
|
1131
1197
|
timeout = undefined;
|
|
1132
|
-
|
|
1133
|
-
const split = id.split(".");
|
|
1134
|
-
const aid = parseInt(split[0], 10);
|
|
1135
|
-
const iid = parseInt(split[1], 10);
|
|
1136
|
-
const accessory = this.getAccessoryByAID(aid);
|
|
1137
|
-
const characteristic = accessory?.getCharacteristicByIID(iid);
|
|
1138
|
-
if (!accessory || !characteristic) {
|
|
1139
|
-
continue;
|
|
1140
|
-
}
|
|
1141
|
-
this.sendCharacteristicWarning(characteristic, "timeout-read" /* CharacteristicWarningType.TIMEOUT_READ */, "The read handler for the characteristic '" +
|
|
1142
|
-
characteristic.displayName + "' on the accessory '" + accessory.displayName + "' didn't respond at all!. " +
|
|
1143
|
-
"Please check that you properly call the callback!");
|
|
1144
|
-
characteristics.push({
|
|
1145
|
-
aid: aid,
|
|
1146
|
-
iid: iid,
|
|
1147
|
-
status: -70408 /* HAPStatus.OPERATION_TIMED_OUT */,
|
|
1148
|
-
});
|
|
1149
|
-
}
|
|
1198
|
+
warnMissing(false);
|
|
1150
1199
|
missingCharacteristics.clear();
|
|
1151
|
-
|
|
1200
|
+
respond(undefined, characteristics);
|
|
1152
1201
|
}, Accessory.TIMEOUT_AFTER_WARNING);
|
|
1153
1202
|
timeout.unref();
|
|
1154
1203
|
}, Accessory.TIMEOUT_WARNING);
|
|
1155
1204
|
timeout.unref();
|
|
1156
|
-
for (const id of
|
|
1157
|
-
|
|
1158
|
-
this.handleCharacteristicRead(connection, id, request).then(value => {
|
|
1205
|
+
for (const [name, id] of missingCharacteristics) {
|
|
1206
|
+
handle(id).then((value) => {
|
|
1159
1207
|
return {
|
|
1160
1208
|
aid: id.aid,
|
|
1161
1209
|
iid: id.iid,
|
|
1162
1210
|
...value,
|
|
1163
1211
|
};
|
|
1164
|
-
}, reason => {
|
|
1165
|
-
console.error(`[${this.displayName}] Read request for characteristic ${name} encountered an error: ${reason.stack}`);
|
|
1212
|
+
}, (reason) => {
|
|
1213
|
+
console.error(`[${this.displayName}] ${operation === "read" ? "Read" : "Write"} request for characteristic ${name} encountered an error: ${reason.stack}`);
|
|
1166
1214
|
return {
|
|
1167
1215
|
aid: id.aid,
|
|
1168
1216
|
iid: id.iid,
|
|
1169
|
-
|
|
1217
|
+
...statusOnly(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */),
|
|
1170
1218
|
};
|
|
1171
|
-
}).then(value => {
|
|
1219
|
+
}).then((value) => {
|
|
1172
1220
|
if (!timeout) {
|
|
1173
1221
|
return; // if timeout is undefined, response was already sent out
|
|
1174
1222
|
}
|
|
1175
1223
|
missingCharacteristics.delete(name);
|
|
1176
1224
|
characteristics.push(value);
|
|
1177
|
-
if (missingCharacteristics.size === 0) {
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
}
|
|
1182
|
-
callback(undefined, response);
|
|
1225
|
+
if (missingCharacteristics.size === 0) { // if everything returned send the response
|
|
1226
|
+
clearTimeout(timeout);
|
|
1227
|
+
timeout = undefined;
|
|
1228
|
+
respond(undefined, characteristics);
|
|
1183
1229
|
}
|
|
1184
1230
|
});
|
|
1185
1231
|
}
|
|
@@ -1234,7 +1280,9 @@ class Accessory extends events_1.EventEmitter {
|
|
|
1234
1280
|
});
|
|
1235
1281
|
}
|
|
1236
1282
|
handleSetCharacteristics(connection, writeRequest, callback) {
|
|
1237
|
-
debug
|
|
1283
|
+
if (debug.enabled) { // the request can be large, so only serialize it when it gets logged
|
|
1284
|
+
debug("[%s] Processing characteristic set: %s", this.displayName, JSON.stringify(writeRequest));
|
|
1285
|
+
}
|
|
1238
1286
|
let writeState = 0 /* WriteRequestState.REGULAR_REQUEST */;
|
|
1239
1287
|
if (writeRequest.pid !== undefined) { // check for timed writes
|
|
1240
1288
|
if (connection.timedWritePid === writeRequest.pid) {
|
|
@@ -1249,85 +1297,7 @@ class Accessory extends events_1.EventEmitter {
|
|
|
1249
1297
|
debug("[%s] TTL for timed write request has probably expired for pid %d", this.displayName, writeRequest.pid);
|
|
1250
1298
|
}
|
|
1251
1299
|
}
|
|
1252
|
-
|
|
1253
|
-
const response = { characteristics: characteristics };
|
|
1254
|
-
const missingCharacteristics = new Set(writeRequest.characteristics
|
|
1255
|
-
.map(characteristic => characteristic.aid + "." + characteristic.iid));
|
|
1256
|
-
if (missingCharacteristics.size !== writeRequest.characteristics.length) {
|
|
1257
|
-
// if those sizes differ, we have duplicates and can't properly handle that
|
|
1258
|
-
callback({ httpCode: 422 /* HAPHTTPCode.UNPROCESSABLE_ENTITY */, status: -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */ });
|
|
1259
|
-
return;
|
|
1260
|
-
}
|
|
1261
|
-
let timeout = setTimeout(() => {
|
|
1262
|
-
for (const id of missingCharacteristics) {
|
|
1263
|
-
const split = id.split(".");
|
|
1264
|
-
const aid = parseInt(split[0], 10);
|
|
1265
|
-
const iid = parseInt(split[1], 10);
|
|
1266
|
-
const accessory = this.getAccessoryByAID(aid);
|
|
1267
|
-
const characteristic = accessory?.getCharacteristicByIID(iid);
|
|
1268
|
-
if (!accessory || !characteristic) {
|
|
1269
|
-
continue;
|
|
1270
|
-
}
|
|
1271
|
-
this.sendCharacteristicWarning(characteristic, "slow-write" /* CharacteristicWarningType.SLOW_WRITE */, "The write handler for the characteristic '" +
|
|
1272
|
-
characteristic.displayName + "' on the accessory '" + accessory.displayName + "' was slow to respond!");
|
|
1273
|
-
}
|
|
1274
|
-
// after a total of 10s we do no longer wait for a request to appear and just return status code timeout
|
|
1275
|
-
timeout = setTimeout(() => {
|
|
1276
|
-
timeout = undefined;
|
|
1277
|
-
for (const id of missingCharacteristics) {
|
|
1278
|
-
const split = id.split(".");
|
|
1279
|
-
const aid = parseInt(split[0], 10);
|
|
1280
|
-
const iid = parseInt(split[1], 10);
|
|
1281
|
-
const accessory = this.getAccessoryByAID(aid);
|
|
1282
|
-
const characteristic = accessory?.getCharacteristicByIID(iid);
|
|
1283
|
-
if (!accessory || !characteristic) {
|
|
1284
|
-
continue;
|
|
1285
|
-
}
|
|
1286
|
-
this.sendCharacteristicWarning(characteristic, "timeout-write" /* CharacteristicWarningType.TIMEOUT_WRITE */, "The write handler for the characteristic '" +
|
|
1287
|
-
characteristic.displayName + "' on the accessory '" + accessory.displayName + "' didn't respond at all!. " +
|
|
1288
|
-
"Please check that you properly call the callback!");
|
|
1289
|
-
characteristics.push({
|
|
1290
|
-
aid: aid,
|
|
1291
|
-
iid: iid,
|
|
1292
|
-
status: -70408 /* HAPStatus.OPERATION_TIMED_OUT */,
|
|
1293
|
-
});
|
|
1294
|
-
}
|
|
1295
|
-
missingCharacteristics.clear();
|
|
1296
|
-
callback(undefined, response);
|
|
1297
|
-
}, Accessory.TIMEOUT_AFTER_WARNING);
|
|
1298
|
-
timeout.unref();
|
|
1299
|
-
}, Accessory.TIMEOUT_WARNING);
|
|
1300
|
-
timeout.unref();
|
|
1301
|
-
for (const data of writeRequest.characteristics) {
|
|
1302
|
-
const name = data.aid + "." + data.iid;
|
|
1303
|
-
this.handleCharacteristicWrite(connection, data, writeState).then(value => {
|
|
1304
|
-
return {
|
|
1305
|
-
aid: data.aid,
|
|
1306
|
-
iid: data.iid,
|
|
1307
|
-
...value,
|
|
1308
|
-
};
|
|
1309
|
-
}, reason => {
|
|
1310
|
-
console.error(`[${this.displayName}] Write request for characteristic ${name} encountered an error: ${reason.stack}`);
|
|
1311
|
-
return {
|
|
1312
|
-
aid: data.aid,
|
|
1313
|
-
iid: data.iid,
|
|
1314
|
-
status: -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */,
|
|
1315
|
-
};
|
|
1316
|
-
}).then(value => {
|
|
1317
|
-
if (!timeout) {
|
|
1318
|
-
return; // if timeout is undefined, response was already sent out
|
|
1319
|
-
}
|
|
1320
|
-
missingCharacteristics.delete(name);
|
|
1321
|
-
characteristics.push(value);
|
|
1322
|
-
if (missingCharacteristics.size === 0) { // if everything returned send the response
|
|
1323
|
-
if (timeout) {
|
|
1324
|
-
clearTimeout(timeout);
|
|
1325
|
-
timeout = undefined;
|
|
1326
|
-
}
|
|
1327
|
-
callback(undefined, response);
|
|
1328
|
-
}
|
|
1329
|
-
});
|
|
1330
|
-
}
|
|
1300
|
+
this.handleCharacteristicRequests(writeRequest.characteristics, "write", data => this.handleCharacteristicWrite(connection, data, writeState), (error, characteristics) => callback(error, characteristics && { characteristics }));
|
|
1331
1301
|
}
|
|
1332
1302
|
async handleCharacteristicWrite(connection, data, writeState) {
|
|
1333
1303
|
const characteristic = this.findCharacteristic(data.aid, data.iid);
|
|
@@ -1401,7 +1371,13 @@ class Accessory extends events_1.EventEmitter {
|
|
|
1401
1371
|
debug("[%s] Tried writing to a timed write only Characteristic without properly preparing (iid of %s and aid of %s)", this.displayName, data.aid, data.iid);
|
|
1402
1372
|
return { status: -70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */ };
|
|
1403
1373
|
}
|
|
1404
|
-
|
|
1374
|
+
const accessory = this.getAccessoryByAID(data.aid);
|
|
1375
|
+
return characteristic.handleSetRequest(data.value, connection).then(async (value) => {
|
|
1376
|
+
if (data.value && accessory.isIdentifyCharacteristic(characteristic)) {
|
|
1377
|
+
await accessory.handlePairedIdentify(characteristic);
|
|
1378
|
+
}
|
|
1379
|
+
return value;
|
|
1380
|
+
}).then((value) => {
|
|
1405
1381
|
debug("[%s] Setting Characteristic \"%s\" to value %s", this.displayName, characteristic.displayName, data.value);
|
|
1406
1382
|
return {
|
|
1407
1383
|
// if write response is requests and value is provided, return that
|
|
@@ -1548,16 +1524,18 @@ class Accessory extends events_1.EventEmitter {
|
|
|
1548
1524
|
this.setupServiceEventHandlers(service);
|
|
1549
1525
|
}
|
|
1550
1526
|
this.services = targetServices.slice();
|
|
1551
|
-
//
|
|
1552
|
-
this
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
1556
|
-
if (value) {
|
|
1557
|
-
const paired = true;
|
|
1558
|
-
this.identificationRequest(paired, callback);
|
|
1527
|
+
// the restored services carry their own primary flag; track it, so a later primary service replaces it
|
|
1528
|
+
for (const service of this.services) {
|
|
1529
|
+
if (!service.isPrimaryService) {
|
|
1530
|
+
continue;
|
|
1559
1531
|
}
|
|
1560
|
-
|
|
1532
|
+
if (this.primaryService) {
|
|
1533
|
+
service.isPrimaryService = false; // only one primary service, which a cache written before this fix may not hold to
|
|
1534
|
+
}
|
|
1535
|
+
else {
|
|
1536
|
+
this.primaryService = service;
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1561
1539
|
}
|
|
1562
1540
|
static _generateSetupID() {
|
|
1563
1541
|
const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|