Esempio n. 1
0
        public HomeKitServer(ILogger logger, int port, string name, string ltsk, string ltpk, string deviceId, string pairCode, string manufacturer, string bridgeName, int configVersion)
        {
            if (!HomeKitSetup.IsSetupCodeValid(pairCode))
            {
                throw new ArgumentException($"{nameof(pairCode)} is not valid...");
            }

            if (configVersion <= 0)
            {
                configVersion = 1;
            }

            Manufacturer = manufacturer;
            BridgeName   = bridgeName;
            var hapPort = port;

            _bonjour   = new BonjourService(logger, Convert.ToUInt16(hapPort), name, deviceId, configVersion);
            _hapServer = new HapControllerServer(logger, this, hapPort, ltsk, ltpk, deviceId, pairCode);

            _bonjour.AlreadyPaired = !string.IsNullOrEmpty(ltpk);

            _hapServer.PairingCompleted += HapServerOnPairingCompleted;

            var bridgeAccessory = new Accessory
            {
                Id = 1
            };

            bridgeAccessory.Services.Add(AccessoryFactory.CreateAccessoryInfo(bridgeAccessory, 1, bridgeName, manufacturer, ServerInfo.ServerUid.ToString()));
            _accessoryContainer.AddAccessory(bridgeAccessory);
        }
Esempio n. 2
0
        public HomeKitServer(ILogger logger, int port, string name, string ltsk, string ltpk, string deviceId, string pairCode, string manufacturer, string bridgeName)
        {
            Manufacturer = manufacturer;
            BridgeName   = bridgeName;
            var hapPort = port;

            _bonjour   = new BonjourService(logger, hapPort, name);
            _hapServer = new HapControllerServer(logger, this, hapPort, ltsk, ltpk, deviceId, pairCode);

            _hapServer.PairingCompleted += HapServerOnPairingCompleted;

            var bridgeAccessory = new Accessory
            {
                Id = 1
            };

            bridgeAccessory.Services.Add(AccessoryFactory.CreateAccessoryInfo(bridgeAccessory, 1, bridgeName, manufacturer, ServerInfo.ServerUid.ToString()));
            _accessory.Accessories.Add(bridgeAccessory);
        }