I'm trying to understand how EADemo works and how the External Accessory Framework works. EADemo is available here:
http://developer.apple.com/library/ios/#samplecode/EADemo/Introduction/Intro.html
All I want to do is modify Apple's EADemo project to display the bytes it receives (assuming they are ASCII type characters) instead of just counting how many bytes it has received.. So I changed EASessionTransferViewController.m...from:
- (void)_sessionDataReceived:(NSNotification *)notification
{
EADSessionController *sessionController = (EADSessionController *)[notification object];
uint32_t bytesAvailable = 0;
while ((bytesAvailable = [sessionController readBytesAvailable]) > 0) {
NSData *data = [sessionController readData:bytesAvailable];
if (data) {
_totalBytesRead += bytesAvailable;
}
}
[_receivedBytesLabel setText:[NSString stringWithFormat:@"Bytes Received from Session: %d", _totalBytesRead]];
}
@end
To...
- (void)_sessionDataReceived:(NSNotification *)notification
{
EADSessionController *sessionController = (EADSessionController *)[notification object];
uint32_t bytesAvailable = 0;
while ((bytesAvailable = [sessionController readBytesAvailable]) > 0) {
NSData *data = [sessionController readData:bytesAvailable];
if (data) {
_totalBytesRead += bytesAvailable;
NSString *asciiStringFromData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
}
}
[_receivedBytesLabel setText:[NSString stringWithFormat:@"ASCII bytes read: %@", asciiStringFromData]];
}
@end
But this is not working at all. Last time I tried, it displayed nothing. It was connected to a bluetooth board that was just echoing back ASCII characters or strings it received.
Can someone help?