该应用程序将自动连接到具有已知设备ID的BT连接。与配对设备的连接成功,但是当我尝试发送数据时,它会崩溃。
这是监听配对设备的BroadcastReceiver
(需要工作但是有效)才能建立连接。
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
devices.add(device);
for (int a = 0; a < pairedDevices.size(); a++) {
if (device.getName().equals(pairedDevices.get(a))) {
// append
Log.i("TAG", "IS Paired " + pairedDevices.get(a));
// s = "(Paired)";
isBTConnected = true;
if (btAdapter.isDiscovering()) {
btAdapter.cancelDiscovery();
}
BluetoothDevice selectedDevice = devices.get(0);
ConnectThread connect = new ConnectThread(selectedDevice);
connect.start();
break;
}
}
} else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) {
Log.i("TAG", "ACTION_DISCOVERY_STARTED");
} else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
Log.i("TAG", "ACTION_DISCOVERY_FINISHED");
if (isBTConnected == false) {
Log.i("TAG", "Unable to connect");
} else {
Log.i("TAG", "Connected");
}
} else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
Log.i("TAG", "ACTION_STATE_CHANGED");
if (btAdapter.getState() == btAdapter.STATE_OFF) {
Log.i("TAG", "Disconnected ");
// turnOnBT();
}
}
}
};
这是ConnectThread
创建套接字并将消息发送到主UI以启动。
private class ConnectThread extends Thread {
private final BluetoothSocket mmSocket;
private final BluetoothDevice mmDevice;
public ConnectThread(BluetoothDevice device) {
BluetoothSocket tmp = null;
mmDevice = device;
Log.d("TAG", "construct");
// Get a BluetoothSocket to connect with the given BluetoothDevice
try {
tmp = device.createRfcommSocketToServiceRecord(MY_UUID); // MY_UUID is the app's UUID string, also used by the server code
} catch (IOException e) {
Log.i("TAG", "get socket failed");
}
mmSocket = tmp;
}
public void run() {
// Cancel discovery because it will slow down the connection
btAdapter.cancelDiscovery();
Log.i("TAG", "connect - run");
try {
// Connect the device through the socket. This will block
// until it succeeds or throws an exception
mmSocket.connect();
Log.i("TAG", "connect - succeeded");
} catch (IOException connectException) {
Log.i("TAG", "connect failed");
// Unable to connect; close the socket and get out
try {
mmSocket.close();
} catch (IOException closeException) {
}
return;
}
// Do work to manage the connection (in a separate thread)
mHandler.obtainMessage(SUCCESS_CONNECT, mmSocket).sendToTarget();
}
}
这是Handler
收到开始收听的成功消息
mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
Log.i("TAG", "in handler");
super.handleMessage(msg);
switch (msg.what) {
case SUCCESS_CONNECT:
ConnectedThread connectedThread = new ConnectedThread((BluetoothSocket) msg.obj);
Toast.makeText(getApplicationContext(), "CONNECT", Toast.LENGTH_SHORT).show();
// String s = "successfully connected";
// connectedThread.write(s.getBytes());
Log.i("TAG", "connected");
break;
case MESSAGE_READ:
byte[] readBuf = (byte[]) msg.obj;
String string = new String(readBuf);
Toast.makeText(getApplicationContext(), string, Toast.LENGTH_SHORT).show();
break;
}
}
};
这是崩溃的踢球者。建立连接并创建套接字,这样我就会陷入困境。
mmOutputStream.write(buffer);
是崩溃
发生错误的方法
private void SendPacket(int FixtureNumber, int R_value, int G_value, int B_value) {
byte buffer[] = new byte[7];
buffer[0] = ((byte) FixtureNumber);
buffer[1] = ((byte) ProcessDimmer(R_value, Master_value));
buffer[2] = ((byte) ProcessDimmer(G_value, Master_value));
buffer[3] = ((byte) ProcessDimmer(B_value, Master_value));
buffer[4] = ((byte) Tx_Control_Byte);
buffer[5] = ((byte) Tx_Control_Byte_0);
buffer[6] = ((byte) 254);
if (isBTConnected == true) {
try {
mmOutputStream.write(buffer);
} catch (IOException e) {
e.printStackTrace();
}
}
}
logcat的
04-02 20:00:02.833: E/InputEventReceiver(6522): Exception dispatching input event.
04-02 20:00:02.833: E/MessageQueue-JNI(6522): Exception in MessageQueue callback: handleReceiveCallback
04-02 20:00:02.843: E/MessageQueue-JNI(6522): java.lang.NullPointerException
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at com.example.simplergb.SimpleRGB_Main.SendPacket(SimpleRGB_Main.java:2277)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at com.example.simplergb.SimpleRGB_Main.onFragmentSliderDoSomething(SimpleRGB_Main.java:1961)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at com.example.simplergb.SliderControls$1.onProgressChanged(SliderControls.java:184)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.widget.SeekBar.onProgressRefresh(SeekBar.java:91)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:655)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.widget.ProgressBar.refreshProgress(ProgressBar.java:667)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.widget.ProgressBar.setProgress(ProgressBar.java:714)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.widget.AbsSeekBar.trackTouchEvent(AbsSeekBar.java:451)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.widget.AbsSeekBar.onTouchEvent(AbsSeekBar.java:372)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.View.dispatchTouchEvent(View.java:7384)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2231)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1966)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1418)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.app.Activity.dispatchTouchEvent(Activity.java:2424)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1914)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.View.dispatchPointerEvent(View.java:7564)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3883)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3778)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5419)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5399)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5370)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5493)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:182)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.os.MessageQueue.nativePollOnce(Native Method)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.os.MessageQueue.next(MessageQueue.java:132)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.os.Looper.loop(Looper.java:124)
04-02 20:00:02.843: E/MessageQueue-JNI(6522): at android.app.Activit
04-02 20:00:02.843: D/AndroidRuntime(6522): Shutting down VM
04-02 20:00:02.843: W/dalvikvm(6522): threadid=1: thread exiting with uncaught exception (group=0x415ce700)
04-02 20:00:02.853: E/AndroidRuntime(6522): FATAL EXCEPTION: main
04-02 20:00:02.853: E/AndroidRuntime(6522): java.lang.NullPointerException
04-02 20:00:02.853: E/AndroidRuntime(6522): at com.example.simplergb.SimpleRGB_Main.SendPacket(SimpleRGB_Main.java:2277)
04-02 20:00:02.853: E/AndroidRuntime(6522): at com.example.simplergb.SimpleRGB_Main.onFragmentSliderDoSomething(SimpleRGB_Main.java:1961)
04-02 20:00:02.853: E/AndroidRuntime(6522): at com.example.simplergb.SliderControls$1.onProgressChanged(SliderControls.java:184)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.widget.SeekBar.onProgressRefresh(SeekBar.java:91)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:655)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.widget.ProgressBar.refreshProgress(ProgressBar.java:667)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.widget.ProgressBar.setProgress(ProgressBar.java:714)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.widget.AbsSeekBar.trackTouchEvent(AbsSeekBar.java:451)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.widget.AbsSeekBar.onTouchEvent(AbsSeekBar.java:372)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.View.dispatchTouchEvent(View.java:7384)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2231)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
04-02 20:00:02.853: E/AndroidRuntime(6522): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1966)
04-02 20:00:02.853: E/AndroidRuntime(6522): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1418)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.app.Activity.dispatchTouchEvent(Activity.java:2424)
04-02 20:00:02.853: E/AndroidRuntime(6522): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1914)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.View.dispatchPointerEvent(View.java:7564)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3883)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3778)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5419)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5399)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5370)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5493)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:182)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.os.MessageQueue.nativePollOnce(Native Method)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.os.MessageQueue.next(MessageQueue.java:132)
04-02 20:00:02.853: E/AndroidRuntime(6522): at android.os.Looper.loop(Looper.java:124)
04-02 20:00:02.853: E/AndroidRuntime(6522): at
04-02 20:00:02.873: D/dalvikvm(6522): GC_FOR_ALLOC freed 1211K, 9% free 12572K/13808K, paused 15ms, total 15ms
这是ConnectedThread
未在发布输出流的原始帖子中发布的内容。
private class ConnectedThread extends Thread {
private final BluetoothSocket mmSocket;
private final InputStream mmInputStream;
private final OutputStream mmOutputStream;
public ConnectedThread(BluetoothSocket socket) {
mmSocket = socket;
InputStream tmpIn = null;
OutputStream tmpOut = null;
// Get the input and output streams, using temp objects because member streams are final
try {
tmpIn = mmSocket.getInputStream();
tmpOut = mmSocket.getOutputStream();
} catch (IOException e) {
}
mmInputStream = tmpIn;
mmOutputStream = tmpOut;
}
public void run() {
byte[] buffer;
int bytes;
// Keep listening to the InputStream until an exception occurs
while (true) {
try {
// Read from the InputStream
buffer = new byte[1024];
bytes = mmInputStream.read(buffer);
// Send the obtained bytes to the UI activity
// mHandler.obtainMessage(MESSAGE_READ, bytes, -1, buffer).sendToTarget();
} catch (IOException e) {
break;
}
}
}
public void write(byte[] bytes) {
try {
mmOutputStream.write(bytes);
} catch (IOException e) {
}
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
}
}
}
更多测试结果。我注释掉了输出流并测试了连接。
private void SendPacket(int FixtureNumber, int R_value, int G_value, int B_value) {
byte buffer[] = new byte[7];
buffer[0] = ((byte) FixtureNumber);
buffer[1] = ((byte) ProcessDimmer(R_value, Master_value));
buffer[2] = ((byte) ProcessDimmer(G_value, Master_value));
buffer[3] = ((byte) ProcessDimmer(B_value, Master_value));
buffer[4] = ((byte) Tx_Control_Byte);
buffer[5] = ((byte) Tx_Control_Byte_0);
buffer[6] = ((byte) 254);
Log.d("TAG", " Test " + isBTConnected + " Socket " + mmSocket + " Device " + mmDevice);
// if (isBTConnected == true) {
//
// try {
//
// mmOutputStream.write(buffer);
// } catch (IOException e) {
//
// e.printStackTrace();
// }
//
// }
}
以下是该测试方法的日志
04-03 17:28:38.605: D/TAG(29004): Test true Socket
android.bluetooth.BluetoothSocket@422f1bb8 Device 00:06:66:4B:45:A9
SendPacket()
来自Fragment listener
。所有代码都正常运行
case 1: {
if (Fixture_Active_ColorRoll[FixtureNumber] == false) {
// RGB Value
// Log.d("TAG", "Scene Data " + Scene_ColorRoll_Option + " " + FixtureNumber);
intArrayRed[0] = R_value;
intArrayGreen[0] = G_value;
intArrayBlue[0] = B_value;
SetColorDot(0, R_value, G_value, B_value);
SendPacket(FixtureNumber, R_value, G_value, B_value);