NSMutableString *tosend=[[NSMutableString alloc] init];
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
NSData *valData = [tosend dataUsingEncoding:NSUTF8StringEncoding];
[peripheral writeValue:valData forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse];这样也不行
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
[tosend appendString:[NSString stringWithFormat:@"%c",0]];
NSData *valData = [tosend dataUsingEncoding:NSUTF8StringEncoding];
[peripheral writeValue:valData forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse];这样也不行
2、0x00000000 存储是就是 0.
3、peripheral 是什么?一个 Socket 封装?
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];