简体   繁体   中英

Bluetooth Fit Watch Connection Xamarin Android

i recently posted about connection to bluetooth devices using Xamarin. I managed to get the device and the mac address on a list. Im having a problem connecting to the device. It doesnt do anything when clicked... What are the next steps to pairing with device and is it even possible to pair with a fit watch, im trying to use the heart rate monitor on the fit watch as well.

I'm guessing the next step would be to setup a Click event on the list... Something like

myListView = FindViewById<ListView>(Resource.Id.list);
myListView.ItemClick += List_Click;
        private void List_Click(object sender, AdapterView.ItemClickEventArgs e)
        {

            //throw new NotImplementedException();
        }

and is it possible to get the data from the fit watch and sync it with a chart. I have managed to get a pie chart. now i just need to pair the fit watch and get the data from bluetooth. Any advice would be grateful thanks

You could get a BluetoothDevice object from the BluetoothAdapter

and something like:

myListView.ItemClick += List_Click;
    private void List_Click(object sender, AdapterView.ItemClickEventArgs e)
    {

         var address = xxxxx; //the address you select
         BluetoothDevice btDevice = mBluetoothAdapter.GetRemoteDevice(address);
         var _socket = btDevice .CreateRfcommSocketToServiceRecord(UUID.FromString("00001101-0000-1000-8000-00805f9b34fb"));
         _socket.Connect();
    }

Much of the specifics for handling paired devices is in the documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM