下面列出了android.bluetooth.BluetoothGatt#GATT_INSUFFICIENT_ENCRYPTION 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
Log.d(TAG, "characteristic wrote " + status);
if (status == BluetoothGatt.GATT_SUCCESS) {
Log.d(TAG, "Wrote a characteristic successfully " + characteristic.getUuid());
if (mAuthenticationCharacteristic.getUuid().equals(characteristic.getUuid())) {
state_authSucess = true;
gatt.readCharacteristic(mHeartBeatCharacteristic);
}
} else if ((status & BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) != 0 || (status & BluetoothGatt.GATT_INSUFFICIENT_ENCRYPTION) != 0) {
if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_NONE) {
device = gatt.getDevice();
state_authInProgress = true;
bondDevice();
} else {
Log.e(TAG, "The phone is trying to read from paired device without encryption. Android Bug? Have the dexcom forget whatever device it was previously paired to: oncharacteristicwrite code: "+status+ "bond: "+gatt.getDevice().getBondState());
}
} else {
Log.e(TAG, "Unknown error writing Characteristic");
}
}
@Override
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
Log.d(TAG, "characteristic wrote " + status);
if (status == BluetoothGatt.GATT_SUCCESS) {
Log.d(TAG, "Wrote a characteristic successfully " + characteristic.getUuid());
if (mAuthenticationCharacteristic.getUuid().equals(characteristic.getUuid())) {
state_authSucess = true;
gatt.readCharacteristic(mHeartBeatCharacteristic);
}
} else if ((status & BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) != 0 || (status & BluetoothGatt.GATT_INSUFFICIENT_ENCRYPTION) != 0) {
if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_NONE) {
device = gatt.getDevice();
state_authInProgress = true;
bondDevice();
} else {
Log.e(TAG, "The phone is trying to read from paired device without encryption. Android Bug? Have the dexcom forget whatever device it was previously paired to: oncharacteristicwrite code: "+status+ "bond: "+gatt.getDevice().getBondState());
}
} else {
Log.e(TAG, "Unknown error writing Characteristic");
}
}
@Override
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
Log.d(TAG, "characteristic wrote " + status);
if (status == BluetoothGatt.GATT_SUCCESS) {
Log.d(TAG, "Wrote a characteristic successfully " + characteristic.getUuid());
if (mAuthenticationCharacteristic.getUuid().equals(characteristic.getUuid())) {
state_authSucess = true;
gatt.readCharacteristic(mHeartBeatCharacteristic);
}
} else if ((status & BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) != 0 || (status & BluetoothGatt.GATT_INSUFFICIENT_ENCRYPTION) != 0) {
if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_NONE) {
device = gatt.getDevice();
state_authInProgress = true;
bondDevice();
} else {
Log.e(TAG, "The phone is trying to read from paired device without encryption. Android Bug? Have the dexcom forget whatever device it was previously paired to: oncharacteristicwrite code: "+status+ "bond: "+gatt.getDevice().getBondState());
}
} else {
Log.e(TAG, "Unknown error writing Characteristic");
}
}
@Override
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
Log.d(TAG, "characteristic wrote " + status);
if (status == BluetoothGatt.GATT_SUCCESS) {
Log.d(TAG, "Wrote a characteristic successfully " + characteristic.getUuid());
if (mAuthenticationCharacteristic.getUuid().equals(characteristic.getUuid())) {
state_authSucess = true;
gatt.readCharacteristic(mHeartBeatCharacteristic);
}
} else if ((status & BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) != 0 || (status & BluetoothGatt.GATT_INSUFFICIENT_ENCRYPTION) != 0) {
if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_NONE) {
device = gatt.getDevice();
state_authInProgress = true;
bondDevice();
} else {
Log.e(TAG, "The phone is trying to read from paired device without encryption. Android Bug? Have the dexcom forget whatever device it was previously paired to: oncharacteristicwrite code: "+status+ "bond: "+gatt.getDevice().getBondState());
}
} else {
Log.e(TAG, "Unknown error writing Characteristic");
}
}
@Override
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
Log.d(TAG, "characteristic wrote " + status);
if (status == BluetoothGatt.GATT_SUCCESS) {
Log.d(TAG, "Wrote a characteristic successfully " + characteristic.getUuid());
if (mAuthenticationCharacteristic.getUuid().equals(characteristic.getUuid())) {
state_authSucess = true;
gatt.readCharacteristic(mHeartBeatCharacteristic);
}
} else if ((status & BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) != 0 || (status & BluetoothGatt.GATT_INSUFFICIENT_ENCRYPTION) != 0) {
if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_NONE) {
device = gatt.getDevice();
state_authInProgress = true;
bondDevice();
} else {
Log.e(TAG, "The phone is trying to read from paired device without encryption. Android Bug? Have the dexcom forget whatever device it was previously paired to");
}
} else {
Log.e(TAG, "Unknown error writing Characteristic");
}
}
@Override
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
Log.d(TAG, "characteristic wrote " + status);
if (status == BluetoothGatt.GATT_SUCCESS) {
Log.d(TAG, "Wrote a characteristic successfully " + characteristic.getUuid());
if (mAuthenticationCharacteristic.getUuid().equals(characteristic.getUuid())) {
state_authSucess = true;
mBluetoothGatt.readCharacteristic(mHeartBeatCharacteristic);
}
} else if ((status & BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) != 0 || (status & BluetoothGatt.GATT_INSUFFICIENT_ENCRYPTION) != 0) {
if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_NONE) {
device = gatt.getDevice();
state_authInProgress = true;
bondDevice();
} else {
Log.e(TAG, "The phone is trying to read from paired device without encryption. Android Bug?");
}
} else {
Log.e(TAG, "Unknown error writing Characteristic");
}
}
@Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
BluetoothGattCharacteristic characteristic = descriptor.getCharacteristic();
Log.d(TAG, "Characteristic onDescriptorWrite ch " + characteristic.getUuid());
if(mHeartBeatCharacteristic.getUuid().equals(characteristic.getUuid())) {
state_notifSetupSucess = true;
setCharacteristicIndication(mReceiveDataCharacteristic);
}
if(mReceiveDataCharacteristic.getUuid().equals(characteristic.getUuid())) {
setCharacteristicIndication(mResponseCharacteristic);
}
if(mResponseCharacteristic.getUuid().equals(characteristic.getUuid())) {
attemptRead();
}
} else if ((status & BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) != 0 || (status & BluetoothGatt.GATT_INSUFFICIENT_ENCRYPTION) != 0) {
if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_NONE) {
device = gatt.getDevice();
state_authInProgress = true;
bondDevice();
} else {
Log.e(TAG, "The phone is trying to read from paired device without encryption. Android Bug? Have the dexcom forget whatever device it was previously paired to: ondescriptorwrite code: "+status+ "bond: "+gatt.getDevice().getBondState());
}
} else {
Log.e(TAG, "Unknown error writing descriptor");
}
}
@Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
BluetoothGattCharacteristic characteristic = descriptor.getCharacteristic();
Log.d(TAG, "Characteristic onDescriptorWrite ch " + characteristic.getUuid());
if(mHeartBeatCharacteristic.getUuid().equals(characteristic.getUuid())) {
state_notifSetupSucess = true;
setCharacteristicIndication(mReceiveDataCharacteristic);
}
if(mReceiveDataCharacteristic.getUuid().equals(characteristic.getUuid())) {
setCharacteristicIndication(mResponseCharacteristic);
}
if(mResponseCharacteristic.getUuid().equals(characteristic.getUuid())) {
attemptRead();
}
} else if ((status & BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) != 0 || (status & BluetoothGatt.GATT_INSUFFICIENT_ENCRYPTION) != 0) {
if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_NONE) {
device = gatt.getDevice();
state_authInProgress = true;
bondDevice();
} else {
Log.e(TAG, "The phone is trying to read from paired device without encryption. Android Bug? Have the dexcom forget whatever device it was previously paired to: ondescriptorwrite code: "+status+ "bond: "+gatt.getDevice().getBondState());
}
} else {
Log.e(TAG, "Unknown error writing descriptor");
}
}
@Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
BluetoothGattCharacteristic characteristic = descriptor.getCharacteristic();
Log.d(TAG, "Characteristic onDescriptorWrite ch " + characteristic.getUuid());
if(mHeartBeatCharacteristic.getUuid().equals(characteristic.getUuid())) {
state_notifSetupSucess = true;
setCharacteristicIndication(mReceiveDataCharacteristic);
}
if(mReceiveDataCharacteristic.getUuid().equals(characteristic.getUuid())) {
setCharacteristicIndication(mResponseCharacteristic);
}
if(mResponseCharacteristic.getUuid().equals(characteristic.getUuid())) {
attemptRead();
}
} else if ((status & BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) != 0 || (status & BluetoothGatt.GATT_INSUFFICIENT_ENCRYPTION) != 0) {
if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_NONE) {
device = gatt.getDevice();
state_authInProgress = true;
bondDevice();
} else {
Log.e(TAG, "The phone is trying to read from paired device without encryption. Android Bug? Have the dexcom forget whatever device it was previously paired to: ondescriptorwrite code: "+status+ "bond: "+gatt.getDevice().getBondState());
}
} else {
Log.e(TAG, "Unknown error writing descriptor");
}
}
@Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
BluetoothGattCharacteristic characteristic = descriptor.getCharacteristic();
Log.d(TAG, "Characteristic onDescriptorWrite ch " + characteristic.getUuid());
if(mHeartBeatCharacteristic.getUuid().equals(characteristic.getUuid())) {
state_notifSetupSucess = true;
setCharacteristicIndication(mReceiveDataCharacteristic);
}
if(mReceiveDataCharacteristic.getUuid().equals(characteristic.getUuid())) {
setCharacteristicIndication(mResponseCharacteristic);
}
if(mResponseCharacteristic.getUuid().equals(characteristic.getUuid())) {
attemptRead();
}
} else if ((status & BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) != 0 || (status & BluetoothGatt.GATT_INSUFFICIENT_ENCRYPTION) != 0) {
if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_NONE) {
device = gatt.getDevice();
state_authInProgress = true;
bondDevice();
} else {
Log.e(TAG, "The phone is trying to read from paired device without encryption. Android Bug? Have the dexcom forget whatever device it was previously paired to: ondescriptorwrite code: "+status+ "bond: "+gatt.getDevice().getBondState());
}
} else {
Log.e(TAG, "Unknown error writing descriptor");
}
}
public static String getGattStatus(int status) {
switch (status) {
case BluetoothGatt.GATT_SUCCESS:
return "GATT_SUCCESS";
case BluetoothGatt.GATT_READ_NOT_PERMITTED:
return "GATT_READ_NOT_PERMITTED";
case BluetoothGatt.GATT_WRITE_NOT_PERMITTED:
return "GATT_WRITE_NOT_PERMITTED";
case BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION:
return "GATT_INSUFFICIENT_AUTHENTICATION";
case BluetoothGatt.GATT_REQUEST_NOT_SUPPORTED:
return "GATT_REQUEST_NOT_SUPPORTED";
case BluetoothGatt.GATT_INSUFFICIENT_ENCRYPTION:
return "GATT_INSUFFICIENT_ENCRYPTION";
case BluetoothGatt.GATT_INVALID_OFFSET:
return "GATT_INVALID_OFFSET";
case BluetoothGatt.GATT_INVALID_ATTRIBUTE_LENGTH:
return "GATT_INVALID_ATTRIBUTE_LENGTH";
case BluetoothGatt.GATT_FAILURE:
return "GATT_FAILURE";
default:
return "STATE_UNKNOWN: " + status;
}
}
@Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
BluetoothGattCharacteristic characteristic = descriptor.getCharacteristic();
Log.d(TAG, "Characteristic onDescriptorWrite ch " + characteristic.getUuid());
if(mHeartBeatCharacteristic.getUuid().equals(characteristic.getUuid())) {
state_notifSetupSucess = true;
setCharacteristicIndication(mReceiveDataCharacteristic);
}
if(mReceiveDataCharacteristic.getUuid().equals(characteristic.getUuid())) {
setCharacteristicIndication(mResponseCharacteristic);
}
if(mResponseCharacteristic.getUuid().equals(characteristic.getUuid())) {
attemptRead();
}
} else if ((status & BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) != 0 || (status & BluetoothGatt.GATT_INSUFFICIENT_ENCRYPTION) != 0) {
if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_NONE) {
device = gatt.getDevice();
state_authInProgress = true;
bondDevice();
} else {
Log.e(TAG, "The phone is trying to read from paired device without encryption. Android Bug? Have the dexcom forget whatever device it was previously paired to");
}
} else {
Log.e(TAG, "Unknown error writing descriptor");
}
}
@Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
BluetoothGattCharacteristic characteristic = descriptor.getCharacteristic();
Log.d(TAG, "Characteristic onDescriptorWrite ch " + characteristic.getUuid());
if(mHeartBeatCharacteristic.getUuid().equals(characteristic.getUuid())) {
state_notifSetupSucess = true;
setCharacteristicIndication(mReceiveDataCharacteristic);
}
if(mReceiveDataCharacteristic.getUuid().equals(characteristic.getUuid())) {
setCharacteristicIndication(mResponseCharacteristic);
}
if(mResponseCharacteristic.getUuid().equals(characteristic.getUuid())) {
attemptRead();
}
} else if ((status & BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) != 0 || (status & BluetoothGatt.GATT_INSUFFICIENT_ENCRYPTION) != 0) {
if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_NONE) {
device = gatt.getDevice();
state_authInProgress = true;
bondDevice();
} else {
Log.e(TAG, "The phone is trying to read from paired device without encryption. Android Bug?");
}
} else {
Log.e(TAG, "Unknown error writing descriptor");
}
}