Не удается найти устройство BLE с помощью 32feet.NET - PullRequest
0 голосов
/ 06 мая 2019

Я использую VS 2017 в Windows 7, чтобы написать инструмент hci для поиска устройства BLE.Я использую Bluetooth CSR 4.0 Dongle (драйвер установлен и работает хорошо) и BlueSoleil.

Но когда после рекламы устройства BLE программа не может его найти.Я пытался использовать другое приложение, такое как lightblue для поиска, устройство BLE можно найти.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using InTheHand.Net.Bluetooth;
using InTheHand.Net;
using InTheHand.Net.Sockets;
using System.Diagnostics;
using System.Net.Sockets;

namespace hcitool
{
partial class Program
{
    static bool infoRatherThanName;
    static BluetoothAddress _searchAddress;

    static int Main(string[] args)
    {
        if (args.Length < 1)
        {
            Console.WriteLine("Please specify command.");
            return 2;
        }
        var cmd = args[0];
        switch (cmd)
        {
            case "name":
                infoRatherThanName = false;
                break;
            case "info":
                infoRatherThanName = true;
                break;
            //-
            case "dev":
                return ShowRadios();
            //case "auth":
            //    return CauseAuth(GETADDRESS());
            default:
                throw new NotImplementedException("Command: '" + cmd + 
     "'");
        }
        if (args.Length < 2)
        {
            Console.WriteLine("Please specify device address.");
            return 2;
        }
        var addrS = args[1];
        _searchAddress = BluetoothAddress.Parse(addrS);
        //
        var dev = new BluetoothDeviceInfo(_searchAddress);
        bool isInRange = GetCanConnectTo(dev);
        if (isInRange)
        {
            PrintDevice(dev);
        }
        else
        {
            Console.WriteLine("Can't see that device.");
        }
        //
        Console.WriteLine("simple");
        return Simple();
        //return Fancier();
    }

Когда я запускаю программу, используя : «имя hcitool.exe 123456654321 (адрес BLE)», оно показывает:не может видеть это устройство.

Возвращаемое значение GetCanConnectTo () имеет значение false, поэтому он показывает: не может видеть это устройство.

Я не знаю, как я могу подключиться к устройству, используя мой код.

...