Commit d264d4e6 by Lee Jaebin

検証

parent 61e9951f
...@@ -2,8 +2,10 @@ package jp.agentec.abook.abv.cl.util; ...@@ -2,8 +2,10 @@ package jp.agentec.abook.abv.cl.util;
import android.bluetooth.BluetoothSocket; import android.bluetooth.BluetoothSocket;
import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.SppDeviceDto; import jp.agentec.abook.abv.bl.dto.SppDeviceDto;
...@@ -55,7 +57,7 @@ public class YamatoBluetoothReceiveTask extends Thread { ...@@ -55,7 +57,7 @@ public class YamatoBluetoothReceiveTask extends Thread {
@Override @Override
public void run() { public void run() {
Logger.i(TAG, "bluetoothReciveTask run"); Logger.i(TAG, "bluetoothReciveTask run");
byte[] buffer = new byte[1024];
int readSize = 0; int readSize = 0;
while (mInputStream != null) { while (mInputStream != null) {
Logger.i(TAG, "start read mInputStream."); Logger.i(TAG, "start read mInputStream.");
...@@ -66,8 +68,14 @@ public class YamatoBluetoothReceiveTask extends Thread { ...@@ -66,8 +68,14 @@ public class YamatoBluetoothReceiveTask extends Thread {
} }
try { try {
readSize = mInputStream.read(buffer); BufferedReader br = new BufferedReader(new InputStreamReader(mInputStream));
String str = new String(buffer, 0, readSize); StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
String str = sb.toString();
Logger.i(TAG, "getData : " + str); Logger.i(TAG, "getData : " + str);
if (str.indexOf(new Character((char) STX).toString()) != -1 && str.indexOf(new Character((char) ETX).toString()) != -1) { if (str.indexOf(new Character((char) STX).toString()) != -1 && str.indexOf(new Character((char) ETX).toString()) != -1) {
String dataStr = str.substring(str.indexOf(new Character((char) STX).toString()) + 1, str.indexOf(new Character((char) ETX).toString())); String dataStr = str.substring(str.indexOf(new Character((char) STX).toString()) + 1, str.indexOf(new Character((char) ETX).toString()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment