예제 #1
0
        public ApiFrame SendRemoteAtCommandSync(ulong destinationSerialNumber, XBeeCommand command)
        {
            AutoResetEvent stopWaitHandle = new AutoResetEvent(false);
            ApiFrame       receivedFrame  = null;

            SendRemoteAtCommand(destinationSerialNumber, command, result =>
            {
                receivedFrame = result;
                stopWaitHandle.Set();
            });
            stopWaitHandle.WaitOne(500, false);

            return(receivedFrame);
        }
예제 #2
0
        public void SetDigitalOutput(ulong destinationSerialNumber, XBeeCommand command, bool state)
        {
            byte stateByte;

            if (state)
            {
                stateByte = 0x5;
            }
            else
            {
                stateByte = 0x4;
            }

            SendRemoteAtCommand(destinationSerialNumber, command, null, stateByte);
        }
예제 #3
0
        internal void ReceivedAtCommandResponse(ApiFrame frame)
        {
            byte        frameID   = frame.FrameData[FrameIdentifier];
            XBeeCommand command   = (XBeeCommand)(frame.FrameData[2] << 8 | frame.FrameData[3]);
            ApiFrame    sentFrame = _frameBuffer[frameID];

            if (sentFrame != null && sentFrame.Callback != null)
            {
                sentFrame.Callback(frame);
                if (!(command == XBeeCommand.NodeDiscover && frame.Length > 0))
                {
                    _frameBuffer[frameID] = null;
                }
            }
        }
예제 #4
0
        public byte SendRemoteAtCommand(ulong destinationSerialNumber, XBeeCommand command, XBeeCallback callback, byte value)
        {
            ApiFrame frame   = new ApiFrame();
            byte     frameId = GetNextFrameId();

            int txDataLenght;

            if (value == 0x0)
            {
                txDataLenght = 3;
            }
            else
            {
                txDataLenght = 4;
            }

            byte[] txDataContent = new byte[txDataLenght];
            txDataContent[0] = 0x02; // appply changes on remote

            ushort commandUShort = (ushort)command;

            txDataContent[1] = (byte)(commandUShort >> 8);
            txDataContent[2] = (byte)commandUShort;

            if (value != 0x0)
            {
                txDataContent[3] = value;
            }

            byte[] txData = Utility.CombineArrays(_txDataBase, txDataContent);
            txData[0] = (byte)ApiFrameName.RemoteCommandRequest;
            txData[1] = frameId;

            for (int i = 0; i < 8; i++)
            {
                txData[9 - i] = (byte)(destinationSerialNumber >> (8 * i));
            }

            frame.FrameData = txData;
            frame.Callback  = callback;

            return(SendApiFrame(frame));
        }
예제 #5
0
        public byte SendAtCommand(XBeeCommand command, XBeeCallback callback, uint value, int size)
        {
            ApiFrame frame   = new ApiFrame();
            byte     frameId = GetNextFrameId();

            byte[] buffer = new byte[4 + size];

            buffer[ApiIdentifier]   = (byte)ApiFrameName.ATCommand;
            buffer[FrameIdentifier] = frameId;
            ushort commandUShort = (ushort)command;

            buffer[2] = (byte)(commandUShort >> 8);
            buffer[3] = (byte)commandUShort;

            if (size > 0)
            {
                Utility.InsertValueIntoArray(buffer, 4, size, value);
            }
            frame.FrameData = buffer;
            frame.Callback  = callback;

            return(SendApiFrame(frame));
        }
예제 #6
0
 public void SendRemoteAtCommand(ulong destinationSerialNumber, XBeeCommand command, XBeeCallback callback)
 {
     SendRemoteAtCommand(destinationSerialNumber, command, callback, 0x0);
 }
예제 #7
0
 public byte SendAtCommand(XBeeCommand command, XBeeCallback callback)
 {
     return(SendAtCommand(command, callback, 0, 0));
 }
예제 #8
0
 public byte SendAtCommand(XBeeCommand command)
 {
     return(SendAtCommand(command, null, 0, 0));
 }
예제 #9
0
파일: XBee.cs 프로젝트: phantomtypist/XBee
 public byte SendAtCommand(XBeeCommand command, XBeeCallback callback)
 {
     return SendAtCommand(command, callback, 0, 0);
 }
예제 #10
0
파일: XBee.cs 프로젝트: phantomtypist/XBee
        public byte SendAtCommand(XBeeCommand command, XBeeCallback callback, uint value, int size)
        {
            ApiFrame frame = new ApiFrame();
            byte frameId = GetNextFrameId();
            byte[] buffer = new byte[4 + size];

            buffer[ApiIdentifier] = (byte)ApiFrameName.ATCommand;
            buffer[FrameIdentifier] = frameId;
            ushort commandUShort = (ushort)command;
            buffer[2] = (byte)(commandUShort >> 8);
            buffer[3] = (byte)commandUShort;

            if (size > 0)
            {
                Utility.InsertValueIntoArray(buffer, 4, size, value);
            }
            frame.FrameData = buffer;
            frame.Callback = callback;

            return SendApiFrame(frame);
        }
예제 #11
0
파일: XBee.cs 프로젝트: phantomtypist/XBee
 public byte SendAtCommand(XBeeCommand command)
 {
     return SendAtCommand(command, null, 0, 0);
 }
예제 #12
0
파일: XBee.cs 프로젝트: phantomtypist/XBee
        public void SetDigitalOutput(ulong destinationSerialNumber, XBeeCommand command, bool state)
        {
            byte stateByte;

            if (state)
                stateByte = 0x5;
            else
                stateByte = 0x4;

            SendRemoteAtCommand(destinationSerialNumber, command, null, stateByte);
        }
예제 #13
0
파일: XBee.cs 프로젝트: phantomtypist/XBee
        public ApiFrame SendRemoteAtCommandSync(ulong destinationSerialNumber, XBeeCommand command)
        {
            AutoResetEvent stopWaitHandle = new AutoResetEvent(false);
            ApiFrame receivedFrame = null;

            SendRemoteAtCommand(destinationSerialNumber, command, result =>
            {
                receivedFrame = result;
                stopWaitHandle.Set();
            });
            stopWaitHandle.WaitOne(500, false);

            return receivedFrame;
        }
예제 #14
0
파일: XBee.cs 프로젝트: phantomtypist/XBee
        public byte SendRemoteAtCommand(ulong destinationSerialNumber, XBeeCommand command, XBeeCallback callback, byte value)
        {
            ApiFrame frame = new ApiFrame();
            byte frameId = GetNextFrameId();

            int txDataLenght;
            if (value == 0x0)
                txDataLenght = 3;
            else
                txDataLenght = 4;

            byte[] txDataContent = new byte[txDataLenght];
            txDataContent[0] = 0x02; // appply changes on remote

            ushort commandUShort = (ushort)command;
            txDataContent[1] = (byte)(commandUShort >> 8);
            txDataContent[2] = (byte)commandUShort;

            if (value != 0x0)
                txDataContent[3] = value;

            byte[] txData = Utility.CombineArrays(_txDataBase, txDataContent);
            txData[0] = (byte)ApiFrameName.RemoteCommandRequest;
            txData[1] = frameId;

            for (int i = 0; i < 8; i++)
            {
                txData[9 - i] = (byte)(destinationSerialNumber >> (8 * i));
            }

            frame.FrameData = txData;
            frame.Callback = callback;

            return SendApiFrame(frame);
        }
예제 #15
0
파일: XBee.cs 프로젝트: phantomtypist/XBee
 public void SendRemoteAtCommand(ulong destinationSerialNumber, XBeeCommand command, XBeeCallback callback)
 {
     SendRemoteAtCommand(destinationSerialNumber, command, callback, 0x0);
 }