audio fsk

36 views
Skip to first unread message

Hex De

unread,
Aug 1, 2013, 2:58:35 AM8/1/13
to android-medi...@googlegroups.com
Hello all,

I've been working on a project which has FSK modem as a part of it.

The project is an android-application that Encodes text to sound-wave and transmits using phone's speaker and on the other phone the sound will be decoded by the modem to display the text .

I have found FSK-based source code and used it, the modulation part is generating the sound but the other phone displays all zeros and sometimes with other letters.

so what is the problem with the code? and how to fix it to decode correctly.

I would very much appreciate any help or guidance you are able to provide.


 The main activity code of my project is as following:



MainActivity  class

       public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText inputBox = (EditText) findViewById(R.id.edtInput);
TextView recvView = (TextView) findViewById(R.id.tvReceived); 
fskm = new FSKModem();
FSKModem.debugPrint(fskm);
 
final Button rBtn = (Button) findViewById(R.id.btnRec);
// to receive text 
rBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
fskm.addDataReceiver(new FSKModemListener() {
@Override
public void dataReceivedFromFSKModem(final byte[] data) {
runOnUiThread(new Runnable() {
   public void run() {
    StringBuilder sb = new StringBuilder();
TextView recvView = (TextView) findViewById(R.id.tvReceived);
sb.append(recvView.getText().toString());
for(int i=0; data != null && i < data.length; i++) {
int v = data[i] & 0xff;
if (v == 0xff) {
continue;
}
if (v > 31 && v < 127) {
sb.append((char)v);
} else {
if (v < 16) {
sb.append(" 0");
sb.append(Integer.toHexString(v));
sb.append(' ');
} else {
sb.append(' ');
sb.append(Integer.toHexString(v));
sb.append(' ');
}
}
}
recvView.setText(sb.toString());
   }
});
}
});
 
}
});
final Button sendBtn = (Button) findViewById(R.id.btnSend);
sendBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
EditText inputBox = (EditText) findViewById(R.id.edtInput);
String msg = inputBox.getText().toString();
fskm.writeBytes(msg.getBytes());
inputBox.setText(null);
}
});

final Button clearBtn = (Button) findViewById(R.id.btnClear);
clearBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
TextView recvView = (TextView) findViewById(R.id.tvReceived);
recvView.setText(null);
}
});

fskm.start();
}


@Override

protected void onDestroy() {
fskm.stop();
fskm = null;
super.onDestroy();
}
}
Reply all
Reply to author
Forward
0 new messages