1.调试工具下载
Windows BLE调试工具是一款运行在Windows下的BLE调试软件,实现了扫描、连接、获取BLE设备上的服务以及向服务写入和读取数据的功能。图1是Windows BLE调试工具主界面。资源地址:
https://download.csdn.net/download/mecompu/86508009?spm=1001.2014.3001.5501&login=from_csdn
图1 Windows BLE调试工具主界面
2.使用工具连接蓝牙设备并查看Service。
在图1所示界面搜索到目标设备CMT4502-20240601后,点击连接按钮打开如下图2页面。
图2 服务展示和操作页面
从上图可以看到从机CMT4502-20240601有7个服务。分别是1800、1801、180A、FFC0、FF90、FFE0、FF01。其中1800,1801,180a是由SIG指定的特定服务的标识号。FFC0、FF90、FFE0、FF01是自定义的服务UUID。
下面代码中GattNativeServiceUUID是一些常见的Service服务UUID。想要了解更多信息,可以登录网站:Assigned Numbers | Bluetooth® Technology Website
public enum GattNativeServiceUuid : ushort
{
None = 0,
AlertNotification = 0x1811,
Battery = 0x180F,
BloodPressure = 0x1810,
CurrentTimeService = 0x1805,
CyclingSpeedandCadence = 0x1816,
DeviceInformation = 0x180A,
GenericAccess = 0x1800,
GenericAttribute = 0x1801,
Glucose = 0x1808,
HealthThermometer = 0x1809,
HeartRate = 0x180D,
HumanInterfaceDevice = 0x1812,
ImmediateAlert = 0x1802,
LinkLoss = 0x1803,
NextDSTChange = 0x1807,
PhoneAlertStatus = 0x180E,
ReferenceTimeUpdateService = 0x1806,
RunningSpeedandCadence = 0x1814,
ScanParameters = 0x1813,
TxPower = 0x1804,
SimpleKeyService = 0xFFE0
}
以下代码中定义了一些常见的特征值:
public enum GattNativeCharacteristicUuid : ushort
{
None = 0,
AlertCategoryID = 0x2A43,
AlertCategoryIDBitMask = 0x2A42,
AlertLevel = 0x2A06,
AlertNotificationControlPoint = 0x2A44,
AlertStatus = 0x2A3F,
Appearance = 0x2A01,
BatteryLevel = 0x2A19,
BloodPressureFeature = 0x2A49,
BloodPressureMeasurement = 0x2A35,
BodySensorLocation = 0x2A38,
BootKeyboardInputReport = 0x2A22,
BootKeyboardOutputReport = 0x2A32,
BootMouseInputReport = 0x2A33,
CSCFeature = 0x2A5C,
CSCMeasurement = 0x2A5B,
CurrentTime = 0x2A2B,
DateTime = 0x2A08,
DayDateTime = 0x2A0A,
DayofWeek = 0x2A09,
DeviceName = 0x2A00,
DSTOffset = 0x2A0D,
ExactTime256 = 0x2A0C,
FirmwareRevisionString = 0x2A26,
GlucoseFeature = 0x2A51,
GlucoseMeasurement = 0x2A18,
GlucoseMeasurementContext = 0x2A34,
HardwareRevisionString = 0x2A27,
HeartRateControlPoint = 0x2A39,
HeartRateMeasurement = 0x2A37,
HIDControlPoint = 0x2A4C,
HIDInformation = 0x2A4A,
IEEE11073_20601RegulatoryCertificationDataList = 0x2A2A,
IntermediateCuffPressure = 0x2A36,
IntermediateTemperature = 0x2A1E,
LocalTimeInformation = 0x2A0F,
ManufacturerNameString = 0x2A29,
MeasurementInterval = 0x2A21,
ModelNumberString = 0x2A24,
NewAlert = 0x2A46,
PeripheralPreferredConnectionParameters = 0x2A04,
PeripheralPrivacyFlag = 0x2A02,
PnPID = 0x2A50,
ProtocolMode = 0x2A4E,
ReconnectionAddress = 0x2A03,
RecordAccessControlPoint = 0x2A52,
ReferenceTimeInformation = 0x2A14,
Report = 0x2A4D,
ReportMap = 0x2A4B,
RingerControlPoint = 0x2A40,
RingerSetting = 0x2A41,
RSCFeature = 0x2A54,
RSCMeasurement = 0x2A53,
SCControlPoint = 0x2A55,
ScanIntervalWindow = 0x2A4F,
ScanRefresh = 0x2A31,
SensorLocation = 0x2A5D,
SerialNumberString = 0x2A25,
ServiceChanged = 0x2A05,
SoftwareRevisionString = 0x2A28,
SupportedNewAlertCategory = 0x2A47,
SupportedUnreadAlertCategory = 0x2A48,
SystemID = 0x2A23,
TemperatureMeasurement = 0x2A1C,
TemperatureType = 0x2A1D,
TimeAccuracy = 0x2A12,
TimeSource = 0x2A13,
TimeUpdateControlPoint = 0x2A16,
TimeUpdateState = 0x2A17,
TimewithDST = 0x2A11,
TimeZone = 0x2A0E,
TxPowerLevel = 0x2A07,
UnreadAlertStatus = 0x2A45,
AggregateInput = 0x2A5A,
AnalogInput = 0x2A58,
AnalogOutput = 0x2A59,
CyclingPowerControlPoint = 0x2A66,
CyclingPowerFeature = 0x2A65,
CyclingPowerMeasurement = 0x2A63,
CyclingPowerVector = 0x2A64,
DigitalInput = 0x2A56,
DigitalOutput = 0x2A57,
ExactTime100 = 0x2A0B,
LNControlPoint = 0x2A6B,
LNFeature = 0x2A6A,
LocationandSpeed = 0x2A67,
Navigation = 0x2A68,
NetworkAvailability = 0x2A3E,
PositionQuality = 0x2A69,
ScientificTemperatureinCelsius = 0x2A3C,
SecondaryTimeZone = 0x2A10,
String = 0x2A3D,
TemperatureinCelsius = 0x2A1F,
TemperatureinFahrenheit = 0x2A20,
TimeBroadcast = 0x2A15,
BatteryLevelState = 0x2A1B,
BatteryPowerState = 0x2A1A,
PulseOximetryContinuousMeasurement = 0x2A5F,
PulseOximetryControlPoint = 0x2A62,
PulseOximetryFeatures = 0x2A61,
PulseOximetryPulsatileEvent = 0x2A60,
SimpleKeyState = 0xFFE1
}
2.1 Service UUID_1800 (GenericAccess = 0x1800)
现在打开1800Service查看其中的特征值,如下图3所示,可以看到2a00,2a01,2a04是由SIG指定的特征UUID的标识号:
读取2a00的值:
特征值UUID_2a00(Appearance = 0x2A01)设备名 :
十六进制:0x43 0x4D 0x54 0x34 0x35 0x30 0x32 0x2D 0x32 0x30 0x32 0x34 0x30 0x36
对应ASCII字符串:CMT4502-202406
读取2a01的值:
特征值UUID_2a01(Appearance = 0x2A01)外观 :
读取返回:
十六进制: 0x00 0x00
读取2a04:
特征值UUID_2a01(PeripheralPreferredConnectionParameters = 0x2A04)外设最佳连接参数。
接下来将会更新说明下其他write,notify属性。敬请期待......