| | |
| | | private Bluetooth mBluetooth = null; |
| | | private BluetoothChatService mChatService = null; |
| | | private String mConnectedDeviceName = null; |
| | | private String mConnectedDeviceAddr = null; |
| | | |
| | | private String mTargetBluetooth = null; |
| | | private String mTargetBluetoothAddr = null; |
| | | private boolean mDiscoveryBluetooth = false; |
| | |
| | | } |
| | | } |
| | | |
| | | public void DisconnectBluetooth() |
| | | { |
| | | handlerConnectBluetooth.removeCallbacks(runnableConnectBluetooth); |
| | | if (mChatService != null) { |
| | | mChatService.stop(); |
| | | } |
| | | } |
| | | |
| | | Handler handlerConnectBluetooth = new Handler(); |
| | | Runnable runnableConnectBluetooth = new Runnable() { |
| | | @Override |
| | |
| | | switch (msg.arg1) { |
| | | case BluetoothChatService.STATE_CONNECTED: |
| | | Log.d(TAG, "蓝牙已连接"); |
| | | BluetoothStatusChange(3); |
| | | // BluetoothStatusChange(3); |
| | | BluetoothConnected(mConnectedDeviceName, mConnectedDeviceAddr); |
| | | break; |
| | | case BluetoothChatService.STATE_CONNECTING: |
| | | Log.d(TAG, "蓝牙连接中..."); |
| | |
| | | mConnectedDeviceName = msg.getData().getString(Constants.DEVICE_NAME); |
| | | Log.d(TAG, "MESSAGE_DEVICE_NAME: " + mConnectedDeviceName); |
| | | break; |
| | | case Constants.MESSAGE_DEVICE_ADDRESS: |
| | | mConnectedDeviceAddr = msg.getData().getString(Constants.DEVICE_ADDRESS); |
| | | Log.d(TAG, "MESSAGE_DEVICE_ADDRESS: " + mConnectedDeviceAddr); |
| | | break; |
| | | case Constants.MESSAGE_TOAST: |
| | | break; |
| | | default:break; |
| | |
| | | public native void MainProcBinMsgEntry(int cmd, byte []data, int length); |
| | | public native void UpgradeMcu(String vercode, byte []rom); |
| | | public native void TextSpeakEnd(int id); |
| | | public native void BluetoothConnected(String name, String addr); |
| | | public native void BluetoothStatusChange(int status); |
| | | public native void BluetoothDataComeIn(byte []data, int length); |
| | | } |