{ .... //Finding the write characteristic //uint8_t val = 1; //NSData* valData = [NSData dataWithBytes:(void*)&val length:sizeof(val)]; NSData* valData = @"1301040238faba000bca3c"; [peripheral writeValue:valData forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse]; ..... } - (void) peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { NSLog(@"Did write characteristic value : %@ with ID %@", characteristic.value, characteristic.UUID); NSLog(@"With error: %@", [error localizedDescription]); }
// I am not familiar with Objective-C but it should be // similar to the following: uint8_t valData[] = { 0x13, 0x01, 0x04, 0x02, 0x38, 0xfa, 0xba, 0x00, 0x0b, 0xca, 0x3c;
NSMutableData *concatenate = [NSMutableData data]; uint16_t first=0x1cbd; uint8_t second = 0x01; uint8_t third = 0xfa; uint8_t fourth=0xea NSData* one = [NSData dataWithBytes:(void*)&first length:sizeof(first)]; NSData* two = [NSData dataWithBytes:(void*)&second length:sizeof(second)]; NSData* three = [NSData dataWithBytes:(void*)&third length:sizeof(third)]; NSData* four = [NSData dataWithBytes:(void*)&fourth length:sizeof(fourth)]; [concatenate appendData:one]; [concatenate appendData:two]; [concatenate appendData:three]; [concatenate appendData:four]; [peripheral writeValue:concatenate forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse];
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)