| | |
| | | mCallback.onConnecting(); |
| | | } |
| | | |
| | | System.out.println("BleGattCallback setting " + scanResult.getDevice().getAddress()); |
| | | System.out.println("Ble onconnectSuccess"); |
| | | |
| | | bleManager.connectDevice(scanResult, false, new BleGattCallback() { |
| | | |
| | | @Override |
| | | public void onFoundDevice(ScanResult scanResult) { |
| | | System.out.println("chenqi blueTooth connect state -> onFoundDevice"); |
| | | BluetoothService.this.name = scanResult.getDevice().getName(); |
| | | BluetoothService.this.mac = scanResult.getDevice().getAddress(); |
| | | } |
| | | |
| | | @Override |
| | | public void onConnecting(BluetoothGatt gatt, int status) { |
| | | |
| | | System.out.println("chenqi blueTooth connect state -> onConnecting"); |
| | | } |
| | | |
| | | @Override |
| | | public void onConnectError(BleException exception) { |
| | | System.out.println("chenqi blueTooth connect state -> onConnectError"); |
| | | runOnMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | |
| | | |
| | | @Override |
| | | public void onConnectSuccess(BluetoothGatt gatt, int status) { |
| | | System.out.println("chenqi blueTooth connect state -> onConnectSuccess"); |
| | | //保存最近连接的蓝牙设备MAC |
| | | MainApp.theApp.sharedPreferencesUtil.saveBLE(gatt.getDevice().getAddress()); |
| | | } |
| | | |
| | | @Override |
| | | public void onServicesDiscovered(final BluetoothGatt gatt, int status) { |
| | | System.out.println("chenqi blueTooth connect state -> onServicesDiscovered"); |
| | | BluetoothService.this.gatt = gatt; |
| | | runOnMainThread(new Runnable() { |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void onDisConnected(BluetoothGatt gatt, int status, BleException exception) { |
| | | System.out.println("chenqi blueTooth connect state -> onDisConnected"); |
| | | runOnMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |