在BLE標準中alert_notify服務的UUID爲:00001811-0000-1000-8000-00805f9b34fb
其服務中文本通知的characteristic的UUID爲:00002a46-0000-1000-8000-00805f9b34fb
我們在連接上小米手環2並認證成功之後就可以使用手環的各種服務了
void text_notify(std::__cxx11::string text)
{
int length = text.length();
uint8_t per_text[2+length]={0x05,0x01};//加上前綴
memcpy(per_text+2,text.c_str(),length);//編碼爲UTF-8
pTextNotifyCharacteristic->writeValue(per_text,length+2,true);//要求response的寫入
}