Exemple #1
0
        private void OnFrameReceived(XBeeResponse response)
        {
            FrameReceivedEventHandler handler = FrameReceived;

            if (handler != null)
            {
                handler(this, new FrameReceivedEventArgs(response));
            }
        }
Exemple #2
0
        private void CheckFrame(short length, ByteReader br)
        {
            XBeeApiType  apiId = (XBeeApiType)br.Peek();
            XBeeResponse res   = null;

            switch (apiId)
            {
            case XBeeApiType.ZNetExplicitRxIndicator:
                res = new ExplicitZigBeeResponse(length, br);
                break;

            case XBeeApiType.AtCommandResponse:
                res = new AtCommandResponse(length, br);
                break;

            case XBeeApiType.RemoteAtCommandResponse:
                res = new RemoteAtResponse(length, br);
                break;

            case XBeeApiType.ModemStatus:
                res = new ModemStatusResponse(length, br);
                if (res != null)
                {
                    OnModemStatusChanged((res as ModemStatusResponse).ModemStatus);
                }
                break;

            case XBeeApiType.RxPacket16:
                res = new RxResponse16(length, br);
                break;

            case XBeeApiType.RxPacket64:
                res = new RxResponse64(length, br);
                break;

            case XBeeApiType.TxStatus:
                res = new TxStatusResponse(length, br);
                break;

            case XBeeApiType.NodeIdentificationIndicator:
                res = new ZNetNodeIdentificationResponse(length, br);
                break;

            case XBeeApiType.ZNetRxPacket:
                res = new ZNetRxResponse(length, br);
                break;

            case XBeeApiType.XBeeSensorReadIndicator:
                res = new XBeeSensorRead(length, br);
                break;

            case XBeeApiType.ZNetIODataSampleRxIndicator:
                res = new ZNetRxIoSampleResponse(length, br);
                break;

            case XBeeApiType.ZNetTxStatus:
                res = new ZNetTxStatusResponse(length, br);
                break;


            default:
                break;
            }

            if (res != null)
            {
                if (_waitResponse && res is XBeeResponse)
                {
                    if (res is AtCommandResponse && (res as AtCommandResponse).FrameID != _frameID)
                    {
                        return;
                    }

                    _receivedPacket = res;
                    _waitResponse   = false;
                }
                else
                {
                    OnFrameReceived(res);
                }
            }
        }
 public FrameReceivedEventArgs(XBeeResponse response)
 {
     Response = response;
 }