1#[allow(unused_imports)]
15use crate::{
16 base58::Uid, byte_converter::*, converting_receiver::BrickletRecvTimeoutError, device::*, error::TinkerforgeError,
17 ip_connection::async_io::AsyncIpConnection, low_level_traits::LowLevelRead,
18};
19#[allow(unused_imports)]
20use futures_core::Stream;
21#[allow(unused_imports)]
22use tokio_stream::StreamExt;
23pub enum OutdoorWeatherBrickletFunction {
24 GetStationIdentifiersLowLevel,
25 GetSensorIdentifiersLowLevel,
26 GetStationData,
27 GetSensorData,
28 SetStationCallbackConfiguration,
29 GetStationCallbackConfiguration,
30 SetSensorCallbackConfiguration,
31 GetSensorCallbackConfiguration,
32 GetSpitfpErrorCount,
33 SetBootloaderMode,
34 GetBootloaderMode,
35 SetWriteFirmwarePointer,
36 WriteFirmware,
37 SetStatusLedConfig,
38 GetStatusLedConfig,
39 GetChipTemperature,
40 Reset,
41 WriteUid,
42 ReadUid,
43 GetIdentity,
44 CallbackStationData,
45 CallbackSensorData,
46}
47impl From<OutdoorWeatherBrickletFunction> for u8 {
48 fn from(fun: OutdoorWeatherBrickletFunction) -> Self {
49 match fun {
50 OutdoorWeatherBrickletFunction::GetStationIdentifiersLowLevel => 1,
51 OutdoorWeatherBrickletFunction::GetSensorIdentifiersLowLevel => 2,
52 OutdoorWeatherBrickletFunction::GetStationData => 3,
53 OutdoorWeatherBrickletFunction::GetSensorData => 4,
54 OutdoorWeatherBrickletFunction::SetStationCallbackConfiguration => 5,
55 OutdoorWeatherBrickletFunction::GetStationCallbackConfiguration => 6,
56 OutdoorWeatherBrickletFunction::SetSensorCallbackConfiguration => 7,
57 OutdoorWeatherBrickletFunction::GetSensorCallbackConfiguration => 8,
58 OutdoorWeatherBrickletFunction::GetSpitfpErrorCount => 234,
59 OutdoorWeatherBrickletFunction::SetBootloaderMode => 235,
60 OutdoorWeatherBrickletFunction::GetBootloaderMode => 236,
61 OutdoorWeatherBrickletFunction::SetWriteFirmwarePointer => 237,
62 OutdoorWeatherBrickletFunction::WriteFirmware => 238,
63 OutdoorWeatherBrickletFunction::SetStatusLedConfig => 239,
64 OutdoorWeatherBrickletFunction::GetStatusLedConfig => 240,
65 OutdoorWeatherBrickletFunction::GetChipTemperature => 242,
66 OutdoorWeatherBrickletFunction::Reset => 243,
67 OutdoorWeatherBrickletFunction::WriteUid => 248,
68 OutdoorWeatherBrickletFunction::ReadUid => 249,
69 OutdoorWeatherBrickletFunction::GetIdentity => 255,
70 OutdoorWeatherBrickletFunction::CallbackStationData => 9,
71 OutdoorWeatherBrickletFunction::CallbackSensorData => 10,
72 }
73 }
74}
75pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_N: u8 = 0;
76pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_NNE: u8 = 1;
77pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_NE: u8 = 2;
78pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_ENE: u8 = 3;
79pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_E: u8 = 4;
80pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_ESE: u8 = 5;
81pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_SE: u8 = 6;
82pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_SSE: u8 = 7;
83pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_S: u8 = 8;
84pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_SSW: u8 = 9;
85pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_SW: u8 = 10;
86pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_WSW: u8 = 11;
87pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_W: u8 = 12;
88pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_WNW: u8 = 13;
89pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_NW: u8 = 14;
90pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_NNW: u8 = 15;
91pub const OUTDOOR_WEATHER_BRICKLET_WIND_DIRECTION_ERROR: u8 = 255;
92pub const OUTDOOR_WEATHER_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
93pub const OUTDOOR_WEATHER_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
94pub const OUTDOOR_WEATHER_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
95pub const OUTDOOR_WEATHER_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
96pub const OUTDOOR_WEATHER_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
97pub const OUTDOOR_WEATHER_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
98pub const OUTDOOR_WEATHER_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
99pub const OUTDOOR_WEATHER_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
100pub const OUTDOOR_WEATHER_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
101pub const OUTDOOR_WEATHER_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
102pub const OUTDOOR_WEATHER_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
103pub const OUTDOOR_WEATHER_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
104pub const OUTDOOR_WEATHER_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
105pub const OUTDOOR_WEATHER_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
106pub const OUTDOOR_WEATHER_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
107
108#[derive(Clone, Copy)]
109pub struct StationIdentifiersLowLevel {
110 pub identifiers_length: u16,
111 pub identifiers_chunk_offset: u16,
112 pub identifiers_chunk_data: [u8; 60],
113}
114impl FromByteSlice for StationIdentifiersLowLevel {
115 fn bytes_expected() -> usize {
116 64
117 }
118 fn from_le_byte_slice(bytes: &[u8]) -> StationIdentifiersLowLevel {
119 StationIdentifiersLowLevel {
120 identifiers_length: <u16>::from_le_byte_slice(&bytes[0..2]),
121 identifiers_chunk_offset: <u16>::from_le_byte_slice(&bytes[2..4]),
122 identifiers_chunk_data: <[u8; 60]>::from_le_byte_slice(&bytes[4..64]),
123 }
124 }
125}
126impl LowLevelRead<u8, StationIdentifiersResult> for StationIdentifiersLowLevel {
127 fn ll_message_length(&self) -> usize {
128 self.identifiers_length as usize
129 }
130
131 fn ll_message_chunk_offset(&self) -> usize {
132 self.identifiers_chunk_offset as usize
133 }
134
135 fn ll_message_chunk_data(&self) -> &[u8] {
136 &self.identifiers_chunk_data
137 }
138
139 fn get_result(&self) -> StationIdentifiersResult {
140 StationIdentifiersResult {}
141 }
142}
143
144#[derive(Clone, Copy)]
145pub struct SensorIdentifiersLowLevel {
146 pub identifiers_length: u16,
147 pub identifiers_chunk_offset: u16,
148 pub identifiers_chunk_data: [u8; 60],
149}
150impl FromByteSlice for SensorIdentifiersLowLevel {
151 fn bytes_expected() -> usize {
152 64
153 }
154 fn from_le_byte_slice(bytes: &[u8]) -> SensorIdentifiersLowLevel {
155 SensorIdentifiersLowLevel {
156 identifiers_length: <u16>::from_le_byte_slice(&bytes[0..2]),
157 identifiers_chunk_offset: <u16>::from_le_byte_slice(&bytes[2..4]),
158 identifiers_chunk_data: <[u8; 60]>::from_le_byte_slice(&bytes[4..64]),
159 }
160 }
161}
162impl LowLevelRead<u8, SensorIdentifiersResult> for SensorIdentifiersLowLevel {
163 fn ll_message_length(&self) -> usize {
164 self.identifiers_length as usize
165 }
166
167 fn ll_message_chunk_offset(&self) -> usize {
168 self.identifiers_chunk_offset as usize
169 }
170
171 fn ll_message_chunk_data(&self) -> &[u8] {
172 &self.identifiers_chunk_data
173 }
174
175 fn get_result(&self) -> SensorIdentifiersResult {
176 SensorIdentifiersResult {}
177 }
178}
179
180#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
181pub struct StationData {
182 pub temperature: i16,
183 pub humidity: u8,
184 pub wind_speed: u32,
185 pub gust_speed: u32,
186 pub rain: u32,
187 pub wind_direction: u8,
188 pub battery_low: bool,
189 pub last_change: u16,
190}
191impl FromByteSlice for StationData {
192 fn bytes_expected() -> usize {
193 19
194 }
195 fn from_le_byte_slice(bytes: &[u8]) -> StationData {
196 StationData {
197 temperature: <i16>::from_le_byte_slice(&bytes[0..2]),
198 humidity: <u8>::from_le_byte_slice(&bytes[2..3]),
199 wind_speed: <u32>::from_le_byte_slice(&bytes[3..7]),
200 gust_speed: <u32>::from_le_byte_slice(&bytes[7..11]),
201 rain: <u32>::from_le_byte_slice(&bytes[11..15]),
202 wind_direction: <u8>::from_le_byte_slice(&bytes[15..16]),
203 battery_low: <bool>::from_le_byte_slice(&bytes[16..17]),
204 last_change: <u16>::from_le_byte_slice(&bytes[17..19]),
205 }
206 }
207}
208
209#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
210pub struct SensorData {
211 pub temperature: i16,
212 pub humidity: u8,
213 pub last_change: u16,
214}
215impl FromByteSlice for SensorData {
216 fn bytes_expected() -> usize {
217 5
218 }
219 fn from_le_byte_slice(bytes: &[u8]) -> SensorData {
220 SensorData {
221 temperature: <i16>::from_le_byte_slice(&bytes[0..2]),
222 humidity: <u8>::from_le_byte_slice(&bytes[2..3]),
223 last_change: <u16>::from_le_byte_slice(&bytes[3..5]),
224 }
225 }
226}
227
228#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
229pub struct StationDataEvent {
230 pub identifier: u8,
231 pub temperature: i16,
232 pub humidity: u8,
233 pub wind_speed: u32,
234 pub gust_speed: u32,
235 pub rain: u32,
236 pub wind_direction: u8,
237 pub battery_low: bool,
238}
239impl FromByteSlice for StationDataEvent {
240 fn bytes_expected() -> usize {
241 18
242 }
243 fn from_le_byte_slice(bytes: &[u8]) -> StationDataEvent {
244 StationDataEvent {
245 identifier: <u8>::from_le_byte_slice(&bytes[0..1]),
246 temperature: <i16>::from_le_byte_slice(&bytes[1..3]),
247 humidity: <u8>::from_le_byte_slice(&bytes[3..4]),
248 wind_speed: <u32>::from_le_byte_slice(&bytes[4..8]),
249 gust_speed: <u32>::from_le_byte_slice(&bytes[8..12]),
250 rain: <u32>::from_le_byte_slice(&bytes[12..16]),
251 wind_direction: <u8>::from_le_byte_slice(&bytes[16..17]),
252 battery_low: <bool>::from_le_byte_slice(&bytes[17..18]),
253 }
254 }
255}
256
257#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
258pub struct SensorDataEvent {
259 pub identifier: u8,
260 pub temperature: i16,
261 pub humidity: u8,
262}
263impl FromByteSlice for SensorDataEvent {
264 fn bytes_expected() -> usize {
265 4
266 }
267 fn from_le_byte_slice(bytes: &[u8]) -> SensorDataEvent {
268 SensorDataEvent {
269 identifier: <u8>::from_le_byte_slice(&bytes[0..1]),
270 temperature: <i16>::from_le_byte_slice(&bytes[1..3]),
271 humidity: <u8>::from_le_byte_slice(&bytes[3..4]),
272 }
273 }
274}
275
276#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
277pub struct SpitfpErrorCount {
278 pub error_count_ack_checksum: u32,
279 pub error_count_message_checksum: u32,
280 pub error_count_frame: u32,
281 pub error_count_overflow: u32,
282}
283impl FromByteSlice for SpitfpErrorCount {
284 fn bytes_expected() -> usize {
285 16
286 }
287 fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
288 SpitfpErrorCount {
289 error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
290 error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
291 error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
292 error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
293 }
294 }
295}
296
297#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
298pub struct Identity {
299 pub uid: String,
300 pub connected_uid: String,
301 pub position: char,
302 pub hardware_version: [u8; 3],
303 pub firmware_version: [u8; 3],
304 pub device_identifier: u16,
305}
306impl FromByteSlice for Identity {
307 fn bytes_expected() -> usize {
308 25
309 }
310 fn from_le_byte_slice(bytes: &[u8]) -> Identity {
311 Identity {
312 uid: <String>::from_le_byte_slice(&bytes[0..8]),
313 connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
314 position: <char>::from_le_byte_slice(&bytes[16..17]),
315 hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
316 firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
317 device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
318 }
319 }
320}
321
322#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
323pub struct StationIdentifiersResult {}
324
325#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
326pub struct SensorIdentifiersResult {}
327
328#[derive(Clone)]
330pub struct OutdoorWeatherBricklet {
331 device: Device,
332}
333impl OutdoorWeatherBricklet {
334 pub const DEVICE_IDENTIFIER: u16 = 288;
335 pub const DEVICE_DISPLAY_NAME: &'static str = "Outdoor Weather Bricklet";
336 pub fn new(uid: Uid, connection: AsyncIpConnection) -> OutdoorWeatherBricklet {
338 let mut result = OutdoorWeatherBricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
339 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::GetStationIdentifiersLowLevel) as usize] =
340 ResponseExpectedFlag::AlwaysTrue;
341 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::GetSensorIdentifiersLowLevel) as usize] =
342 ResponseExpectedFlag::AlwaysTrue;
343 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::GetStationData) as usize] =
344 ResponseExpectedFlag::AlwaysTrue;
345 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::GetSensorData) as usize] =
346 ResponseExpectedFlag::AlwaysTrue;
347 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::SetStationCallbackConfiguration) as usize] =
348 ResponseExpectedFlag::True;
349 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::GetStationCallbackConfiguration) as usize] =
350 ResponseExpectedFlag::AlwaysTrue;
351 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::SetSensorCallbackConfiguration) as usize] =
352 ResponseExpectedFlag::True;
353 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::GetSensorCallbackConfiguration) as usize] =
354 ResponseExpectedFlag::AlwaysTrue;
355 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::GetSpitfpErrorCount) as usize] =
356 ResponseExpectedFlag::AlwaysTrue;
357 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::SetBootloaderMode) as usize] =
358 ResponseExpectedFlag::AlwaysTrue;
359 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::GetBootloaderMode) as usize] =
360 ResponseExpectedFlag::AlwaysTrue;
361 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::SetWriteFirmwarePointer) as usize] =
362 ResponseExpectedFlag::False;
363 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::WriteFirmware) as usize] =
364 ResponseExpectedFlag::AlwaysTrue;
365 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::SetStatusLedConfig) as usize] =
366 ResponseExpectedFlag::False;
367 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::GetStatusLedConfig) as usize] =
368 ResponseExpectedFlag::AlwaysTrue;
369 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::GetChipTemperature) as usize] =
370 ResponseExpectedFlag::AlwaysTrue;
371 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
372 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
373 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
374 result.device.response_expected[u8::from(OutdoorWeatherBrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
375 result
376 }
377
378 pub fn get_response_expected(&mut self, fun: OutdoorWeatherBrickletFunction) -> Result<bool, GetResponseExpectedError> {
393 self.device.get_response_expected(u8::from(fun))
394 }
395
396 pub fn set_response_expected(
405 &mut self,
406 fun: OutdoorWeatherBrickletFunction,
407 response_expected: bool,
408 ) -> Result<(), SetResponseExpectedError> {
409 self.device.set_response_expected(u8::from(fun), response_expected)
410 }
411
412 pub fn set_response_expected_all(&mut self, response_expected: bool) {
414 self.device.set_response_expected_all(response_expected)
415 }
416
417 pub fn get_api_version(&self) -> [u8; 3] {
420 self.device.api_version
421 }
422
423 pub async fn get_station_data_callback_receiver(&mut self) -> impl Stream<Item = StationDataEvent> {
434 self.device
435 .get_callback_receiver(u8::from(OutdoorWeatherBrickletFunction::CallbackStationData))
436 .await
437 .map(|p| StationDataEvent::from_le_byte_slice(p.body()))
438 }
439
440 pub async fn get_sensor_data_callback_receiver(&mut self) -> impl Stream<Item = SensorDataEvent> {
448 self.device
449 .get_callback_receiver(u8::from(OutdoorWeatherBrickletFunction::CallbackSensorData))
450 .await
451 .map(|p| SensorDataEvent::from_le_byte_slice(p.body()))
452 }
453
454 pub async fn get_station_identifiers_low_level(&mut self) -> Result<StationIdentifiersLowLevel, TinkerforgeError> {
463 let payload = [0; 0];
464
465 #[allow(unused_variables)]
466 let result = self.device.get(u8::from(OutdoorWeatherBrickletFunction::GetStationIdentifiersLowLevel), &payload).await?;
467 Ok(StationIdentifiersLowLevel::from_le_byte_slice(result.body()))
468 }
469
470 pub async fn get_sensor_identifiers_low_level(&mut self) -> Result<SensorIdentifiersLowLevel, TinkerforgeError> {
479 let payload = [0; 0];
480
481 #[allow(unused_variables)]
482 let result = self.device.get(u8::from(OutdoorWeatherBrickletFunction::GetSensorIdentifiersLowLevel), &payload).await?;
483 Ok(SensorIdentifiersLowLevel::from_le_byte_slice(result.body()))
484 }
485
486 pub async fn get_station_data(&mut self, identifier: u8) -> Result<StationData, TinkerforgeError> {
519 let mut payload = [0; 1];
520 identifier.write_to_slice(&mut payload[0..1]);
521
522 #[allow(unused_variables)]
523 let result = self.device.get(u8::from(OutdoorWeatherBrickletFunction::GetStationData), &payload).await?;
524 Ok(StationData::from_le_byte_slice(result.body()))
525 }
526
527 pub async fn get_sensor_data(&mut self, identifier: u8) -> Result<SensorData, TinkerforgeError> {
536 let mut payload = [0; 1];
537 identifier.write_to_slice(&mut payload[0..1]);
538
539 #[allow(unused_variables)]
540 let result = self.device.get(u8::from(OutdoorWeatherBrickletFunction::GetSensorData), &payload).await?;
541 Ok(SensorData::from_le_byte_slice(result.body()))
542 }
543
544 pub async fn set_station_callback_configuration(&mut self, enable_callback: bool) -> Result<(), TinkerforgeError> {
546 let mut payload = [0; 1];
547 enable_callback.write_to_slice(&mut payload[0..1]);
548
549 #[allow(unused_variables)]
550 let result = self.device.set(u8::from(OutdoorWeatherBrickletFunction::SetStationCallbackConfiguration), &payload).await?;
551 Ok(())
552 }
553
554 pub async fn get_station_callback_configuration(&mut self) -> Result<bool, TinkerforgeError> {
556 let payload = [0; 0];
557
558 #[allow(unused_variables)]
559 let result = self.device.get(u8::from(OutdoorWeatherBrickletFunction::GetStationCallbackConfiguration), &payload).await?;
560 Ok(bool::from_le_byte_slice(result.body()))
561 }
562
563 pub async fn set_sensor_callback_configuration(&mut self, enable_callback: bool) -> Result<(), TinkerforgeError> {
565 let mut payload = [0; 1];
566 enable_callback.write_to_slice(&mut payload[0..1]);
567
568 #[allow(unused_variables)]
569 let result = self.device.set(u8::from(OutdoorWeatherBrickletFunction::SetSensorCallbackConfiguration), &payload).await?;
570 Ok(())
571 }
572
573 pub async fn get_sensor_callback_configuration(&mut self) -> Result<bool, TinkerforgeError> {
575 let payload = [0; 0];
576
577 #[allow(unused_variables)]
578 let result = self.device.get(u8::from(OutdoorWeatherBrickletFunction::GetSensorCallbackConfiguration), &payload).await?;
579 Ok(bool::from_le_byte_slice(result.body()))
580 }
581
582 pub async fn get_spitfp_error_count(&mut self) -> Result<SpitfpErrorCount, TinkerforgeError> {
594 let payload = [0; 0];
595
596 #[allow(unused_variables)]
597 let result = self.device.get(u8::from(OutdoorWeatherBrickletFunction::GetSpitfpErrorCount), &payload).await?;
598 Ok(SpitfpErrorCount::from_le_byte_slice(result.body()))
599 }
600
601 pub async fn set_bootloader_mode(&mut self, mode: u8) -> Result<u8, TinkerforgeError> {
624 let mut payload = [0; 1];
625 mode.write_to_slice(&mut payload[0..1]);
626
627 #[allow(unused_variables)]
628 let result = self.device.get(u8::from(OutdoorWeatherBrickletFunction::SetBootloaderMode), &payload).await?;
629 Ok(u8::from_le_byte_slice(result.body()))
630 }
631
632 pub async fn get_bootloader_mode(&mut self) -> Result<u8, TinkerforgeError> {
641 let payload = [0; 0];
642
643 #[allow(unused_variables)]
644 let result = self.device.get(u8::from(OutdoorWeatherBrickletFunction::GetBootloaderMode), &payload).await?;
645 Ok(u8::from_le_byte_slice(result.body()))
646 }
647
648 pub async fn set_write_firmware_pointer(&mut self, pointer: u32) -> Result<(), TinkerforgeError> {
655 let mut payload = [0; 4];
656 pointer.write_to_slice(&mut payload[0..4]);
657
658 #[allow(unused_variables)]
659 let result = self.device.set(u8::from(OutdoorWeatherBrickletFunction::SetWriteFirmwarePointer), &payload).await?;
660 Ok(())
661 }
662
663 pub async fn write_firmware(&mut self, data: &[u8; 64]) -> Result<u8, TinkerforgeError> {
672 let mut payload = [0; 64];
673 data.write_to_slice(&mut payload[0..64]);
674
675 #[allow(unused_variables)]
676 let result = self.device.get(u8::from(OutdoorWeatherBrickletFunction::WriteFirmware), &payload).await?;
677 Ok(u8::from_le_byte_slice(result.body()))
678 }
679
680 pub async fn set_status_led_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
694 let mut payload = [0; 1];
695 config.write_to_slice(&mut payload[0..1]);
696
697 #[allow(unused_variables)]
698 let result = self.device.set(u8::from(OutdoorWeatherBrickletFunction::SetStatusLedConfig), &payload).await?;
699 Ok(())
700 }
701
702 pub async fn get_status_led_config(&mut self) -> Result<u8, TinkerforgeError> {
710 let payload = [0; 0];
711
712 #[allow(unused_variables)]
713 let result = self.device.get(u8::from(OutdoorWeatherBrickletFunction::GetStatusLedConfig), &payload).await?;
714 Ok(u8::from_le_byte_slice(result.body()))
715 }
716
717 pub async fn get_chip_temperature(&mut self) -> Result<i16, TinkerforgeError> {
724 let payload = [0; 0];
725
726 #[allow(unused_variables)]
727 let result = self.device.get(u8::from(OutdoorWeatherBrickletFunction::GetChipTemperature), &payload).await?;
728 Ok(i16::from_le_byte_slice(result.body()))
729 }
730
731 pub async fn reset(&mut self) -> Result<(), TinkerforgeError> {
738 let payload = [0; 0];
739
740 #[allow(unused_variables)]
741 let result = self.device.set(u8::from(OutdoorWeatherBrickletFunction::Reset), &payload).await?;
742 Ok(())
743 }
744
745 pub async fn write_uid(&mut self, uid: u32) -> Result<(), TinkerforgeError> {
751 let mut payload = [0; 4];
752 uid.write_to_slice(&mut payload[0..4]);
753
754 #[allow(unused_variables)]
755 let result = self.device.set(u8::from(OutdoorWeatherBrickletFunction::WriteUid), &payload).await?;
756 Ok(())
757 }
758
759 pub async fn read_uid(&mut self) -> Result<u32, TinkerforgeError> {
762 let payload = [0; 0];
763
764 #[allow(unused_variables)]
765 let result = self.device.get(u8::from(OutdoorWeatherBrickletFunction::ReadUid), &payload).await?;
766 Ok(u32::from_le_byte_slice(result.body()))
767 }
768
769 pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
780 let payload = [0; 0];
781
782 #[allow(unused_variables)]
783 let result = self.device.get(u8::from(OutdoorWeatherBrickletFunction::GetIdentity), &payload).await?;
784 Ok(Identity::from_le_byte_slice(result.body()))
785 }
786}