我正在使用EADemo的示例代码。它工作正常并显示MFI设备列表。但是当我试图将正确的测试字符串发送到附件时。它得到了回应。
发送测试字符串的代码:
neech@nicolaw.uk:~ $ touch file_number
neech@nicolaw.uk:~ $ echo 1 > serial_number
neech@nicolaw.uk:~ $ cat serial_number
1
neech@nicolaw.uk:~ $ ls -l
total 8
-rw-r--r-- 1 nicolaw staff 0 25 Oct 14:07 file_number
-rw-r--r-- 1 nicolaw staff 2 25 Oct 14:07 serial_number
neech@nicolaw.uk:~ $ mv "file_number" "file_number_$(< serial_number)"
neech@nicolaw.uk:~ $ ls -l
total 8
-rw-r--r-- 1 nicolaw staff 0 25 Oct 14:07 file_number_1
-rw-r--r-- 1 nicolaw staff 2 25 Oct 14:07 serial_number
neech@nicolaw.uk:~ $
获取响应代码 的UIViewController
- (IBAction)sendStringButtonPressed:(id)sender;
{
if ([_stringToSendText isFirstResponder]) {
[_stringToSendText resignFirstResponder];
}
const char *buf = [[_stringToSendText text] UTF8String];
if (buf)
{
uint32_t len = (uint32_t)strlen(buf) + 1;
[[EADSessionController sharedController] writeData:[NSData dataWithBytes:buf length:len]];
}
}
收到回复:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// watch for the accessory being disconnected
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_accessoryDidDisconnect:) name:EAAccessoryDidDisconnectNotification object:nil];
// watch for received data from the accessory
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_sessionDataReceived:) name:EADSessionDataReceivedNotification object:nil];
EADSessionController *sessionController = [EADSessionController sharedController];
_accessory = [sessionController accessory];
[self setTitle:[sessionController protocolString]];
[sessionController openSession];
_totalBytesRead = 0;
}
但我的问题是当我向配件发送错误的测试字符串时。 我没有得到任何失败的回应。
我需要收到失败的回复。