问题描述
大家好,我正在尝试开发与小米Band 1s集成的通用应用程序。我跟着这个
Hi everyone , I'm trying to develop an Universal app integrate with XiaoMi Band 1s. I followed thisarticle : http://allmydroids.blogspot.com/2014/12/xiaomi-mi-band-ble-protocol-reverse.html
这是我的代码
realDevice = await BluetoothLEDevice.FromIdAsync({{DeviceId}});
await realDevice.DeviceInformation.Pairing.PairAsync();
Debug.WriteLine(realDevice.GattServices.Count);
writer = new DataWriter();
writer.WriteBye((byte)2);
try
{
var GatDevices = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(Guid.Parse(" 0000fee0-0000-1000-8000-00805f9b34fb" )));
Debug.WriteLine(GatDevices [0] .Id);
var miliService = await GattDeviceService.FromIdAsync(GatDevices [0] .Id);
var pairCharacteristic = miliService.GetAllCharacteristics()。FirstOrDefault(c => c.Uuid == Guid.Parse(" 0000ff0f-0000-1000-8000-00805f9b34fb"));
var pairStatus = await pairCharacteristic.WriteValueAsync(writer.DetachBuffer(),GattWriteOption.WriteWithoutResponse);
Debug.WriteLine(pairStatus);
}
catch(exception ex)
{
throw ex;
}
writer.WriteBye((byte)2); try { var GatDevices = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(Guid.Parse("0000fee0-0000-1000-8000-00805f9b34fb"))); Debug.WriteLine(GatDevices[0].Id); var miliService = await GattDeviceService.FromIdAsync(GatDevices[0].Id); var pairCharacteristic = miliService.GetAllCharacteristics().FirstOrDefault(c => c.Uuid == Guid.Parse("0000ff0f-0000-1000-8000-00805f9b34fb")); var pairStatus = await pairCharacteristic.WriteValueAsync(writer.DetachBuffer(), GattWriteOption.WriteWithoutResponse); Debug.WriteLine(pairStatus); } catch (Exception ex) { throw ex; }
响应 pairStatus 是成功但是我的乐队没有像文章那样震动 - " Write
2 到特色 0xFF0F (对)。也许您必须通过将手指放在Mi Band的铝制部分来确认。"
The respone pairStatus is Success but my Band not vibrate like the article metioned - "Write2 to Characteristic 0xFF0F (PAIR). Maybe you have to confirm by putting your finger on the aluminium part of the Mi Band. "
我认为需要更多的东西来触发乐队,是吗?
I think there is need more some thing to trigger the Band, is that right?
OmegaVN - 窗口电话应用研究与开发
OmegaVN - Window Phone Application Researching and Development
推荐答案
这篇关于[UWP]使用蓝牙LE设备!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!