no.nordicsemi.android.ble.error.GattError Java Examples

The following examples show how to use no.nordicsemi.android.ble.error.GattError. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProximityManager.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Writes the HIGH ALERT or NO ALERT command to the target device.
 *
 * @param on true to enable the alarm on proximity tag, false to disable it.
 */
public void writeImmediateAlert(final boolean on) {
	if (!isConnected())
		return;

	writeCharacteristic(alertLevelCharacteristic, on ? AlertLevelData.highAlert() : AlertLevelData.noAlert())
			.before(device -> log(Log.VERBOSE,
					on ? "Setting alarm to HIGH..." : "Disabling alarm..."))
			.with((device, data) -> log(LogContract.Log.Level.APPLICATION,
					"\"" + AlertLevelParser.parse(data) + "\" sent"))
			.done(device -> {
				alertOn = on;
				mCallbacks.onRemoteAlarmSwitched(device, on);
			})
			.fail((device, status) -> log(Log.WARN,
					status == FailCallback.REASON_NULL_ATTRIBUTE ?
							"Alert Level characteristic not found" :
							GattError.parse(status)))
			.enqueue();
}
 
Example #2
Source File: BleManagerHandler.java    From Android-BLE-Library with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private int mapDisconnectStatusToReason(final int status) {
	switch (status) {
		case GattError.GATT_SUCCESS:
			return ConnectionObserver.REASON_SUCCESS;
		case GattError.GATT_CONN_TERMINATE_LOCAL_HOST:
			return ConnectionObserver.REASON_TERMINATE_LOCAL_HOST;
		case GattError.GATT_CONN_TERMINATE_PEER_USER:
			return ConnectionObserver.REASON_TERMINATE_PEER_USER;
		case GattError.GATT_CONN_TIMEOUT:
			return ConnectionObserver.REASON_TIMEOUT;
		default:
			return ConnectionObserver.REASON_UNKNOWN;
	}
}
 
Example #3
Source File: BleManagerHandler.java    From Android-BLE-Library with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void onError(final BluetoothDevice device, final String message, final int errorCode) {
	log(Log.ERROR, "Error (0x" + Integer.toHexString(errorCode) + "): "
			+ GattError.parse(errorCode));
	postCallback(c -> c.onError(device, message, errorCode));
}