no.nordicsemi.android.ble.common.profile.ht.TemperatureMeasurementCallback Java Examples
The following examples show how to use
no.nordicsemi.android.ble.common.profile.ht.TemperatureMeasurementCallback.
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: HTService.java From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void onTemperatureMeasurementReceived(@NonNull final BluetoothDevice device, final float temperature, @TemperatureUnit final int unit, @Nullable final Calendar calendar, @Nullable @TemperatureType final Integer type) { temp = TemperatureMeasurementCallback.toCelsius(temperature, unit); final Intent broadcast = new Intent(BROADCAST_HTS_MEASUREMENT); broadcast.putExtra(EXTRA_DEVICE, getBluetoothDevice()); broadcast.putExtra(EXTRA_TEMPERATURE, temp); // ignore the rest LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast); if (!bound) { // Here we may update the notification to display the current temperature. // TODO modify the notification here } }
Example #2
Source File: TemperatureMeasurementDataCallbackTest.java From Android-BLE-Common-Library with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void onTemperatureMeasurementReceived() { final ProfileReadResponse response = new TemperatureMeasurementDataCallback() { @Override public void onTemperatureMeasurementReceived(@NonNull final BluetoothDevice device, final float temperature, final int unit, @Nullable final Calendar calendar, @Nullable final Integer type) { called = true; assertEquals("Temperature", 37.60f, temperature, 0.001f); assertEquals("Unit", TemperatureMeasurementCallback.UNIT_C, unit); assertNotNull("Calendar present", calendar); assertTrue("Year set", calendar.isSet(Calendar.YEAR)); assertEquals("Year", calendar.get(Calendar.YEAR), 2012); assertTrue("Month set", calendar.isSet(Calendar.MONTH)); assertEquals("Month", calendar.get(Calendar.MONTH), Calendar.DECEMBER); assertTrue("Day set", calendar.isSet(Calendar.DATE)); assertEquals("Day", 5, calendar.get(Calendar.DATE)); assertEquals("Hour", 11, calendar.get(Calendar.HOUR_OF_DAY)); assertEquals("Minute", 50, calendar.get(Calendar.MINUTE)); assertEquals("Seconds", 27, calendar.get(Calendar.SECOND)); assertEquals("Milliseconds", 0, calendar.get(Calendar.MILLISECOND)); assertNotNull("Type present", type); assertEquals(TemperatureMeasurementCallback.TYPE_FINGER, type.intValue()); } }; final Data data = new Data(new byte[] { 0x06, (byte) 0xB0, 0x0E, 0x00, (byte) 0xFE, (byte) 0xDC, 0x07, 0x0C, 0x05, 0x0B, 0x32, 0x1B, 0x04 }); called = false; response.onDataReceived(null, data); assertTrue(called); assertTrue(response.isValid()); }
Example #3
Source File: TemperatureMeasurementDataCallbackTest.java From Android-BLE-Library with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void onTemperatureMeasurementReceived() { final ProfileReadResponse response = new TemperatureMeasurementDataCallback() { @Override public void onTemperatureMeasurementReceived(@NonNull final BluetoothDevice device, final float temperature, final int unit, @Nullable final Calendar calendar, @Nullable final Integer type) { called = true; assertEquals("Temperature", 37.60f, temperature, 0.001f); assertEquals("Unit", TemperatureMeasurementCallback.UNIT_C, unit); assertNotNull("Calendar present", calendar); assertTrue("Year set", calendar.isSet(Calendar.YEAR)); assertEquals("Year", calendar.get(Calendar.YEAR), 2012); assertTrue("Month set", calendar.isSet(Calendar.MONTH)); assertEquals("Month", calendar.get(Calendar.MONTH), Calendar.DECEMBER); assertTrue("Day set", calendar.isSet(Calendar.DATE)); assertEquals("Day", 5, calendar.get(Calendar.DATE)); assertEquals("Hour", 11, calendar.get(Calendar.HOUR_OF_DAY)); assertEquals("Minute", 50, calendar.get(Calendar.MINUTE)); assertEquals("Seconds", 27, calendar.get(Calendar.SECOND)); assertEquals("Milliseconds", 0, calendar.get(Calendar.MILLISECOND)); assertNotNull("Type present", type); assertEquals(TemperatureMeasurementCallback.TYPE_FINGER, type.intValue()); } }; final Data data = new Data(new byte[] { 0x06, (byte) 0xB0, 0x0E, 0x00, (byte) 0xFE, (byte) 0xDC, 0x07, 0x0C, 0x05, 0x0B, 0x32, 0x1B, 0x04 }); called = false; response.onDataReceived(null, data); assertTrue(called); assertTrue(response.isValid()); }
Example #4
Source File: TemperatureMeasurementResponse.java From Android-BLE-Common-Library with BSD 3-Clause "New" or "Revised" License | 4 votes |
public float getTemperatureCelsius() { return TemperatureMeasurementCallback.toCelsius(temperature, unit); }
Example #5
Source File: TemperatureMeasurementResponse.java From Android-BLE-Common-Library with BSD 3-Clause "New" or "Revised" License | 4 votes |
public float getTemperatureFahrenheit() { return TemperatureMeasurementCallback.toFahrenheit(temperature, unit); }
Example #6
Source File: TemperatureMeasurementResponse.java From Android-BLE-Library with BSD 3-Clause "New" or "Revised" License | 4 votes |
public float getTemperatureCelsius() { return TemperatureMeasurementCallback.toCelsius(temperature, unit); }
Example #7
Source File: TemperatureMeasurementResponse.java From Android-BLE-Library with BSD 3-Clause "New" or "Revised" License | 4 votes |
public float getTemperatureFahrenheit() { return TemperatureMeasurementCallback.toFahrenheit(temperature, unit); }