quiet / org.quietmodem.Quiet

Quiet for Android - TCP over sound
1.43k stars 125 forks source link

Complete string is not received at once #22

Closed Sumit-Chakole closed 6 years ago

Sumit-Chakole commented 6 years ago

I am sending 40 characters long string from webapp (queitjs) to android app (quiet android sdk). However I am receiving this string in parts of 32 and 8 characters. I have used code as stated in samples as below-

transmit.transmit(Quiet.str2ab(cryptogram));

final byte[] buf = new byte[BUFFER_SIZE];
private static final int TIEMOUT = 30;
private static final int BUFFER_SIZE = 1024;

while (keepListening) {
                    long recvLen = 0;
                    try {
                        recvLen = frameReceiver.receive(buf);
                        byte[] immutableBuf = java.util.Arrays.copyOf(buf, (int) recvLen);
                        String receivedText = new String(immutableBuf, Charset.forName("UTF-8"));
                        Log.d("quiet", "run: receivedText: " + receivedText);
brian-armstrong commented 6 years ago

Hi @Sumit-Chakole,

Try disabling clamp frame (clampFrame: false) when instantiating the transmitter in JS. If that doesn't help, increase the frame length for the profile you are using.

edit: example of how to pass that param https://github.com/quiet/quiet-js/blob/gh-pages/javascripts/sendtext.js#L30

Sumit-Chakole commented 6 years ago

Thanks @brian-armstrong , that solves my issue :)