Exemplo n.º 1
0
        public int connect(string uri)
        {
            Regex reg   = new Regex("^radio://([0-9]+)(/(([0-9]+))(/((250K|1M|2M))?(/([A-F0-9]+))?)?)?$");
            Match match = reg.Match(uri);

            if (!match.Success)
            {
                return(1);
            }
            this.uri = uri;
            int channel = int.Parse(match.Groups[3].Value);

            if (channel == 0)
            {
                channel = 2;
            }
            Crazyradio.DATA_RATE datarate = Crazyradio.DATA_RATE.DR_2MPS;
            if (match.Groups[7].Value == "250K")
            {
                datarate = Crazyradio.DATA_RATE.DR_250KPS;
            }
            else if (match.Groups[7].Value == "1M")
            {
                datarate = Crazyradio.DATA_RATE.DR_1MPS;
            }
            else if (match.Groups[7].Value == "2M")
            {
                datarate = Crazyradio.DATA_RATE.DR_2MPS;
            }
            long addr    = Convert.ToInt64(match.Groups[9].Value, 16);
            long address = addr != 0 ? addr : 0xE7E7E7E7E7;

            if (_radio_manager == null)
            {
                _radio_manager = new _RadioManager(int.Parse(match.Groups[1].Value), channel, datarate, address);
            }
            else
            {
                return(2);
            }
            Crazyradio cradio = _radio_manager.enter();

            if (cradio.version >= 40)
            {
                cradio.set_arc(3);
            }

            _thread      = new Thread(run);
            _thread.Name = uri;
            _thread.Start();

            return(0);
        }
Exemplo n.º 2
0
        public _RadioManager(int devid, int channel = 0, Crazyradio.DATA_RATE datarate = Crazyradio.DATA_RATE.DR_250KPS, long address = 0xE7E7E7E7E7)
        {
            _devid    = devid;
            _channel  = channel;
            _datarate = datarate;
            _address  = address;

            lock (_radios)
            {
                _SharedRadio radio;
                if (_radios.ContainsKey(devid))
                {
                    radio = _radios[devid];
                }
                else
                {
                    radio = new _SharedRadio(devid);
                    _radios.Add(devid, radio);
                }
                radio.usage_counter++;
            }
        }
Exemplo n.º 3
0
 public radio_interface(Crazyradio.DATA_RATE rate, int channel)
 {
     this.rate    = rate;
     this.channel = channel;
 }