資源簡介
C# ble 4.0 低能耗 藍牙交互 藍牙連接 適配 服務 特征 編程,通過windows模塊配對藍牙進行數據交互

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?Windows.Devices.Bluetooth;
using?Windows.Devices.Bluetooth.GenericAttributeProfile;
using?Windows.Devices.Enumeration;
using?Windows.Foundation;
using?Windows.Networking;
using?Windows.Networking.Proximity;
using?Windows.Networking.Sockets;
using?Windows.Security.Cryptography;
using?Windows.Storage.Streams;
namespace?BleSolution
{
????public?class?BleCore
????{
????????private?Boolean?asyncLock?=?false;
????????///?
????????///?搜索藍牙設備對象
????????///?
????????private?DeviceWatcher?deviceWatcher;
????????///?
????????///?當前連接的服務
????????///?
????????public?GattDeviceService?CurrentService?{?get;?set;?}
????????///?
????????///?當前連接的藍牙設備
????????///?
????????public?BluetoothLEDevice?CurrentDevice?{?get;?set;?}
????????///?
????????///?寫特征對象
????????///?
????????public?GattCharacteristic?CurrentWriteCharacteristic?{?get;?set;?}
????????///?
????????///?通知特征對象
????????///?
????????public?GattCharacteristic?CurrentNotifyCharacteristic?{?get;?set;?}
????????///?
????????///?特性通知類型通知啟用
????????///?
????????private?const?GattClientCharacteristicConfigurationDescriptorValue?CHARACTERISTIC_NOTIFICATION_TYPE?=?GattClientCharacteristicConfigurationDescriptorValue.Notify;
????????///?
????????///?存儲檢測到的設備
????????///?
????????private?List?DeviceList?=?new?List();
????????///?
????????///?定義搜索藍牙設備委托
????????///?
????????public?delegate?void?DeviceWatcherChangedEvent(MsgType?type?BluetoothLEDevice?bluetoothLEDevice);
????????///?
????????///?搜索藍牙事件
????????///?
????????public?event?DeviceWatcherChangedEvent?DeviceWatcherChanged;
????????///?
????????///?獲取服務委托
????????///?
????????public?delegate?void?GattDeviceServiceAddedEvent(GattDeviceService?gattDeviceService);
????????///?
????????///?獲取服務事件
????????///?
????????public?event?GattDeviceServiceAddedEvent?GattDeviceServiceAdded;
????????///?
????????///?獲取特征委托
????????///?
????????public?delegate?void?CharacteristicAddedEvent(GattCharacteristic?gattCharacteristic);
????????///?
????????///?獲取特征事件
????????///?
????????public?event?CharacteristicAddedEvent?CharacteristicAdded;
????????///?
????????///?提示信息委托
????????///?
????????public?delegate?void?MessAgeChangedEvent(MsgType?type?string?message?byte[]?data?=?null);
????????///?
????????///?提示信息事件
????????///?
????????public?event?MessAgeChangedEvent?MessAgeChanged;
????????///?
????????///?當前連接的藍牙Mac
????????///?
????????private?string?CurrentDeviceMAC?{?get;?set;?}
????????public?BleC
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2020-07-03?11:43??BleSolution\
?????目錄???????????0??2020-07-03?11:43??BleSolution\.vs\
?????目錄???????????0??2020-07-03?11:43??BleSolution\.vs\BleSolution\
?????目錄???????????0??2020-07-03?11:43??BleSolution\.vs\BleSolution\v14\
?????文件??????109568??2020-12-11?10:17??BleSolution\.vs\BleSolution\v14\.suo
?????目錄???????????0??2020-12-14?15:59??BleSolution\BleSolution\
?????文件?????????189??2020-07-03?11:43??BleSolution\BleSolution\App.config
?????文件???????14294??2020-12-11?09:16??BleSolution\BleSolution\BleCore.cs
?????文件?????????251??2020-07-03?11:43??BleSolution\BleSolution\BleEnum.cs
?????文件????????4725??2020-12-11?09:13??BleSolution\BleSolution\BleSolution.csproj
?????文件?????????228??2020-07-03?11:43??BleSolution\BleSolution\BleSolution.csproj.user
?????文件???????17672??2020-12-14?15:58??BleSolution\BleSolution\BluetoothLECode.cs
?????文件????????9243??2020-10-15?11:32??BleSolution\BleSolution\Form1.Designer.cs
?????文件???????10848??2020-10-15?11:34??BleSolution\BleSolution\Form1.cs
?????文件????????5817??2020-10-15?10:27??BleSolution\BleSolution\Form1.resx
?????文件????????5179??2020-12-11?09:54??BleSolution\BleSolution\Form2.Designer.cs
?????文件????????3622??2020-12-14?15:59??BleSolution\BleSolution\Form2.cs
?????文件????????5817??2020-12-11?09:54??BleSolution\BleSolution\Form2.resx
?????文件?????????536??2020-12-11?09:37??BleSolution\BleSolution\Program.cs
?????目錄???????????0??2020-07-03?11:43??BleSolution\BleSolution\Properties\
?????文件????????1320??2020-07-03?11:43??BleSolution\BleSolution\Properties\AssemblyInfo.cs
?????文件????????2864??2020-07-14?09:44??BleSolution\BleSolution\Properties\Resources.Designer.cs
?????文件????????5612??2020-07-03?11:43??BleSolution\BleSolution\Properties\Resources.resx
?????文件????????1112??2020-07-14?09:44??BleSolution\BleSolution\Properties\Settings.Designer.cs
?????文件?????????249??2020-07-03?11:43??BleSolution\BleSolution\Properties\Settings.settings
?????目錄???????????0??2020-07-14?09:43??BleSolution\BleSolution\bin\
?????目錄???????????0??2020-12-11?14:09??BleSolution\BleSolution\bin\Debug\
?????文件???????28216??2012-09-26?03:16??BleSolution\BleSolution\bin\Debug\System.Runtime.WindowsRuntime.dll
?????文件???????76981??2018-10-15?11:17??BleSolution\BleSolution\bin\Debug\System.Runtime.WindowsRuntime.xm
?????文件?????6852608??2019-03-18?17:33??BleSolution\BleSolution\bin\Debug\Windows.winmd
?????文件???????22696??2020-07-14?09:41??BleSolution\BleSolution\bin\Debug\WindowsFormsApplication1.vshost.exe
............此處省略27個文件信息
- 上一篇:倉庫管理系統/課程設計/ASP.NET/C#
- 下一篇:基于C#和AE的二次開發
評論
共有 條評論