I have to communicate over bluetooth with a device, the device expects commands to be separated by carriage return + linefeed. Connection is established using RFCOMMChannel.
Atm it seems that my code is not working since I am expecting a reply from the device, which it does when I send it commands using a simpel terminal program.
This code is run after the connection is established (this is definately working since I can log data coming in from the external device)
NSString *clockRequest = @"C\r\n";
void *clockRequestData = (__bridge void *)([clockRequest dataUsingEncoding:NSASCIIStringEncoding]);
NSLog(@"Data buffer to write: %@", clockRequestData);
[rfcommChannel writeAsync: clockRequestData length:100 refcon:NULL];
//writing data from rfcomm
- (void)rfcommChannelWriteComplete:(IOBluetoothRFCOMMChannel*)rfcommChannel refcon:(void*)refcon status:(IOReturn)error {
NSLog(@"Macbook wrote to Timecube, status: %d", error);
}
The code for establishing a connection was taken and adjusted from https://gist.github.com/crazycoder1999/3139668
thx in advance