C# 实现蓝牙检测及蓝牙设备信息获取代码

C# 实现蓝牙检测及蓝牙设备信息获取代码

using System;
using System.IO;
using System.Net.Sockets;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
// 需添加命名空间
using InTheHand.Net.Bluetooth;

namespace bluetooth
{
    class Program
    {
        static void Main(string[] args)
        {
            BluetoothRadio bluetoothRadio = BluetoothRadio.PrimaryRadio;
            if (bluetoothRadio != null)
            {
                localBluetoothInfo(bluetoothRadio);
            }
            else
            {
                Console.WriteLine("未找到本机蓝牙设备!");
                Console.ReadLine();
            }
        }

        /**
         * 
         * 显示本地蓝牙设备信息
         * 
         * **/
        private void localBluetoothInfo(BluetoothRadio bluetoothRadio)
        {
            Console.WriteLine("ClassOfDevice: " + bluetoothRadio.ClassOfDevice);
            Console.WriteLine("HardwareStatus: " + bluetoothRadio.HardwareStatus);
            Console.WriteLine("HciRevision: " + bluetoothRadio.HciRevision);
            Console.WriteLine("HciVersion: " + bluetoothRadio.HciVersion);
            Console.WriteLine("LmpSubversion: " + bluetoothRadio.LmpSubversion);
            Console.WriteLine("LmpVersion: " + bluetoothRadio.LmpVersion);
            Console.WriteLine("LocalAddress: " + bluetoothRadio.LocalAddress);
            Console.WriteLine("Manufacturer: " + bluetoothRadio.Manufacturer);
            Console.WriteLine("Mode: " + bluetoothRadio.Mode);
            Console.WriteLine("Name: " + bluetoothRadio.Name);
            Console.WriteLine("Remote: " + bluetoothRadio.Remote);
            Console.WriteLine("SoftwareManufacturer: " + bluetoothRadio.SoftwareManufacturer);
            Console.WriteLine("StackFactory: " + bluetoothRadio.StackFactory);
            Console.ReadLine();
        }
    }
}

你可能感兴趣的:(c#,蓝牙)