0
EADemoの動作方法と外部アクセサリフレームワークの仕組みを理解しようとしています。 EADemoは、ここに提供されています:AppleのEADemoプロジェクトを変更してバイトを表示する
http://developer.apple.com/library/ios/#samplecode/EADemo/Introduction/Intro.html
私はそれを受け取るバイトを表示するには、AppleのEADemoプロジェクトを変更されてやりたいすべては、(彼らはASCIIタイプ文字であると仮定した場合)の代わりに、ちょうどそれが受信したバイト数を数える..私ので、 ... EASessionTransferViewController.mを変更:
- (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
へ...
- (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
しかし、これはまったく機能していません。私が最後に試した時、何も表示されませんでした。それは、受信したASCII文字または文字列を返すだけのBluetoothボードに接続されていました。
誰かが助けることができますか?
あなたはまったく応答を取得したことを確認しましたか? 「何も表示していない」と言うと、「ASCII bytes read:」と表示されているという意味ですか、それ以外は何も表示されないという意味ですか? – Jim
"ASCII bytes read:"と表示されますが、それ以外は表示されません。ボードは、エコーを示すアンドロイドのBluetoothプログラムで動作するので、間違いなく機能しています。 –
Androidと連携するということは何も意味しません。 iPhoneと通信するためにはボードが必要とするいくつかのことがありますが、それはAndroidで行う必要はありません。元のプログラムは、バイトを変更する前にそのバイトが読み取られていることを正しく報告していますか? – Jim