看板 AndroidDev 關於我們 聯絡資訊
最近使用藍芽的時候,想用藍芽傳大筆資料出去 使用STREAM的方式,一次大約1k Byte左右 (檔案最小大約25K,大的話差不多3Mb左右) 為何傳完都要DELAY一小段時間,對方才能收到 才能繼續往下傳 如何讓傳遞速度增加?手機用藍芽傳輸的速度還蠻快的 想試試看可以可以跟手機都速度差不多 接收端我用ARDUINO+HC06模組 String path = Environment.getExternalStorageDirectory().getPath(); File file = new File(path + "/" + "data.txt"); int i = 0; try { fin = new FileInputStream(file); ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream(); //byte[] wrong=new byte[2048]; byte[] data = new byte[1000]; //byte[] test=new byte[100]; int length = 0; while ((length = fin.read(data)) != -1) { byteBuffer.write(data, 0, length); mmOutStream.write(data); try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } //mmOutStream.flush(); android.util.Log.i("DATA MESSAGE", "" + data + "------------" + i); i++; } fin.close(); android.util.Log.i("TAG OVER", "OK OK OK OK OK OK OK OK OK"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } startSend = false; android.util.Log.i("TAG OVER", "" + count);String path = E nv File file = new File(path + "/" + "data.txt"); int i = 0; try { fin = new FileInputStream(file); ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream(); //byte[] wrong=new byte[2048]; byte[] data = new byte[1000]; //byte[] test=new byte[100]; int length = 0; while ((length = fin.read(data)) != -1) { byteBuffer.write(data, 0, length); mmOutStream.write(data); try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } //mmOutStream.flush(); android.util.Log.i("DATA MESSAGE", "" + data + "------------" + i); i++; } fin.close(); android.util.Log.i("TAG OVER", "OK OK OK OK OK OK OK OK OK"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } startSend = false; android.util.Log.i("TAG OVER", "" + count); -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.44.150.234 ※ 文章網址: https://www.ptt.cc/bbs/AndroidDev/M.1447679821.A.59F.html
kevin31a2: 改個錯字吧...11/16 21:28
※ 編輯: barry0123 (223.140.23.96), 11/16/2015 21:59:18
hans5300609: 有試過調高頻率嗎? Arduino和藍牙模組之間的頻率 11/20 08:16
hans5300609: 現在有Printer3D板可以問Arduino,要去問問嗎? 11/20 08:30
hans5300609: 記得先看板龜,Arduino方面要用 [程式] 這個分類 11/20 08:31