Пример #1
0
        private bool _rxThreadExit;        // A flag that tells the receive thread to exit

        public MacLayer(IPhy phy)
        {
            // poweron Phy first
            _phy = phy;
            _phy.IsCapabilitySupported(Capabilities.PowerOff, out _phyCapPower);
            if (_phyCapPower)
            {
                _phy.SetPower(true); // should be on-demand
            }

            _state             = new State(this, phy);
            _taskAddedEvent    = new AutoResetEvent(false);
            _taskQueue         = new TaskQueue(cQueueCmdSize, cQueueDataSize, _taskAddedEvent);
            _taskProcessorExit = false;
            _taskProcessor     = new Thread(TaskProcessor);
#if !MICROFRAMEWORK
            _taskProcessor.IsBackground = true;
#endif
            _sendReceive    = new PhySendReceive(_state, _phy, this);
            _scannedBeacons = new ArrayList();

            ResetHandler();

            // initialize channels
            Phy.Status   status;
            Phy.PibValue value;
            _phy.GetRequest(Phy.PibAttribute.phyCurrentPage, out status, out value);
            _state.phyChannelPage = (Byte)value.Int;
            _phy.GetRequest(Phy.PibAttribute.phyCurrentChannel, out status, out value);
            _state.phyChannelNumber = (Byte)value.Int;

            _rxFrameQueue = new Frame.Queue(cQueueRxSize, true, 0);
            _rxThread     = new Thread(DataIndicationThread);
#if !MICROFRAMEWORK
            _rxThread.IsBackground = true;
#endif
            _rxEvent      = new AutoResetEvent(false);
            _rxThreadExit = false;
            _rxThread.Start();

            _taskProcessor.Start();
        }
Пример #2
0
        private bool _rxThreadExit;        // A flag that tells the receive thread to exit

        public MacLayer(IPhy phy)
        {
            // poweron Phy first
            _phy = phy;
            _phy.IsCapabilitySupported(Capabilities.PowerOff, out _phyCapPower);
            if (_phyCapPower)
            {
                _phy.SetPower(true); // should be on-demand
            }

            _state = new State(this, phy);
            _taskAddedEvent = new AutoResetEvent(false);
            _taskQueue = new TaskQueue(cQueueCmdSize, cQueueDataSize, _taskAddedEvent);
            _taskProcessorExit = false;
            _taskProcessor = new Thread(TaskProcessor);
#if !MICROFRAMEWORK
            _taskProcessor.IsBackground = true;
#endif
            _sendReceive = new PhySendReceive(_state, _phy, this);
            _scannedBeacons = new ArrayList();

            ResetHandler();

            // initialize channels
            Phy.Status status;
            Phy.PibValue value;
            _phy.GetRequest(Phy.PibAttribute.phyCurrentPage, out status, out value);
            _state.phyChannelPage = (Byte)value.Int;
            _phy.GetRequest(Phy.PibAttribute.phyCurrentChannel, out status, out value);
            _state.phyChannelNumber = (Byte)value.Int;

            _rxFrameQueue = new Frame.Queue(cQueueRxSize, true, 0);
            _rxThread = new Thread(DataIndicationThread);
#if !MICROFRAMEWORK
            _rxThread.IsBackground = true;
#endif
            _rxEvent = new AutoResetEvent(false);
            _rxThreadExit = false;
            _rxThread.Start();

            _taskProcessor.Start();
        }