コード例 #1
0
        //Handle any valid data retrieved here
        void xbeePacketHandler_ValidDataGet(object sender, WATR_ValidDataGetArgs e)
        {
            //Log information
            db.LogReceivePacket(e.Data.RawData);

            //Figure out what type of packet it is and raise the proper event
            if (e.Data.GetFrameType() is WATR_XBeeRemoteATCommandResponseFrameData)
            {
                WATR_RemoteATCmdResponseGetArgs remoteATcmdResp = new WATR_RemoteATCmdResponseGetArgs(e.Data.GetFrameType());
                if (remoteATcmdResp != null)
                    ReceivedRemoteATCommandResponse(this, remoteATcmdResp);
            }
            else if (e.Data.GetFrameType() is WATR_XBeeATCommandFrameData)
            {
                WATR_ATCmdResponseGetArgs atCmdResp = new WATR_ATCmdResponseGetArgs(e.Data.GetFrameType());
                if (atCmdResp != null)
                    ReceivedATCmdResponse(this, atCmdResp);
            }
            else if (e.Data.GetFrameType() is WATR_XBeeReceivePacketFrameData)
            {
                WATR_RxPacketGetArgs rxFrameData = new WATR_RxPacketGetArgs(e.Data.GetFrameType());
                if (rxFrameData != null)
                    ReceivedRxPacket(this, rxFrameData);
            }
            else
            {
                WATR_TransmitStatusGetArgs transmitStatusGet = new WATR_TransmitStatusGetArgs(e.Data.GetFrameType());
                if (transmitStatusGet != null)
                    ReceivedTransmitStatus(this, transmitStatusGet);
            }
        }
コード例 #2
0
ファイル: WATR_BackEndSS.cs プロジェクト: JCritchfield/WATR
        void packetHandler_ReceivedRemoteATCommandResponse(object sender, WATR_RemoteATCmdResponseGetArgs e)
        {
            //Let's face it - I am seriously only using this as a way to find all of the devices in our network.
            //if I needed to populate information on a device itself, I'd need to disable this event
            //And add a custom one in that only interprets packets from a specific serial number.
            bool matchFound = false;

            foreach (ulong serial in deviceList.Keys)
            {
                if (e.FrameData.SourceAddress == serial)
                    matchFound = true;
            }

            if (!matchFound)
            {
                //Make sure that the device ID is NOT 0; I've been having MAJOR issues with this for some reason
                //This usually occurs when a packet is "valid" but still misread - meaning, there is something wrong
                //With either the way the packet received the information, or the way I transmitted it.
                if (e.FrameData.SourceAddress > 0)
                {
                    //Create the device
                    WATR_XBeeDevice temp = new WATR_XBeeDevice(e.FrameData.SourceAddress, e.FrameData.CommandData);

                    //Add the proper event handler to it
                    temp.RefreshRequest += xbee_RefreshRequest;
                    temp.LogbookRequest += temp_LogbookRequest;

                    //Force refresh - OUTDATED; moved so that this doesn't screw up
                    //temp.ForceRefresh();

                    //Add it to the list
                    deviceList.Add(e.FrameData.SourceAddress, temp);
                }
            }
        }