private void Init()
        {
            _context = this;
            //   _app = (App)Application;
            _rfidManager = HoneywellDeviceHub.GetInstance().RfidMgr;


            _bTSeartTv        = (Button)FindViewById(Resource.Id.btn_search);
            _lvBleScan        = (ListView)FindViewById(Resource.Id.bt_list);
            _accessReadBtn    = (Button)FindViewById(Resource.Id.access_read);
            _bluetoothAdapter = BluetoothAdapter.DefaultAdapter;



            _bTSeartTv.SetOnClickListener(this);
            _bTSeartTv.Enabled = true;
            _accessReadBtn.SetOnClickListener(this);

            _bleScanListAdapter            = new BluetoothDeviceListAdapter(this, ref _bleScanDevices);
            _lvBleScan.Adapter             = _bleScanListAdapter;
            _lvBleScan.OnItemClickListener = this;

            _progressDialog = new ProgressDialog(this);
            _progressDialog.SetMessage(GetString(Resource.String.loading_text));
            _connectionHandler = new BtConnectionHandler(this);
            _leScanCallback    = new BleScanCallBack(_connectionHandler);

            _btReceiver = new BtReceiver();
            _btReceiver.OnBtStateChange += _btReceiver_OnBtStateChange;
            IntentFilter filter = new IntentFilter();

            filter.AddAction("android.bluetooth.adapter.action.STATE_CHANGED");
            RegisterReceiver(_btReceiver, filter);
        }
예제 #2
0
        //LIFE CYCLE CONTROL
        protected override void OnPause()
        {
            PubSubHandler.GetInstance().Unsubscribe <TagMessage>(_tagEventToken);
            PubSubHandler.GetInstance().Unsubscribe <RfidTriggeredMessage>(_rfIdTriggeredEventToken);
            HoneywellDeviceHub.GetInstance().Detach();

            base.OnPause();
        }
예제 #3
0
        //LIFE CYCLE CONTROL

        protected override void OnResume()
        {
            base.OnResume();

            HoneywellDeviceHub.GetInstance().Attach();

            _rfIdTriggeredEventToken = PubSubHandler.GetInstance().Subscribe <RfidTriggeredMessage>(OnRfidTriggerMessage);
            _tagEventToken           = PubSubHandler.GetInstance().Subscribe <TagMessage>(OnTagMessage);
        }
예제 #4
0
 private void UpdateUi()
 {
     if (HoneywellDeviceHub.GetInstance().IsReading)
     {
         _rfidScanButton.Text = "Stop";
     }
     else
     {
         _rfidScanButton.Text = "Start";
     }
 }
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View       v;
            ViewHolder vh;

            if (convertView == null)
            {
                v = LayoutInflater.From(_context).Inflate(
                    Resource.Layout.listview_item, parent, false);
                vh           = new ViewHolder();
                vh.TvName    = (TextView)v.FindViewById(Resource.Id.text1);
                vh.TvAddress = (TextView)v.FindViewById(Resource.Id.text2);
                vh.TvRssi    = (TextView)v.FindViewById(Resource.Id.rssi);
                v.Tag        = vh;
            }
            else
            {
                v  = convertView;
                vh = (ViewHolder)v.Tag;
            }

            BluetoothDevice device = GetItem(position) as BluetoothDevice;

            vh.TvName.Text    = device.Name != null ? device.Name : device.Address;
            vh.TvRssi.Text    = _context.GetString(Resource.String.tv_rssi) + _bleScanDevicesRssi[device.Address];
            vh.TvAddress.Text = device.Address;
            v.SetBackgroundColor(_colorDefault);

            var selectedDev = HoneywellDeviceHub.GetInstance().SelectedBleDev;
            var rfIdMgr     = HoneywellDeviceHub.GetInstance().RfidMgr;

            if (device.Equals(selectedDev))
            {
                if (rfIdMgr.ConnectionState == ConnectionState.StateConnected)
                {
                    vh.TvAddress.Text = _context.GetString(Resource.String.state_connected);
                    v.SetBackgroundColor(_colorConnected);
                }
                else if (rfIdMgr.ConnectionState == ConnectionState.StateConnecting)
                {
                    vh.TvAddress.Text = _context.GetString(Resource.String.state_connecting);
                    v.SetBackgroundColor(_colorDisconnected);
                }
                else if (rfIdMgr.ConnectionState == ConnectionState.StateDisconnected)
                {
                    vh.TvAddress.Text = device.Address;
                    v.SetBackgroundColor(_colorDisconnected);
                }
            }

            return(v);
        }
예제 #6
0
        private void RfidScanButton_Click(object sender, EventArgs e)
        {
            if (!HoneywellDeviceHub.GetInstance().IsReading)
            {
                HoneywellDeviceHub.GetInstance().StartReading();
            }
            else
            {
                HoneywellDeviceHub.GetInstance().StopReading();
            }

            UpdateUi();
        }
 private void RfidMgr_ReaderCreated(object sender, ReaderCreatedEventArgs e)
 {
     if (e.Success)
     {
         HoneywellDeviceHub.GetInstance().RfIdRdr = e.Reader;
         _connectionHandler.SendEmptyMessage(BleMsgConsts.MSG_CREATE_READER_SUCCESSFULLY);
         Intent intent = new Intent(this, typeof(RfIdReaderActivity));
         StartActivity(intent);
     }
     else
     {
         _connectionHandler.SendEmptyMessage(BleMsgConsts.MSG_CREATE_READER_FAILED);
     }
 }
예제 #8
0
        private void OnRfidTriggerMessage(RfidTriggeredMessage message)
        {
            if (message.Triggered)
            {
                _scannedTags.Clear();
                _tagListAdapter.NotifyDataSetChanged();


                HoneywellDeviceHub.GetInstance().StartReading();
            }
            else
            {
                HoneywellDeviceHub.GetInstance().StopReading();
            }

            UpdateUi();
        }
 private BluetoothDevice GetSelectedDev()
 {
     return(HoneywellDeviceHub.GetInstance().SelectedBleDev);
 }
 private void SetSelectedDev(BluetoothDevice dev)
 {
     HoneywellDeviceHub.GetInstance().SelectedBleDev = dev;
 }
예제 #11
0
        public override void OnCreate()
        {
            base.OnCreate();

            HoneywellDeviceHub.Create(this);
        }