1#[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 DistanceIrV2BrickletFunction {
24 GetDistance,
25 SetDistanceCallbackConfiguration,
26 GetDistanceCallbackConfiguration,
27 GetAnalogValue,
28 SetAnalogValueCallbackConfiguration,
29 GetAnalogValueCallbackConfiguration,
30 SetMovingAverageConfiguration,
31 GetMovingAverageConfiguration,
32 SetDistanceLedConfig,
33 GetDistanceLedConfig,
34 SetSensorType,
35 GetSensorType,
36 GetSpitfpErrorCount,
37 SetBootloaderMode,
38 GetBootloaderMode,
39 SetWriteFirmwarePointer,
40 WriteFirmware,
41 SetStatusLedConfig,
42 GetStatusLedConfig,
43 GetChipTemperature,
44 Reset,
45 WriteUid,
46 ReadUid,
47 GetIdentity,
48 CallbackDistance,
49 CallbackAnalogValue,
50}
51impl From<DistanceIrV2BrickletFunction> for u8 {
52 fn from(fun: DistanceIrV2BrickletFunction) -> Self {
53 match fun {
54 DistanceIrV2BrickletFunction::GetDistance => 1,
55 DistanceIrV2BrickletFunction::SetDistanceCallbackConfiguration => 2,
56 DistanceIrV2BrickletFunction::GetDistanceCallbackConfiguration => 3,
57 DistanceIrV2BrickletFunction::GetAnalogValue => 5,
58 DistanceIrV2BrickletFunction::SetAnalogValueCallbackConfiguration => 6,
59 DistanceIrV2BrickletFunction::GetAnalogValueCallbackConfiguration => 7,
60 DistanceIrV2BrickletFunction::SetMovingAverageConfiguration => 9,
61 DistanceIrV2BrickletFunction::GetMovingAverageConfiguration => 10,
62 DistanceIrV2BrickletFunction::SetDistanceLedConfig => 11,
63 DistanceIrV2BrickletFunction::GetDistanceLedConfig => 12,
64 DistanceIrV2BrickletFunction::SetSensorType => 13,
65 DistanceIrV2BrickletFunction::GetSensorType => 14,
66 DistanceIrV2BrickletFunction::GetSpitfpErrorCount => 234,
67 DistanceIrV2BrickletFunction::SetBootloaderMode => 235,
68 DistanceIrV2BrickletFunction::GetBootloaderMode => 236,
69 DistanceIrV2BrickletFunction::SetWriteFirmwarePointer => 237,
70 DistanceIrV2BrickletFunction::WriteFirmware => 238,
71 DistanceIrV2BrickletFunction::SetStatusLedConfig => 239,
72 DistanceIrV2BrickletFunction::GetStatusLedConfig => 240,
73 DistanceIrV2BrickletFunction::GetChipTemperature => 242,
74 DistanceIrV2BrickletFunction::Reset => 243,
75 DistanceIrV2BrickletFunction::WriteUid => 248,
76 DistanceIrV2BrickletFunction::ReadUid => 249,
77 DistanceIrV2BrickletFunction::GetIdentity => 255,
78 DistanceIrV2BrickletFunction::CallbackDistance => 4,
79 DistanceIrV2BrickletFunction::CallbackAnalogValue => 8,
80 }
81 }
82}
83pub const DISTANCE_IR_V2_BRICKLET_THRESHOLD_OPTION_OFF: char = 'x';
84pub const DISTANCE_IR_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE: char = 'o';
85pub const DISTANCE_IR_V2_BRICKLET_THRESHOLD_OPTION_INSIDE: char = 'i';
86pub const DISTANCE_IR_V2_BRICKLET_THRESHOLD_OPTION_SMALLER: char = '<';
87pub const DISTANCE_IR_V2_BRICKLET_THRESHOLD_OPTION_GREATER: char = '>';
88pub const DISTANCE_IR_V2_BRICKLET_DISTANCE_LED_CONFIG_OFF: u8 = 0;
89pub const DISTANCE_IR_V2_BRICKLET_DISTANCE_LED_CONFIG_ON: u8 = 1;
90pub const DISTANCE_IR_V2_BRICKLET_DISTANCE_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
91pub const DISTANCE_IR_V2_BRICKLET_DISTANCE_LED_CONFIG_SHOW_DISTANCE: u8 = 3;
92pub const DISTANCE_IR_V2_BRICKLET_SENSOR_TYPE_2Y0A41: u8 = 0;
93pub const DISTANCE_IR_V2_BRICKLET_SENSOR_TYPE_2Y0A21: u8 = 1;
94pub const DISTANCE_IR_V2_BRICKLET_SENSOR_TYPE_2Y0A02: u8 = 2;
95pub const DISTANCE_IR_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
96pub const DISTANCE_IR_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
97pub const DISTANCE_IR_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
98pub const DISTANCE_IR_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
99pub const DISTANCE_IR_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
100pub const DISTANCE_IR_V2_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
101pub const DISTANCE_IR_V2_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
102pub const DISTANCE_IR_V2_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
103pub const DISTANCE_IR_V2_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
104pub const DISTANCE_IR_V2_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
105pub const DISTANCE_IR_V2_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
106pub const DISTANCE_IR_V2_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
107pub const DISTANCE_IR_V2_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
108pub const DISTANCE_IR_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
109pub const DISTANCE_IR_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
110
111#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
112pub struct DistanceCallbackConfiguration {
113 pub period: u32,
114 pub value_has_to_change: bool,
115 pub option: char,
116 pub min: u16,
117 pub max: u16,
118}
119impl FromByteSlice for DistanceCallbackConfiguration {
120 fn bytes_expected() -> usize {
121 10
122 }
123 fn from_le_byte_slice(bytes: &[u8]) -> DistanceCallbackConfiguration {
124 DistanceCallbackConfiguration {
125 period: <u32>::from_le_byte_slice(&bytes[0..4]),
126 value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
127 option: <char>::from_le_byte_slice(&bytes[5..6]),
128 min: <u16>::from_le_byte_slice(&bytes[6..8]),
129 max: <u16>::from_le_byte_slice(&bytes[8..10]),
130 }
131 }
132}
133
134#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
135pub struct AnalogValueCallbackConfiguration {
136 pub period: u32,
137 pub value_has_to_change: bool,
138 pub option: char,
139 pub min: u32,
140 pub max: u32,
141}
142impl FromByteSlice for AnalogValueCallbackConfiguration {
143 fn bytes_expected() -> usize {
144 14
145 }
146 fn from_le_byte_slice(bytes: &[u8]) -> AnalogValueCallbackConfiguration {
147 AnalogValueCallbackConfiguration {
148 period: <u32>::from_le_byte_slice(&bytes[0..4]),
149 value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
150 option: <char>::from_le_byte_slice(&bytes[5..6]),
151 min: <u32>::from_le_byte_slice(&bytes[6..10]),
152 max: <u32>::from_le_byte_slice(&bytes[10..14]),
153 }
154 }
155}
156
157#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
158pub struct SpitfpErrorCount {
159 pub error_count_ack_checksum: u32,
160 pub error_count_message_checksum: u32,
161 pub error_count_frame: u32,
162 pub error_count_overflow: u32,
163}
164impl FromByteSlice for SpitfpErrorCount {
165 fn bytes_expected() -> usize {
166 16
167 }
168 fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
169 SpitfpErrorCount {
170 error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
171 error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
172 error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
173 error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
174 }
175 }
176}
177
178#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
179pub struct Identity {
180 pub uid: String,
181 pub connected_uid: String,
182 pub position: char,
183 pub hardware_version: [u8; 3],
184 pub firmware_version: [u8; 3],
185 pub device_identifier: u16,
186}
187impl FromByteSlice for Identity {
188 fn bytes_expected() -> usize {
189 25
190 }
191 fn from_le_byte_slice(bytes: &[u8]) -> Identity {
192 Identity {
193 uid: <String>::from_le_byte_slice(&bytes[0..8]),
194 connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
195 position: <char>::from_le_byte_slice(&bytes[16..17]),
196 hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
197 firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
198 device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
199 }
200 }
201}
202
203#[derive(Clone)]
205pub struct DistanceIrV2Bricklet {
206 device: Device,
207}
208impl DistanceIrV2Bricklet {
209 pub const DEVICE_IDENTIFIER: u16 = 2125;
210 pub const DEVICE_DISPLAY_NAME: &'static str = "Distance IR Bricklet 2.0";
211 pub fn new(uid: Uid, connection: AsyncIpConnection) -> DistanceIrV2Bricklet {
213 let mut result = DistanceIrV2Bricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
214 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::GetDistance) as usize] = ResponseExpectedFlag::AlwaysTrue;
215 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::SetDistanceCallbackConfiguration) as usize] =
216 ResponseExpectedFlag::True;
217 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::GetDistanceCallbackConfiguration) as usize] =
218 ResponseExpectedFlag::AlwaysTrue;
219 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::GetAnalogValue) as usize] = ResponseExpectedFlag::AlwaysTrue;
220 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::SetAnalogValueCallbackConfiguration) as usize] =
221 ResponseExpectedFlag::True;
222 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::GetAnalogValueCallbackConfiguration) as usize] =
223 ResponseExpectedFlag::AlwaysTrue;
224 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::SetMovingAverageConfiguration) as usize] =
225 ResponseExpectedFlag::False;
226 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::GetMovingAverageConfiguration) as usize] =
227 ResponseExpectedFlag::AlwaysTrue;
228 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::SetDistanceLedConfig) as usize] =
229 ResponseExpectedFlag::False;
230 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::GetDistanceLedConfig) as usize] =
231 ResponseExpectedFlag::AlwaysTrue;
232 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::SetSensorType) as usize] = ResponseExpectedFlag::False;
233 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::GetSensorType) as usize] = ResponseExpectedFlag::AlwaysTrue;
234 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::GetSpitfpErrorCount) as usize] =
235 ResponseExpectedFlag::AlwaysTrue;
236 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::SetBootloaderMode) as usize] =
237 ResponseExpectedFlag::AlwaysTrue;
238 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::GetBootloaderMode) as usize] =
239 ResponseExpectedFlag::AlwaysTrue;
240 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::SetWriteFirmwarePointer) as usize] =
241 ResponseExpectedFlag::False;
242 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::WriteFirmware) as usize] = ResponseExpectedFlag::AlwaysTrue;
243 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::SetStatusLedConfig) as usize] = ResponseExpectedFlag::False;
244 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::GetStatusLedConfig) as usize] =
245 ResponseExpectedFlag::AlwaysTrue;
246 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::GetChipTemperature) as usize] =
247 ResponseExpectedFlag::AlwaysTrue;
248 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
249 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
250 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
251 result.device.response_expected[u8::from(DistanceIrV2BrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
252 result
253 }
254
255 pub fn get_response_expected(&mut self, fun: DistanceIrV2BrickletFunction) -> Result<bool, GetResponseExpectedError> {
270 self.device.get_response_expected(u8::from(fun))
271 }
272
273 pub fn set_response_expected(
282 &mut self,
283 fun: DistanceIrV2BrickletFunction,
284 response_expected: bool,
285 ) -> Result<(), SetResponseExpectedError> {
286 self.device.set_response_expected(u8::from(fun), response_expected)
287 }
288
289 pub fn set_response_expected_all(&mut self, response_expected: bool) {
291 self.device.set_response_expected_all(response_expected)
292 }
293
294 pub fn get_api_version(&self) -> [u8; 3] {
297 self.device.api_version
298 }
299
300 pub async fn get_distance_callback_receiver(&mut self) -> impl Stream<Item = u16> {
308 self.device
309 .get_callback_receiver(u8::from(DistanceIrV2BrickletFunction::CallbackDistance))
310 .await
311 .map(|p| u16::from_le_byte_slice(p.body()))
312 }
313
314 pub async fn get_analog_value_callback_receiver(&mut self) -> impl Stream<Item = u32> {
319 self.device
320 .get_callback_receiver(u8::from(DistanceIrV2BrickletFunction::CallbackAnalogValue))
321 .await
322 .map(|p| u32::from_le_byte_slice(p.body()))
323 }
324
325 pub async fn get_distance(&mut self) -> Result<u16, TinkerforgeError> {
334 let payload = [0; 0];
335
336 #[allow(unused_variables)]
337 let result = self.device.get(u8::from(DistanceIrV2BrickletFunction::GetDistance), &payload).await?;
338 Ok(u16::from_le_byte_slice(result.body()))
339 }
340
341 pub async fn set_distance_callback_configuration(
374 &mut self,
375 period: u32,
376 value_has_to_change: bool,
377 option: char,
378 min: u16,
379 max: u16,
380 ) -> Result<(), TinkerforgeError> {
381 let mut payload = [0; 10];
382 period.write_to_slice(&mut payload[0..4]);
383 value_has_to_change.write_to_slice(&mut payload[4..5]);
384 option.write_to_slice(&mut payload[5..6]);
385 min.write_to_slice(&mut payload[6..8]);
386 max.write_to_slice(&mut payload[8..10]);
387
388 #[allow(unused_variables)]
389 let result = self.device.set(u8::from(DistanceIrV2BrickletFunction::SetDistanceCallbackConfiguration), &payload).await?;
390 Ok(())
391 }
392
393 pub async fn get_distance_callback_configuration(&mut self) -> Result<DistanceCallbackConfiguration, TinkerforgeError> {
402 let payload = [0; 0];
403
404 #[allow(unused_variables)]
405 let result = self.device.get(u8::from(DistanceIrV2BrickletFunction::GetDistanceCallbackConfiguration), &payload).await?;
406 Ok(DistanceCallbackConfiguration::from_le_byte_slice(result.body()))
407 }
408
409 pub async fn get_analog_value(&mut self) -> Result<u32, TinkerforgeError> {
423 let payload = [0; 0];
424
425 #[allow(unused_variables)]
426 let result = self.device.get(u8::from(DistanceIrV2BrickletFunction::GetAnalogValue), &payload).await?;
427 Ok(u32::from_le_byte_slice(result.body()))
428 }
429
430 pub async fn set_analog_value_callback_configuration(
463 &mut self,
464 period: u32,
465 value_has_to_change: bool,
466 option: char,
467 min: u32,
468 max: u32,
469 ) -> Result<(), TinkerforgeError> {
470 let mut payload = [0; 14];
471 period.write_to_slice(&mut payload[0..4]);
472 value_has_to_change.write_to_slice(&mut payload[4..5]);
473 option.write_to_slice(&mut payload[5..6]);
474 min.write_to_slice(&mut payload[6..10]);
475 max.write_to_slice(&mut payload[10..14]);
476
477 #[allow(unused_variables)]
478 let result = self.device.set(u8::from(DistanceIrV2BrickletFunction::SetAnalogValueCallbackConfiguration), &payload).await?;
479 Ok(())
480 }
481
482 pub async fn get_analog_value_callback_configuration(&mut self) -> Result<AnalogValueCallbackConfiguration, TinkerforgeError> {
491 let payload = [0; 0];
492
493 #[allow(unused_variables)]
494 let result = self.device.get(u8::from(DistanceIrV2BrickletFunction::GetAnalogValueCallbackConfiguration), &payload).await?;
495 Ok(AnalogValueCallbackConfiguration::from_le_byte_slice(result.body()))
496 }
497
498 pub async fn set_moving_average_configuration(&mut self, moving_average_length: u16) -> Result<(), TinkerforgeError> {
508 let mut payload = [0; 2];
509 moving_average_length.write_to_slice(&mut payload[0..2]);
510
511 #[allow(unused_variables)]
512 let result = self.device.set(u8::from(DistanceIrV2BrickletFunction::SetMovingAverageConfiguration), &payload).await?;
513 Ok(())
514 }
515
516 pub async fn get_moving_average_configuration(&mut self) -> Result<u16, TinkerforgeError> {
518 let payload = [0; 0];
519
520 #[allow(unused_variables)]
521 let result = self.device.get(u8::from(DistanceIrV2BrickletFunction::GetMovingAverageConfiguration), &payload).await?;
522 Ok(u16::from_le_byte_slice(result.body()))
523 }
524
525 pub async fn set_distance_led_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
534 let mut payload = [0; 1];
535 config.write_to_slice(&mut payload[0..1]);
536
537 #[allow(unused_variables)]
538 let result = self.device.set(u8::from(DistanceIrV2BrickletFunction::SetDistanceLedConfig), &payload).await?;
539 Ok(())
540 }
541
542 pub async fn get_distance_led_config(&mut self) -> Result<u8, TinkerforgeError> {
550 let payload = [0; 0];
551
552 #[allow(unused_variables)]
553 let result = self.device.get(u8::from(DistanceIrV2BrickletFunction::GetDistanceLedConfig), &payload).await?;
554 Ok(u8::from_le_byte_slice(result.body()))
555 }
556
557 pub async fn set_sensor_type(&mut self, sensor: u8) -> Result<(), TinkerforgeError> {
571 let mut payload = [0; 1];
572 sensor.write_to_slice(&mut payload[0..1]);
573
574 #[allow(unused_variables)]
575 let result = self.device.set(u8::from(DistanceIrV2BrickletFunction::SetSensorType), &payload).await?;
576 Ok(())
577 }
578
579 pub async fn get_sensor_type(&mut self) -> Result<u8, TinkerforgeError> {
586 let payload = [0; 0];
587
588 #[allow(unused_variables)]
589 let result = self.device.get(u8::from(DistanceIrV2BrickletFunction::GetSensorType), &payload).await?;
590 Ok(u8::from_le_byte_slice(result.body()))
591 }
592
593 pub async fn get_spitfp_error_count(&mut self) -> Result<SpitfpErrorCount, TinkerforgeError> {
605 let payload = [0; 0];
606
607 #[allow(unused_variables)]
608 let result = self.device.get(u8::from(DistanceIrV2BrickletFunction::GetSpitfpErrorCount), &payload).await?;
609 Ok(SpitfpErrorCount::from_le_byte_slice(result.body()))
610 }
611
612 pub async fn set_bootloader_mode(&mut self, mode: u8) -> Result<u8, TinkerforgeError> {
635 let mut payload = [0; 1];
636 mode.write_to_slice(&mut payload[0..1]);
637
638 #[allow(unused_variables)]
639 let result = self.device.get(u8::from(DistanceIrV2BrickletFunction::SetBootloaderMode), &payload).await?;
640 Ok(u8::from_le_byte_slice(result.body()))
641 }
642
643 pub async fn get_bootloader_mode(&mut self) -> Result<u8, TinkerforgeError> {
652 let payload = [0; 0];
653
654 #[allow(unused_variables)]
655 let result = self.device.get(u8::from(DistanceIrV2BrickletFunction::GetBootloaderMode), &payload).await?;
656 Ok(u8::from_le_byte_slice(result.body()))
657 }
658
659 pub async fn set_write_firmware_pointer(&mut self, pointer: u32) -> Result<(), TinkerforgeError> {
666 let mut payload = [0; 4];
667 pointer.write_to_slice(&mut payload[0..4]);
668
669 #[allow(unused_variables)]
670 let result = self.device.set(u8::from(DistanceIrV2BrickletFunction::SetWriteFirmwarePointer), &payload).await?;
671 Ok(())
672 }
673
674 pub async fn write_firmware(&mut self, data: &[u8; 64]) -> Result<u8, TinkerforgeError> {
683 let mut payload = [0; 64];
684 data.write_to_slice(&mut payload[0..64]);
685
686 #[allow(unused_variables)]
687 let result = self.device.get(u8::from(DistanceIrV2BrickletFunction::WriteFirmware), &payload).await?;
688 Ok(u8::from_le_byte_slice(result.body()))
689 }
690
691 pub async fn set_status_led_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
705 let mut payload = [0; 1];
706 config.write_to_slice(&mut payload[0..1]);
707
708 #[allow(unused_variables)]
709 let result = self.device.set(u8::from(DistanceIrV2BrickletFunction::SetStatusLedConfig), &payload).await?;
710 Ok(())
711 }
712
713 pub async fn get_status_led_config(&mut self) -> Result<u8, TinkerforgeError> {
721 let payload = [0; 0];
722
723 #[allow(unused_variables)]
724 let result = self.device.get(u8::from(DistanceIrV2BrickletFunction::GetStatusLedConfig), &payload).await?;
725 Ok(u8::from_le_byte_slice(result.body()))
726 }
727
728 pub async fn get_chip_temperature(&mut self) -> Result<i16, TinkerforgeError> {
735 let payload = [0; 0];
736
737 #[allow(unused_variables)]
738 let result = self.device.get(u8::from(DistanceIrV2BrickletFunction::GetChipTemperature), &payload).await?;
739 Ok(i16::from_le_byte_slice(result.body()))
740 }
741
742 pub async fn reset(&mut self) -> Result<(), TinkerforgeError> {
749 let payload = [0; 0];
750
751 #[allow(unused_variables)]
752 let result = self.device.set(u8::from(DistanceIrV2BrickletFunction::Reset), &payload).await?;
753 Ok(())
754 }
755
756 pub async fn write_uid(&mut self, uid: u32) -> Result<(), TinkerforgeError> {
762 let mut payload = [0; 4];
763 uid.write_to_slice(&mut payload[0..4]);
764
765 #[allow(unused_variables)]
766 let result = self.device.set(u8::from(DistanceIrV2BrickletFunction::WriteUid), &payload).await?;
767 Ok(())
768 }
769
770 pub async fn read_uid(&mut self) -> Result<u32, TinkerforgeError> {
773 let payload = [0; 0];
774
775 #[allow(unused_variables)]
776 let result = self.device.get(u8::from(DistanceIrV2BrickletFunction::ReadUid), &payload).await?;
777 Ok(u32::from_le_byte_slice(result.body()))
778 }
779
780 pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
791 let payload = [0; 0];
792
793 #[allow(unused_variables)]
794 let result = self.device.get(u8::from(DistanceIrV2BrickletFunction::GetIdentity), &payload).await?;
795 Ok(Identity::from_le_byte_slice(result.body()))
796 }
797}