Exemplo n.º 1
0
        private void UpdateReadersList()
        {
            if (Readers != null)
            {
                CAENRFIDPort isTCP = null;
                ((ListView)FindViewById(Resource.Id.reader_list)).Adapter = null;
                _data.Clear();

                for (int i = 0; i < Readers.Count; i++)
                {
                    DemoReader r = Readers[i];

                    var readerMap = new JavaDictionary <string, object>();
                    isTCP = r.ConnectionType;
                    readerMap["image"] = isTCP == CAENRFIDPort.CaenrfidTcp
                        ? Resource.Drawable.ic_tcp_reader
                        : Resource.Drawable.ic_bt_reader;
                    readerMap["name"] = r.ReaderName;
                    readerMap["info"] = "Serial: " + r.Serial
                                        + "\nFirmware: " + r.FirmwareRelease
                                        + "\nRegulation: " + r.GetRegulation();
                    _data.Add(readerMap);
                }
            }

            string[] from = { "image", "name", "info" };
            int[]    to   = { Resource.Id.reader_image, Resource.Id.reader_name, Resource.Id.reader_info };

            _adapter = new SimpleAdapter(ApplicationContext, _data,
                                         Resource.Layout.list_reader, from, to);

            ((ListView)FindViewById(Resource.Id.reader_list)).Adapter = _adapter;
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.inventory_selection);

            _rFIDTagAdapter = new RfidTagAdapter(ApplicationContext, Resource.Id.inventory_list);

            _inventoryList         = (ListView)this.FindViewById(Resource.Id.inventory_list);
            _inventoryList.Adapter = _rFIDTagAdapter;


            Reader      = MainActivity.Readers[MainActivity.SelectedReader];
            _totalFound = (TextView)this.FindViewById(Resource.Id.total_found_num);

            StartReceivingTags();
        }
Exemplo n.º 3
0
        protected override async void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            string          ip  = null;
            BluetoothDevice dev = null;

            switch (requestCode)
            {
            case AddReaderBt:
                if (resultCode == Result.Ok)
                {
                    dev = (BluetoothDevice)((Intent)data).GetParcelableExtra("BT_DEVICE");

                    _tcpBtWaitProgressDialog = ProgressDialog.Show(this,
                                                                   "Connection ", "Connecting to " + dev.Name, true,
                                                                   true);

                    await Task.Run(() =>
                    {
                        BluetoothSocket sock;
                        CAENRFIDReader reader   = null;
                        CAENRFIDReaderInfo info = null;
                        string fwrel            = null;

                        bool no_connection = true;

                        try
                        {
                            sock = dev.CreateRfcommSocketToServiceRecord(_myUuid);

                            reader = new CAENRFIDReader();


                            reader.Connect(sock);
                            var state = dev.BondState;

                            while (state != Bond.Bonded)
                            {
                                state = dev.BondState;
                            }


                            info  = reader.ReaderInfo;
                            fwrel = reader.FirmwareRelease;

                            DemoReader dr = new DemoReader(reader, info.Model,
                                                           info.SerialNumber, fwrel, CAENRFIDPort.CaenrfidBt);
                            Readers.Add(dr);
                        }
                        catch (CAENRFIDException e)
                        {
                            Log.Error(TAG, "Exception " + e.Message);

                            Toast.MakeText(ApplicationContext, "Failed", ToastLength.Long);
                        }
                    });


                    UpdateReadersList();
                    _tcpBtWaitProgressDialog.Dismiss();
                }
                break;
            }
        }