tinkerforge_async/bindings/
current25_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 AC/DC current between -25A and +25A.
12//!
13//! See also the documentation [here](https://www.tinkerforge.com/en/doc/Software/Bricklets/Current25_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 Current25BrickletFunction {
24    GetCurrent,
25    Calibrate,
26    IsOverCurrent,
27    GetAnalogValue,
28    SetCurrentCallbackPeriod,
29    GetCurrentCallbackPeriod,
30    SetAnalogValueCallbackPeriod,
31    GetAnalogValueCallbackPeriod,
32    SetCurrentCallbackThreshold,
33    GetCurrentCallbackThreshold,
34    SetAnalogValueCallbackThreshold,
35    GetAnalogValueCallbackThreshold,
36    SetDebouncePeriod,
37    GetDebouncePeriod,
38    GetIdentity,
39    CallbackCurrent,
40    CallbackAnalogValue,
41    CallbackCurrentReached,
42    CallbackAnalogValueReached,
43    CallbackOverCurrent,
44}
45impl From<Current25BrickletFunction> for u8 {
46    fn from(fun: Current25BrickletFunction) -> Self {
47        match fun {
48            Current25BrickletFunction::GetCurrent => 1,
49            Current25BrickletFunction::Calibrate => 2,
50            Current25BrickletFunction::IsOverCurrent => 3,
51            Current25BrickletFunction::GetAnalogValue => 4,
52            Current25BrickletFunction::SetCurrentCallbackPeriod => 5,
53            Current25BrickletFunction::GetCurrentCallbackPeriod => 6,
54            Current25BrickletFunction::SetAnalogValueCallbackPeriod => 7,
55            Current25BrickletFunction::GetAnalogValueCallbackPeriod => 8,
56            Current25BrickletFunction::SetCurrentCallbackThreshold => 9,
57            Current25BrickletFunction::GetCurrentCallbackThreshold => 10,
58            Current25BrickletFunction::SetAnalogValueCallbackThreshold => 11,
59            Current25BrickletFunction::GetAnalogValueCallbackThreshold => 12,
60            Current25BrickletFunction::SetDebouncePeriod => 13,
61            Current25BrickletFunction::GetDebouncePeriod => 14,
62            Current25BrickletFunction::GetIdentity => 255,
63            Current25BrickletFunction::CallbackCurrent => 15,
64            Current25BrickletFunction::CallbackAnalogValue => 16,
65            Current25BrickletFunction::CallbackCurrentReached => 17,
66            Current25BrickletFunction::CallbackAnalogValueReached => 18,
67            Current25BrickletFunction::CallbackOverCurrent => 19,
68        }
69    }
70}
71pub const CURRENT25_BRICKLET_THRESHOLD_OPTION_OFF: char = 'x';
72pub const CURRENT25_BRICKLET_THRESHOLD_OPTION_OUTSIDE: char = 'o';
73pub const CURRENT25_BRICKLET_THRESHOLD_OPTION_INSIDE: char = 'i';
74pub const CURRENT25_BRICKLET_THRESHOLD_OPTION_SMALLER: char = '<';
75pub const CURRENT25_BRICKLET_THRESHOLD_OPTION_GREATER: char = '>';
76
77#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
78pub struct CurrentCallbackThreshold {
79    pub option: char,
80    pub min: i16,
81    pub max: i16,
82}
83impl FromByteSlice for CurrentCallbackThreshold {
84    fn bytes_expected() -> usize {
85        5
86    }
87    fn from_le_byte_slice(bytes: &[u8]) -> CurrentCallbackThreshold {
88        CurrentCallbackThreshold {
89            option: <char>::from_le_byte_slice(&bytes[0..1]),
90            min: <i16>::from_le_byte_slice(&bytes[1..3]),
91            max: <i16>::from_le_byte_slice(&bytes[3..5]),
92        }
93    }
94}
95
96#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
97pub struct AnalogValueCallbackThreshold {
98    pub option: char,
99    pub min: u16,
100    pub max: u16,
101}
102impl FromByteSlice for AnalogValueCallbackThreshold {
103    fn bytes_expected() -> usize {
104        5
105    }
106    fn from_le_byte_slice(bytes: &[u8]) -> AnalogValueCallbackThreshold {
107        AnalogValueCallbackThreshold {
108            option: <char>::from_le_byte_slice(&bytes[0..1]),
109            min: <u16>::from_le_byte_slice(&bytes[1..3]),
110            max: <u16>::from_le_byte_slice(&bytes[3..5]),
111        }
112    }
113}
114
115#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
116pub struct Identity {
117    pub uid: String,
118    pub connected_uid: String,
119    pub position: char,
120    pub hardware_version: [u8; 3],
121    pub firmware_version: [u8; 3],
122    pub device_identifier: u16,
123}
124impl FromByteSlice for Identity {
125    fn bytes_expected() -> usize {
126        25
127    }
128    fn from_le_byte_slice(bytes: &[u8]) -> Identity {
129        Identity {
130            uid: <String>::from_le_byte_slice(&bytes[0..8]),
131            connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
132            position: <char>::from_le_byte_slice(&bytes[16..17]),
133            hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
134            firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
135            device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
136        }
137    }
138}
139
140/// Measures AC/DC current between -25A and +25A
141#[derive(Clone)]
142pub struct Current25Bricklet {
143    device: Device,
144}
145impl Current25Bricklet {
146    pub const DEVICE_IDENTIFIER: u16 = 24;
147    pub const DEVICE_DISPLAY_NAME: &'static str = "Current25 Bricklet";
148    /// Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ip_connection` is connected.
149    pub fn new(uid: Uid, connection: AsyncIpConnection) -> Current25Bricklet {
150        let mut result = Current25Bricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
151        result.device.response_expected[u8::from(Current25BrickletFunction::GetCurrent) as usize] = ResponseExpectedFlag::AlwaysTrue;
152        result.device.response_expected[u8::from(Current25BrickletFunction::Calibrate) as usize] = ResponseExpectedFlag::False;
153        result.device.response_expected[u8::from(Current25BrickletFunction::IsOverCurrent) as usize] = ResponseExpectedFlag::AlwaysTrue;
154        result.device.response_expected[u8::from(Current25BrickletFunction::GetAnalogValue) as usize] = ResponseExpectedFlag::AlwaysTrue;
155        result.device.response_expected[u8::from(Current25BrickletFunction::SetCurrentCallbackPeriod) as usize] =
156            ResponseExpectedFlag::True;
157        result.device.response_expected[u8::from(Current25BrickletFunction::GetCurrentCallbackPeriod) as usize] =
158            ResponseExpectedFlag::AlwaysTrue;
159        result.device.response_expected[u8::from(Current25BrickletFunction::SetAnalogValueCallbackPeriod) as usize] =
160            ResponseExpectedFlag::True;
161        result.device.response_expected[u8::from(Current25BrickletFunction::GetAnalogValueCallbackPeriod) as usize] =
162            ResponseExpectedFlag::AlwaysTrue;
163        result.device.response_expected[u8::from(Current25BrickletFunction::SetCurrentCallbackThreshold) as usize] =
164            ResponseExpectedFlag::True;
165        result.device.response_expected[u8::from(Current25BrickletFunction::GetCurrentCallbackThreshold) as usize] =
166            ResponseExpectedFlag::AlwaysTrue;
167        result.device.response_expected[u8::from(Current25BrickletFunction::SetAnalogValueCallbackThreshold) as usize] =
168            ResponseExpectedFlag::True;
169        result.device.response_expected[u8::from(Current25BrickletFunction::GetAnalogValueCallbackThreshold) as usize] =
170            ResponseExpectedFlag::AlwaysTrue;
171        result.device.response_expected[u8::from(Current25BrickletFunction::SetDebouncePeriod) as usize] = ResponseExpectedFlag::True;
172        result.device.response_expected[u8::from(Current25BrickletFunction::GetDebouncePeriod) as usize] = ResponseExpectedFlag::AlwaysTrue;
173        result.device.response_expected[u8::from(Current25BrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
174        result
175    }
176
177    /// Returns the response expected flag for the function specified by the function ID parameter.
178    /// It is true if the function is expected to send a response, false otherwise.
179    ///
180    /// For getter functions this is enabled by default and cannot be disabled, because those
181    /// functions will always send a response. For callback configuration functions it is enabled
182    /// by default too, but can be disabled by [`set_response_expected`](crate::current25_bricklet::Current25Bricklet::set_response_expected).
183    /// For setter functions it is disabled by default and can be enabled.
184    ///
185    /// Enabling the response expected flag for a setter function allows to detect timeouts
186    /// and other error conditions calls of this setter as well. The device will then send a response
187    /// for this purpose. If this flag is disabled for a setter function then no response is sent
188    /// and errors are silently ignored, because they cannot be detected.
189    ///
190    /// See [`set_response_expected`](crate::current25_bricklet::Current25Bricklet::set_response_expected) for the list of function ID constants available for this function.
191    pub fn get_response_expected(&mut self, fun: Current25BrickletFunction) -> Result<bool, GetResponseExpectedError> {
192        self.device.get_response_expected(u8::from(fun))
193    }
194
195    /// Changes the response expected flag of the function specified by the function ID parameter.
196    /// This flag can only be changed for setter (default value: false) and callback configuration
197    /// functions (default value: true). For getter functions it is always enabled.
198    ///
199    /// Enabling the response expected flag for a setter function allows to detect timeouts and
200    /// other error conditions calls of this setter as well. The device will then send a response
201    /// for this purpose. If this flag is disabled for a setter function then no response is sent
202    /// and errors are silently ignored, because they cannot be detected.
203    pub fn set_response_expected(
204        &mut self,
205        fun: Current25BrickletFunction,
206        response_expected: bool,
207    ) -> Result<(), SetResponseExpectedError> {
208        self.device.set_response_expected(u8::from(fun), response_expected)
209    }
210
211    /// Changes the response expected flag for all setter and callback configuration functions of this device at once.
212    pub fn set_response_expected_all(&mut self, response_expected: bool) {
213        self.device.set_response_expected_all(response_expected)
214    }
215
216    /// Returns the version of the API definition (major, minor, revision) implemented by this API bindings.
217    /// This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
218    pub fn get_api_version(&self) -> [u8; 3] {
219        self.device.api_version
220    }
221
222    /// This receiver is triggered periodically with the period that is set by
223    /// [`set_current_callback_period`]. The parameter is the current of the
224    /// sensor.
225    ///
226    /// The [`get_current_callback_receiver`] receiver is only triggered if the current has changed since the
227    /// last triggering.
228    ///
229    /// [`set_current_callback_period`]: #method.set_current_callback_period
230    /// [`get_current_callback_receiver`]: #method.get_current_callback_receiver
231    pub async fn get_current_callback_receiver(&mut self) -> impl Stream<Item = i16> {
232        self.device
233            .get_callback_receiver(u8::from(Current25BrickletFunction::CallbackCurrent))
234            .await
235            .map(|p| i16::from_le_byte_slice(p.body()))
236    }
237
238    /// This receiver is triggered periodically with the period that is set by
239    /// [`set_analog_value_callback_period`]. The parameter is the analog value of the
240    /// sensor.
241    ///
242    /// The [`get_analog_value_callback_receiver`] receiver is only triggered if the current has changed since the
243    /// last triggering.
244    pub async fn get_analog_value_callback_receiver(&mut self) -> impl Stream<Item = u16> {
245        self.device
246            .get_callback_receiver(u8::from(Current25BrickletFunction::CallbackAnalogValue))
247            .await
248            .map(|p| u16::from_le_byte_slice(p.body()))
249    }
250
251    /// This receiver is triggered when the threshold as set by
252    /// [`set_current_callback_threshold`] is reached.
253    /// The parameter is the current of the sensor.
254    ///
255    /// If the threshold keeps being reached, the receiver is triggered periodically
256    /// with the period as set by [`set_debounce_period`].
257    pub async fn get_current_reached_callback_receiver(&mut self) -> impl Stream<Item = i16> {
258        self.device
259            .get_callback_receiver(u8::from(Current25BrickletFunction::CallbackCurrentReached))
260            .await
261            .map(|p| i16::from_le_byte_slice(p.body()))
262    }
263
264    /// This receiver is triggered when the threshold as set by
265    /// [`set_analog_value_callback_threshold`] is reached.
266    /// The parameter is the analog value of the sensor.
267    ///
268    /// If the threshold keeps being reached, the receiver is triggered periodically
269    /// with the period as set by [`set_debounce_period`].
270    pub async fn get_analog_value_reached_callback_receiver(&mut self) -> impl Stream<Item = u16> {
271        self.device
272            .get_callback_receiver(u8::from(Current25BrickletFunction::CallbackAnalogValueReached))
273            .await
274            .map(|p| u16::from_le_byte_slice(p.body()))
275    }
276
277    /// This receiver is triggered when an over current is measured
278    /// (see [`is_over_current`]).
279    pub async fn get_over_current_callback_receiver(&mut self) -> impl Stream<Item = ()> {
280        self.device.get_callback_receiver(u8::from(Current25BrickletFunction::CallbackOverCurrent)).await.map(|_p| ())
281    }
282
283    /// Returns the current of the sensor.
284    ///
285    /// If you want to get the current periodically, it is recommended to use the
286    /// [`get_current_callback_receiver`] receiver and set the period with
287    /// [`set_current_callback_period`].
288    pub async fn get_current(&mut self) -> Result<i16, TinkerforgeError> {
289        let payload = [0; 0];
290
291        #[allow(unused_variables)]
292        let result = self.device.get(u8::from(Current25BrickletFunction::GetCurrent), &payload).await?;
293        Ok(i16::from_le_byte_slice(result.body()))
294    }
295
296    /// Calibrates the 0 value of the sensor. You have to call this function
297    /// when there is no current present.
298    ///
299    /// The zero point of the current sensor
300    /// is depending on the exact properties of the analog-to-digital converter,
301    /// the length of the Bricklet cable and the temperature. Thus, if you change
302    /// the Brick or the environment in which the Bricklet is used, you might
303    /// have to recalibrate.
304    ///
305    /// The resulting calibration will be saved on the EEPROM of the Current
306    /// Bricklet.
307    pub async fn calibrate(&mut self) -> Result<(), TinkerforgeError> {
308        let payload = [0; 0];
309
310        #[allow(unused_variables)]
311        let result = self.device.set(u8::from(Current25BrickletFunction::Calibrate), &payload).await?;
312        Ok(())
313    }
314
315    /// Returns *true* if more than 25A were measured.
316    ///
317    /// # Note
318    ///  To reset this value you have to power cycle the Bricklet.
319    pub async fn is_over_current(&mut self) -> Result<bool, TinkerforgeError> {
320        let payload = [0; 0];
321
322        #[allow(unused_variables)]
323        let result = self.device.get(u8::from(Current25BrickletFunction::IsOverCurrent), &payload).await?;
324        Ok(bool::from_le_byte_slice(result.body()))
325    }
326
327    /// Returns the value as read by a 12-bit analog-to-digital converter.
328    ///
329    /// # Note
330    ///  The value returned by [`get_current`] is averaged over several samples
331    ///  to yield less noise, while [`get_analog_value`] gives back raw
332    ///  unfiltered analog values. The only reason to use [`get_analog_value`] is,
333    ///  if you need the full resolution of the analog-to-digital converter.
334    ///
335    /// If you want the analog value periodically, it is recommended to use the
336    /// [`get_analog_value_callback_receiver`] receiver and set the period with
337    /// [`set_analog_value_callback_period`].
338    pub async fn get_analog_value(&mut self) -> Result<u16, TinkerforgeError> {
339        let payload = [0; 0];
340
341        #[allow(unused_variables)]
342        let result = self.device.get(u8::from(Current25BrickletFunction::GetAnalogValue), &payload).await?;
343        Ok(u16::from_le_byte_slice(result.body()))
344    }
345
346    /// Sets the period with which the [`get_current_callback_receiver`] receiver is triggered
347    /// periodically. A value of 0 turns the receiver off.
348    ///
349    /// The [`get_current_callback_receiver`] receiver is only triggered if the current has changed since
350    /// the last triggering.
351    pub async fn set_current_callback_period(&mut self, period: u32) -> Result<(), TinkerforgeError> {
352        let mut payload = [0; 4];
353        period.write_to_slice(&mut payload[0..4]);
354
355        #[allow(unused_variables)]
356        let result = self.device.set(u8::from(Current25BrickletFunction::SetCurrentCallbackPeriod), &payload).await?;
357        Ok(())
358    }
359
360    /// Returns the period as set by [`set_current_callback_period`].
361    pub async fn get_current_callback_period(&mut self) -> Result<u32, TinkerforgeError> {
362        let payload = [0; 0];
363
364        #[allow(unused_variables)]
365        let result = self.device.get(u8::from(Current25BrickletFunction::GetCurrentCallbackPeriod), &payload).await?;
366        Ok(u32::from_le_byte_slice(result.body()))
367    }
368
369    /// Sets the period with which the [`get_analog_value_callback_receiver`] receiver is triggered
370    /// periodically. A value of 0 turns the receiver off.
371    ///
372    /// The [`get_analog_value_callback_receiver`] receiver is only triggered if the analog value has
373    /// changed since the last triggering.
374    pub async fn set_analog_value_callback_period(&mut self, period: u32) -> Result<(), TinkerforgeError> {
375        let mut payload = [0; 4];
376        period.write_to_slice(&mut payload[0..4]);
377
378        #[allow(unused_variables)]
379        let result = self.device.set(u8::from(Current25BrickletFunction::SetAnalogValueCallbackPeriod), &payload).await?;
380        Ok(())
381    }
382
383    /// Returns the period as set by [`set_analog_value_callback_period`].
384    pub async fn get_analog_value_callback_period(&mut self) -> Result<u32, TinkerforgeError> {
385        let payload = [0; 0];
386
387        #[allow(unused_variables)]
388        let result = self.device.get(u8::from(Current25BrickletFunction::GetAnalogValueCallbackPeriod), &payload).await?;
389        Ok(u32::from_le_byte_slice(result.body()))
390    }
391
392    /// Sets the thresholds for the [`get_current_reached_callback_receiver`] receiver.
393    ///
394    /// The following options are possible:
395    ///
396    ///  Option| Description
397    ///  --- | ---
398    ///  'x'|    Receiver is turned off
399    ///  'o'|    Receiver is triggered when the current is *outside* the min and max values
400    ///  'i'|    Receiver is triggered when the current is *inside* the min and max values
401    ///  '<'|    Receiver is triggered when the current is smaller than the min value (max is ignored)
402    ///  '>'|    Receiver is triggered when the current is greater than the min value (max is ignored)
403    ///
404    /// Associated constants:
405    /// * CURRENT25_BRICKLET_THRESHOLD_OPTION_OFF
406    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_OUTSIDE
407    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_INSIDE
408    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_SMALLER
409    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_GREATER
410    pub async fn set_current_callback_threshold(&mut self, option: char, min: i16, max: i16) -> Result<(), TinkerforgeError> {
411        let mut payload = [0; 5];
412        option.write_to_slice(&mut payload[0..1]);
413        min.write_to_slice(&mut payload[1..3]);
414        max.write_to_slice(&mut payload[3..5]);
415
416        #[allow(unused_variables)]
417        let result = self.device.set(u8::from(Current25BrickletFunction::SetCurrentCallbackThreshold), &payload).await?;
418        Ok(())
419    }
420
421    /// Returns the threshold as set by [`set_current_callback_threshold`].
422    ///
423    /// Associated constants:
424    /// * CURRENT25_BRICKLET_THRESHOLD_OPTION_OFF
425    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_OUTSIDE
426    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_INSIDE
427    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_SMALLER
428    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_GREATER
429    pub async fn get_current_callback_threshold(&mut self) -> Result<CurrentCallbackThreshold, TinkerforgeError> {
430        let payload = [0; 0];
431
432        #[allow(unused_variables)]
433        let result = self.device.get(u8::from(Current25BrickletFunction::GetCurrentCallbackThreshold), &payload).await?;
434        Ok(CurrentCallbackThreshold::from_le_byte_slice(result.body()))
435    }
436
437    /// Sets the thresholds for the [`get_analog_value_reached_callback_receiver`] receiver.
438    ///
439    /// The following options are possible:
440    ///
441    ///  Option| Description
442    ///  --- | ---
443    ///  'x'|    Receiver is turned off
444    ///  'o'|    Receiver is triggered when the analog value is *outside* the min and max values
445    ///  'i'|    Receiver is triggered when the analog value is *inside* the min and max values
446    ///  '<'|    Receiver is triggered when the analog value is smaller than the min value (max is ignored)
447    ///  '>'|    Receiver is triggered when the analog value is greater than the min value (max is ignored)
448    ///
449    /// Associated constants:
450    /// * CURRENT25_BRICKLET_THRESHOLD_OPTION_OFF
451    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_OUTSIDE
452    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_INSIDE
453    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_SMALLER
454    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_GREATER
455    pub async fn set_analog_value_callback_threshold(&mut self, option: char, min: u16, max: u16) -> Result<(), TinkerforgeError> {
456        let mut payload = [0; 5];
457        option.write_to_slice(&mut payload[0..1]);
458        min.write_to_slice(&mut payload[1..3]);
459        max.write_to_slice(&mut payload[3..5]);
460
461        #[allow(unused_variables)]
462        let result = self.device.set(u8::from(Current25BrickletFunction::SetAnalogValueCallbackThreshold), &payload).await?;
463        Ok(())
464    }
465
466    /// Returns the threshold as set by [`set_analog_value_callback_threshold`].
467    ///
468    /// Associated constants:
469    /// * CURRENT25_BRICKLET_THRESHOLD_OPTION_OFF
470    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_OUTSIDE
471    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_INSIDE
472    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_SMALLER
473    ///	* CURRENT25_BRICKLET_THRESHOLD_OPTION_GREATER
474    pub async fn get_analog_value_callback_threshold(&mut self) -> Result<AnalogValueCallbackThreshold, TinkerforgeError> {
475        let payload = [0; 0];
476
477        #[allow(unused_variables)]
478        let result = self.device.get(u8::from(Current25BrickletFunction::GetAnalogValueCallbackThreshold), &payload).await?;
479        Ok(AnalogValueCallbackThreshold::from_le_byte_slice(result.body()))
480    }
481
482    /// Sets the period with which the threshold receivers
483    ///
484    /// * [`get_current_reached_callback_receiver`],
485    /// * [`get_analog_value_reached_callback_receiver`]
486    ///
487    /// are triggered, if the thresholds
488    ///
489    /// * [`set_current_callback_threshold`],
490    /// * [`set_analog_value_callback_threshold`]
491    ///
492    /// keep being reached.
493    pub async fn set_debounce_period(&mut self, debounce: u32) -> Result<(), TinkerforgeError> {
494        let mut payload = [0; 4];
495        debounce.write_to_slice(&mut payload[0..4]);
496
497        #[allow(unused_variables)]
498        let result = self.device.set(u8::from(Current25BrickletFunction::SetDebouncePeriod), &payload).await?;
499        Ok(())
500    }
501
502    /// Returns the debounce period as set by [`set_debounce_period`].
503    pub async fn get_debounce_period(&mut self) -> Result<u32, TinkerforgeError> {
504        let payload = [0; 0];
505
506        #[allow(unused_variables)]
507        let result = self.device.get(u8::from(Current25BrickletFunction::GetDebouncePeriod), &payload).await?;
508        Ok(u32::from_le_byte_slice(result.body()))
509    }
510
511    /// Returns the UID, the UID where the Bricklet is connected to,
512    /// the position, the hardware and firmware version as well as the
513    /// device identifier.
514    ///
515    /// The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
516    /// A Bricklet connected to an [Isolator Bricklet](isolator_bricklet) is always at
517    /// position 'z'.
518    ///
519    /// The device identifier numbers can be found [here](device_identifier).
520    /// |device_identifier_constant|
521    pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
522        let payload = [0; 0];
523
524        #[allow(unused_variables)]
525        let result = self.device.get(u8::from(Current25BrickletFunction::GetIdentity), &payload).await?;
526        Ok(Identity::from_le_byte_slice(result.body()))
527    }
528}