这样可以:
NSMutableData *data=[[NSMutableData alloc] initWithCapacity:0];
int8_t byte0 = 0xfe;
[data appendBytes:&byte0 length:sizeof(byte0)];
int8_t byte1 = 0x82;
[data appendBytes:&byte1 length:sizeof(byte1)];
int8_t byte2 = 0x00;
[data appendBytes:&byte2 length:sizeof(byte2)];
int8_t byte3 = 0x00;
[data appendBytes:&byte3 length:sizeof(byte3)];
int8_t byte4 = 0x00;
[data appendBytes:&byte4 length:sizeof(byte4)];
int8_t byte5 = 0x02;
[data appendBytes:&byte5 length:sizeof(byte5)];
NSLog(@"%@",data);//<fe820000 0002>
NSMutableData *data=[[NSMutableData alloc] initWithCapacity:0];
int8_t byte0 = 0xfe;
[data appendBytes:&byte0 length:sizeof(byte0)];
int8_t byte1 = 0x82;
[data appendBytes:&byte1 length:sizeof(byte1)];
int8_t byte2 = 0x00;
[data appendBytes:&byte2 length:sizeof(byte2)];
int8_t byte3 = 0x00;
[data appendBytes:&byte3 length:sizeof(byte3)];
int8_t byte4 = 0x00;
[data appendBytes:&byte4 length:sizeof(byte4)];
int8_t byte5 = 0x02;
[data appendBytes:&byte5 length:sizeof(byte5)];
NSLog(@"%@",data);//<fe820000 0002>
[_peripheral writeValue:data forCharacteristic:_characteristic type:CBCharacteristicWriteWithResponse];
摘录:http://bbs.csdn.net/topics/390191999