public BrickReply OnTunnelCommand(BrickCommand command){ BrickReply reply = null; BrickCommand replyCommand = null; if(command is MonoBrick.NXT.Command){ var nxtCommand = new MonoBrick.NXT.Command (command.Data); switch(nxtCommand.CommandByte){ case MonoBrick.NXT.CommandByte.GetTunnelCommands: replyCommand = new MonoBrick.NXT.Command(MonoBrick.NXT.CommandType.ReplyCommand,nxtCommand.CommandByte,true); replyCommand.Append((byte) 0x00);//no error if(streamingSettings.EnableRTSP){ replyCommand.Append((byte) MonoBrick.NXT.CommandByte.GetTunnelRTSPSettings); replyCommand.Append((byte) MonoBrick.NXT.CommandByte.StartTunnelRTSP); } if(streamingSettings.EnableGPS){ replyCommand.Append((byte) MonoBrick.NXT.CommandByte.GetTunnelGPSPosition); } if(streamingSettings.EnableSpeak){ replyCommand.Append((byte) MonoBrick.NXT.CommandByte.TunnelSpeak); } reply = new MonoBrick.NXT.Reply(replyCommand.Data); break; case MonoBrick.NXT.CommandByte.GetTunnelRTSPSettings: if(streamingSettings.EnableRTSP){ replyCommand = new MonoBrick.NXT.Command(MonoBrick.NXT.CommandType.ReplyCommand,nxtCommand.CommandByte,true); replyCommand.Append((byte) 0x00);//no error replyCommand.Append((Int32)streamingSettings.RTSPPort); replyCommand.Append((Int32)streamingSettings.VideoPort); reply = new MonoBrick.NXT.Reply(replyCommand.Data); } else{ reply = new MonoBrick.NXT.Reply(MonoBrick.NXT.CommandType.ReplyCommand,nxtCommand.CommandByte,(byte) TunnelError.ErrorExecuting); } break; case MonoBrick. NXT.CommandByte.StartTunnelRTSP: if(rtspServer.Start(clientIpAddress.ToString(),streamingSettings.RTSPPort,streamingSettings.VideoPort,streamingSettings.VideoQuality)){ reply = new MonoBrick.NXT.Reply(MonoBrick.NXT.CommandType.ReplyCommand,nxtCommand.CommandByte); } else{ reply = new MonoBrick.NXT.Reply(MonoBrick.NXT.CommandType.ReplyCommand,nxtCommand.CommandByte,(byte) TunnelError.ErrorExecuting); } break; default: reply = new MonoBrick.NXT.Reply(MonoBrick.NXT.CommandType.ReplyCommand,nxtCommand.CommandByte,(byte) TunnelError.UnsupportedCommand); break; } } else{ throw new NotImplementedException ("EV3 support has been implemented"); } return reply; }
private void OnCommandSend(BrickCommand command){ Gtk.Application.Invoke (delegate { sendStatusbar.Pop(1); if(brickType == BrickType.NXT){ sendStatusbar.Push(1,((MonoBrick.NXT.Command)command).CommandByteAsString); } }); }