@Override
 public void onServicesDiscovered(BluetoothGatt gatt, int status) {
   if (status == BluetoothGatt.GATT_SUCCESS) {
     broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED);
   } else {
     Log.w(TAG, "onServicesDiscovered received: " + status);
   }
 }
 @Override
 public void onCharacteristicRead(
     BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
   if (status == BluetoothGatt.GATT_SUCCESS) {
     broadcastUpdate(
         ACTION_READ_DATA_AVAILABLE, characteristic, gatt.getDevice().getAddress());
   }
 }
        @Override
        public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
          String intentAction;
          System.out.println("=======status:" + status);
          if (newState == BluetoothProfile.STATE_CONNECTED) {
            intentAction = ACTION_GATT_CONNECTED;
            mConnectionState = STATE_CONNECTED;
            broadcastUpdate(intentAction);
            Log.i(TAG, "Connected to GATT server.");
            // Attempts to discover services after successful connection.
            Log.i(
                TAG, "Attempting to start service discovery:" + mBluetoothGatt.discoverServices());

          } else if (status == 133) {
            mHandler.sendEmptyMessage(0);
          } else if (status != 133 && newState == BluetoothProfile.STATE_DISCONNECTED) {
            intentAction = ACTION_GATT_DISCONNECTED;
            mConnectionState = STATE_DISCONNECTED;
            Log.e(TAG, "Disconnected from GATT server.");
            // broadcastUpdate(intentAction);
            // mHandler.sendEmptyMessage(0);
            broadcastDeviceBleUpdate(intentAction, gatt.getDevice().getAddress());
          }
        }
 @Override
 public void onCharacteristicChanged(
     BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
   broadcastUpdate(
       ACTION_NOTIFY_DATA_AVAILABLE, characteristic, gatt.getDevice().getAddress());
 }