当前位置: 首页>>代码示例>>Java>>正文


Java AlertLevelParser类代码示例

本文整理汇总了Java中no.nordicsemi.android.nrftoolbox.parser.AlertLevelParser的典型用法代码示例。如果您正苦于以下问题:Java AlertLevelParser类的具体用法?Java AlertLevelParser怎么用?Java AlertLevelParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AlertLevelParser类属于no.nordicsemi.android.nrftoolbox.parser包,在下文中一共展示了AlertLevelParser类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCharacteristicWriteRequest

import no.nordicsemi.android.nrftoolbox.parser.AlertLevelParser; //导入依赖的package包/类
@Override
public void onCharacteristicWriteRequest(final BluetoothDevice device, final int requestId, final BluetoothGattCharacteristic characteristic, final boolean preparedWrite,
										 final boolean responseNeeded, final int offset, final byte[] value) {
	Logger.i(mLogSession, "[Server] Write request to characteristic " + characteristic.getUuid() + " (requestId = " + requestId + ", value = " + ParserUtils.parse(value) + ", offset = " + offset + ")");
	characteristic.setValue(value);

	if (value != null && value.length == 1) { // small validation
		if (value[0] != NO_ALERT[0]) {
			Logger.a(mLogSession, "[Server] Immediate alarm request received: " + AlertLevelParser.parse(characteristic));
			mCallbacks.onAlarmTriggered();
		} else {
			Logger.a(mLogSession, "[Server] Immediate alarm request received: OFF");
			mCallbacks.onAlarmStopped();
		}
	}
	if (responseNeeded) {
		Logger.v(mLogSession, "[Server] Sending response: SUCCESS");
		Logger.d(mLogSession, "[Server] sendResponse(GATT_SUCCESS)");
		mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, null);
	}
}
 
开发者ID:frostmournex,项目名称:nRFToolbox,代码行数:22,代码来源:ProximityManager.java

示例2: onCharacteristicWriteRequest

import no.nordicsemi.android.nrftoolbox.parser.AlertLevelParser; //导入依赖的package包/类
@Override
public void onCharacteristicWriteRequest(final BluetoothDevice device, final int requestId, final BluetoothGattCharacteristic characteristic, final boolean preparedWrite,
										 final boolean responseNeeded, final int offset, final byte[] value) {
	Logger.d(mLogSession, "[Server callback] Write request to characteristic " + characteristic.getUuid()
			+ " (requestId=" + requestId + ", prepareWrite=" + preparedWrite + ", responseNeeded=" + responseNeeded + ", offset=" + offset + ", value=" + ParserUtils.parse(value) + ")");
	final String writeType = !responseNeeded ? "WRITE NO RESPONSE" : "WRITE COMMAND";
	Logger.i(mLogSession, "[Server] " + writeType + " request for characteristic " + characteristic.getUuid() + " received, value: " + ParserUtils.parse(value));

	if (offset == 0) {
		characteristic.setValue(value);
	} else {
		final byte[] currentValue = characteristic.getValue();
		final byte[] newValue = new byte[currentValue.length + value.length];
		System.arraycopy(currentValue, 0, newValue, 0, currentValue.length);
		System.arraycopy(value, 0, newValue, offset, value.length);
		characteristic.setValue(newValue);
	}

	if (!preparedWrite && value != null && value.length == 1) { // small validation
		if (value[0] != NO_ALERT[0]) {
			Logger.a(mLogSession, "[Server] Immediate alarm request received: " + AlertLevelParser.parse(characteristic));
			mCallbacks.onAlarmTriggered();
		} else {
			Logger.a(mLogSession, "[Server] Immediate alarm request received: OFF");
			mCallbacks.onAlarmStopped();
		}
	}

	Logger.d(mLogSession, "server.sendResponse(GATT_SUCCESS, offset=" + offset + ", value=" + ParserUtils.parse(value) + ")");
	mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, null);
	Logger.v(mLogSession, "[Server] Response sent");
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:33,代码来源:ProximityManager.java

示例3: onCharacteristicWriteRequest

import no.nordicsemi.android.nrftoolbox.parser.AlertLevelParser; //导入依赖的package包/类
@Override
public void onCharacteristicWriteRequest(final BluetoothDevice device, final int requestId, final BluetoothGattCharacteristic characteristic, final boolean preparedWrite,
										 final boolean responseNeeded, final int offset, final byte[] value) {
	mLogger.log(device, LogContract.Log.Level.DEBUG, "[Server callback] Write request to characteristic " + characteristic.getUuid()
			+ " (requestId=" + requestId + ", prepareWrite=" + preparedWrite + ", responseNeeded=" + responseNeeded + ", offset=" + offset + ", value=" + ParserUtils.parseDebug(value) + ")");
	final String writeType = !responseNeeded ? "WRITE NO RESPONSE" : "WRITE COMMAND";
	mLogger.log(device, LogContract.Log.Level.INFO, "[Server] " + writeType + " request for characteristic " + characteristic.getUuid() + " received, value: " + ParserUtils.parse(value));

	if (offset == 0) {
		characteristic.setValue(value);
	} else {
		final byte[] currentValue = characteristic.getValue();
		final byte[] newValue = new byte[currentValue.length + value.length];
		System.arraycopy(currentValue, 0, newValue, 0, currentValue.length);
		System.arraycopy(value, 0, newValue, offset, value.length);
		characteristic.setValue(newValue);
	}

	if (!preparedWrite && value != null && value.length == 1) { // small validation
		if (value[0] != NO_ALERT[0]) {
			mLogger.log(device, LogContract.Log.Level.APPLICATION, "[Server] Immediate alarm request received: " + AlertLevelParser.parse(characteristic));
			mCallbacks.onAlarmTriggered(device);
		} else {
			mLogger.log(device, LogContract.Log.Level.APPLICATION, "[Server] Immediate alarm request received: OFF");
			mCallbacks.onAlarmStopped(device);
		}
	}

	mLogger.log(device, LogContract.Log.Level.DEBUG, "server.sendResponse(GATT_SUCCESS, offset=" + offset + ", value=" + ParserUtils.parseDebug(value) + ")");
	mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, null);
	mLogger.log(device, LogContract.Log.Level.VERBOSE, "[Server] Response sent");
}
 
开发者ID:NordicSemiconductor,项目名称:Android-nRF-Toolbox,代码行数:33,代码来源:ProximityServerManager.java

示例4: onCharacteristicWrite

import no.nordicsemi.android.nrftoolbox.parser.AlertLevelParser; //导入依赖的package包/类
@Override
protected void onCharacteristicWrite(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
	Logger.a(mLogSession, "\"" + AlertLevelParser.parse(characteristic) + "\" sent");
}
 
开发者ID:NordicSemiconductor,项目名称:Android-nRF-Toolbox,代码行数:5,代码来源:ProximityManager.java


注:本文中的no.nordicsemi.android.nrftoolbox.parser.AlertLevelParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。