tinkerforge/bindings/
solid_state_relay_v2_bricklet.rs

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