public MasterRegistrationRequest(RadioID id, RadioSystemType type) : base(PacketType.RegistrationRequest)
 {
     this.id           = id;
     this.digital      = true;
     this.supportsCSBK = true;
     this.systype      = type;
 }
Esempio n. 2
0
 public MasterKeepAliveRequest(RadioID id, RadioSystemType type) : base(PacketType.MasterKeepAliveRequest)
 {
     this.id           = id;
     this.digital      = true;
     this.supportsCSBK = true;
     this.systype      = type;
 }
 public MasterRegistrationReply(Byte[] data) : base(data)
 {
     this.digital             = (this.data[0] & 0x20) != 0;
     this.supportsCSBK        = (this.data[3] & 0x80) != 0;
     this.peerCount           = (UInt16)(this.data[5] << 8 | this.data[6]);
     this.masterSystemType    = (RadioSystemType)this.data[7];
     this.MasterVersion       = this.data[8];
     this.requestedSystemType = (RadioSystemType)this.data[9];
     this.requestedVersion    = this.data[10];
 }
Esempio n. 4
0
 public RadioSystem(uint radioid, RadioSystemType type, UInt16 port)
 {
     this.peers       = new List <Radio>();
     this.activeCalls = new Dictionary <RadioID, RadioCall>();
     this.myID        = new RadioID(radioid);
     this.type        = type;
     this.client      = new UDPClient(port);
     this.client.GotPeerRegisterRequest  += new PacketHandler(this.HandlePeerRegisterRequest);
     this.client.GetPeerKeepAliveRequest += new PacketHandler(this.HandlePeerKeepAliveRequest);
     this.client.GotPeerListReply        += new PacketHandler(this.NullHandler);
     this.client.GotUserPacket           += RestClient_GotUserPacket;
 }
Esempio n. 5
0
        static void Main(string[] args)
        {
            bool go = true;

            srv = new RPCServer();

            db = new Database(ConfigurationManager.AppSettings.Get("dbConnectionString"));
            if (!db.IsSetup)
            {
                Console.WriteLine("Seting up DB...");
                db.CreateTables();
            }

            string masterIP   = "192.168.0.100";
            int    masterPort = 50000;

            if (args.Length > 1)
            {
                string[] parts = args[1].Split(':');
                masterIP = parts[0];
                if (parts.Length > 1)
                {
                    masterPort = int.Parse(parts[1]);
                }
            }

            RadioSystemType type = (RadioSystemType)RadioSystemType.Parse(typeof(RadioSystemType), ConfigurationManager.AppSettings.Get("systemType"));

            sys = new RadioSystem(uint.Parse(ConfigurationManager.AppSettings.Get("systemId")), type);
            srv.SetSystem(sys);
            sys.GotRadioCall += HandleUserCall;
            Radio master = sys.ConnectToMaster(masterIP, masterPort);

            Console.WriteLine("Master ID = {0}", master.ID);
            master.InitXNL();
            Console.WriteLine("    XNL ID = {0}", master.XNLID);
            Console.WriteLine("    XCMP Version = {0}", master.XCMPVersion);
            string serialNum = master.SerialNumber;
            string modelNum  = master.ModelNumber;
            string fwver     = master.FirmwareVersion;

            Console.WriteLine("    Serial Number = {0}", serialNum);
            Console.WriteLine("    Model Number = {0}", modelNum);
            Console.WriteLine("    Firmware Version = {0}", fwver);
            Console.WriteLine("    Alarms:");
            Dictionary <string, bool> alarms = master.GetAlarmStatus();

            foreach (KeyValuePair <string, bool> kvp in alarms)
            {
                Console.WriteLine("        {0}: {1}", kvp.Key, kvp.Value);
            }
            string name = db.UpdateRepeater(master.ID, serialNum, modelNum, fwver);

            sys.Master.Name = name;
            Tuple <float, float> rssis = master.RSSI;

            Console.WriteLine("    RSSI: {0} {1}", rssis.Item1, rssis.Item2);
            db.WriteRSSI(master.ID, rssis);
            Radio[] radios = sys.GetPeers();
            Console.WriteLine("Found {0} other radios...", radios.Length);
            foreach (Radio r in radios)
            {
                PeerRadio pr = (PeerRadio)r;
                pr.SendPeerRegistration();
                Console.WriteLine("Peer ID = {0}", r.ID);
                Console.WriteLine("    Peer IP = {0}", pr.Endpoint);
                if (r.InitXNL() == false)
                {
                    Console.WriteLine("    Retrying peer init!");
                    pr.SendPeerRegistration();
                    r.InitXNL();
                }
                Console.WriteLine("    XNL ID = {0}", r.XNLID);
                Console.WriteLine("    XCMP Version = {0}", r.XCMPVersion);
                serialNum = r.SerialNumber;
                modelNum  = r.ModelNumber;
                fwver     = r.FirmwareVersion;
                Console.WriteLine("    Serial Number = {0}", serialNum);
                Console.WriteLine("    Model Number = {0}", modelNum);
                Console.WriteLine("    Firmware Version = {0}", fwver);
                Console.WriteLine("    Alarms:");
                alarms = r.GetAlarmStatus();
                foreach (KeyValuePair <string, bool> kvp in alarms)
                {
                    Console.WriteLine("        {0}: {1}", kvp.Key, kvp.Value);
                }
                name   = db.UpdateRepeater(r.ID, serialNum, modelNum, fwver);
                r.Name = name;
                rssis  = r.RSSI;
                Console.WriteLine("    RSSI: {0} {1}", rssis.Item1, rssis.Item2);
                db.WriteRSSI(r.ID, rssis);
            }
            System.Timers.Timer t = new System.Timers.Timer(30000);
            t.Elapsed  += GetRSSI;
            t.Enabled   = true;
            t.AutoReset = true;
            lrrp        = new LRRPClient();
            tms         = new TMSClient();
            sys.RegisterLRRPClient(lrrp);
            sys.RegisterTMSClient(tms);
            CommandProcessor cmd = new CommandProcessor(sys, lrrp, tms);

            while (go)
            {
                Console.Write("cmd> ");
                string   cmdStr = Console.ReadLine();
                string[] parts  = cmdStr.Split(' ');
                switch (parts[0])
                {
                case "exit":
                    go = false;
                    break;

                case "":
                    //Just print the new command line
                    break;

                default:
                    CommandResult res = cmd.ProcessCommand(parts[0], parts.Skip(1).ToArray());
                    if (res.Success == false)
                    {
                        if (res.ex != null)
                        {
                            Console.WriteLine("Command Failed! " + res.ex);
                        }
                        else
                        {
                            Console.WriteLine("Command Failed!");
                        }
                    }
                    else
                    {
                        StringBuilder sb = new StringBuilder();
                        foreach (KeyValuePair <string, object> pair in res.Data)
                        {
                            sb.Append(pair.Key + ": " + pair.Value + ", ");
                        }
                        Console.WriteLine("Success! " + sb.ToString());
                    }
                    break;
                }
            }
            sys.Dispose();
            lrrp.Dispose();
            tms.Dispose();
        }
Esempio n. 6
0
 public PeerKeepAliveReply(RadioID id, RadioSystemType type) : base(PacketType.PeerKeepAliveReply)
 {
     this.id      = id;
     this.systype = type;
 }
Esempio n. 7
0
 public PeerRegistrationRequest(byte[] data) : base(data)
 {
     this.systype = (RadioSystemType)this.data[0];
 }
Esempio n. 8
0
 public PeerRegistrationRequest(RadioID id, RadioSystemType type) : base(PacketType.PeerRegisterRequest)
 {
     this.id      = id;
     this.systype = type;
 }
Esempio n. 9
0
 public RadioSystem(uint radioid, RadioSystemType type) : this(radioid, type, 50000)
 {
 }