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