コード例 #1
0
ファイル: XBee.cs プロジェクト: genomics-admin/monbat
 /**
 * Creates a RemoteAtCommandRequest with 16-bit address to query a command.
 * 16-bit address defaults to broadcast and applyChanges is true.
 */
 public RemoteAtCommandRequest(XBeeAddress64 remoteAddress64, byte[] command)
     : base(command, null, 0)
 {
     _remoteAddress64 = remoteAddress64;
     _remoteAddress16 = ZB_BROADCAST_ADDRESS;
     _applyChanges = false;
     setApiId(REMOTE_AT_REQUEST);
 }
コード例 #2
0
ファイル: XBee.cs プロジェクト: genomics-admin/monbat
 public void setRemoteAddress64(XBeeAddress64 remoteAddress64)
 {
     _remoteAddress64 = remoteAddress64;
 }
コード例 #3
0
ファイル: XBee.cs プロジェクト: genomics-admin/monbat
 /**
 * Creates a RemoteAtCommandRequest with 16-bit address to query a command.
 * 64-bit address defaults to broadcast and applyChanges is true.
 */
 public RemoteAtCommandRequest(UInt16 remoteAddress16, byte[] command)
     : base(command, null, 0)
 {
     _remoteAddress64 = broadcastAddress64;
     _remoteAddress16 = remoteAddress16;
     _applyChanges = false;
     setApiId(REMOTE_AT_REQUEST);
 }
コード例 #4
0
ファイル: XBee.cs プロジェクト: genomics-admin/monbat
 /**
 * Creates a RemoteAtCommandRequest with 64-bit address to set a command.
 * 16-bit address defaults to broadcast and applyChanges is true.
 */
 public RemoteAtCommandRequest(XBeeAddress64 remoteAddress64, byte[] command, byte[] commandValue, byte commandValueLength)
     : base(command, commandValue, commandValueLength)
 {
     _remoteAddress64 = remoteAddress64;
     // don't worry.. works for series 1 too!
     _remoteAddress16 = ZB_BROADCAST_ADDRESS;
     _applyChanges = true;
     setApiId(REMOTE_AT_REQUEST);
 }
コード例 #5
0
ファイル: XBee.cs プロジェクト: genomics-admin/monbat
 /**
 * Creates a RemoteAtCommandRequest with 16-bit address to set a command.
 * 64-bit address defaults to broadcast and applyChanges is true.
 */
 public RemoteAtCommandRequest(UInt16 remoteAddress16, byte[] command, byte[] commandValue, byte commandValueLength)
     : base(command, commandValue, commandValueLength)
 {
     _remoteAddress64 = broadcastAddress64;
     _remoteAddress16 = remoteAddress16;
     _applyChanges = true;
     setApiId(REMOTE_AT_REQUEST);
 }
コード例 #6
0
ファイル: XBee.cs プロジェクト: genomics-admin/monbat
 //unsafe public XBeeAddress64& getAddress64(){}
 public ZBTxRequest(XBeeAddress64 addr64, byte[] data, byte dataLength)
     : base(ZB_TX_REQUEST, DEFAULT_FRAME_ID, data, dataLength)
 {
     _addr64 = addr64;
     _addr16 = ZB_BROADCAST_ADDRESS;
     _broadcastRadius = ZB_BROADCAST_RADIUS_MAX_HOPS;
     _option = ZB_TX_UNICAST;
 }
コード例 #7
0
ファイル: XBee.cs プロジェクト: genomics-admin/monbat
 public ZBTxRequest(XBeeAddress64 addr64, UInt16 addr16, byte broadcastRadius, byte option, byte[] data, byte dataLength, byte frameId)
     : base(ZB_TX_REQUEST, frameId, data, dataLength)
 {
     _addr64 = addr64;
     _addr16 = addr16;
     _broadcastRadius = broadcastRadius;
     _option = option;
 }
コード例 #8
0
ファイル: XBee.cs プロジェクト: genomics-admin/monbat
 public ZBRxResponse()
 {
     _remoteAddress64 = new XBeeAddress64();
 }
コード例 #9
0
ファイル: TestXBee.cs プロジェクト: genomics-admin/monbat
        private void ComA_Enviar_Click(object sender, EventArgs e)
        {
            byte[] commandoAT = new byte[2];
            char[] temp;
            string dato;
            XBeeAddress64 remoteAddress = new XBeeAddress64();

            switch (ComA_TipoTrama.Text)
            {
                case "AtCommandReq":
                    #region AtCommandReq
                    ComA_Mensajes.AppendText("Pulsado AtCommand Request" + Environment.NewLine);
                    ComA_Mensajes.AppendText("      Enviando comando : " + ComA_ATCommand.Text + Environment.NewLine);
                    temp = ComA_ATCommand.Text.ToCharArray();
                    for (int k = 0; k < temp.Length; k++)
                    {
                        commandoAT[k] = (byte)temp[k];
                    }

                    atRequest.setCommand(commandoAT);
                    XBeeA.send(atRequest);
                    if (XBeeA.readPacket(500))
                    {
                        if (XBeeA.getResponse().getApiId() == XBeeConstants.AT_COMMAND_RESPONSE)
                        {
                            XBeeA.getResponse().getAtCommandResponse(ref atResponse);

                            if (atResponse.isOk())
                            {
                                if (atResponse.getValueLength() > 0)
                                {
                                    dato = "";
                                    for (int i = 0; i < atResponse.getValueLength(); i++)
                                    {
                                        dato = string.Concat(dato, string.Format("{0:X2}", atResponse.getValue()[i]));
                                    }
                                    ComA_Mensajes.AppendText("Resultado del comando : " + dato + Environment.NewLine);
                                }
                            }
                            else
                            {
                                ComA_Mensajes.AppendText("Command return error code: ");
                                ComA_Mensajes.AppendText(Convert.ToString(atResponse.getStatus()));
                            }
                        }
                        else
                        {
                            Console.Write("Expected AT response but got ");
                            Console.Write(XBeeA.getResponse().getApiId());
                        }
                    }
                    else
                    {
                        // at command failed
                        if (XBeeA.getResponse().isError())
                        {
                            Console.Write("Error reading packet.  Error code: ");
                            Console.WriteLine(XBeeA.getResponse().getErrorCode());
                        }
                        else
                        {
                            Console.Write("No response from radio");
                        }
                    }
                    break;
                    #endregion

                case "RemoteAtCommandReq":
                    #region RemoteAtCommandReq

                    remoteAddress.setMsb(UInt32.Parse(ComA_64Addr.Text.Substring(0, 8), System.Globalization.NumberStyles.AllowHexSpecifier));
                    remoteAddress.setLsb(UInt32.Parse(ComA_64Addr.Text.Substring(8, 8), System.Globalization.NumberStyles.AllowHexSpecifier));
                    remoteatRequest.setRemoteAddress64(remoteAddress);
                    remoteatRequest.setRemoteAddress16(UInt16.Parse(ComA_16Addr.Text, System.Globalization.NumberStyles.AllowHexSpecifier));

                    temp = ComA_ATCommand.Text.ToCharArray();
                    for (int k = 0; k < temp.Length; k++)
                    {
                        commandoAT[k] = (byte)temp[k];
                    }
                    remoteatRequest.setCommand(commandoAT);

                    ComA_Mensajes.AppendText("Pulsado Remote AtCommand Request");
                    ComA_Mensajes.AppendText(Environment.NewLine);

                    XBeeA.send(remoteatRequest);
                    if (XBeeA.readPacket(5000))
                    {
                        if (XBeeA.getResponse().getApiId() == XBeeConstants.REMOTE_AT_COMMAND_RESPONSE)
                        {
                            XBeeA.getResponse().getRemoteAtCommandResponse(ref remoteatResponse);

                            if (remoteatResponse.isOk())
                            {
                                if (remoteatResponse.getValueLength() > 0)
                                {
                                    dato = "";
                                    for (int i = 0; i < remoteatResponse.getValueLength(); i++)
                                    {
                                        dato = string.Concat(dato, string.Format("{0:X2}", remoteatResponse.getValue()[i]));
                                    }
                                    ComA_Mensajes.AppendText("Resultado del comando : " + dato + Environment.NewLine);
                                }
                            }
                            else
                            {
                                ComA_Mensajes.AppendText("Command return error code: ");
                                ComA_Mensajes.AppendText(Convert.ToString(remoteatResponse.getStatus()) + Environment.NewLine);
                            }
                        }
                        else
                        {
                            ComA_Mensajes.AppendText("Expected Remote AT response but got ");
                            ComA_Mensajes.AppendText(Convert.ToString(XBeeA.getResponse().getApiId()) + Environment.NewLine);
                        }
                    }
                    else
                    {
                        // at command failed
                        if (XBeeA.getResponse().isError())
                        {
                            ComA_Mensajes.AppendText("Error reading packet.  Error code: ");
                            ComA_Mensajes.AppendText(Convert.ToString(XBeeA.getResponse().getErrorCode()) + Environment.NewLine);
                        }
                        else
                        {
                            Console.Write("No response from radio" + Environment.NewLine);
                        }
                    }

                    break;
                    #endregion

                case "ZBTransmitReq":
                    #region ZBTransmitReq
                    ComA_Mensajes.AppendText("Pulsado ZigBee Data Request");
                    ComA_Mensajes.AppendText(Environment.NewLine);
                    break;
                    #endregion

                default:
                    break;
            }
        }