0

In my BLE project, I will write a hex data which include time in it.

The hex data is like this below:

<160922162300> , what mean 2016 - 09 - 22 - 16:23:00

I use the function to write the data to my BLE develop board:

[weakSelf.currPeripheral writeValue:myData forCharacteristic:characteristic type:CBCharacteristicPropertyWrite];

and the myData content is <160922162300>

How can I get the content is the certain info hex data?

Filburt
  • 17,626
  • 12
  • 64
  • 115
aircraft
  • 25,146
  • 28
  • 91
  • 166
  • 1
    Use http://stackoverflow.com/questions/1305225/best-way-to-serialize-an-nsdata-into-a-hexadeximal-string to transform `yourCharacteristic.value` (which is a `NSData`) into `NSString`, then use `NSDateFormatter` with `yyMMddHHmmss` for the `dateFormat` and you'll get the corresponding `NSDate`. For the reverse, you can also use the `NSDateFormatter` to transform the `NSDate` into `NSString` and http://stackoverflow.com/questions/7317860/converting-hex-nsstring-to-nsdata to transform it into the wanted `NSData` object. – Larme Sep 22 '16 at 12:07
  • @Larme Your answer is so well. – aircraft Sep 26 '16 at 01:45

0 Answers0