ios - 如何启用自定义 CBDescriptor 值?
<p><p>我正在开发 BLE 应用程序(与 Heath 相关),我有一个选项可以从 BLE 设备获取 ECG 值。我需要启用 8 个波形才能在我的应用程序中获取 ECG 数据。</p>
<p>我的问题是如何使用 CBDescriptor 启用所有波形。我需要将如下数据传递给 CBDescriptor。
波形 ID 格式
0:8bit,1:16bit,2:32bit,3:64bit,4:128bit,5:8bit*3,6:16bit*3,7:32bit*3</p>
<pre><code> uint8_t waveArray = {0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00};
NSData *waveData = ;
;
</code></pre>
<p>但我没有得到设备的任何响应。请帮帮我。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>最后我得到了我的问题的解决方案。首先我们需要调用 CBDescriptor 的 discover 方法。</p>
<pre><code>;
-(void)peripheral:(CBPeripheral *)peripheral didDiscoverDescriptorsForCharacteristic:(CBCharacteristic *)characteristicerror:(NSError *)error {
NSArray *Descroptors = ;
CBDescriptor *descript;
;
for (descript in Descroptors)
{
if (])
{
uint8_t waveArray = {0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00};//Your data which you need to send to BLE device
NSData *waveData = ;
;
NSLog(@"waveData ==%@",waveData);
CBUUID * sCBUUID = ;
CBUUID * cCBUUID = ;
;
}else
{
const unsigned char bytes[] = { 0x28, 0x00 };//Your data which you need to send BLE device
NSData *descriptorData = ;
CBUUID * sCBUUID = ;
CBUUID * cCBUUID = ;
;
}
}
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 如何启用自定义 CBDescriptor 值?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/46617943/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/46617943/
</a>
</p>
页:
[1]