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 IndustrialPtcBrickletFunction {
24 GetTemperature,
25 SetTemperatureCallbackConfiguration,
26 GetTemperatureCallbackConfiguration,
27 GetResistance,
28 SetResistanceCallbackConfiguration,
29 GetResistanceCallbackConfiguration,
30 SetNoiseRejectionFilter,
31 GetNoiseRejectionFilter,
32 IsSensorConnected,
33 SetWireMode,
34 GetWireMode,
35 SetMovingAverageConfiguration,
36 GetMovingAverageConfiguration,
37 SetSensorConnectedCallbackConfiguration,
38 GetSensorConnectedCallbackConfiguration,
39 GetSpitfpErrorCount,
40 SetBootloaderMode,
41 GetBootloaderMode,
42 SetWriteFirmwarePointer,
43 WriteFirmware,
44 SetStatusLedConfig,
45 GetStatusLedConfig,
46 GetChipTemperature,
47 Reset,
48 WriteUid,
49 ReadUid,
50 GetIdentity,
51 CallbackTemperature,
52 CallbackResistance,
53 CallbackSensorConnected,
54}
55impl From<IndustrialPtcBrickletFunction> for u8 {
56 fn from(fun: IndustrialPtcBrickletFunction) -> Self {
57 match fun {
58 IndustrialPtcBrickletFunction::GetTemperature => 1,
59 IndustrialPtcBrickletFunction::SetTemperatureCallbackConfiguration => 2,
60 IndustrialPtcBrickletFunction::GetTemperatureCallbackConfiguration => 3,
61 IndustrialPtcBrickletFunction::GetResistance => 5,
62 IndustrialPtcBrickletFunction::SetResistanceCallbackConfiguration => 6,
63 IndustrialPtcBrickletFunction::GetResistanceCallbackConfiguration => 7,
64 IndustrialPtcBrickletFunction::SetNoiseRejectionFilter => 9,
65 IndustrialPtcBrickletFunction::GetNoiseRejectionFilter => 10,
66 IndustrialPtcBrickletFunction::IsSensorConnected => 11,
67 IndustrialPtcBrickletFunction::SetWireMode => 12,
68 IndustrialPtcBrickletFunction::GetWireMode => 13,
69 IndustrialPtcBrickletFunction::SetMovingAverageConfiguration => 14,
70 IndustrialPtcBrickletFunction::GetMovingAverageConfiguration => 15,
71 IndustrialPtcBrickletFunction::SetSensorConnectedCallbackConfiguration => 16,
72 IndustrialPtcBrickletFunction::GetSensorConnectedCallbackConfiguration => 17,
73 IndustrialPtcBrickletFunction::GetSpitfpErrorCount => 234,
74 IndustrialPtcBrickletFunction::SetBootloaderMode => 235,
75 IndustrialPtcBrickletFunction::GetBootloaderMode => 236,
76 IndustrialPtcBrickletFunction::SetWriteFirmwarePointer => 237,
77 IndustrialPtcBrickletFunction::WriteFirmware => 238,
78 IndustrialPtcBrickletFunction::SetStatusLedConfig => 239,
79 IndustrialPtcBrickletFunction::GetStatusLedConfig => 240,
80 IndustrialPtcBrickletFunction::GetChipTemperature => 242,
81 IndustrialPtcBrickletFunction::Reset => 243,
82 IndustrialPtcBrickletFunction::WriteUid => 248,
83 IndustrialPtcBrickletFunction::ReadUid => 249,
84 IndustrialPtcBrickletFunction::GetIdentity => 255,
85 IndustrialPtcBrickletFunction::CallbackTemperature => 4,
86 IndustrialPtcBrickletFunction::CallbackResistance => 8,
87 IndustrialPtcBrickletFunction::CallbackSensorConnected => 18,
88 }
89 }
90}
91pub const INDUSTRIAL_PTC_BRICKLET_THRESHOLD_OPTION_OFF: char = 'x';
92pub const INDUSTRIAL_PTC_BRICKLET_THRESHOLD_OPTION_OUTSIDE: char = 'o';
93pub const INDUSTRIAL_PTC_BRICKLET_THRESHOLD_OPTION_INSIDE: char = 'i';
94pub const INDUSTRIAL_PTC_BRICKLET_THRESHOLD_OPTION_SMALLER: char = '<';
95pub const INDUSTRIAL_PTC_BRICKLET_THRESHOLD_OPTION_GREATER: char = '>';
96pub const INDUSTRIAL_PTC_BRICKLET_FILTER_OPTION_50HZ: u8 = 0;
97pub const INDUSTRIAL_PTC_BRICKLET_FILTER_OPTION_60HZ: u8 = 1;
98pub const INDUSTRIAL_PTC_BRICKLET_WIRE_MODE_2: u8 = 2;
99pub const INDUSTRIAL_PTC_BRICKLET_WIRE_MODE_3: u8 = 3;
100pub const INDUSTRIAL_PTC_BRICKLET_WIRE_MODE_4: u8 = 4;
101pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
102pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
103pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
104pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
105pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
106pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
107pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
108pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
109pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
110pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
111pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
112pub const INDUSTRIAL_PTC_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
113pub const INDUSTRIAL_PTC_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
114pub const INDUSTRIAL_PTC_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
115pub const INDUSTRIAL_PTC_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
116
117#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
118pub struct TemperatureCallbackConfiguration {
119 pub period: u32,
120 pub value_has_to_change: bool,
121 pub option: char,
122 pub min: i32,
123 pub max: i32,
124}
125impl FromByteSlice for TemperatureCallbackConfiguration {
126 fn bytes_expected() -> usize {
127 14
128 }
129 fn from_le_byte_slice(bytes: &[u8]) -> TemperatureCallbackConfiguration {
130 TemperatureCallbackConfiguration {
131 period: <u32>::from_le_byte_slice(&bytes[0..4]),
132 value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
133 option: <char>::from_le_byte_slice(&bytes[5..6]),
134 min: <i32>::from_le_byte_slice(&bytes[6..10]),
135 max: <i32>::from_le_byte_slice(&bytes[10..14]),
136 }
137 }
138}
139
140#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
141pub struct ResistanceCallbackConfiguration {
142 pub period: u32,
143 pub value_has_to_change: bool,
144 pub option: char,
145 pub min: i32,
146 pub max: i32,
147}
148impl FromByteSlice for ResistanceCallbackConfiguration {
149 fn bytes_expected() -> usize {
150 14
151 }
152 fn from_le_byte_slice(bytes: &[u8]) -> ResistanceCallbackConfiguration {
153 ResistanceCallbackConfiguration {
154 period: <u32>::from_le_byte_slice(&bytes[0..4]),
155 value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
156 option: <char>::from_le_byte_slice(&bytes[5..6]),
157 min: <i32>::from_le_byte_slice(&bytes[6..10]),
158 max: <i32>::from_le_byte_slice(&bytes[10..14]),
159 }
160 }
161}
162
163#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
164pub struct MovingAverageConfiguration {
165 pub moving_average_length_resistance: u16,
166 pub moving_average_length_temperature: u16,
167}
168impl FromByteSlice for MovingAverageConfiguration {
169 fn bytes_expected() -> usize {
170 4
171 }
172 fn from_le_byte_slice(bytes: &[u8]) -> MovingAverageConfiguration {
173 MovingAverageConfiguration {
174 moving_average_length_resistance: <u16>::from_le_byte_slice(&bytes[0..2]),
175 moving_average_length_temperature: <u16>::from_le_byte_slice(&bytes[2..4]),
176 }
177 }
178}
179
180#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
181pub struct SpitfpErrorCount {
182 pub error_count_ack_checksum: u32,
183 pub error_count_message_checksum: u32,
184 pub error_count_frame: u32,
185 pub error_count_overflow: u32,
186}
187impl FromByteSlice for SpitfpErrorCount {
188 fn bytes_expected() -> usize {
189 16
190 }
191 fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
192 SpitfpErrorCount {
193 error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
194 error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
195 error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
196 error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
197 }
198 }
199}
200
201#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
202pub struct Identity {
203 pub uid: String,
204 pub connected_uid: String,
205 pub position: char,
206 pub hardware_version: [u8; 3],
207 pub firmware_version: [u8; 3],
208 pub device_identifier: u16,
209}
210impl FromByteSlice for Identity {
211 fn bytes_expected() -> usize {
212 25
213 }
214 fn from_le_byte_slice(bytes: &[u8]) -> Identity {
215 Identity {
216 uid: <String>::from_le_byte_slice(&bytes[0..8]),
217 connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
218 position: <char>::from_le_byte_slice(&bytes[16..17]),
219 hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
220 firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
221 device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
222 }
223 }
224}
225
226#[derive(Clone)]
228pub struct IndustrialPtcBricklet {
229 device: Device,
230}
231impl IndustrialPtcBricklet {
232 pub const DEVICE_IDENTIFIER: u16 = 2164;
233 pub const DEVICE_DISPLAY_NAME: &'static str = "Industrial PTC Bricklet";
234 pub fn new(uid: Uid, connection: AsyncIpConnection) -> IndustrialPtcBricklet {
236 let mut result = IndustrialPtcBricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
237 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetTemperature) as usize] =
238 ResponseExpectedFlag::AlwaysTrue;
239 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetTemperatureCallbackConfiguration) as usize] =
240 ResponseExpectedFlag::True;
241 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetTemperatureCallbackConfiguration) as usize] =
242 ResponseExpectedFlag::AlwaysTrue;
243 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetResistance) as usize] = ResponseExpectedFlag::AlwaysTrue;
244 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetResistanceCallbackConfiguration) as usize] =
245 ResponseExpectedFlag::True;
246 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetResistanceCallbackConfiguration) as usize] =
247 ResponseExpectedFlag::AlwaysTrue;
248 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetNoiseRejectionFilter) as usize] =
249 ResponseExpectedFlag::False;
250 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetNoiseRejectionFilter) as usize] =
251 ResponseExpectedFlag::AlwaysTrue;
252 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::IsSensorConnected) as usize] =
253 ResponseExpectedFlag::AlwaysTrue;
254 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetWireMode) as usize] = ResponseExpectedFlag::False;
255 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetWireMode) as usize] = ResponseExpectedFlag::AlwaysTrue;
256 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetMovingAverageConfiguration) as usize] =
257 ResponseExpectedFlag::False;
258 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetMovingAverageConfiguration) as usize] =
259 ResponseExpectedFlag::AlwaysTrue;
260 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetSensorConnectedCallbackConfiguration) as usize] =
261 ResponseExpectedFlag::True;
262 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetSensorConnectedCallbackConfiguration) as usize] =
263 ResponseExpectedFlag::AlwaysTrue;
264 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetSpitfpErrorCount) as usize] =
265 ResponseExpectedFlag::AlwaysTrue;
266 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetBootloaderMode) as usize] =
267 ResponseExpectedFlag::AlwaysTrue;
268 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetBootloaderMode) as usize] =
269 ResponseExpectedFlag::AlwaysTrue;
270 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetWriteFirmwarePointer) as usize] =
271 ResponseExpectedFlag::False;
272 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::WriteFirmware) as usize] = ResponseExpectedFlag::AlwaysTrue;
273 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetStatusLedConfig) as usize] = ResponseExpectedFlag::False;
274 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetStatusLedConfig) as usize] =
275 ResponseExpectedFlag::AlwaysTrue;
276 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetChipTemperature) as usize] =
277 ResponseExpectedFlag::AlwaysTrue;
278 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
279 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
280 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
281 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
282 result
283 }
284
285 pub fn get_response_expected(&mut self, fun: IndustrialPtcBrickletFunction) -> Result<bool, GetResponseExpectedError> {
300 self.device.get_response_expected(u8::from(fun))
301 }
302
303 pub fn set_response_expected(
312 &mut self,
313 fun: IndustrialPtcBrickletFunction,
314 response_expected: bool,
315 ) -> Result<(), SetResponseExpectedError> {
316 self.device.set_response_expected(u8::from(fun), response_expected)
317 }
318
319 pub fn set_response_expected_all(&mut self, response_expected: bool) {
321 self.device.set_response_expected_all(response_expected)
322 }
323
324 pub fn get_api_version(&self) -> [u8; 3] {
327 self.device.api_version
328 }
329
330 pub async fn get_temperature_callback_receiver(&mut self) -> impl Stream<Item = i32> {
338 self.device
339 .get_callback_receiver(u8::from(IndustrialPtcBrickletFunction::CallbackTemperature))
340 .await
341 .map(|p| i32::from_le_byte_slice(p.body()))
342 }
343
344 pub async fn get_resistance_callback_receiver(&mut self) -> impl Stream<Item = i32> {
349 self.device
350 .get_callback_receiver(u8::from(IndustrialPtcBrickletFunction::CallbackResistance))
351 .await
352 .map(|p| i32::from_le_byte_slice(p.body()))
353 }
354
355 pub async fn get_sensor_connected_callback_receiver(&mut self) -> impl Stream<Item = bool> {
360 self.device
361 .get_callback_receiver(u8::from(IndustrialPtcBrickletFunction::CallbackSensorConnected))
362 .await
363 .map(|p| bool::from_le_byte_slice(p.body()))
364 }
365
366 pub async fn get_temperature(&mut self) -> Result<i32, TinkerforgeError> {
373 let payload = [0; 0];
374
375 #[allow(unused_variables)]
376 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::GetTemperature), &payload).await?;
377 Ok(i32::from_le_byte_slice(result.body()))
378 }
379
380 pub async fn set_temperature_callback_configuration(
413 &mut self,
414 period: u32,
415 value_has_to_change: bool,
416 option: char,
417 min: i32,
418 max: i32,
419 ) -> Result<(), TinkerforgeError> {
420 let mut payload = [0; 14];
421 period.write_to_slice(&mut payload[0..4]);
422 value_has_to_change.write_to_slice(&mut payload[4..5]);
423 option.write_to_slice(&mut payload[5..6]);
424 min.write_to_slice(&mut payload[6..10]);
425 max.write_to_slice(&mut payload[10..14]);
426
427 #[allow(unused_variables)]
428 let result = self.device.set(u8::from(IndustrialPtcBrickletFunction::SetTemperatureCallbackConfiguration), &payload).await?;
429 Ok(())
430 }
431
432 pub async fn get_temperature_callback_configuration(&mut self) -> Result<TemperatureCallbackConfiguration, TinkerforgeError> {
441 let payload = [0; 0];
442
443 #[allow(unused_variables)]
444 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::GetTemperatureCallbackConfiguration), &payload).await?;
445 Ok(TemperatureCallbackConfiguration::from_le_byte_slice(result.body()))
446 }
447
448 pub async fn get_resistance(&mut self) -> Result<i32, TinkerforgeError> {
460 let payload = [0; 0];
461
462 #[allow(unused_variables)]
463 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::GetResistance), &payload).await?;
464 Ok(i32::from_le_byte_slice(result.body()))
465 }
466
467 pub async fn set_resistance_callback_configuration(
500 &mut self,
501 period: u32,
502 value_has_to_change: bool,
503 option: char,
504 min: i32,
505 max: i32,
506 ) -> Result<(), TinkerforgeError> {
507 let mut payload = [0; 14];
508 period.write_to_slice(&mut payload[0..4]);
509 value_has_to_change.write_to_slice(&mut payload[4..5]);
510 option.write_to_slice(&mut payload[5..6]);
511 min.write_to_slice(&mut payload[6..10]);
512 max.write_to_slice(&mut payload[10..14]);
513
514 #[allow(unused_variables)]
515 let result = self.device.set(u8::from(IndustrialPtcBrickletFunction::SetResistanceCallbackConfiguration), &payload).await?;
516 Ok(())
517 }
518
519 pub async fn get_resistance_callback_configuration(&mut self) -> Result<ResistanceCallbackConfiguration, TinkerforgeError> {
528 let payload = [0; 0];
529
530 #[allow(unused_variables)]
531 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::GetResistanceCallbackConfiguration), &payload).await?;
532 Ok(ResistanceCallbackConfiguration::from_le_byte_slice(result.body()))
533 }
534
535 pub async fn set_noise_rejection_filter(&mut self, filter: u8) -> Result<(), TinkerforgeError> {
544 let mut payload = [0; 1];
545 filter.write_to_slice(&mut payload[0..1]);
546
547 #[allow(unused_variables)]
548 let result = self.device.set(u8::from(IndustrialPtcBrickletFunction::SetNoiseRejectionFilter), &payload).await?;
549 Ok(())
550 }
551
552 pub async fn get_noise_rejection_filter(&mut self) -> Result<u8, TinkerforgeError> {
559 let payload = [0; 0];
560
561 #[allow(unused_variables)]
562 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::GetNoiseRejectionFilter), &payload).await?;
563 Ok(u8::from_le_byte_slice(result.body()))
564 }
565
566 pub async fn is_sensor_connected(&mut self) -> Result<bool, TinkerforgeError> {
576 let payload = [0; 0];
577
578 #[allow(unused_variables)]
579 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::IsSensorConnected), &payload).await?;
580 Ok(bool::from_le_byte_slice(result.body()))
581 }
582
583 pub async fn set_wire_mode(&mut self, mode: u8) -> Result<(), TinkerforgeError> {
592 let mut payload = [0; 1];
593 mode.write_to_slice(&mut payload[0..1]);
594
595 #[allow(unused_variables)]
596 let result = self.device.set(u8::from(IndustrialPtcBrickletFunction::SetWireMode), &payload).await?;
597 Ok(())
598 }
599
600 pub async fn get_wire_mode(&mut self) -> Result<u8, TinkerforgeError> {
607 let payload = [0; 0];
608
609 #[allow(unused_variables)]
610 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::GetWireMode), &payload).await?;
611 Ok(u8::from_le_byte_slice(result.body()))
612 }
613
614 pub async fn set_moving_average_configuration(
626 &mut self,
627 moving_average_length_resistance: u16,
628 moving_average_length_temperature: u16,
629 ) -> Result<(), TinkerforgeError> {
630 let mut payload = [0; 4];
631 moving_average_length_resistance.write_to_slice(&mut payload[0..2]);
632 moving_average_length_temperature.write_to_slice(&mut payload[2..4]);
633
634 #[allow(unused_variables)]
635 let result = self.device.set(u8::from(IndustrialPtcBrickletFunction::SetMovingAverageConfiguration), &payload).await?;
636 Ok(())
637 }
638
639 pub async fn get_moving_average_configuration(&mut self) -> Result<MovingAverageConfiguration, TinkerforgeError> {
641 let payload = [0; 0];
642
643 #[allow(unused_variables)]
644 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::GetMovingAverageConfiguration), &payload).await?;
645 Ok(MovingAverageConfiguration::from_le_byte_slice(result.body()))
646 }
647
648 pub async fn set_sensor_connected_callback_configuration(&mut self, enabled: bool) -> Result<(), TinkerforgeError> {
651 let mut payload = [0; 1];
652 enabled.write_to_slice(&mut payload[0..1]);
653
654 #[allow(unused_variables)]
655 let result = self.device.set(u8::from(IndustrialPtcBrickletFunction::SetSensorConnectedCallbackConfiguration), &payload).await?;
656 Ok(())
657 }
658
659 pub async fn get_sensor_connected_callback_configuration(&mut self) -> Result<bool, TinkerforgeError> {
661 let payload = [0; 0];
662
663 #[allow(unused_variables)]
664 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::GetSensorConnectedCallbackConfiguration), &payload).await?;
665 Ok(bool::from_le_byte_slice(result.body()))
666 }
667
668 pub async fn get_spitfp_error_count(&mut self) -> Result<SpitfpErrorCount, TinkerforgeError> {
680 let payload = [0; 0];
681
682 #[allow(unused_variables)]
683 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::GetSpitfpErrorCount), &payload).await?;
684 Ok(SpitfpErrorCount::from_le_byte_slice(result.body()))
685 }
686
687 pub async fn set_bootloader_mode(&mut self, mode: u8) -> Result<u8, TinkerforgeError> {
710 let mut payload = [0; 1];
711 mode.write_to_slice(&mut payload[0..1]);
712
713 #[allow(unused_variables)]
714 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::SetBootloaderMode), &payload).await?;
715 Ok(u8::from_le_byte_slice(result.body()))
716 }
717
718 pub async fn get_bootloader_mode(&mut self) -> Result<u8, TinkerforgeError> {
727 let payload = [0; 0];
728
729 #[allow(unused_variables)]
730 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::GetBootloaderMode), &payload).await?;
731 Ok(u8::from_le_byte_slice(result.body()))
732 }
733
734 pub async fn set_write_firmware_pointer(&mut self, pointer: u32) -> Result<(), TinkerforgeError> {
741 let mut payload = [0; 4];
742 pointer.write_to_slice(&mut payload[0..4]);
743
744 #[allow(unused_variables)]
745 let result = self.device.set(u8::from(IndustrialPtcBrickletFunction::SetWriteFirmwarePointer), &payload).await?;
746 Ok(())
747 }
748
749 pub async fn write_firmware(&mut self, data: &[u8; 64]) -> Result<u8, TinkerforgeError> {
758 let mut payload = [0; 64];
759 data.write_to_slice(&mut payload[0..64]);
760
761 #[allow(unused_variables)]
762 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::WriteFirmware), &payload).await?;
763 Ok(u8::from_le_byte_slice(result.body()))
764 }
765
766 pub async fn set_status_led_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
780 let mut payload = [0; 1];
781 config.write_to_slice(&mut payload[0..1]);
782
783 #[allow(unused_variables)]
784 let result = self.device.set(u8::from(IndustrialPtcBrickletFunction::SetStatusLedConfig), &payload).await?;
785 Ok(())
786 }
787
788 pub async fn get_status_led_config(&mut self) -> Result<u8, TinkerforgeError> {
796 let payload = [0; 0];
797
798 #[allow(unused_variables)]
799 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::GetStatusLedConfig), &payload).await?;
800 Ok(u8::from_le_byte_slice(result.body()))
801 }
802
803 pub async fn get_chip_temperature(&mut self) -> Result<i16, TinkerforgeError> {
810 let payload = [0; 0];
811
812 #[allow(unused_variables)]
813 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::GetChipTemperature), &payload).await?;
814 Ok(i16::from_le_byte_slice(result.body()))
815 }
816
817 pub async fn reset(&mut self) -> Result<(), TinkerforgeError> {
824 let payload = [0; 0];
825
826 #[allow(unused_variables)]
827 let result = self.device.set(u8::from(IndustrialPtcBrickletFunction::Reset), &payload).await?;
828 Ok(())
829 }
830
831 pub async fn write_uid(&mut self, uid: u32) -> Result<(), TinkerforgeError> {
837 let mut payload = [0; 4];
838 uid.write_to_slice(&mut payload[0..4]);
839
840 #[allow(unused_variables)]
841 let result = self.device.set(u8::from(IndustrialPtcBrickletFunction::WriteUid), &payload).await?;
842 Ok(())
843 }
844
845 pub async fn read_uid(&mut self) -> Result<u32, TinkerforgeError> {
848 let payload = [0; 0];
849
850 #[allow(unused_variables)]
851 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::ReadUid), &payload).await?;
852 Ok(u32::from_le_byte_slice(result.body()))
853 }
854
855 pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
866 let payload = [0; 0];
867
868 #[allow(unused_variables)]
869 let result = self.device.get(u8::from(IndustrialPtcBrickletFunction::GetIdentity), &payload).await?;
870 Ok(Identity::from_le_byte_slice(result.body()))
871 }
872}