0

I am using 32Feet.Net's sample (list below) with using statements removed for brevity.

    static void Main(string[] args)
    {
        BluetoothClient client = new BluetoothClient();

        BluetoothDeviceInfo device = null;
        foreach (var dev in client.DiscoverDevices())
        {
            if (dev.DeviceName.Contains("moto g(6)"))
            {
                device = dev;
                break;
            }
        }

        client.Connect(device.DeviceAddress, BluetoothService.SerialPort);
        client.Close();
    }

The line client.Connect(device.DeviceAddress, BluetoothService.SerialPort); blows up with this error {"The requested address is not valid in its context 601D914C50BF:0000110100001000800000805f9b34fb"}.

The only thing I altered in the sample was to find my smart phone, the moto g6. What am I missing?

Before putting a bounty on this question, I need to clarify that I am also looking for documentation or examples of having a desktop computer running Windows 10 be able to receive a file from iOS or Android and without having to use the built-in Bluetooth step by step in Windows 10. I would like to know what to do to correct the error.

I realize there is Command Line Bluetooth, but it would be nice to click a button in a gui and transfer a file using 32Feet.net.

octopusgrabbus
  • 10,555
  • 15
  • 68
  • 131

1 Answers1

1

Looks like the issue is because of services that are running on the device https://archive.codeplex.com/?p=32feet

Are you sure that device you are using has SerialPort profile running?

Also, Can you try the following code by using

private void BluetoothClientConnectCallback(IAsyncResult ar)
{
    // Write your Call Back Code here
}

 static void Main(string[] args)
    {
        BluetoothClient client = new BluetoothClient();
        
        AllDevices = client.DiscoverDevicesInRange();
        foreach (BluetoothDeviceInfo Device in AllDevices)
        {
            if (Device.DeviceName.Equals("moto g(6)"))
            {
                if (!client.Connected)
                    client = new BluetoothClient();
                client.BeginConnect(Device.DeviceAddress, Device.InstalledServices[0], this.BluetoothClientConnectCallback, client);
                break;
            }
        }
        client.Close();
    }

Also, you have to pair your device before connecting. Check here

BluetoothSecurity.PairRequest(Device.DeviceAddress,"123456");
Sreeram Nair
  • 2,369
  • 12
  • 27