簡體   English   中英

BLE設備的節奏

[英]Cadence from BLE Device

-(void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
{
     dispatch_async(dispatch_get_main_queue(), ^{

         NSData *data = characteristic.value;
         uint8_t *array = (uint8_t*) data.bytes;

         cadenceValue = [CharacteristicReader readUInt8Value:&array];
         self.cadence.text = [NSString stringWithFormat:@"%d", cadenceValue];
         });
}

如何從BLE(低功耗藍牙)設備迅速得到2節奏。 我無法找到確切的代碼。 為此,將調用didUpdateValueForCharacteristic委托方法。

我有一個nRF Toolbox的代碼,但是它在目標cswift 3中,但是我的項目在swift 2中 我嘗試使用橋接標頭調用目標c方法,但始終返回0節奏。

我不確定CharacteristicReader的定義,但是您可以嘗試:

[CharacteristicReader readUInt8Value:&array];
cadenceValue = Int(array[0])
self.cadence.text = [NSString stringWithFormat:@"%d", cadenceValue];

上面的示例假設對readUInt8Value的調用結果被放入UInt8對象的數組中,並且節奏值在數組的第一個字節中。 您還可以通過嘗試cadenceValue = Int(array[1])cadenceValue = Int(array[2])等來檢查是否在其他字節中是正確的值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM