no.nordicsemi.android.ble.common.data.alert.AlertLevelData Java Examples
The following examples show how to use
no.nordicsemi.android.ble.common.data.alert.AlertLevelData.
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 |
@Override protected void initialize() { super.initialize(); // This callback will be called whenever local Alert Level char is written // by a connected proximity tag. setWriteCallback(localAlertLevelCharacteristic) .with(new AlertLevelDataCallback() { @Override public void onAlertLevelChanged(@NonNull final BluetoothDevice device, final int level) { mCallbacks.onLocalAlarmSwitched(device, level != ALERT_NONE); } }); // After connection, set the Link Loss behaviour on the tag. writeCharacteristic(linkLossCharacteristic, AlertLevelData.highAlert()) .done(device -> log(Log.INFO, "Link loss alert level set")) .fail((device, status) -> log(Log.WARN, "Failed to set link loss level: " + status)) .enqueue(); }
Example #2
Source File: ProximityManager.java From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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 #3
Source File: ProximityServerManager.java From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License | 6 votes |
@NonNull @Override protected List<BluetoothGattService> initializeServer() { final List<BluetoothGattService> services = new ArrayList<>(); services.add( service(ProximityManager.IMMEDIATE_ALERT_SERVICE_UUID, characteristic(ProximityManager.ALERT_LEVEL_CHARACTERISTIC_UUID, BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE, BluetoothGattCharacteristic.PERMISSION_WRITE)) ); services.add( service(ProximityManager.LINK_LOSS_SERVICE_UUID, characteristic(ProximityManager.ALERT_LEVEL_CHARACTERISTIC_UUID, BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_WRITE | BluetoothGattCharacteristic.PERMISSION_READ, AlertLevelData.highAlert())) ); return services; }