You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.0 KiB
36 lines
1.0 KiB
import { deepFreeze } from "../../utils/index.js";
|
|
|
|
export class Core {
|
|
constructor({
|
|
supportsBattery = false,
|
|
supportsManufacturerData = false,
|
|
gattServices,
|
|
gattCharacteristics,
|
|
manufacturer,
|
|
model,
|
|
firmwareVersion,
|
|
serial,
|
|
reconnectOnDisconnect = true,
|
|
requiresPairing = false,
|
|
} = {}) {
|
|
this.supportsBattery = Boolean(supportsBattery);
|
|
this.supportsManufacturerData = Boolean(supportsManufacturerData);
|
|
this.gattServices = Array.isArray(gattServices)
|
|
? gattServices.slice()
|
|
: undefined;
|
|
this.gattCharacteristics =
|
|
gattCharacteristics && typeof gattCharacteristics === "object"
|
|
? Object.assign({}, gattCharacteristics)
|
|
: undefined;
|
|
this.manufacturer = manufacturer;
|
|
this.model = model;
|
|
this.firmwareVersion = firmwareVersion;
|
|
this.serial = serial;
|
|
this.reconnectOnDisconnect = Boolean(reconnectOnDisconnect);
|
|
this.requiresPairing = Boolean(requiresPairing);
|
|
deepFreeze(this);
|
|
}
|
|
|
|
merge = (partial) => new Core(Object.assign({}, this, partial));
|
|
}
|