1#[allow(unused_imports)]
15use crate::{
16 base58::Uid, byte_converter::*, converting_high_level_callback_receiver::ConvertingHighLevelCallbackReceiver,
17 converting_receiver::BrickletRecvTimeoutError, device::*, error::TinkerforgeError, ip_connection::async_io::AsyncIpConnection,
18 low_level_traits::LowLevelRead,
19};
20#[allow(unused_imports)]
21use futures_core::Stream;
22#[allow(unused_imports)]
23use tokio_stream::StreamExt;
24pub enum SoundPressureLevelBrickletFunction {
25 GetDecibel,
26 SetDecibelCallbackConfiguration,
27 GetDecibelCallbackConfiguration,
28 GetSpectrumLowLevel,
29 SetSpectrumCallbackConfiguration,
30 GetSpectrumCallbackConfiguration,
31 SetConfiguration,
32 GetConfiguration,
33 GetSpitfpErrorCount,
34 SetBootloaderMode,
35 GetBootloaderMode,
36 SetWriteFirmwarePointer,
37 WriteFirmware,
38 SetStatusLedConfig,
39 GetStatusLedConfig,
40 GetChipTemperature,
41 Reset,
42 WriteUid,
43 ReadUid,
44 GetIdentity,
45 CallbackDecibel,
46 CallbackSpectrumLowLevel,
47}
48impl From<SoundPressureLevelBrickletFunction> for u8 {
49 fn from(fun: SoundPressureLevelBrickletFunction) -> Self {
50 match fun {
51 SoundPressureLevelBrickletFunction::GetDecibel => 1,
52 SoundPressureLevelBrickletFunction::SetDecibelCallbackConfiguration => 2,
53 SoundPressureLevelBrickletFunction::GetDecibelCallbackConfiguration => 3,
54 SoundPressureLevelBrickletFunction::GetSpectrumLowLevel => 5,
55 SoundPressureLevelBrickletFunction::SetSpectrumCallbackConfiguration => 6,
56 SoundPressureLevelBrickletFunction::GetSpectrumCallbackConfiguration => 7,
57 SoundPressureLevelBrickletFunction::SetConfiguration => 9,
58 SoundPressureLevelBrickletFunction::GetConfiguration => 10,
59 SoundPressureLevelBrickletFunction::GetSpitfpErrorCount => 234,
60 SoundPressureLevelBrickletFunction::SetBootloaderMode => 235,
61 SoundPressureLevelBrickletFunction::GetBootloaderMode => 236,
62 SoundPressureLevelBrickletFunction::SetWriteFirmwarePointer => 237,
63 SoundPressureLevelBrickletFunction::WriteFirmware => 238,
64 SoundPressureLevelBrickletFunction::SetStatusLedConfig => 239,
65 SoundPressureLevelBrickletFunction::GetStatusLedConfig => 240,
66 SoundPressureLevelBrickletFunction::GetChipTemperature => 242,
67 SoundPressureLevelBrickletFunction::Reset => 243,
68 SoundPressureLevelBrickletFunction::WriteUid => 248,
69 SoundPressureLevelBrickletFunction::ReadUid => 249,
70 SoundPressureLevelBrickletFunction::GetIdentity => 255,
71 SoundPressureLevelBrickletFunction::CallbackDecibel => 4,
72 SoundPressureLevelBrickletFunction::CallbackSpectrumLowLevel => 8,
73 }
74 }
75}
76pub const SOUND_PRESSURE_LEVEL_BRICKLET_THRESHOLD_OPTION_OFF: char = 'x';
77pub const SOUND_PRESSURE_LEVEL_BRICKLET_THRESHOLD_OPTION_OUTSIDE: char = 'o';
78pub const SOUND_PRESSURE_LEVEL_BRICKLET_THRESHOLD_OPTION_INSIDE: char = 'i';
79pub const SOUND_PRESSURE_LEVEL_BRICKLET_THRESHOLD_OPTION_SMALLER: char = '<';
80pub const SOUND_PRESSURE_LEVEL_BRICKLET_THRESHOLD_OPTION_GREATER: char = '>';
81pub const SOUND_PRESSURE_LEVEL_BRICKLET_FFT_SIZE_128: u8 = 0;
82pub const SOUND_PRESSURE_LEVEL_BRICKLET_FFT_SIZE_256: u8 = 1;
83pub const SOUND_PRESSURE_LEVEL_BRICKLET_FFT_SIZE_512: u8 = 2;
84pub const SOUND_PRESSURE_LEVEL_BRICKLET_FFT_SIZE_1024: u8 = 3;
85pub const SOUND_PRESSURE_LEVEL_BRICKLET_WEIGHTING_A: u8 = 0;
86pub const SOUND_PRESSURE_LEVEL_BRICKLET_WEIGHTING_B: u8 = 1;
87pub const SOUND_PRESSURE_LEVEL_BRICKLET_WEIGHTING_C: u8 = 2;
88pub const SOUND_PRESSURE_LEVEL_BRICKLET_WEIGHTING_D: u8 = 3;
89pub const SOUND_PRESSURE_LEVEL_BRICKLET_WEIGHTING_Z: u8 = 4;
90pub const SOUND_PRESSURE_LEVEL_BRICKLET_WEIGHTING_ITU_R_468: u8 = 5;
91pub const SOUND_PRESSURE_LEVEL_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
92pub const SOUND_PRESSURE_LEVEL_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
93pub const SOUND_PRESSURE_LEVEL_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
94pub const SOUND_PRESSURE_LEVEL_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
95pub const SOUND_PRESSURE_LEVEL_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
96pub const SOUND_PRESSURE_LEVEL_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
97pub const SOUND_PRESSURE_LEVEL_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
98pub const SOUND_PRESSURE_LEVEL_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
99pub const SOUND_PRESSURE_LEVEL_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
100pub const SOUND_PRESSURE_LEVEL_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
101pub const SOUND_PRESSURE_LEVEL_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
102pub const SOUND_PRESSURE_LEVEL_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
103pub const SOUND_PRESSURE_LEVEL_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
104pub const SOUND_PRESSURE_LEVEL_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
105pub const SOUND_PRESSURE_LEVEL_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
106
107#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
108pub struct DecibelCallbackConfiguration {
109 pub period: u32,
110 pub value_has_to_change: bool,
111 pub option: char,
112 pub min: u16,
113 pub max: u16,
114}
115impl FromByteSlice for DecibelCallbackConfiguration {
116 fn bytes_expected() -> usize {
117 10
118 }
119 fn from_le_byte_slice(bytes: &[u8]) -> DecibelCallbackConfiguration {
120 DecibelCallbackConfiguration {
121 period: <u32>::from_le_byte_slice(&bytes[0..4]),
122 value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
123 option: <char>::from_le_byte_slice(&bytes[5..6]),
124 min: <u16>::from_le_byte_slice(&bytes[6..8]),
125 max: <u16>::from_le_byte_slice(&bytes[8..10]),
126 }
127 }
128}
129
130#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
131pub struct SpectrumLowLevel {
132 pub spectrum_length: u16,
133 pub spectrum_chunk_offset: u16,
134 pub spectrum_chunk_data: [u16; 30],
135}
136impl FromByteSlice for SpectrumLowLevel {
137 fn bytes_expected() -> usize {
138 64
139 }
140 fn from_le_byte_slice(bytes: &[u8]) -> SpectrumLowLevel {
141 SpectrumLowLevel {
142 spectrum_length: <u16>::from_le_byte_slice(&bytes[0..2]),
143 spectrum_chunk_offset: <u16>::from_le_byte_slice(&bytes[2..4]),
144 spectrum_chunk_data: <[u16; 30]>::from_le_byte_slice(&bytes[4..64]),
145 }
146 }
147}
148impl LowLevelRead<u16, SpectrumResult> for SpectrumLowLevel {
149 fn ll_message_length(&self) -> usize {
150 self.spectrum_length as usize
151 }
152
153 fn ll_message_chunk_offset(&self) -> usize {
154 self.spectrum_chunk_offset as usize
155 }
156
157 fn ll_message_chunk_data(&self) -> &[u16] {
158 &self.spectrum_chunk_data
159 }
160
161 fn get_result(&self) -> SpectrumResult {
162 SpectrumResult {}
163 }
164}
165
166#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
167pub struct SpectrumLowLevelEvent {
168 pub spectrum_length: u16,
169 pub spectrum_chunk_offset: u16,
170 pub spectrum_chunk_data: [u16; 30],
171}
172impl FromByteSlice for SpectrumLowLevelEvent {
173 fn bytes_expected() -> usize {
174 64
175 }
176 fn from_le_byte_slice(bytes: &[u8]) -> SpectrumLowLevelEvent {
177 SpectrumLowLevelEvent {
178 spectrum_length: <u16>::from_le_byte_slice(&bytes[0..2]),
179 spectrum_chunk_offset: <u16>::from_le_byte_slice(&bytes[2..4]),
180 spectrum_chunk_data: <[u16; 30]>::from_le_byte_slice(&bytes[4..64]),
181 }
182 }
183}
184impl LowLevelRead<u16, SpectrumResult> for SpectrumLowLevelEvent {
185 fn ll_message_length(&self) -> usize {
186 self.spectrum_length as usize
187 }
188
189 fn ll_message_chunk_offset(&self) -> usize {
190 self.spectrum_chunk_offset as usize
191 }
192
193 fn ll_message_chunk_data(&self) -> &[u16] {
194 &self.spectrum_chunk_data
195 }
196
197 fn get_result(&self) -> SpectrumResult {
198 SpectrumResult {}
199 }
200}
201
202#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
203pub struct Configuration {
204 pub fft_size: u8,
205 pub weighting: u8,
206}
207impl FromByteSlice for Configuration {
208 fn bytes_expected() -> usize {
209 2
210 }
211 fn from_le_byte_slice(bytes: &[u8]) -> Configuration {
212 Configuration { fft_size: <u8>::from_le_byte_slice(&bytes[0..1]), weighting: <u8>::from_le_byte_slice(&bytes[1..2]) }
213 }
214}
215
216#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
217pub struct SpitfpErrorCount {
218 pub error_count_ack_checksum: u32,
219 pub error_count_message_checksum: u32,
220 pub error_count_frame: u32,
221 pub error_count_overflow: u32,
222}
223impl FromByteSlice for SpitfpErrorCount {
224 fn bytes_expected() -> usize {
225 16
226 }
227 fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
228 SpitfpErrorCount {
229 error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
230 error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
231 error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
232 error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
233 }
234 }
235}
236
237#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
238pub struct Identity {
239 pub uid: String,
240 pub connected_uid: String,
241 pub position: char,
242 pub hardware_version: [u8; 3],
243 pub firmware_version: [u8; 3],
244 pub device_identifier: u16,
245}
246impl FromByteSlice for Identity {
247 fn bytes_expected() -> usize {
248 25
249 }
250 fn from_le_byte_slice(bytes: &[u8]) -> Identity {
251 Identity {
252 uid: <String>::from_le_byte_slice(&bytes[0..8]),
253 connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
254 position: <char>::from_le_byte_slice(&bytes[16..17]),
255 hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
256 firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
257 device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
258 }
259 }
260}
261
262#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
263pub struct SpectrumResult {}
264
265#[derive(Clone)]
267pub struct SoundPressureLevelBricklet {
268 device: Device,
269}
270impl SoundPressureLevelBricklet {
271 pub const DEVICE_IDENTIFIER: u16 = 290;
272 pub const DEVICE_DISPLAY_NAME: &'static str = "Sound Pressure Level Bricklet";
273 pub fn new(uid: Uid, connection: AsyncIpConnection) -> SoundPressureLevelBricklet {
275 let mut result = SoundPressureLevelBricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
276 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::GetDecibel) as usize] =
277 ResponseExpectedFlag::AlwaysTrue;
278 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::SetDecibelCallbackConfiguration) as usize] =
279 ResponseExpectedFlag::True;
280 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::GetDecibelCallbackConfiguration) as usize] =
281 ResponseExpectedFlag::AlwaysTrue;
282 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::GetSpectrumLowLevel) as usize] =
283 ResponseExpectedFlag::AlwaysTrue;
284 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::SetSpectrumCallbackConfiguration) as usize] =
285 ResponseExpectedFlag::True;
286 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::GetSpectrumCallbackConfiguration) as usize] =
287 ResponseExpectedFlag::AlwaysTrue;
288 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::SetConfiguration) as usize] =
289 ResponseExpectedFlag::False;
290 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::GetConfiguration) as usize] =
291 ResponseExpectedFlag::AlwaysTrue;
292 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::GetSpitfpErrorCount) as usize] =
293 ResponseExpectedFlag::AlwaysTrue;
294 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::SetBootloaderMode) as usize] =
295 ResponseExpectedFlag::AlwaysTrue;
296 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::GetBootloaderMode) as usize] =
297 ResponseExpectedFlag::AlwaysTrue;
298 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::SetWriteFirmwarePointer) as usize] =
299 ResponseExpectedFlag::False;
300 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::WriteFirmware) as usize] =
301 ResponseExpectedFlag::AlwaysTrue;
302 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::SetStatusLedConfig) as usize] =
303 ResponseExpectedFlag::False;
304 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::GetStatusLedConfig) as usize] =
305 ResponseExpectedFlag::AlwaysTrue;
306 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::GetChipTemperature) as usize] =
307 ResponseExpectedFlag::AlwaysTrue;
308 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
309 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
310 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
311 result.device.response_expected[u8::from(SoundPressureLevelBrickletFunction::GetIdentity) as usize] =
312 ResponseExpectedFlag::AlwaysTrue;
313 result
314 }
315
316 pub fn get_response_expected(&mut self, fun: SoundPressureLevelBrickletFunction) -> Result<bool, GetResponseExpectedError> {
331 self.device.get_response_expected(u8::from(fun))
332 }
333
334 pub fn set_response_expected(
343 &mut self,
344 fun: SoundPressureLevelBrickletFunction,
345 response_expected: bool,
346 ) -> Result<(), SetResponseExpectedError> {
347 self.device.set_response_expected(u8::from(fun), response_expected)
348 }
349
350 pub fn set_response_expected_all(&mut self, response_expected: bool) {
352 self.device.set_response_expected_all(response_expected)
353 }
354
355 pub fn get_api_version(&self) -> [u8; 3] {
358 self.device.api_version
359 }
360
361 pub async fn get_decibel_callback_receiver(&mut self) -> impl Stream<Item = u16> {
369 self.device
370 .get_callback_receiver(u8::from(SoundPressureLevelBrickletFunction::CallbackDecibel))
371 .await
372 .map(|p| u16::from_le_byte_slice(p.body()))
373 }
374
375 pub async fn get_spectrum_low_level_callback_receiver(&mut self) -> impl Stream<Item = SpectrumLowLevelEvent> {
377 self.device
378 .get_callback_receiver(u8::from(SoundPressureLevelBrickletFunction::CallbackSpectrumLowLevel))
379 .await
380 .map(|p| SpectrumLowLevelEvent::from_le_byte_slice(p.body()))
381 }
382
383 pub async fn get_decibel(&mut self) -> Result<u16, TinkerforgeError> {
395 let payload = [0; 0];
396
397 #[allow(unused_variables)]
398 let result = self.device.get(u8::from(SoundPressureLevelBrickletFunction::GetDecibel), &payload).await?;
399 Ok(u16::from_le_byte_slice(result.body()))
400 }
401
402 pub async fn set_decibel_callback_configuration(
435 &mut self,
436 period: u32,
437 value_has_to_change: bool,
438 option: char,
439 min: u16,
440 max: u16,
441 ) -> Result<(), TinkerforgeError> {
442 let mut payload = [0; 10];
443 period.write_to_slice(&mut payload[0..4]);
444 value_has_to_change.write_to_slice(&mut payload[4..5]);
445 option.write_to_slice(&mut payload[5..6]);
446 min.write_to_slice(&mut payload[6..8]);
447 max.write_to_slice(&mut payload[8..10]);
448
449 #[allow(unused_variables)]
450 let result = self.device.set(u8::from(SoundPressureLevelBrickletFunction::SetDecibelCallbackConfiguration), &payload).await?;
451 Ok(())
452 }
453
454 pub async fn get_decibel_callback_configuration(&mut self) -> Result<DecibelCallbackConfiguration, TinkerforgeError> {
463 let payload = [0; 0];
464
465 #[allow(unused_variables)]
466 let result = self.device.get(u8::from(SoundPressureLevelBrickletFunction::GetDecibelCallbackConfiguration), &payload).await?;
467 Ok(DecibelCallbackConfiguration::from_le_byte_slice(result.body()))
468 }
469
470 pub async fn get_spectrum_low_level(&mut self) -> Result<SpectrumLowLevel, TinkerforgeError> {
489 let payload = [0; 0];
490
491 #[allow(unused_variables)]
492 let result = self.device.get(u8::from(SoundPressureLevelBrickletFunction::GetSpectrumLowLevel), &payload).await?;
493 Ok(SpectrumLowLevel::from_le_byte_slice(result.body()))
494 }
495
496 pub async fn set_spectrum_callback_configuration(&mut self, period: u32) -> Result<(), TinkerforgeError> {
502 let mut payload = [0; 4];
503 period.write_to_slice(&mut payload[0..4]);
504
505 #[allow(unused_variables)]
506 let result = self.device.set(u8::from(SoundPressureLevelBrickletFunction::SetSpectrumCallbackConfiguration), &payload).await?;
507 Ok(())
508 }
509
510 pub async fn get_spectrum_callback_configuration(&mut self) -> Result<u32, TinkerforgeError> {
513 let payload = [0; 0];
514
515 #[allow(unused_variables)]
516 let result = self.device.get(u8::from(SoundPressureLevelBrickletFunction::GetSpectrumCallbackConfiguration), &payload).await?;
517 Ok(u32::from_le_byte_slice(result.body()))
518 }
519
520 pub async fn set_configuration(&mut self, fft_size: u8, weighting: u8) -> Result<(), TinkerforgeError> {
554 let mut payload = [0; 2];
555 fft_size.write_to_slice(&mut payload[0..1]);
556 weighting.write_to_slice(&mut payload[1..2]);
557
558 #[allow(unused_variables)]
559 let result = self.device.set(u8::from(SoundPressureLevelBrickletFunction::SetConfiguration), &payload).await?;
560 Ok(())
561 }
562
563 pub async fn get_configuration(&mut self) -> Result<Configuration, TinkerforgeError> {
577 let payload = [0; 0];
578
579 #[allow(unused_variables)]
580 let result = self.device.get(u8::from(SoundPressureLevelBrickletFunction::GetConfiguration), &payload).await?;
581 Ok(Configuration::from_le_byte_slice(result.body()))
582 }
583
584 pub async fn get_spitfp_error_count(&mut self) -> Result<SpitfpErrorCount, TinkerforgeError> {
596 let payload = [0; 0];
597
598 #[allow(unused_variables)]
599 let result = self.device.get(u8::from(SoundPressureLevelBrickletFunction::GetSpitfpErrorCount), &payload).await?;
600 Ok(SpitfpErrorCount::from_le_byte_slice(result.body()))
601 }
602
603 pub async fn set_bootloader_mode(&mut self, mode: u8) -> Result<u8, TinkerforgeError> {
626 let mut payload = [0; 1];
627 mode.write_to_slice(&mut payload[0..1]);
628
629 #[allow(unused_variables)]
630 let result = self.device.get(u8::from(SoundPressureLevelBrickletFunction::SetBootloaderMode), &payload).await?;
631 Ok(u8::from_le_byte_slice(result.body()))
632 }
633
634 pub async fn get_bootloader_mode(&mut self) -> Result<u8, TinkerforgeError> {
643 let payload = [0; 0];
644
645 #[allow(unused_variables)]
646 let result = self.device.get(u8::from(SoundPressureLevelBrickletFunction::GetBootloaderMode), &payload).await?;
647 Ok(u8::from_le_byte_slice(result.body()))
648 }
649
650 pub async fn set_write_firmware_pointer(&mut self, pointer: u32) -> Result<(), TinkerforgeError> {
657 let mut payload = [0; 4];
658 pointer.write_to_slice(&mut payload[0..4]);
659
660 #[allow(unused_variables)]
661 let result = self.device.set(u8::from(SoundPressureLevelBrickletFunction::SetWriteFirmwarePointer), &payload).await?;
662 Ok(())
663 }
664
665 pub async fn write_firmware(&mut self, data: &[u8; 64]) -> Result<u8, TinkerforgeError> {
674 let mut payload = [0; 64];
675 data.write_to_slice(&mut payload[0..64]);
676
677 #[allow(unused_variables)]
678 let result = self.device.get(u8::from(SoundPressureLevelBrickletFunction::WriteFirmware), &payload).await?;
679 Ok(u8::from_le_byte_slice(result.body()))
680 }
681
682 pub async fn set_status_led_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
696 let mut payload = [0; 1];
697 config.write_to_slice(&mut payload[0..1]);
698
699 #[allow(unused_variables)]
700 let result = self.device.set(u8::from(SoundPressureLevelBrickletFunction::SetStatusLedConfig), &payload).await?;
701 Ok(())
702 }
703
704 pub async fn get_status_led_config(&mut self) -> Result<u8, TinkerforgeError> {
712 let payload = [0; 0];
713
714 #[allow(unused_variables)]
715 let result = self.device.get(u8::from(SoundPressureLevelBrickletFunction::GetStatusLedConfig), &payload).await?;
716 Ok(u8::from_le_byte_slice(result.body()))
717 }
718
719 pub async fn get_chip_temperature(&mut self) -> Result<i16, TinkerforgeError> {
726 let payload = [0; 0];
727
728 #[allow(unused_variables)]
729 let result = self.device.get(u8::from(SoundPressureLevelBrickletFunction::GetChipTemperature), &payload).await?;
730 Ok(i16::from_le_byte_slice(result.body()))
731 }
732
733 pub async fn reset(&mut self) -> Result<(), TinkerforgeError> {
740 let payload = [0; 0];
741
742 #[allow(unused_variables)]
743 let result = self.device.set(u8::from(SoundPressureLevelBrickletFunction::Reset), &payload).await?;
744 Ok(())
745 }
746
747 pub async fn write_uid(&mut self, uid: u32) -> Result<(), TinkerforgeError> {
753 let mut payload = [0; 4];
754 uid.write_to_slice(&mut payload[0..4]);
755
756 #[allow(unused_variables)]
757 let result = self.device.set(u8::from(SoundPressureLevelBrickletFunction::WriteUid), &payload).await?;
758 Ok(())
759 }
760
761 pub async fn read_uid(&mut self) -> Result<u32, TinkerforgeError> {
764 let payload = [0; 0];
765
766 #[allow(unused_variables)]
767 let result = self.device.get(u8::from(SoundPressureLevelBrickletFunction::ReadUid), &payload).await?;
768 Ok(u32::from_le_byte_slice(result.body()))
769 }
770
771 pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
782 let payload = [0; 0];
783
784 #[allow(unused_variables)]
785 let result = self.device.get(u8::from(SoundPressureLevelBrickletFunction::GetIdentity), &payload).await?;
786 Ok(Identity::from_le_byte_slice(result.body()))
787 }
788}