yapısına bir NSData dönüştürmek için: < 840100ec d5045715 00010014 00240018 00>ben cihazı (BLE) bir veri var doğru
ama ikinci bayt doğru dönüştüremiyor. Bu gibi:
Ama Uint8 dizisi kullanabilirsiniz yapabilir, neden? Teşekkür ederim. Bu gibi
kodu: derleyici bellekte bir yapının bireysel alanlarını ortaya koyan Nasıl
// I got the data:<840100ec d5045715 00010014 00240018 00>
case SPK_FEEDBACK_HistoryDataPort:
// Log
NSLog(@"receive data:%@", [NSData dataWithBytes:originalCommandBytes length:sizeof(D2MHistoryDataPort)]);
// originalCommandBytes dataType:UInt8 *
D2MHistoryDataPort *historyData = (D2MHistoryDataPort *)originalCommandBytes;
// Log
NSLog(@"收到硬件返回的0x%x指令(历史数据体): 历史数据包的索引:%d; 时间戳:%d; 步数:%d; 卡路里:%d; 距离:%d; 睡眠:%d; 运动时长:%d",
historyData->cmd,
historyData->index,
(unsigned int)historyData->timeStamp,
historyData->steps,
historyData->calories,
historyData->distance,
historyData->sleep,
historyData->duration);
break;
// I declare this struct in another class
typedef struct {
UInt8 cmd;
UInt16 index;
UInt32 timeStamp;
UInt16 steps;// 步数
UInt16 calories;// 卡路里
UInt16 distance;// 距离,单位m
UInt16 sleep;// 睡眠
UInt16 duration;// 运动时长,单位minute
} D2MHistoryDataPort;
Ne sorduğun belli değil. NsData'ya eriştiğiniz kodu gösterebilir misiniz? – Paulw11
Freebck'iniz için teşekkürler, kodu güncelledim :) –
Sorununuzun ne olduğu hala net değil. Beklenen çıktı nedir ve sahip olduklarınızdan nasıl farklıdır? – Paulw11