1use crate::{
15 byte_converter::*, converting_callback_receiver::ConvertingCallbackReceiver, converting_receiver::ConvertingReceiver, device::*,
16 ip_connection::GetRequestSender,
17};
18pub enum IndustrialPtcBrickletFunction {
19 GetTemperature,
20 SetTemperatureCallbackConfiguration,
21 GetTemperatureCallbackConfiguration,
22 GetResistance,
23 SetResistanceCallbackConfiguration,
24 GetResistanceCallbackConfiguration,
25 SetNoiseRejectionFilter,
26 GetNoiseRejectionFilter,
27 IsSensorConnected,
28 SetWireMode,
29 GetWireMode,
30 SetMovingAverageConfiguration,
31 GetMovingAverageConfiguration,
32 SetSensorConnectedCallbackConfiguration,
33 GetSensorConnectedCallbackConfiguration,
34 GetSpitfpErrorCount,
35 SetBootloaderMode,
36 GetBootloaderMode,
37 SetWriteFirmwarePointer,
38 WriteFirmware,
39 SetStatusLedConfig,
40 GetStatusLedConfig,
41 GetChipTemperature,
42 Reset,
43 WriteUid,
44 ReadUid,
45 GetIdentity,
46 CallbackTemperature,
47 CallbackResistance,
48 CallbackSensorConnected,
49}
50impl From<IndustrialPtcBrickletFunction> for u8 {
51 fn from(fun: IndustrialPtcBrickletFunction) -> Self {
52 match fun {
53 IndustrialPtcBrickletFunction::GetTemperature => 1,
54 IndustrialPtcBrickletFunction::SetTemperatureCallbackConfiguration => 2,
55 IndustrialPtcBrickletFunction::GetTemperatureCallbackConfiguration => 3,
56 IndustrialPtcBrickletFunction::GetResistance => 5,
57 IndustrialPtcBrickletFunction::SetResistanceCallbackConfiguration => 6,
58 IndustrialPtcBrickletFunction::GetResistanceCallbackConfiguration => 7,
59 IndustrialPtcBrickletFunction::SetNoiseRejectionFilter => 9,
60 IndustrialPtcBrickletFunction::GetNoiseRejectionFilter => 10,
61 IndustrialPtcBrickletFunction::IsSensorConnected => 11,
62 IndustrialPtcBrickletFunction::SetWireMode => 12,
63 IndustrialPtcBrickletFunction::GetWireMode => 13,
64 IndustrialPtcBrickletFunction::SetMovingAverageConfiguration => 14,
65 IndustrialPtcBrickletFunction::GetMovingAverageConfiguration => 15,
66 IndustrialPtcBrickletFunction::SetSensorConnectedCallbackConfiguration => 16,
67 IndustrialPtcBrickletFunction::GetSensorConnectedCallbackConfiguration => 17,
68 IndustrialPtcBrickletFunction::GetSpitfpErrorCount => 234,
69 IndustrialPtcBrickletFunction::SetBootloaderMode => 235,
70 IndustrialPtcBrickletFunction::GetBootloaderMode => 236,
71 IndustrialPtcBrickletFunction::SetWriteFirmwarePointer => 237,
72 IndustrialPtcBrickletFunction::WriteFirmware => 238,
73 IndustrialPtcBrickletFunction::SetStatusLedConfig => 239,
74 IndustrialPtcBrickletFunction::GetStatusLedConfig => 240,
75 IndustrialPtcBrickletFunction::GetChipTemperature => 242,
76 IndustrialPtcBrickletFunction::Reset => 243,
77 IndustrialPtcBrickletFunction::WriteUid => 248,
78 IndustrialPtcBrickletFunction::ReadUid => 249,
79 IndustrialPtcBrickletFunction::GetIdentity => 255,
80 IndustrialPtcBrickletFunction::CallbackTemperature => 4,
81 IndustrialPtcBrickletFunction::CallbackResistance => 8,
82 IndustrialPtcBrickletFunction::CallbackSensorConnected => 18,
83 }
84 }
85}
86pub const INDUSTRIAL_PTC_BRICKLET_THRESHOLD_OPTION_OFF: char = 'x';
87pub const INDUSTRIAL_PTC_BRICKLET_THRESHOLD_OPTION_OUTSIDE: char = 'o';
88pub const INDUSTRIAL_PTC_BRICKLET_THRESHOLD_OPTION_INSIDE: char = 'i';
89pub const INDUSTRIAL_PTC_BRICKLET_THRESHOLD_OPTION_SMALLER: char = '<';
90pub const INDUSTRIAL_PTC_BRICKLET_THRESHOLD_OPTION_GREATER: char = '>';
91pub const INDUSTRIAL_PTC_BRICKLET_FILTER_OPTION_50HZ: u8 = 0;
92pub const INDUSTRIAL_PTC_BRICKLET_FILTER_OPTION_60HZ: u8 = 1;
93pub const INDUSTRIAL_PTC_BRICKLET_WIRE_MODE_2: u8 = 2;
94pub const INDUSTRIAL_PTC_BRICKLET_WIRE_MODE_3: u8 = 3;
95pub const INDUSTRIAL_PTC_BRICKLET_WIRE_MODE_4: u8 = 4;
96pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
97pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
98pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
99pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
100pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
101pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
102pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
103pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
104pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
105pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
106pub const INDUSTRIAL_PTC_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
107pub const INDUSTRIAL_PTC_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
108pub const INDUSTRIAL_PTC_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
109pub const INDUSTRIAL_PTC_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
110pub const INDUSTRIAL_PTC_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
111
112#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
113pub struct TemperatureCallbackConfiguration {
114 pub period: u32,
115 pub value_has_to_change: bool,
116 pub option: char,
117 pub min: i32,
118 pub max: i32,
119}
120impl FromByteSlice for TemperatureCallbackConfiguration {
121 fn bytes_expected() -> usize { 14 }
122 fn from_le_byte_slice(bytes: &[u8]) -> TemperatureCallbackConfiguration {
123 TemperatureCallbackConfiguration {
124 period: <u32>::from_le_byte_slice(&bytes[0..4]),
125 value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
126 option: <char>::from_le_byte_slice(&bytes[5..6]),
127 min: <i32>::from_le_byte_slice(&bytes[6..10]),
128 max: <i32>::from_le_byte_slice(&bytes[10..14]),
129 }
130 }
131}
132
133#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
134pub struct ResistanceCallbackConfiguration {
135 pub period: u32,
136 pub value_has_to_change: bool,
137 pub option: char,
138 pub min: i32,
139 pub max: i32,
140}
141impl FromByteSlice for ResistanceCallbackConfiguration {
142 fn bytes_expected() -> usize { 14 }
143 fn from_le_byte_slice(bytes: &[u8]) -> ResistanceCallbackConfiguration {
144 ResistanceCallbackConfiguration {
145 period: <u32>::from_le_byte_slice(&bytes[0..4]),
146 value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
147 option: <char>::from_le_byte_slice(&bytes[5..6]),
148 min: <i32>::from_le_byte_slice(&bytes[6..10]),
149 max: <i32>::from_le_byte_slice(&bytes[10..14]),
150 }
151 }
152}
153
154#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
155pub struct MovingAverageConfiguration {
156 pub moving_average_length_resistance: u16,
157 pub moving_average_length_temperature: u16,
158}
159impl FromByteSlice for MovingAverageConfiguration {
160 fn bytes_expected() -> usize { 4 }
161 fn from_le_byte_slice(bytes: &[u8]) -> MovingAverageConfiguration {
162 MovingAverageConfiguration {
163 moving_average_length_resistance: <u16>::from_le_byte_slice(&bytes[0..2]),
164 moving_average_length_temperature: <u16>::from_le_byte_slice(&bytes[2..4]),
165 }
166 }
167}
168
169#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
170pub struct SpitfpErrorCount {
171 pub error_count_ack_checksum: u32,
172 pub error_count_message_checksum: u32,
173 pub error_count_frame: u32,
174 pub error_count_overflow: u32,
175}
176impl FromByteSlice for SpitfpErrorCount {
177 fn bytes_expected() -> usize { 16 }
178 fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
179 SpitfpErrorCount {
180 error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
181 error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
182 error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
183 error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
184 }
185 }
186}
187
188#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
189pub struct Identity {
190 pub uid: String,
191 pub connected_uid: String,
192 pub position: char,
193 pub hardware_version: [u8; 3],
194 pub firmware_version: [u8; 3],
195 pub device_identifier: u16,
196}
197impl FromByteSlice for Identity {
198 fn bytes_expected() -> usize { 25 }
199 fn from_le_byte_slice(bytes: &[u8]) -> Identity {
200 Identity {
201 uid: <String>::from_le_byte_slice(&bytes[0..8]),
202 connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
203 position: <char>::from_le_byte_slice(&bytes[16..17]),
204 hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
205 firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
206 device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
207 }
208 }
209}
210
211#[derive(Clone)]
213pub struct IndustrialPtcBricklet {
214 device: Device,
215}
216impl IndustrialPtcBricklet {
217 pub const DEVICE_IDENTIFIER: u16 = 2164;
218 pub const DEVICE_DISPLAY_NAME: &'static str = "Industrial PTC Bricklet";
219 pub fn new<T: GetRequestSender>(uid: &str, req_sender: T) -> IndustrialPtcBricklet {
221 let mut result = IndustrialPtcBricklet { device: Device::new([2, 0, 0], uid, req_sender, 0) };
222 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetTemperature) as usize] =
223 ResponseExpectedFlag::AlwaysTrue;
224 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetTemperatureCallbackConfiguration) as usize] =
225 ResponseExpectedFlag::True;
226 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetTemperatureCallbackConfiguration) as usize] =
227 ResponseExpectedFlag::AlwaysTrue;
228 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetResistance) as usize] = ResponseExpectedFlag::AlwaysTrue;
229 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetResistanceCallbackConfiguration) as usize] =
230 ResponseExpectedFlag::True;
231 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetResistanceCallbackConfiguration) as usize] =
232 ResponseExpectedFlag::AlwaysTrue;
233 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetNoiseRejectionFilter) as usize] =
234 ResponseExpectedFlag::False;
235 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetNoiseRejectionFilter) as usize] =
236 ResponseExpectedFlag::AlwaysTrue;
237 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::IsSensorConnected) as usize] =
238 ResponseExpectedFlag::AlwaysTrue;
239 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetWireMode) as usize] = ResponseExpectedFlag::False;
240 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetWireMode) as usize] = ResponseExpectedFlag::AlwaysTrue;
241 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetMovingAverageConfiguration) as usize] =
242 ResponseExpectedFlag::False;
243 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetMovingAverageConfiguration) as usize] =
244 ResponseExpectedFlag::AlwaysTrue;
245 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetSensorConnectedCallbackConfiguration) as usize] =
246 ResponseExpectedFlag::True;
247 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetSensorConnectedCallbackConfiguration) as usize] =
248 ResponseExpectedFlag::AlwaysTrue;
249 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetSpitfpErrorCount) as usize] =
250 ResponseExpectedFlag::AlwaysTrue;
251 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetBootloaderMode) as usize] =
252 ResponseExpectedFlag::AlwaysTrue;
253 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetBootloaderMode) as usize] =
254 ResponseExpectedFlag::AlwaysTrue;
255 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetWriteFirmwarePointer) as usize] =
256 ResponseExpectedFlag::False;
257 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::WriteFirmware) as usize] = ResponseExpectedFlag::AlwaysTrue;
258 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::SetStatusLedConfig) as usize] = ResponseExpectedFlag::False;
259 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetStatusLedConfig) as usize] =
260 ResponseExpectedFlag::AlwaysTrue;
261 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetChipTemperature) as usize] =
262 ResponseExpectedFlag::AlwaysTrue;
263 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
264 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
265 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
266 result.device.response_expected[u8::from(IndustrialPtcBrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
267 result
268 }
269
270 pub fn get_response_expected(&mut self, fun: IndustrialPtcBrickletFunction) -> Result<bool, GetResponseExpectedError> {
285 self.device.get_response_expected(u8::from(fun))
286 }
287
288 pub fn set_response_expected(
297 &mut self,
298 fun: IndustrialPtcBrickletFunction,
299 response_expected: bool,
300 ) -> Result<(), SetResponseExpectedError> {
301 self.device.set_response_expected(u8::from(fun), response_expected)
302 }
303
304 pub fn set_response_expected_all(&mut self, response_expected: bool) { self.device.set_response_expected_all(response_expected) }
306
307 pub fn get_api_version(&self) -> [u8; 3] { self.device.api_version }
310
311 pub fn get_temperature_callback_receiver(&self) -> ConvertingCallbackReceiver<i32> {
319 self.device.get_callback_receiver(u8::from(IndustrialPtcBrickletFunction::CallbackTemperature))
320 }
321
322 pub fn get_resistance_callback_receiver(&self) -> ConvertingCallbackReceiver<i32> {
327 self.device.get_callback_receiver(u8::from(IndustrialPtcBrickletFunction::CallbackResistance))
328 }
329
330 pub fn get_sensor_connected_callback_receiver(&self) -> ConvertingCallbackReceiver<bool> {
335 self.device.get_callback_receiver(u8::from(IndustrialPtcBrickletFunction::CallbackSensorConnected))
336 }
337
338 pub fn get_temperature(&self) -> ConvertingReceiver<i32> {
345 let payload = vec![0; 0];
346
347 self.device.get(u8::from(IndustrialPtcBrickletFunction::GetTemperature), payload)
348 }
349
350 pub fn set_temperature_callback_configuration(
383 &self,
384 period: u32,
385 value_has_to_change: bool,
386 option: char,
387 min: i32,
388 max: i32,
389 ) -> ConvertingReceiver<()> {
390 let mut payload = vec![0; 14];
391 payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
392 payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
393 payload[5..6].copy_from_slice(&<char>::to_le_byte_vec(option));
394 payload[6..10].copy_from_slice(&<i32>::to_le_byte_vec(min));
395 payload[10..14].copy_from_slice(&<i32>::to_le_byte_vec(max));
396
397 self.device.set(u8::from(IndustrialPtcBrickletFunction::SetTemperatureCallbackConfiguration), payload)
398 }
399
400 pub fn get_temperature_callback_configuration(&self) -> ConvertingReceiver<TemperatureCallbackConfiguration> {
409 let payload = vec![0; 0];
410
411 self.device.get(u8::from(IndustrialPtcBrickletFunction::GetTemperatureCallbackConfiguration), payload)
412 }
413
414 pub fn get_resistance(&self) -> ConvertingReceiver<i32> {
426 let payload = vec![0; 0];
427
428 self.device.get(u8::from(IndustrialPtcBrickletFunction::GetResistance), payload)
429 }
430
431 pub fn set_resistance_callback_configuration(
464 &self,
465 period: u32,
466 value_has_to_change: bool,
467 option: char,
468 min: i32,
469 max: i32,
470 ) -> ConvertingReceiver<()> {
471 let mut payload = vec![0; 14];
472 payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
473 payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
474 payload[5..6].copy_from_slice(&<char>::to_le_byte_vec(option));
475 payload[6..10].copy_from_slice(&<i32>::to_le_byte_vec(min));
476 payload[10..14].copy_from_slice(&<i32>::to_le_byte_vec(max));
477
478 self.device.set(u8::from(IndustrialPtcBrickletFunction::SetResistanceCallbackConfiguration), payload)
479 }
480
481 pub fn get_resistance_callback_configuration(&self) -> ConvertingReceiver<ResistanceCallbackConfiguration> {
490 let payload = vec![0; 0];
491
492 self.device.get(u8::from(IndustrialPtcBrickletFunction::GetResistanceCallbackConfiguration), payload)
493 }
494
495 pub fn set_noise_rejection_filter(&self, filter: u8) -> ConvertingReceiver<()> {
504 let mut payload = vec![0; 1];
505 payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(filter));
506
507 self.device.set(u8::from(IndustrialPtcBrickletFunction::SetNoiseRejectionFilter), payload)
508 }
509
510 pub fn get_noise_rejection_filter(&self) -> ConvertingReceiver<u8> {
517 let payload = vec![0; 0];
518
519 self.device.get(u8::from(IndustrialPtcBrickletFunction::GetNoiseRejectionFilter), payload)
520 }
521
522 pub fn is_sensor_connected(&self) -> ConvertingReceiver<bool> {
532 let payload = vec![0; 0];
533
534 self.device.get(u8::from(IndustrialPtcBrickletFunction::IsSensorConnected), payload)
535 }
536
537 pub fn set_wire_mode(&self, mode: u8) -> ConvertingReceiver<()> {
546 let mut payload = vec![0; 1];
547 payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(mode));
548
549 self.device.set(u8::from(IndustrialPtcBrickletFunction::SetWireMode), payload)
550 }
551
552 pub fn get_wire_mode(&self) -> ConvertingReceiver<u8> {
559 let payload = vec![0; 0];
560
561 self.device.get(u8::from(IndustrialPtcBrickletFunction::GetWireMode), payload)
562 }
563
564 pub fn set_moving_average_configuration(
576 &self,
577 moving_average_length_resistance: u16,
578 moving_average_length_temperature: u16,
579 ) -> ConvertingReceiver<()> {
580 let mut payload = vec![0; 4];
581 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(moving_average_length_resistance));
582 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(moving_average_length_temperature));
583
584 self.device.set(u8::from(IndustrialPtcBrickletFunction::SetMovingAverageConfiguration), payload)
585 }
586
587 pub fn get_moving_average_configuration(&self) -> ConvertingReceiver<MovingAverageConfiguration> {
589 let payload = vec![0; 0];
590
591 self.device.get(u8::from(IndustrialPtcBrickletFunction::GetMovingAverageConfiguration), payload)
592 }
593
594 pub fn set_sensor_connected_callback_configuration(&self, enabled: bool) -> ConvertingReceiver<()> {
597 let mut payload = vec![0; 1];
598 payload[0..1].copy_from_slice(&<bool>::to_le_byte_vec(enabled));
599
600 self.device.set(u8::from(IndustrialPtcBrickletFunction::SetSensorConnectedCallbackConfiguration), payload)
601 }
602
603 pub fn get_sensor_connected_callback_configuration(&self) -> ConvertingReceiver<bool> {
605 let payload = vec![0; 0];
606
607 self.device.get(u8::from(IndustrialPtcBrickletFunction::GetSensorConnectedCallbackConfiguration), payload)
608 }
609
610 pub fn get_spitfp_error_count(&self) -> ConvertingReceiver<SpitfpErrorCount> {
622 let payload = vec![0; 0];
623
624 self.device.get(u8::from(IndustrialPtcBrickletFunction::GetSpitfpErrorCount), payload)
625 }
626
627 pub fn set_bootloader_mode(&self, mode: u8) -> ConvertingReceiver<u8> {
650 let mut payload = vec![0; 1];
651 payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(mode));
652
653 self.device.get(u8::from(IndustrialPtcBrickletFunction::SetBootloaderMode), payload)
654 }
655
656 pub fn get_bootloader_mode(&self) -> ConvertingReceiver<u8> {
665 let payload = vec![0; 0];
666
667 self.device.get(u8::from(IndustrialPtcBrickletFunction::GetBootloaderMode), payload)
668 }
669
670 pub fn set_write_firmware_pointer(&self, pointer: u32) -> ConvertingReceiver<()> {
677 let mut payload = vec![0; 4];
678 payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(pointer));
679
680 self.device.set(u8::from(IndustrialPtcBrickletFunction::SetWriteFirmwarePointer), payload)
681 }
682
683 pub fn write_firmware(&self, data: [u8; 64]) -> ConvertingReceiver<u8> {
692 let mut payload = vec![0; 64];
693 payload[0..64].copy_from_slice(&<[u8; 64]>::to_le_byte_vec(data));
694
695 self.device.get(u8::from(IndustrialPtcBrickletFunction::WriteFirmware), payload)
696 }
697
698 pub fn set_status_led_config(&self, config: u8) -> ConvertingReceiver<()> {
712 let mut payload = vec![0; 1];
713 payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(config));
714
715 self.device.set(u8::from(IndustrialPtcBrickletFunction::SetStatusLedConfig), payload)
716 }
717
718 pub fn get_status_led_config(&self) -> ConvertingReceiver<u8> {
726 let payload = vec![0; 0];
727
728 self.device.get(u8::from(IndustrialPtcBrickletFunction::GetStatusLedConfig), payload)
729 }
730
731 pub fn get_chip_temperature(&self) -> ConvertingReceiver<i16> {
738 let payload = vec![0; 0];
739
740 self.device.get(u8::from(IndustrialPtcBrickletFunction::GetChipTemperature), payload)
741 }
742
743 pub fn reset(&self) -> ConvertingReceiver<()> {
750 let payload = vec![0; 0];
751
752 self.device.set(u8::from(IndustrialPtcBrickletFunction::Reset), payload)
753 }
754
755 pub fn write_uid(&self, uid: u32) -> ConvertingReceiver<()> {
761 let mut payload = vec![0; 4];
762 payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(uid));
763
764 self.device.set(u8::from(IndustrialPtcBrickletFunction::WriteUid), payload)
765 }
766
767 pub fn read_uid(&self) -> ConvertingReceiver<u32> {
770 let payload = vec![0; 0];
771
772 self.device.get(u8::from(IndustrialPtcBrickletFunction::ReadUid), payload)
773 }
774
775 pub fn get_identity(&self) -> ConvertingReceiver<Identity> {
786 let payload = vec![0; 0];
787
788 self.device.get(u8::from(IndustrialPtcBrickletFunction::GetIdentity), payload)
789 }
790}