Beispiel #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();
        }
        public PhySendReceive(State state, IPhy phy, SendReceiveCallbacks mac)
        {
            _state = state;
            _phy = phy;
            _mac = mac;

            _ackPending = false;
            _ackReceived = new AutoResetEvent(false);

            _phy.IsCapabilitySupported(Capabilities.AutoFcs, out _phyCapAutoFCS);
            if (_phyCapAutoFCS)
            {
                _phy.SetAutoFCS(true);
            }

            _phy.IsCapabilitySupported(Capabilities.AddressFilter, out _phyCapAddressFilter);
            _phy.IsCapabilitySupported(Capabilities.AutoAck, out _phyCapAutoAck);
            _phy.IsCapabilitySupported(Capabilities.TxCache, out _phyCapTxCache);

            _filterEnabled = false;
        }