import { Command, CommandType } from './command';
export const AccessoryInfoService = '180A';
export const FirmwareVersionCharacteristic = '2A28';
export const SerialNumberCharacteristic = '2A25';
export class GetVersionCommand extends Command<number> {
constructor() {
super(AccessoryInfoService, FirmwareVersionCharacteristic, (encoder) => {}, CommandType.read);
this.name = "GetVersion";
}
parseResponse = (buffer: Buffer): number => {
Iif (!buffer) { throw new Error("No response body"); }
const uint8array: Uint8Array = buffer;
const values = Array.from(uint8array);
const number = parseInt(String.fromCharCode(... values));
return number;
}
}
export class GetSerialNumberCommand extends Command<string> {
constructor() {
super(AccessoryInfoService, SerialNumberCharacteristic, (encoder) => {}, CommandType.read);
this.name = "GetSerialNumber";
}
parseResponse = (buffer: Buffer): string => {
if (!buffer) { throw new Error("No response body"); }
const uint8array: Uint8Array = buffer;
const values = Array.from(uint8array);
const str = String.fromCharCode(... values);
return str;
}
}
|