tinkerforge_async/bindings/
temperature_ir_bricklet.rs

1/* ***********************************************************
2 * This file was automatically generated on 2024-02-16.      *
3 *                                                           *
4 * Rust Bindings Version 2.0.20                              *
5 *                                                           *
6 * If you have a bugfix for this file and want to commit it, *
7 * please fix the bug in the generator. You can find a link  *
8 * to the generators git repository on tinkerforge.com       *
9 *************************************************************/
10
11//! Measures contactless object temperature between -70°C and +380°C.
12//!
13//! See also the documentation [here](https://www.tinkerforge.com/en/doc/Software/Bricklets/TemperatureIR_Bricklet_Rust.html).
14#[allow(unused_imports)]
15use crate::{
16    base58::Uid, byte_converter::*, device::*, error::TinkerforgeError, ip_connection::async_io::AsyncIpConnection,
17    low_level_traits::LowLevelRead,
18};
19#[allow(unused_imports)]
20use futures_core::Stream;
21#[allow(unused_imports)]
22use tokio_stream::StreamExt;
23pub enum TemperatureIrBrickletFunction {
24    GetAmbientTemperature,
25    GetObjectTemperature,
26    SetEmissivity,
27    GetEmissivity,
28    SetAmbientTemperatureCallbackPeriod,
29    GetAmbientTemperatureCallbackPeriod,
30    SetObjectTemperatureCallbackPeriod,
31    GetObjectTemperatureCallbackPeriod,
32    SetAmbientTemperatureCallbackThreshold,
33    GetAmbientTemperatureCallbackThreshold,
34    SetObjectTemperatureCallbackThreshold,
35    GetObjectTemperatureCallbackThreshold,
36    SetDebouncePeriod,
37    GetDebouncePeriod,
38    GetIdentity,
39    CallbackAmbientTemperature,
40    CallbackObjectTemperature,
41    CallbackAmbientTemperatureReached,
42    CallbackObjectTemperatureReached,
43}
44impl From<TemperatureIrBrickletFunction> for u8 {
45    fn from(fun: TemperatureIrBrickletFunction) -> Self {
46        match fun {
47            TemperatureIrBrickletFunction::GetAmbientTemperature => 1,
48            TemperatureIrBrickletFunction::GetObjectTemperature => 2,
49            TemperatureIrBrickletFunction::SetEmissivity => 3,
50            TemperatureIrBrickletFunction::GetEmissivity => 4,
51            TemperatureIrBrickletFunction::SetAmbientTemperatureCallbackPeriod => 5,
52            TemperatureIrBrickletFunction::GetAmbientTemperatureCallbackPeriod => 6,
53            TemperatureIrBrickletFunction::SetObjectTemperatureCallbackPeriod => 7,
54            TemperatureIrBrickletFunction::GetObjectTemperatureCallbackPeriod => 8,
55            TemperatureIrBrickletFunction::SetAmbientTemperatureCallbackThreshold => 9,
56            TemperatureIrBrickletFunction::GetAmbientTemperatureCallbackThreshold => 10,
57            TemperatureIrBrickletFunction::SetObjectTemperatureCallbackThreshold => 11,
58            TemperatureIrBrickletFunction::GetObjectTemperatureCallbackThreshold => 12,
59            TemperatureIrBrickletFunction::SetDebouncePeriod => 13,
60            TemperatureIrBrickletFunction::GetDebouncePeriod => 14,
61            TemperatureIrBrickletFunction::GetIdentity => 255,
62            TemperatureIrBrickletFunction::CallbackAmbientTemperature => 15,
63            TemperatureIrBrickletFunction::CallbackObjectTemperature => 16,
64            TemperatureIrBrickletFunction::CallbackAmbientTemperatureReached => 17,
65            TemperatureIrBrickletFunction::CallbackObjectTemperatureReached => 18,
66        }
67    }
68}
69pub const TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_OFF: char = 'x';
70pub const TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_OUTSIDE: char = 'o';
71pub const TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_INSIDE: char = 'i';
72pub const TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_SMALLER: char = '<';
73pub const TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_GREATER: char = '>';
74
75#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
76pub struct AmbientTemperatureCallbackThreshold {
77    pub option: char,
78    pub min: i16,
79    pub max: i16,
80}
81impl FromByteSlice for AmbientTemperatureCallbackThreshold {
82    fn bytes_expected() -> usize {
83        5
84    }
85    fn from_le_byte_slice(bytes: &[u8]) -> AmbientTemperatureCallbackThreshold {
86        AmbientTemperatureCallbackThreshold {
87            option: <char>::from_le_byte_slice(&bytes[0..1]),
88            min: <i16>::from_le_byte_slice(&bytes[1..3]),
89            max: <i16>::from_le_byte_slice(&bytes[3..5]),
90        }
91    }
92}
93
94#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
95pub struct ObjectTemperatureCallbackThreshold {
96    pub option: char,
97    pub min: i16,
98    pub max: i16,
99}
100impl FromByteSlice for ObjectTemperatureCallbackThreshold {
101    fn bytes_expected() -> usize {
102        5
103    }
104    fn from_le_byte_slice(bytes: &[u8]) -> ObjectTemperatureCallbackThreshold {
105        ObjectTemperatureCallbackThreshold {
106            option: <char>::from_le_byte_slice(&bytes[0..1]),
107            min: <i16>::from_le_byte_slice(&bytes[1..3]),
108            max: <i16>::from_le_byte_slice(&bytes[3..5]),
109        }
110    }
111}
112
113#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
114pub struct Identity {
115    pub uid: String,
116    pub connected_uid: String,
117    pub position: char,
118    pub hardware_version: [u8; 3],
119    pub firmware_version: [u8; 3],
120    pub device_identifier: u16,
121}
122impl FromByteSlice for Identity {
123    fn bytes_expected() -> usize {
124        25
125    }
126    fn from_le_byte_slice(bytes: &[u8]) -> Identity {
127        Identity {
128            uid: <String>::from_le_byte_slice(&bytes[0..8]),
129            connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
130            position: <char>::from_le_byte_slice(&bytes[16..17]),
131            hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
132            firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
133            device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
134        }
135    }
136}
137
138/// Measures contactless object temperature between -70°C and +380°C
139#[derive(Clone)]
140pub struct TemperatureIrBricklet {
141    device: Device,
142}
143impl TemperatureIrBricklet {
144    pub const DEVICE_IDENTIFIER: u16 = 217;
145    pub const DEVICE_DISPLAY_NAME: &'static str = "Temperature IR Bricklet";
146    /// Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ip_connection` is connected.
147    pub fn new(uid: Uid, connection: AsyncIpConnection) -> TemperatureIrBricklet {
148        let mut result = TemperatureIrBricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
149        result.device.response_expected[u8::from(TemperatureIrBrickletFunction::GetAmbientTemperature) as usize] =
150            ResponseExpectedFlag::AlwaysTrue;
151        result.device.response_expected[u8::from(TemperatureIrBrickletFunction::GetObjectTemperature) as usize] =
152            ResponseExpectedFlag::AlwaysTrue;
153        result.device.response_expected[u8::from(TemperatureIrBrickletFunction::SetEmissivity) as usize] = ResponseExpectedFlag::False;
154        result.device.response_expected[u8::from(TemperatureIrBrickletFunction::GetEmissivity) as usize] = ResponseExpectedFlag::AlwaysTrue;
155        result.device.response_expected[u8::from(TemperatureIrBrickletFunction::SetAmbientTemperatureCallbackPeriod) as usize] =
156            ResponseExpectedFlag::True;
157        result.device.response_expected[u8::from(TemperatureIrBrickletFunction::GetAmbientTemperatureCallbackPeriod) as usize] =
158            ResponseExpectedFlag::AlwaysTrue;
159        result.device.response_expected[u8::from(TemperatureIrBrickletFunction::SetObjectTemperatureCallbackPeriod) as usize] =
160            ResponseExpectedFlag::True;
161        result.device.response_expected[u8::from(TemperatureIrBrickletFunction::GetObjectTemperatureCallbackPeriod) as usize] =
162            ResponseExpectedFlag::AlwaysTrue;
163        result.device.response_expected[u8::from(TemperatureIrBrickletFunction::SetAmbientTemperatureCallbackThreshold) as usize] =
164            ResponseExpectedFlag::True;
165        result.device.response_expected[u8::from(TemperatureIrBrickletFunction::GetAmbientTemperatureCallbackThreshold) as usize] =
166            ResponseExpectedFlag::AlwaysTrue;
167        result.device.response_expected[u8::from(TemperatureIrBrickletFunction::SetObjectTemperatureCallbackThreshold) as usize] =
168            ResponseExpectedFlag::True;
169        result.device.response_expected[u8::from(TemperatureIrBrickletFunction::GetObjectTemperatureCallbackThreshold) as usize] =
170            ResponseExpectedFlag::AlwaysTrue;
171        result.device.response_expected[u8::from(TemperatureIrBrickletFunction::SetDebouncePeriod) as usize] = ResponseExpectedFlag::True;
172        result.device.response_expected[u8::from(TemperatureIrBrickletFunction::GetDebouncePeriod) as usize] =
173            ResponseExpectedFlag::AlwaysTrue;
174        result.device.response_expected[u8::from(TemperatureIrBrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
175        result
176    }
177
178    /// Returns the response expected flag for the function specified by the function ID parameter.
179    /// It is true if the function is expected to send a response, false otherwise.
180    ///
181    /// For getter functions this is enabled by default and cannot be disabled, because those
182    /// functions will always send a response. For callback configuration functions it is enabled
183    /// by default too, but can be disabled by [`set_response_expected`](crate::temperature_ir_bricklet::TemperatureIrBricklet::set_response_expected).
184    /// For setter functions it is disabled by default and can be enabled.
185    ///
186    /// Enabling the response expected flag for a setter function allows to detect timeouts
187    /// and other error conditions calls of this setter as well. The device will then send a response
188    /// for this purpose. If this flag is disabled for a setter function then no response is sent
189    /// and errors are silently ignored, because they cannot be detected.
190    ///
191    /// See [`set_response_expected`](crate::temperature_ir_bricklet::TemperatureIrBricklet::set_response_expected) for the list of function ID constants available for this function.
192    pub fn get_response_expected(&mut self, fun: TemperatureIrBrickletFunction) -> Result<bool, GetResponseExpectedError> {
193        self.device.get_response_expected(u8::from(fun))
194    }
195
196    /// Changes the response expected flag of the function specified by the function ID parameter.
197    /// This flag can only be changed for setter (default value: false) and callback configuration
198    /// functions (default value: true). For getter functions it is always enabled.
199    ///
200    /// Enabling the response expected flag for a setter function allows to detect timeouts and
201    /// other error conditions calls of this setter as well. The device will then send a response
202    /// for this purpose. If this flag is disabled for a setter function then no response is sent
203    /// and errors are silently ignored, because they cannot be detected.
204    pub fn set_response_expected(
205        &mut self,
206        fun: TemperatureIrBrickletFunction,
207        response_expected: bool,
208    ) -> Result<(), SetResponseExpectedError> {
209        self.device.set_response_expected(u8::from(fun), response_expected)
210    }
211
212    /// Changes the response expected flag for all setter and callback configuration functions of this device at once.
213    pub fn set_response_expected_all(&mut self, response_expected: bool) {
214        self.device.set_response_expected_all(response_expected)
215    }
216
217    /// Returns the version of the API definition (major, minor, revision) implemented by this API bindings.
218    /// This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
219    pub fn get_api_version(&self) -> [u8; 3] {
220        self.device.api_version
221    }
222
223    /// This receiver is triggered periodically with the period that is set by
224    /// [`set_ambient_temperature_callback_period`]. The parameter is the
225    /// ambient temperature of the sensor.
226    ///
227    /// The [`get_ambient_temperature_callback_receiver`] receiver is only triggered if the ambient
228    /// temperature has changed since the last triggering.
229    ///
230    /// [`set_ambient_temperature_callback_period`]: #method.set_ambient_temperature_callback_period
231    /// [`get_ambient_temperature_callback_receiver`]: #method.get_ambient_temperature_callback_receiver
232    pub async fn get_ambient_temperature_callback_receiver(&mut self) -> impl Stream<Item = i16> {
233        self.device
234            .get_callback_receiver(u8::from(TemperatureIrBrickletFunction::CallbackAmbientTemperature))
235            .await
236            .map(|p| i16::from_le_byte_slice(p.body()))
237    }
238
239    /// This receiver is triggered periodically with the period that is set by
240    /// [`set_object_temperature_callback_period`]. The parameter is the
241    /// object temperature of the sensor.
242    ///
243    /// The [`get_object_temperature_callback_receiver`] receiver is only triggered if the object
244    /// temperature has changed since the last triggering.
245    pub async fn get_object_temperature_callback_receiver(&mut self) -> impl Stream<Item = i16> {
246        self.device
247            .get_callback_receiver(u8::from(TemperatureIrBrickletFunction::CallbackObjectTemperature))
248            .await
249            .map(|p| i16::from_le_byte_slice(p.body()))
250    }
251
252    /// This receiver is triggered when the threshold as set by
253    /// [`set_ambient_temperature_callback_threshold`] is reached.
254    /// The parameter is the ambient temperature of the sensor.
255    ///
256    /// If the threshold keeps being reached, the receiver is triggered periodically
257    /// with the period as set by [`set_debounce_period`].
258    pub async fn get_ambient_temperature_reached_callback_receiver(&mut self) -> impl Stream<Item = i16> {
259        self.device
260            .get_callback_receiver(u8::from(TemperatureIrBrickletFunction::CallbackAmbientTemperatureReached))
261            .await
262            .map(|p| i16::from_le_byte_slice(p.body()))
263    }
264
265    /// This receiver is triggered when the threshold as set by
266    /// [`set_object_temperature_callback_threshold`] is reached.
267    /// The parameter is the object temperature of the sensor.
268    ///
269    /// If the threshold keeps being reached, the receiver is triggered periodically
270    /// with the period as set by [`set_debounce_period`].
271    pub async fn get_object_temperature_reached_callback_receiver(&mut self) -> impl Stream<Item = i16> {
272        self.device
273            .get_callback_receiver(u8::from(TemperatureIrBrickletFunction::CallbackObjectTemperatureReached))
274            .await
275            .map(|p| i16::from_le_byte_slice(p.body()))
276    }
277
278    /// Returns the ambient temperature of the sensor.
279    ///
280    /// If you want to get the ambient temperature periodically, it is recommended
281    /// to use the [`get_ambient_temperature_callback_receiver`] receiver and set the period with
282    /// [`set_ambient_temperature_callback_period`].
283    pub async fn get_ambient_temperature(&mut self) -> Result<i16, TinkerforgeError> {
284        let payload = [0; 0];
285
286        #[allow(unused_variables)]
287        let result = self.device.get(u8::from(TemperatureIrBrickletFunction::GetAmbientTemperature), &payload).await?;
288        Ok(i16::from_le_byte_slice(result.body()))
289    }
290
291    /// Returns the object temperature of the sensor, i.e. the temperature
292    /// of the surface of the object the sensor is aimed at.
293    ///
294    /// The temperature of different materials is dependent on their `emissivity
295    /// <https://en.wikipedia.org/wiki/Emissivity>`__. The emissivity of the material
296    /// can be set with [`set_emissivity`].
297    ///
298    /// If you want to get the object temperature periodically, it is recommended
299    /// to use the [`get_object_temperature_callback_receiver`] receiver and set the period with
300    /// [`set_object_temperature_callback_period`].
301    pub async fn get_object_temperature(&mut self) -> Result<i16, TinkerforgeError> {
302        let payload = [0; 0];
303
304        #[allow(unused_variables)]
305        let result = self.device.get(u8::from(TemperatureIrBrickletFunction::GetObjectTemperature), &payload).await?;
306        Ok(i16::from_le_byte_slice(result.body()))
307    }
308
309    /// Sets the [emissivity](https://en.wikipedia.org/wiki/Emissivity)__ that is
310    /// used to calculate the surface temperature as returned by
311    /// :func:[Get Object Temperature`.
312    ///
313    /// The emissivity is usually given as a value between 0.0 and 1.0. A list of
314    /// emissivities of different materials can be found
315    /// `here](https://www.infrared-thermography.com/material.htm)__.
316    ///
317    /// The parameter of [`set_emissivity`] has to be given with a factor of
318    /// 65535 (16-bit). For example: An emissivity of 0.1 can be set with the
319    /// value 6553, an emissivity of 0.5 with the value 32767 and so on.
320    ///
321    /// # Note
322    ///  If you need a precise measurement for the object temperature, it is
323    ///  absolutely crucial that you also provide a precise emissivity.
324    ///
325    /// The emissivity is stored in non-volatile memory and will still be used after a restart or power cycle of the Bricklet.
326    pub async fn set_emissivity(&mut self, emissivity: u16) -> Result<(), TinkerforgeError> {
327        let mut payload = [0; 2];
328        emissivity.write_to_slice(&mut payload[0..2]);
329
330        #[allow(unused_variables)]
331        let result = self.device.set(u8::from(TemperatureIrBrickletFunction::SetEmissivity), &payload).await?;
332        Ok(())
333    }
334
335    /// Returns the emissivity as set by [`set_emissivity`].
336    pub async fn get_emissivity(&mut self) -> Result<u16, TinkerforgeError> {
337        let payload = [0; 0];
338
339        #[allow(unused_variables)]
340        let result = self.device.get(u8::from(TemperatureIrBrickletFunction::GetEmissivity), &payload).await?;
341        Ok(u16::from_le_byte_slice(result.body()))
342    }
343
344    /// Sets the period with which the [`get_ambient_temperature_callback_receiver`] receiver is
345    /// triggered periodically. A value of 0 turns the receiver off.
346    ///
347    /// The [`get_ambient_temperature_callback_receiver`] receiver is only triggered if the temperature has
348    /// changed since the last triggering.
349    pub async fn set_ambient_temperature_callback_period(&mut self, period: u32) -> Result<(), TinkerforgeError> {
350        let mut payload = [0; 4];
351        period.write_to_slice(&mut payload[0..4]);
352
353        #[allow(unused_variables)]
354        let result = self.device.set(u8::from(TemperatureIrBrickletFunction::SetAmbientTemperatureCallbackPeriod), &payload).await?;
355        Ok(())
356    }
357
358    /// Returns the period as set by [`set_ambient_temperature_callback_period`].
359    pub async fn get_ambient_temperature_callback_period(&mut self) -> Result<u32, TinkerforgeError> {
360        let payload = [0; 0];
361
362        #[allow(unused_variables)]
363        let result = self.device.get(u8::from(TemperatureIrBrickletFunction::GetAmbientTemperatureCallbackPeriod), &payload).await?;
364        Ok(u32::from_le_byte_slice(result.body()))
365    }
366
367    /// Sets the period with which the [`get_object_temperature_callback_receiver`] receiver is
368    /// triggered periodically. A value of 0 turns the receiver off.
369    ///
370    /// The [`get_object_temperature_callback_receiver`] receiver is only triggered if the temperature
371    /// has changed since the last triggering.
372    pub async fn set_object_temperature_callback_period(&mut self, period: u32) -> Result<(), TinkerforgeError> {
373        let mut payload = [0; 4];
374        period.write_to_slice(&mut payload[0..4]);
375
376        #[allow(unused_variables)]
377        let result = self.device.set(u8::from(TemperatureIrBrickletFunction::SetObjectTemperatureCallbackPeriod), &payload).await?;
378        Ok(())
379    }
380
381    /// Returns the period as set by [`set_object_temperature_callback_period`].
382    pub async fn get_object_temperature_callback_period(&mut self) -> Result<u32, TinkerforgeError> {
383        let payload = [0; 0];
384
385        #[allow(unused_variables)]
386        let result = self.device.get(u8::from(TemperatureIrBrickletFunction::GetObjectTemperatureCallbackPeriod), &payload).await?;
387        Ok(u32::from_le_byte_slice(result.body()))
388    }
389
390    /// Sets the thresholds for the [`get_ambient_temperature_reached_callback_receiver`] receiver.
391    ///
392    /// The following options are possible:
393    ///
394    ///  Option| Description
395    ///  --- | ---
396    ///  'x'|    Receiver is turned off
397    ///  'o'|    Receiver is triggered when the ambient temperature is *outside* the min and max values
398    ///  'i'|    Receiver is triggered when the ambient temperature is *inside* the min and max values
399    ///  '<'|    Receiver is triggered when the ambient temperature is smaller than the min value (max is ignored)
400    ///  '>'|    Receiver is triggered when the ambient temperature is greater than the min value (max is ignored)
401    ///
402    /// Associated constants:
403    /// * TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_OFF
404    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_OUTSIDE
405    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_INSIDE
406    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_SMALLER
407    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_GREATER
408    pub async fn set_ambient_temperature_callback_threshold(&mut self, option: char, min: i16, max: i16) -> Result<(), TinkerforgeError> {
409        let mut payload = [0; 5];
410        option.write_to_slice(&mut payload[0..1]);
411        min.write_to_slice(&mut payload[1..3]);
412        max.write_to_slice(&mut payload[3..5]);
413
414        #[allow(unused_variables)]
415        let result = self.device.set(u8::from(TemperatureIrBrickletFunction::SetAmbientTemperatureCallbackThreshold), &payload).await?;
416        Ok(())
417    }
418
419    /// Returns the threshold as set by [`set_ambient_temperature_callback_threshold`].
420    ///
421    /// Associated constants:
422    /// * TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_OFF
423    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_OUTSIDE
424    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_INSIDE
425    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_SMALLER
426    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_GREATER
427    pub async fn get_ambient_temperature_callback_threshold(&mut self) -> Result<AmbientTemperatureCallbackThreshold, TinkerforgeError> {
428        let payload = [0; 0];
429
430        #[allow(unused_variables)]
431        let result = self.device.get(u8::from(TemperatureIrBrickletFunction::GetAmbientTemperatureCallbackThreshold), &payload).await?;
432        Ok(AmbientTemperatureCallbackThreshold::from_le_byte_slice(result.body()))
433    }
434
435    /// Sets the thresholds for the [`get_object_temperature_reached_callback_receiver`] receiver.
436    ///
437    /// The following options are possible:
438    ///
439    ///  Option| Description
440    ///  --- | ---
441    ///  'x'|    Receiver is turned off
442    ///  'o'|    Receiver is triggered when the object temperature is *outside* the min and max values
443    ///  'i'|    Receiver is triggered when the object temperature is *inside* the min and max values
444    ///  '<'|    Receiver is triggered when the object temperature is smaller than the min value (max is ignored)
445    ///  '>'|    Receiver is triggered when the object temperature is greater than the min value (max is ignored)
446    ///
447    /// Associated constants:
448    /// * TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_OFF
449    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_OUTSIDE
450    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_INSIDE
451    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_SMALLER
452    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_GREATER
453    pub async fn set_object_temperature_callback_threshold(&mut self, option: char, min: i16, max: i16) -> Result<(), TinkerforgeError> {
454        let mut payload = [0; 5];
455        option.write_to_slice(&mut payload[0..1]);
456        min.write_to_slice(&mut payload[1..3]);
457        max.write_to_slice(&mut payload[3..5]);
458
459        #[allow(unused_variables)]
460        let result = self.device.set(u8::from(TemperatureIrBrickletFunction::SetObjectTemperatureCallbackThreshold), &payload).await?;
461        Ok(())
462    }
463
464    /// Returns the threshold as set by [`set_object_temperature_callback_threshold`].
465    ///
466    /// Associated constants:
467    /// * TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_OFF
468    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_OUTSIDE
469    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_INSIDE
470    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_SMALLER
471    ///	* TEMPERATURE_IR_BRICKLET_THRESHOLD_OPTION_GREATER
472    pub async fn get_object_temperature_callback_threshold(&mut self) -> Result<ObjectTemperatureCallbackThreshold, TinkerforgeError> {
473        let payload = [0; 0];
474
475        #[allow(unused_variables)]
476        let result = self.device.get(u8::from(TemperatureIrBrickletFunction::GetObjectTemperatureCallbackThreshold), &payload).await?;
477        Ok(ObjectTemperatureCallbackThreshold::from_le_byte_slice(result.body()))
478    }
479
480    /// Sets the period with which the threshold receivers
481    ///
482    /// * [`get_ambient_temperature_reached_callback_receiver`],
483    /// * [`get_object_temperature_reached_callback_receiver`]
484    ///
485    /// are triggered, if the thresholds
486    ///
487    /// * [`set_ambient_temperature_callback_threshold`],
488    /// * [`set_object_temperature_callback_threshold`]
489    ///
490    /// keep being reached.
491    pub async fn set_debounce_period(&mut self, debounce: u32) -> Result<(), TinkerforgeError> {
492        let mut payload = [0; 4];
493        debounce.write_to_slice(&mut payload[0..4]);
494
495        #[allow(unused_variables)]
496        let result = self.device.set(u8::from(TemperatureIrBrickletFunction::SetDebouncePeriod), &payload).await?;
497        Ok(())
498    }
499
500    /// Returns the debounce period as set by [`set_debounce_period`].
501    pub async fn get_debounce_period(&mut self) -> Result<u32, TinkerforgeError> {
502        let payload = [0; 0];
503
504        #[allow(unused_variables)]
505        let result = self.device.get(u8::from(TemperatureIrBrickletFunction::GetDebouncePeriod), &payload).await?;
506        Ok(u32::from_le_byte_slice(result.body()))
507    }
508
509    /// Returns the UID, the UID where the Bricklet is connected to,
510    /// the position, the hardware and firmware version as well as the
511    /// device identifier.
512    ///
513    /// The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
514    /// A Bricklet connected to an [Isolator Bricklet](isolator_bricklet) is always at
515    /// position 'z'.
516    ///
517    /// The device identifier numbers can be found [here](device_identifier).
518    /// |device_identifier_constant|
519    pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
520        let payload = [0; 0];
521
522        #[allow(unused_variables)]
523        let result = self.device.get(u8::from(TemperatureIrBrickletFunction::GetIdentity), &payload).await?;
524        Ok(Identity::from_le_byte_slice(result.body()))
525    }
526}