# node-poweredup Source: hubs/controlplushub.js

# Source: hubs/controlplushub.js

    "use strict";
    var __importStar = (this && this.__importStar) || function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
        result["default"] = mod;
        return result;
    };
    Object.defineProperty(exports, "__esModule", { value: true });
    const lpf2hub_1 = require("./lpf2hub");
    const Consts = __importStar(require("../consts"));
    const Debug = require("debug");
    const debug = Debug("ControlPlusHub");
    /**
     * The ControlPlusHub is emitted if the discovered device is a Control+ Hub.
     * @class ControlPlusHub
     * @extends LPF2Hub
     * @extends Hub
     */
    class ControlPlusHub extends lpf2hub_1.LPF2Hub {
        constructor(device) {
            super(device, Consts.HubType.CONTROL_PLUS_HUB);
            this._currentPort = 0x3b;
            this._currentMaxMA = 4175;
            this._voltagePort = 0x3c;
            this._voltageMaxRaw = 4095;
            this._voltageMaxV = 9.615;
            this._portNames = {
                "A": 0,
                "B": 1,
                "C": 2,
                "D": 3,
                "ACCEL": 97,
                "GYRO": 98,
                "TILT": 99
            };
            debug("Discovered Control+ Hub");
        }
        static IsControlPlusHub(peripheral) {
            return (peripheral.advertisement &&
                peripheral.advertisement.serviceUuids &&
                peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &&
                peripheral.advertisement.manufacturerData &&
                peripheral.advertisement.manufacturerData.length > 3 &&
                peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.CONTROL_PLUS_LARGE_HUB);
        }
        connect() {
            return new Promise(async (resolve, reject) => {
                debug("Connecting to Control+ Hub");
                await super.connect();
                this.send(Buffer.from([0x41, 0x3d, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01]), Consts.BLECharacteristic.LPF2_ALL); // Temperature
                debug("Connect completed");
                return resolve();
            });
        }
    }
    exports.ControlPlusHub = ControlPlusHub;
    //# sourceMappingURL=controlplushub.js.map

#### Search results