예제 #1
0
        public ZigBeeStatus Startup(bool reinitialize)
        {
            Log.Debug("CC2531 transport startup");

            // Add listeners for ZCL and ZDO received messages
            _networkManager.AddAFMessageListener(this);
            _networkManager.AddAsynchronousCommandListener(this);

            if (!_networkManager.InitializeZigBeeNetwork(reinitialize))
            {
                return(ZigBeeStatus.INVALID_STATE);
            }

            // TODO: ugly ugly ugly
            // See: https://github.com/zigbeenet/ZigbeeNet/issues/46
            while (true)
            {
                if (_networkManager.GetDriverStatus() == DriverStatus.NETWORK_READY)
                {
                    break;
                }
                if (_networkManager.GetDriverStatus() == DriverStatus.CLOSED)
                {
                    return(ZigBeeStatus.BAD_RESPONSE);
                }

                Thread.Sleep(50);
            }

            CreateEndpoint(1, 0x104);

            return(ZigBeeStatus.SUCCESS);
        }
예제 #2
0
        public ZigBeeStatus Startup(bool reinitialize)
        {
            _logger.Debug("CC2531 transport startup");

            // Add listeners for ZCL and ZDO received messages
            _networkManager.AddAFMessageListener(this);
            _networkManager.AddAsynchronousCommandListener(this);

            if (!_networkManager.InitializeZigBeeNetwork(reinitialize))
            {
                return(ZigBeeStatus.INVALID_STATE);
            }

            while (true)
            {
                if (_networkManager.GetDriverStatus() == DriverStatus.NETWORK_READY)
                {
                    break;
                }
                if (_networkManager.GetDriverStatus() == DriverStatus.CLOSED)
                {
                    return(ZigBeeStatus.BAD_RESPONSE);
                }
                try
                {
                    Thread.Sleep(50);
                }
                catch (Exception e) {
                    return(ZigBeeStatus.BAD_RESPONSE);
                }
            }

            CreateEndpoint(1, 0x104);

            return(ZigBeeStatus.SUCCESS);
        }