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