tinkerforge_async/bindings/
rgb_led_button_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//! Push button with built-in RGB LED.
12//!
13//! See also the documentation [here](https://www.tinkerforge.com/en/doc/Software/Bricklets/RGBLEDButton_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 RgbLedButtonBrickletFunction {
24    SetColor,
25    GetColor,
26    GetButtonState,
27    SetColorCalibration,
28    GetColorCalibration,
29    GetSpitfpErrorCount,
30    SetBootloaderMode,
31    GetBootloaderMode,
32    SetWriteFirmwarePointer,
33    WriteFirmware,
34    SetStatusLedConfig,
35    GetStatusLedConfig,
36    GetChipTemperature,
37    Reset,
38    WriteUid,
39    ReadUid,
40    GetIdentity,
41    CallbackButtonStateChanged,
42}
43impl From<RgbLedButtonBrickletFunction> for u8 {
44    fn from(fun: RgbLedButtonBrickletFunction) -> Self {
45        match fun {
46            RgbLedButtonBrickletFunction::SetColor => 1,
47            RgbLedButtonBrickletFunction::GetColor => 2,
48            RgbLedButtonBrickletFunction::GetButtonState => 3,
49            RgbLedButtonBrickletFunction::SetColorCalibration => 5,
50            RgbLedButtonBrickletFunction::GetColorCalibration => 6,
51            RgbLedButtonBrickletFunction::GetSpitfpErrorCount => 234,
52            RgbLedButtonBrickletFunction::SetBootloaderMode => 235,
53            RgbLedButtonBrickletFunction::GetBootloaderMode => 236,
54            RgbLedButtonBrickletFunction::SetWriteFirmwarePointer => 237,
55            RgbLedButtonBrickletFunction::WriteFirmware => 238,
56            RgbLedButtonBrickletFunction::SetStatusLedConfig => 239,
57            RgbLedButtonBrickletFunction::GetStatusLedConfig => 240,
58            RgbLedButtonBrickletFunction::GetChipTemperature => 242,
59            RgbLedButtonBrickletFunction::Reset => 243,
60            RgbLedButtonBrickletFunction::WriteUid => 248,
61            RgbLedButtonBrickletFunction::ReadUid => 249,
62            RgbLedButtonBrickletFunction::GetIdentity => 255,
63            RgbLedButtonBrickletFunction::CallbackButtonStateChanged => 4,
64        }
65    }
66}
67pub const RGB_LED_BUTTON_BRICKLET_BUTTON_STATE_PRESSED: u8 = 0;
68pub const RGB_LED_BUTTON_BRICKLET_BUTTON_STATE_RELEASED: u8 = 1;
69pub const RGB_LED_BUTTON_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
70pub const RGB_LED_BUTTON_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
71pub const RGB_LED_BUTTON_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
72pub const RGB_LED_BUTTON_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
73pub const RGB_LED_BUTTON_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
74pub const RGB_LED_BUTTON_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
75pub const RGB_LED_BUTTON_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
76pub const RGB_LED_BUTTON_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
77pub const RGB_LED_BUTTON_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
78pub const RGB_LED_BUTTON_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
79pub const RGB_LED_BUTTON_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
80pub const RGB_LED_BUTTON_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
81pub const RGB_LED_BUTTON_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
82pub const RGB_LED_BUTTON_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
83pub const RGB_LED_BUTTON_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
84
85#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
86pub struct Color {
87    pub red: u8,
88    pub green: u8,
89    pub blue: u8,
90}
91impl FromByteSlice for Color {
92    fn bytes_expected() -> usize {
93        3
94    }
95    fn from_le_byte_slice(bytes: &[u8]) -> Color {
96        Color {
97            red: <u8>::from_le_byte_slice(&bytes[0..1]),
98            green: <u8>::from_le_byte_slice(&bytes[1..2]),
99            blue: <u8>::from_le_byte_slice(&bytes[2..3]),
100        }
101    }
102}
103
104#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
105pub struct ColorCalibration {
106    pub red: u8,
107    pub green: u8,
108    pub blue: u8,
109}
110impl FromByteSlice for ColorCalibration {
111    fn bytes_expected() -> usize {
112        3
113    }
114    fn from_le_byte_slice(bytes: &[u8]) -> ColorCalibration {
115        ColorCalibration {
116            red: <u8>::from_le_byte_slice(&bytes[0..1]),
117            green: <u8>::from_le_byte_slice(&bytes[1..2]),
118            blue: <u8>::from_le_byte_slice(&bytes[2..3]),
119        }
120    }
121}
122
123#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
124pub struct SpitfpErrorCount {
125    pub error_count_ack_checksum: u32,
126    pub error_count_message_checksum: u32,
127    pub error_count_frame: u32,
128    pub error_count_overflow: u32,
129}
130impl FromByteSlice for SpitfpErrorCount {
131    fn bytes_expected() -> usize {
132        16
133    }
134    fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
135        SpitfpErrorCount {
136            error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
137            error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
138            error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
139            error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
140        }
141    }
142}
143
144#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
145pub struct Identity {
146    pub uid: String,
147    pub connected_uid: String,
148    pub position: char,
149    pub hardware_version: [u8; 3],
150    pub firmware_version: [u8; 3],
151    pub device_identifier: u16,
152}
153impl FromByteSlice for Identity {
154    fn bytes_expected() -> usize {
155        25
156    }
157    fn from_le_byte_slice(bytes: &[u8]) -> Identity {
158        Identity {
159            uid: <String>::from_le_byte_slice(&bytes[0..8]),
160            connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
161            position: <char>::from_le_byte_slice(&bytes[16..17]),
162            hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
163            firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
164            device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
165        }
166    }
167}
168
169/// Push button with built-in RGB LED
170#[derive(Clone)]
171pub struct RgbLedButtonBricklet {
172    device: Device,
173}
174impl RgbLedButtonBricklet {
175    pub const DEVICE_IDENTIFIER: u16 = 282;
176    pub const DEVICE_DISPLAY_NAME: &'static str = "RGB LED Button Bricklet";
177    /// Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ip_connection` is connected.
178    pub fn new(uid: Uid, connection: AsyncIpConnection) -> RgbLedButtonBricklet {
179        let mut result = RgbLedButtonBricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
180        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::SetColor) as usize] = ResponseExpectedFlag::False;
181        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::GetColor) as usize] = ResponseExpectedFlag::AlwaysTrue;
182        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::GetButtonState) as usize] = ResponseExpectedFlag::AlwaysTrue;
183        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::SetColorCalibration) as usize] = ResponseExpectedFlag::False;
184        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::GetColorCalibration) as usize] =
185            ResponseExpectedFlag::AlwaysTrue;
186        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::GetSpitfpErrorCount) as usize] =
187            ResponseExpectedFlag::AlwaysTrue;
188        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::SetBootloaderMode) as usize] =
189            ResponseExpectedFlag::AlwaysTrue;
190        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::GetBootloaderMode) as usize] =
191            ResponseExpectedFlag::AlwaysTrue;
192        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::SetWriteFirmwarePointer) as usize] =
193            ResponseExpectedFlag::False;
194        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::WriteFirmware) as usize] = ResponseExpectedFlag::AlwaysTrue;
195        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::SetStatusLedConfig) as usize] = ResponseExpectedFlag::False;
196        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::GetStatusLedConfig) as usize] =
197            ResponseExpectedFlag::AlwaysTrue;
198        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::GetChipTemperature) as usize] =
199            ResponseExpectedFlag::AlwaysTrue;
200        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
201        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
202        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
203        result.device.response_expected[u8::from(RgbLedButtonBrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
204        result
205    }
206
207    /// Returns the response expected flag for the function specified by the function ID parameter.
208    /// It is true if the function is expected to send a response, false otherwise.
209    ///
210    /// For getter functions this is enabled by default and cannot be disabled, because those
211    /// functions will always send a response. For callback configuration functions it is enabled
212    /// by default too, but can be disabled by [`set_response_expected`](crate::rgb_led_button_bricklet::RgbLedButtonBricklet::set_response_expected).
213    /// For setter functions it is disabled by default and can be enabled.
214    ///
215    /// Enabling the response expected flag for a setter function allows to detect timeouts
216    /// and other error conditions calls of this setter as well. The device will then send a response
217    /// for this purpose. If this flag is disabled for a setter function then no response is sent
218    /// and errors are silently ignored, because they cannot be detected.
219    ///
220    /// See [`set_response_expected`](crate::rgb_led_button_bricklet::RgbLedButtonBricklet::set_response_expected) for the list of function ID constants available for this function.
221    pub fn get_response_expected(&mut self, fun: RgbLedButtonBrickletFunction) -> Result<bool, GetResponseExpectedError> {
222        self.device.get_response_expected(u8::from(fun))
223    }
224
225    /// Changes the response expected flag of the function specified by the function ID parameter.
226    /// This flag can only be changed for setter (default value: false) and callback configuration
227    /// functions (default value: true). For getter functions it is always enabled.
228    ///
229    /// Enabling the response expected flag for a setter function allows to detect timeouts and
230    /// other error conditions calls of this setter as well. The device will then send a response
231    /// for this purpose. If this flag is disabled for a setter function then no response is sent
232    /// and errors are silently ignored, because they cannot be detected.
233    pub fn set_response_expected(
234        &mut self,
235        fun: RgbLedButtonBrickletFunction,
236        response_expected: bool,
237    ) -> Result<(), SetResponseExpectedError> {
238        self.device.set_response_expected(u8::from(fun), response_expected)
239    }
240
241    /// Changes the response expected flag for all setter and callback configuration functions of this device at once.
242    pub fn set_response_expected_all(&mut self, response_expected: bool) {
243        self.device.set_response_expected_all(response_expected)
244    }
245
246    /// Returns the version of the API definition (major, minor, revision) implemented by this API bindings.
247    /// This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
248    pub fn get_api_version(&self) -> [u8; 3] {
249        self.device.api_version
250    }
251
252    /// This receiver is triggered every time the button state changes from pressed to
253    /// released or from released to pressed.
254    ///
255    /// The parameter is the current state of the button.
256    pub async fn get_button_state_changed_callback_receiver(&mut self) -> impl Stream<Item = u8> {
257        self.device
258            .get_callback_receiver(u8::from(RgbLedButtonBrickletFunction::CallbackButtonStateChanged))
259            .await
260            .map(|p| u8::from_le_byte_slice(p.body()))
261    }
262
263    /// Sets the color of the LED.
264    pub async fn set_color(&mut self, red: u8, green: u8, blue: u8) -> Result<(), TinkerforgeError> {
265        let mut payload = [0; 3];
266        red.write_to_slice(&mut payload[0..1]);
267        green.write_to_slice(&mut payload[1..2]);
268        blue.write_to_slice(&mut payload[2..3]);
269
270        #[allow(unused_variables)]
271        let result = self.device.set(u8::from(RgbLedButtonBrickletFunction::SetColor), &payload).await?;
272        Ok(())
273    }
274
275    /// Returns the LED color as set by [`set_color`].
276    pub async fn get_color(&mut self) -> Result<Color, TinkerforgeError> {
277        let payload = [0; 0];
278
279        #[allow(unused_variables)]
280        let result = self.device.get(u8::from(RgbLedButtonBrickletFunction::GetColor), &payload).await?;
281        Ok(Color::from_le_byte_slice(result.body()))
282    }
283
284    /// Returns the current state of the button (either pressed or released).
285    ///
286    /// Associated constants:
287    /// * RGB_LED_BUTTON_BRICKLET_BUTTON_STATE_PRESSED
288    ///	* RGB_LED_BUTTON_BRICKLET_BUTTON_STATE_RELEASED
289    pub async fn get_button_state(&mut self) -> Result<u8, TinkerforgeError> {
290        let payload = [0; 0];
291
292        #[allow(unused_variables)]
293        let result = self.device.get(u8::from(RgbLedButtonBrickletFunction::GetButtonState), &payload).await?;
294        Ok(u8::from_le_byte_slice(result.body()))
295    }
296
297    /// Sets a color calibration. Some colors appear brighter then others,
298    /// so a calibration may be necessary for uniform colors.
299    ///
300    /// The calibration is saved in flash. You don't need to call this
301    /// function on every startup.
302    pub async fn set_color_calibration(&mut self, red: u8, green: u8, blue: u8) -> Result<(), TinkerforgeError> {
303        let mut payload = [0; 3];
304        red.write_to_slice(&mut payload[0..1]);
305        green.write_to_slice(&mut payload[1..2]);
306        blue.write_to_slice(&mut payload[2..3]);
307
308        #[allow(unused_variables)]
309        let result = self.device.set(u8::from(RgbLedButtonBrickletFunction::SetColorCalibration), &payload).await?;
310        Ok(())
311    }
312
313    /// Returns the color calibration as set by [`set_color_calibration`].
314    pub async fn get_color_calibration(&mut self) -> Result<ColorCalibration, TinkerforgeError> {
315        let payload = [0; 0];
316
317        #[allow(unused_variables)]
318        let result = self.device.get(u8::from(RgbLedButtonBrickletFunction::GetColorCalibration), &payload).await?;
319        Ok(ColorCalibration::from_le_byte_slice(result.body()))
320    }
321
322    /// Returns the error count for the communication between Brick and Bricklet.
323    ///
324    /// The errors are divided into
325    ///
326    /// * ACK checksum errors,
327    /// * message checksum errors,
328    /// * framing errors and
329    /// * overflow errors.
330    ///
331    /// The errors counts are for errors that occur on the Bricklet side. All
332    /// Bricks have a similar function that returns the errors on the Brick side.
333    pub async fn get_spitfp_error_count(&mut self) -> Result<SpitfpErrorCount, TinkerforgeError> {
334        let payload = [0; 0];
335
336        #[allow(unused_variables)]
337        let result = self.device.get(u8::from(RgbLedButtonBrickletFunction::GetSpitfpErrorCount), &payload).await?;
338        Ok(SpitfpErrorCount::from_le_byte_slice(result.body()))
339    }
340
341    /// Sets the bootloader mode and returns the status after the requested
342    /// mode change was instigated.
343    ///
344    /// You can change from bootloader mode to firmware mode and vice versa. A change
345    /// from bootloader mode to firmware mode will only take place if the entry function,
346    /// device identifier and CRC are present and correct.
347    ///
348    /// This function is used by Brick Viewer during flashing. It should not be
349    /// necessary to call it in a normal user program.
350    ///
351    /// Associated constants:
352    /// * RGB_LED_BUTTON_BRICKLET_BOOTLOADER_MODE_BOOTLOADER
353    ///	* RGB_LED_BUTTON_BRICKLET_BOOTLOADER_MODE_FIRMWARE
354    ///	* RGB_LED_BUTTON_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
355    ///	* RGB_LED_BUTTON_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
356    ///	* RGB_LED_BUTTON_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
357    ///	* RGB_LED_BUTTON_BRICKLET_BOOTLOADER_STATUS_OK
358    ///	* RGB_LED_BUTTON_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE
359    ///	* RGB_LED_BUTTON_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE
360    ///	* RGB_LED_BUTTON_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT
361    ///	* RGB_LED_BUTTON_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT
362    ///	* RGB_LED_BUTTON_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH
363    pub async fn set_bootloader_mode(&mut self, mode: u8) -> Result<u8, TinkerforgeError> {
364        let mut payload = [0; 1];
365        mode.write_to_slice(&mut payload[0..1]);
366
367        #[allow(unused_variables)]
368        let result = self.device.get(u8::from(RgbLedButtonBrickletFunction::SetBootloaderMode), &payload).await?;
369        Ok(u8::from_le_byte_slice(result.body()))
370    }
371
372    /// Returns the current bootloader mode, see [`set_bootloader_mode`].
373    ///
374    /// Associated constants:
375    /// * RGB_LED_BUTTON_BRICKLET_BOOTLOADER_MODE_BOOTLOADER
376    ///	* RGB_LED_BUTTON_BRICKLET_BOOTLOADER_MODE_FIRMWARE
377    ///	* RGB_LED_BUTTON_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
378    ///	* RGB_LED_BUTTON_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
379    ///	* RGB_LED_BUTTON_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
380    pub async fn get_bootloader_mode(&mut self) -> Result<u8, TinkerforgeError> {
381        let payload = [0; 0];
382
383        #[allow(unused_variables)]
384        let result = self.device.get(u8::from(RgbLedButtonBrickletFunction::GetBootloaderMode), &payload).await?;
385        Ok(u8::from_le_byte_slice(result.body()))
386    }
387
388    /// Sets the firmware pointer for [`write_firmware`]. The pointer has
389    /// to be increased by chunks of size 64. The data is written to flash
390    /// every 4 chunks (which equals to one page of size 256).
391    ///
392    /// This function is used by Brick Viewer during flashing. It should not be
393    /// necessary to call it in a normal user program.
394    pub async fn set_write_firmware_pointer(&mut self, pointer: u32) -> Result<(), TinkerforgeError> {
395        let mut payload = [0; 4];
396        pointer.write_to_slice(&mut payload[0..4]);
397
398        #[allow(unused_variables)]
399        let result = self.device.set(u8::from(RgbLedButtonBrickletFunction::SetWriteFirmwarePointer), &payload).await?;
400        Ok(())
401    }
402
403    /// Writes 64 Bytes of firmware at the position as written by
404    /// [`set_write_firmware_pointer`] before. The firmware is written
405    /// to flash every 4 chunks.
406    ///
407    /// You can only write firmware in bootloader mode.
408    ///
409    /// This function is used by Brick Viewer during flashing. It should not be
410    /// necessary to call it in a normal user program.
411    pub async fn write_firmware(&mut self, data: &[u8; 64]) -> Result<u8, TinkerforgeError> {
412        let mut payload = [0; 64];
413        data.write_to_slice(&mut payload[0..64]);
414
415        #[allow(unused_variables)]
416        let result = self.device.get(u8::from(RgbLedButtonBrickletFunction::WriteFirmware), &payload).await?;
417        Ok(u8::from_le_byte_slice(result.body()))
418    }
419
420    /// Sets the status LED configuration. By default the LED shows
421    /// communication traffic between Brick and Bricklet, it flickers once
422    /// for every 10 received data packets.
423    ///
424    /// You can also turn the LED permanently on/off or show a heartbeat.
425    ///
426    /// If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
427    ///
428    /// Associated constants:
429    /// * RGB_LED_BUTTON_BRICKLET_STATUS_LED_CONFIG_OFF
430    ///	* RGB_LED_BUTTON_BRICKLET_STATUS_LED_CONFIG_ON
431    ///	* RGB_LED_BUTTON_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT
432    ///	* RGB_LED_BUTTON_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS
433    pub async fn set_status_led_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
434        let mut payload = [0; 1];
435        config.write_to_slice(&mut payload[0..1]);
436
437        #[allow(unused_variables)]
438        let result = self.device.set(u8::from(RgbLedButtonBrickletFunction::SetStatusLedConfig), &payload).await?;
439        Ok(())
440    }
441
442    /// Returns the configuration as set by [`set_status_led_config`]
443    ///
444    /// Associated constants:
445    /// * RGB_LED_BUTTON_BRICKLET_STATUS_LED_CONFIG_OFF
446    ///	* RGB_LED_BUTTON_BRICKLET_STATUS_LED_CONFIG_ON
447    ///	* RGB_LED_BUTTON_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT
448    ///	* RGB_LED_BUTTON_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS
449    pub async fn get_status_led_config(&mut self) -> Result<u8, TinkerforgeError> {
450        let payload = [0; 0];
451
452        #[allow(unused_variables)]
453        let result = self.device.get(u8::from(RgbLedButtonBrickletFunction::GetStatusLedConfig), &payload).await?;
454        Ok(u8::from_le_byte_slice(result.body()))
455    }
456
457    /// Returns the temperature as measured inside the microcontroller. The
458    /// value returned is not the ambient temperature!
459    ///
460    /// The temperature is only proportional to the real temperature and it has bad
461    /// accuracy. Practically it is only useful as an indicator for
462    /// temperature changes.
463    pub async fn get_chip_temperature(&mut self) -> Result<i16, TinkerforgeError> {
464        let payload = [0; 0];
465
466        #[allow(unused_variables)]
467        let result = self.device.get(u8::from(RgbLedButtonBrickletFunction::GetChipTemperature), &payload).await?;
468        Ok(i16::from_le_byte_slice(result.body()))
469    }
470
471    /// Calling this function will reset the Bricklet. All configurations
472    /// will be lost.
473    ///
474    /// After a reset you have to create new device objects,
475    /// calling functions on the existing ones will result in
476    /// undefined behavior!
477    pub async fn reset(&mut self) -> Result<(), TinkerforgeError> {
478        let payload = [0; 0];
479
480        #[allow(unused_variables)]
481        let result = self.device.set(u8::from(RgbLedButtonBrickletFunction::Reset), &payload).await?;
482        Ok(())
483    }
484
485    /// Writes a new UID into flash. If you want to set a new UID
486    /// you have to decode the Base58 encoded UID string into an
487    /// integer first.
488    ///
489    /// We recommend that you use Brick Viewer to change the UID.
490    pub async fn write_uid(&mut self, uid: u32) -> Result<(), TinkerforgeError> {
491        let mut payload = [0; 4];
492        uid.write_to_slice(&mut payload[0..4]);
493
494        #[allow(unused_variables)]
495        let result = self.device.set(u8::from(RgbLedButtonBrickletFunction::WriteUid), &payload).await?;
496        Ok(())
497    }
498
499    /// Returns the current UID as an integer. Encode as
500    /// Base58 to get the usual string version.
501    pub async fn read_uid(&mut self) -> Result<u32, TinkerforgeError> {
502        let payload = [0; 0];
503
504        #[allow(unused_variables)]
505        let result = self.device.get(u8::from(RgbLedButtonBrickletFunction::ReadUid), &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(RgbLedButtonBrickletFunction::GetIdentity), &payload).await?;
524        Ok(Identity::from_le_byte_slice(result.body()))
525    }
526}