tinkerforge_async/bindings/
master_brick.rs

1/* ***********************************************************
2 * This file was automatically generated on 2024-02-16.      *
3 *                                                           *
4 * Rust Bindings Version 2.0.20                              *
5 *                                                           *
6 * If you have a bugfix for this file and want to commit it, *
7 * please fix the bug in the generator. You can find a link  *
8 * to the generators git repository on tinkerforge.com       *
9 *************************************************************/
10
11//! Basis to build stacks and has 4 Bricklet ports.
12//!
13//! See also the documentation [here](https://www.tinkerforge.com/en/doc/Software/Bricks/Master_Brick_Rust.html).
14#[allow(unused_imports)]
15use crate::{
16    base58::Uid, byte_converter::*, converting_receiver::BrickletError, 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 MasterBrickFunction {
24    GetStackVoltage,
25    GetStackCurrent,
26    SetExtensionType,
27    GetExtensionType,
28    IsChibiPresent,
29    SetChibiAddress,
30    GetChibiAddress,
31    SetChibiMasterAddress,
32    GetChibiMasterAddress,
33    SetChibiSlaveAddress,
34    GetChibiSlaveAddress,
35    GetChibiSignalStrength,
36    GetChibiErrorLog,
37    SetChibiFrequency,
38    GetChibiFrequency,
39    SetChibiChannel,
40    GetChibiChannel,
41    IsRs485Present,
42    SetRs485Address,
43    GetRs485Address,
44    SetRs485SlaveAddress,
45    GetRs485SlaveAddress,
46    GetRs485ErrorLog,
47    SetRs485Configuration,
48    GetRs485Configuration,
49    IsWifiPresent,
50    SetWifiConfiguration,
51    GetWifiConfiguration,
52    SetWifiEncryption,
53    GetWifiEncryption,
54    GetWifiStatus,
55    RefreshWifiStatus,
56    SetWifiCertificate,
57    GetWifiCertificate,
58    SetWifiPowerMode,
59    GetWifiPowerMode,
60    GetWifiBufferInfo,
61    SetWifiRegulatoryDomain,
62    GetWifiRegulatoryDomain,
63    GetUsbVoltage,
64    SetLongWifiKey,
65    GetLongWifiKey,
66    SetWifiHostname,
67    GetWifiHostname,
68    SetStackCurrentCallbackPeriod,
69    GetStackCurrentCallbackPeriod,
70    SetStackVoltageCallbackPeriod,
71    GetStackVoltageCallbackPeriod,
72    SetUsbVoltageCallbackPeriod,
73    GetUsbVoltageCallbackPeriod,
74    SetStackCurrentCallbackThreshold,
75    GetStackCurrentCallbackThreshold,
76    SetStackVoltageCallbackThreshold,
77    GetStackVoltageCallbackThreshold,
78    SetUsbVoltageCallbackThreshold,
79    GetUsbVoltageCallbackThreshold,
80    SetDebouncePeriod,
81    GetDebouncePeriod,
82    IsEthernetPresent,
83    SetEthernetConfiguration,
84    GetEthernetConfiguration,
85    GetEthernetStatus,
86    SetEthernetHostname,
87    SetEthernetMacAddress,
88    SetEthernetWebsocketConfiguration,
89    GetEthernetWebsocketConfiguration,
90    SetEthernetAuthenticationSecret,
91    GetEthernetAuthenticationSecret,
92    SetWifiAuthenticationSecret,
93    GetWifiAuthenticationSecret,
94    GetConnectionType,
95    IsWifi2Present,
96    StartWifi2Bootloader,
97    WriteWifi2SerialPort,
98    ReadWifi2SerialPort,
99    SetWifi2AuthenticationSecret,
100    GetWifi2AuthenticationSecret,
101    SetWifi2Configuration,
102    GetWifi2Configuration,
103    GetWifi2Status,
104    SetWifi2ClientConfiguration,
105    GetWifi2ClientConfiguration,
106    SetWifi2ClientHostname,
107    GetWifi2ClientHostname,
108    SetWifi2ClientPassword,
109    GetWifi2ClientPassword,
110    SetWifi2ApConfiguration,
111    GetWifi2ApConfiguration,
112    SetWifi2ApPassword,
113    GetWifi2ApPassword,
114    SaveWifi2Configuration,
115    GetWifi2FirmwareVersion,
116    EnableWifi2StatusLed,
117    DisableWifi2StatusLed,
118    IsWifi2StatusLedEnabled,
119    SetWifi2MeshConfiguration,
120    GetWifi2MeshConfiguration,
121    SetWifi2MeshRouterSsid,
122    GetWifi2MeshRouterSsid,
123    SetWifi2MeshRouterPassword,
124    GetWifi2MeshRouterPassword,
125    GetWifi2MeshCommonStatus,
126    GetWifi2MeshClientStatus,
127    GetWifi2MeshApStatus,
128    SetBrickletXmcFlashConfig,
129    SetBrickletXmcFlashData,
130    SetBrickletsEnabled,
131    GetBrickletsEnabled,
132    SetSpitfpBaudrateConfig,
133    GetSpitfpBaudrateConfig,
134    GetSendTimeoutCount,
135    SetSpitfpBaudrate,
136    GetSpitfpBaudrate,
137    GetSpitfpErrorCount,
138    EnableStatusLed,
139    DisableStatusLed,
140    IsStatusLedEnabled,
141    GetProtocol1BrickletName,
142    GetChipTemperature,
143    Reset,
144    WriteBrickletPlugin,
145    ReadBrickletPlugin,
146    GetIdentity,
147    CallbackStackCurrent,
148    CallbackStackVoltage,
149    CallbackUsbVoltage,
150    CallbackStackCurrentReached,
151    CallbackStackVoltageReached,
152    CallbackUsbVoltageReached,
153}
154impl From<MasterBrickFunction> for u8 {
155    fn from(fun: MasterBrickFunction) -> Self {
156        match fun {
157            MasterBrickFunction::GetStackVoltage => 1,
158            MasterBrickFunction::GetStackCurrent => 2,
159            MasterBrickFunction::SetExtensionType => 3,
160            MasterBrickFunction::GetExtensionType => 4,
161            MasterBrickFunction::IsChibiPresent => 5,
162            MasterBrickFunction::SetChibiAddress => 6,
163            MasterBrickFunction::GetChibiAddress => 7,
164            MasterBrickFunction::SetChibiMasterAddress => 8,
165            MasterBrickFunction::GetChibiMasterAddress => 9,
166            MasterBrickFunction::SetChibiSlaveAddress => 10,
167            MasterBrickFunction::GetChibiSlaveAddress => 11,
168            MasterBrickFunction::GetChibiSignalStrength => 12,
169            MasterBrickFunction::GetChibiErrorLog => 13,
170            MasterBrickFunction::SetChibiFrequency => 14,
171            MasterBrickFunction::GetChibiFrequency => 15,
172            MasterBrickFunction::SetChibiChannel => 16,
173            MasterBrickFunction::GetChibiChannel => 17,
174            MasterBrickFunction::IsRs485Present => 18,
175            MasterBrickFunction::SetRs485Address => 19,
176            MasterBrickFunction::GetRs485Address => 20,
177            MasterBrickFunction::SetRs485SlaveAddress => 21,
178            MasterBrickFunction::GetRs485SlaveAddress => 22,
179            MasterBrickFunction::GetRs485ErrorLog => 23,
180            MasterBrickFunction::SetRs485Configuration => 24,
181            MasterBrickFunction::GetRs485Configuration => 25,
182            MasterBrickFunction::IsWifiPresent => 26,
183            MasterBrickFunction::SetWifiConfiguration => 27,
184            MasterBrickFunction::GetWifiConfiguration => 28,
185            MasterBrickFunction::SetWifiEncryption => 29,
186            MasterBrickFunction::GetWifiEncryption => 30,
187            MasterBrickFunction::GetWifiStatus => 31,
188            MasterBrickFunction::RefreshWifiStatus => 32,
189            MasterBrickFunction::SetWifiCertificate => 33,
190            MasterBrickFunction::GetWifiCertificate => 34,
191            MasterBrickFunction::SetWifiPowerMode => 35,
192            MasterBrickFunction::GetWifiPowerMode => 36,
193            MasterBrickFunction::GetWifiBufferInfo => 37,
194            MasterBrickFunction::SetWifiRegulatoryDomain => 38,
195            MasterBrickFunction::GetWifiRegulatoryDomain => 39,
196            MasterBrickFunction::GetUsbVoltage => 40,
197            MasterBrickFunction::SetLongWifiKey => 41,
198            MasterBrickFunction::GetLongWifiKey => 42,
199            MasterBrickFunction::SetWifiHostname => 43,
200            MasterBrickFunction::GetWifiHostname => 44,
201            MasterBrickFunction::SetStackCurrentCallbackPeriod => 45,
202            MasterBrickFunction::GetStackCurrentCallbackPeriod => 46,
203            MasterBrickFunction::SetStackVoltageCallbackPeriod => 47,
204            MasterBrickFunction::GetStackVoltageCallbackPeriod => 48,
205            MasterBrickFunction::SetUsbVoltageCallbackPeriod => 49,
206            MasterBrickFunction::GetUsbVoltageCallbackPeriod => 50,
207            MasterBrickFunction::SetStackCurrentCallbackThreshold => 51,
208            MasterBrickFunction::GetStackCurrentCallbackThreshold => 52,
209            MasterBrickFunction::SetStackVoltageCallbackThreshold => 53,
210            MasterBrickFunction::GetStackVoltageCallbackThreshold => 54,
211            MasterBrickFunction::SetUsbVoltageCallbackThreshold => 55,
212            MasterBrickFunction::GetUsbVoltageCallbackThreshold => 56,
213            MasterBrickFunction::SetDebouncePeriod => 57,
214            MasterBrickFunction::GetDebouncePeriod => 58,
215            MasterBrickFunction::IsEthernetPresent => 65,
216            MasterBrickFunction::SetEthernetConfiguration => 66,
217            MasterBrickFunction::GetEthernetConfiguration => 67,
218            MasterBrickFunction::GetEthernetStatus => 68,
219            MasterBrickFunction::SetEthernetHostname => 69,
220            MasterBrickFunction::SetEthernetMacAddress => 70,
221            MasterBrickFunction::SetEthernetWebsocketConfiguration => 71,
222            MasterBrickFunction::GetEthernetWebsocketConfiguration => 72,
223            MasterBrickFunction::SetEthernetAuthenticationSecret => 73,
224            MasterBrickFunction::GetEthernetAuthenticationSecret => 74,
225            MasterBrickFunction::SetWifiAuthenticationSecret => 75,
226            MasterBrickFunction::GetWifiAuthenticationSecret => 76,
227            MasterBrickFunction::GetConnectionType => 77,
228            MasterBrickFunction::IsWifi2Present => 78,
229            MasterBrickFunction::StartWifi2Bootloader => 79,
230            MasterBrickFunction::WriteWifi2SerialPort => 80,
231            MasterBrickFunction::ReadWifi2SerialPort => 81,
232            MasterBrickFunction::SetWifi2AuthenticationSecret => 82,
233            MasterBrickFunction::GetWifi2AuthenticationSecret => 83,
234            MasterBrickFunction::SetWifi2Configuration => 84,
235            MasterBrickFunction::GetWifi2Configuration => 85,
236            MasterBrickFunction::GetWifi2Status => 86,
237            MasterBrickFunction::SetWifi2ClientConfiguration => 87,
238            MasterBrickFunction::GetWifi2ClientConfiguration => 88,
239            MasterBrickFunction::SetWifi2ClientHostname => 89,
240            MasterBrickFunction::GetWifi2ClientHostname => 90,
241            MasterBrickFunction::SetWifi2ClientPassword => 91,
242            MasterBrickFunction::GetWifi2ClientPassword => 92,
243            MasterBrickFunction::SetWifi2ApConfiguration => 93,
244            MasterBrickFunction::GetWifi2ApConfiguration => 94,
245            MasterBrickFunction::SetWifi2ApPassword => 95,
246            MasterBrickFunction::GetWifi2ApPassword => 96,
247            MasterBrickFunction::SaveWifi2Configuration => 97,
248            MasterBrickFunction::GetWifi2FirmwareVersion => 98,
249            MasterBrickFunction::EnableWifi2StatusLed => 99,
250            MasterBrickFunction::DisableWifi2StatusLed => 100,
251            MasterBrickFunction::IsWifi2StatusLedEnabled => 101,
252            MasterBrickFunction::SetWifi2MeshConfiguration => 102,
253            MasterBrickFunction::GetWifi2MeshConfiguration => 103,
254            MasterBrickFunction::SetWifi2MeshRouterSsid => 104,
255            MasterBrickFunction::GetWifi2MeshRouterSsid => 105,
256            MasterBrickFunction::SetWifi2MeshRouterPassword => 106,
257            MasterBrickFunction::GetWifi2MeshRouterPassword => 107,
258            MasterBrickFunction::GetWifi2MeshCommonStatus => 108,
259            MasterBrickFunction::GetWifi2MeshClientStatus => 109,
260            MasterBrickFunction::GetWifi2MeshApStatus => 110,
261            MasterBrickFunction::SetBrickletXmcFlashConfig => 111,
262            MasterBrickFunction::SetBrickletXmcFlashData => 112,
263            MasterBrickFunction::SetBrickletsEnabled => 113,
264            MasterBrickFunction::GetBrickletsEnabled => 114,
265            MasterBrickFunction::SetSpitfpBaudrateConfig => 231,
266            MasterBrickFunction::GetSpitfpBaudrateConfig => 232,
267            MasterBrickFunction::GetSendTimeoutCount => 233,
268            MasterBrickFunction::SetSpitfpBaudrate => 234,
269            MasterBrickFunction::GetSpitfpBaudrate => 235,
270            MasterBrickFunction::GetSpitfpErrorCount => 237,
271            MasterBrickFunction::EnableStatusLed => 238,
272            MasterBrickFunction::DisableStatusLed => 239,
273            MasterBrickFunction::IsStatusLedEnabled => 240,
274            MasterBrickFunction::GetProtocol1BrickletName => 241,
275            MasterBrickFunction::GetChipTemperature => 242,
276            MasterBrickFunction::Reset => 243,
277            MasterBrickFunction::WriteBrickletPlugin => 246,
278            MasterBrickFunction::ReadBrickletPlugin => 247,
279            MasterBrickFunction::GetIdentity => 255,
280            MasterBrickFunction::CallbackStackCurrent => 59,
281            MasterBrickFunction::CallbackStackVoltage => 60,
282            MasterBrickFunction::CallbackUsbVoltage => 61,
283            MasterBrickFunction::CallbackStackCurrentReached => 62,
284            MasterBrickFunction::CallbackStackVoltageReached => 63,
285            MasterBrickFunction::CallbackUsbVoltageReached => 64,
286        }
287    }
288}
289pub const MASTER_BRICK_EXTENSION_TYPE_CHIBI: u32 = 1;
290pub const MASTER_BRICK_EXTENSION_TYPE_RS485: u32 = 2;
291pub const MASTER_BRICK_EXTENSION_TYPE_WIFI: u32 = 3;
292pub const MASTER_BRICK_EXTENSION_TYPE_ETHERNET: u32 = 4;
293pub const MASTER_BRICK_EXTENSION_TYPE_WIFI2: u32 = 5;
294pub const MASTER_BRICK_CHIBI_FREQUENCY_OQPSK_868_MHZ: u8 = 0;
295pub const MASTER_BRICK_CHIBI_FREQUENCY_OQPSK_915_MHZ: u8 = 1;
296pub const MASTER_BRICK_CHIBI_FREQUENCY_OQPSK_780_MHZ: u8 = 2;
297pub const MASTER_BRICK_CHIBI_FREQUENCY_BPSK40_915_MHZ: u8 = 3;
298pub const MASTER_BRICK_RS485_PARITY_NONE: char = 'n';
299pub const MASTER_BRICK_RS485_PARITY_EVEN: char = 'e';
300pub const MASTER_BRICK_RS485_PARITY_ODD: char = 'o';
301pub const MASTER_BRICK_WIFI_CONNECTION_DHCP: u8 = 0;
302pub const MASTER_BRICK_WIFI_CONNECTION_STATIC_IP: u8 = 1;
303pub const MASTER_BRICK_WIFI_CONNECTION_ACCESS_POINT_DHCP: u8 = 2;
304pub const MASTER_BRICK_WIFI_CONNECTION_ACCESS_POINT_STATIC_IP: u8 = 3;
305pub const MASTER_BRICK_WIFI_CONNECTION_AD_HOC_DHCP: u8 = 4;
306pub const MASTER_BRICK_WIFI_CONNECTION_AD_HOC_STATIC_IP: u8 = 5;
307pub const MASTER_BRICK_WIFI_ENCRYPTION_WPA_WPA2: u8 = 0;
308pub const MASTER_BRICK_WIFI_ENCRYPTION_WPA_ENTERPRISE: u8 = 1;
309pub const MASTER_BRICK_WIFI_ENCRYPTION_WEP: u8 = 2;
310pub const MASTER_BRICK_WIFI_ENCRYPTION_NO_ENCRYPTION: u8 = 3;
311pub const MASTER_BRICK_WIFI_EAP_OPTION_OUTER_AUTH_EAP_FAST: u8 = 0;
312pub const MASTER_BRICK_WIFI_EAP_OPTION_OUTER_AUTH_EAP_TLS: u8 = 1;
313pub const MASTER_BRICK_WIFI_EAP_OPTION_OUTER_AUTH_EAP_TTLS: u8 = 2;
314pub const MASTER_BRICK_WIFI_EAP_OPTION_OUTER_AUTH_EAP_PEAP: u8 = 3;
315pub const MASTER_BRICK_WIFI_EAP_OPTION_INNER_AUTH_EAP_MSCHAP: u8 = 0;
316pub const MASTER_BRICK_WIFI_EAP_OPTION_INNER_AUTH_EAP_GTC: u8 = 4;
317pub const MASTER_BRICK_WIFI_EAP_OPTION_CERT_TYPE_CA_CERT: u8 = 0;
318pub const MASTER_BRICK_WIFI_EAP_OPTION_CERT_TYPE_CLIENT_CERT: u8 = 8;
319pub const MASTER_BRICK_WIFI_EAP_OPTION_CERT_TYPE_PRIVATE_KEY: u8 = 16;
320pub const MASTER_BRICK_WIFI_STATE_DISASSOCIATED: u8 = 0;
321pub const MASTER_BRICK_WIFI_STATE_ASSOCIATED: u8 = 1;
322pub const MASTER_BRICK_WIFI_STATE_ASSOCIATING: u8 = 2;
323pub const MASTER_BRICK_WIFI_STATE_ERROR: u8 = 3;
324pub const MASTER_BRICK_WIFI_STATE_NOT_INITIALIZED_YET: u8 = 255;
325pub const MASTER_BRICK_WIFI_POWER_MODE_FULL_SPEED: u8 = 0;
326pub const MASTER_BRICK_WIFI_POWER_MODE_LOW_POWER: u8 = 1;
327pub const MASTER_BRICK_WIFI_DOMAIN_CHANNEL_1TO11: u8 = 0;
328pub const MASTER_BRICK_WIFI_DOMAIN_CHANNEL_1TO13: u8 = 1;
329pub const MASTER_BRICK_WIFI_DOMAIN_CHANNEL_1TO14: u8 = 2;
330pub const MASTER_BRICK_THRESHOLD_OPTION_OFF: char = 'x';
331pub const MASTER_BRICK_THRESHOLD_OPTION_OUTSIDE: char = 'o';
332pub const MASTER_BRICK_THRESHOLD_OPTION_INSIDE: char = 'i';
333pub const MASTER_BRICK_THRESHOLD_OPTION_SMALLER: char = '<';
334pub const MASTER_BRICK_THRESHOLD_OPTION_GREATER: char = '>';
335pub const MASTER_BRICK_ETHERNET_CONNECTION_DHCP: u8 = 0;
336pub const MASTER_BRICK_ETHERNET_CONNECTION_STATIC_IP: u8 = 1;
337pub const MASTER_BRICK_CONNECTION_TYPE_NONE: u8 = 0;
338pub const MASTER_BRICK_CONNECTION_TYPE_USB: u8 = 1;
339pub const MASTER_BRICK_CONNECTION_TYPE_SPI_STACK: u8 = 2;
340pub const MASTER_BRICK_CONNECTION_TYPE_CHIBI: u8 = 3;
341pub const MASTER_BRICK_CONNECTION_TYPE_RS485: u8 = 4;
342pub const MASTER_BRICK_CONNECTION_TYPE_WIFI: u8 = 5;
343pub const MASTER_BRICK_CONNECTION_TYPE_ETHERNET: u8 = 6;
344pub const MASTER_BRICK_CONNECTION_TYPE_WIFI2: u8 = 7;
345pub const MASTER_BRICK_WIFI2_PHY_MODE_B: u8 = 0;
346pub const MASTER_BRICK_WIFI2_PHY_MODE_G: u8 = 1;
347pub const MASTER_BRICK_WIFI2_PHY_MODE_N: u8 = 2;
348pub const MASTER_BRICK_WIFI2_CLIENT_STATUS_IDLE: u8 = 0;
349pub const MASTER_BRICK_WIFI2_CLIENT_STATUS_CONNECTING: u8 = 1;
350pub const MASTER_BRICK_WIFI2_CLIENT_STATUS_WRONG_PASSWORD: u8 = 2;
351pub const MASTER_BRICK_WIFI2_CLIENT_STATUS_NO_AP_FOUND: u8 = 3;
352pub const MASTER_BRICK_WIFI2_CLIENT_STATUS_CONNECT_FAILED: u8 = 4;
353pub const MASTER_BRICK_WIFI2_CLIENT_STATUS_GOT_IP: u8 = 5;
354pub const MASTER_BRICK_WIFI2_CLIENT_STATUS_UNKNOWN: u8 = 255;
355pub const MASTER_BRICK_WIFI2_AP_ENCRYPTION_OPEN: u8 = 0;
356pub const MASTER_BRICK_WIFI2_AP_ENCRYPTION_WEP: u8 = 1;
357pub const MASTER_BRICK_WIFI2_AP_ENCRYPTION_WPA_PSK: u8 = 2;
358pub const MASTER_BRICK_WIFI2_AP_ENCRYPTION_WPA2_PSK: u8 = 3;
359pub const MASTER_BRICK_WIFI2_AP_ENCRYPTION_WPA_WPA2_PSK: u8 = 4;
360pub const MASTER_BRICK_WIFI2_MESH_STATUS_DISABLED: u8 = 0;
361pub const MASTER_BRICK_WIFI2_MESH_STATUS_WIFI_CONNECTING: u8 = 1;
362pub const MASTER_BRICK_WIFI2_MESH_STATUS_GOT_IP: u8 = 2;
363pub const MASTER_BRICK_WIFI2_MESH_STATUS_MESH_LOCAL: u8 = 3;
364pub const MASTER_BRICK_WIFI2_MESH_STATUS_MESH_ONLINE: u8 = 4;
365pub const MASTER_BRICK_WIFI2_MESH_STATUS_AP_AVAILABLE: u8 = 5;
366pub const MASTER_BRICK_WIFI2_MESH_STATUS_AP_SETUP: u8 = 6;
367pub const MASTER_BRICK_WIFI2_MESH_STATUS_LEAF_AVAILABLE: u8 = 7;
368pub const MASTER_BRICK_COMMUNICATION_METHOD_NONE: u8 = 0;
369pub const MASTER_BRICK_COMMUNICATION_METHOD_USB: u8 = 1;
370pub const MASTER_BRICK_COMMUNICATION_METHOD_SPI_STACK: u8 = 2;
371pub const MASTER_BRICK_COMMUNICATION_METHOD_CHIBI: u8 = 3;
372pub const MASTER_BRICK_COMMUNICATION_METHOD_RS485: u8 = 4;
373pub const MASTER_BRICK_COMMUNICATION_METHOD_WIFI: u8 = 5;
374pub const MASTER_BRICK_COMMUNICATION_METHOD_ETHERNET: u8 = 6;
375pub const MASTER_BRICK_COMMUNICATION_METHOD_WIFI_V2: u8 = 7;
376
377#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
378pub struct ChibiErrorLog {
379    pub underrun: u16,
380    pub crc_error: u16,
381    pub no_ack: u16,
382    pub overflow: u16,
383}
384impl FromByteSlice for ChibiErrorLog {
385    fn bytes_expected() -> usize {
386        8
387    }
388    fn from_le_byte_slice(bytes: &[u8]) -> ChibiErrorLog {
389        ChibiErrorLog {
390            underrun: <u16>::from_le_byte_slice(&bytes[0..2]),
391            crc_error: <u16>::from_le_byte_slice(&bytes[2..4]),
392            no_ack: <u16>::from_le_byte_slice(&bytes[4..6]),
393            overflow: <u16>::from_le_byte_slice(&bytes[6..8]),
394        }
395    }
396}
397
398#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
399pub struct Rs485Configuration {
400    pub speed: u32,
401    pub parity: char,
402    pub stopbits: u8,
403}
404impl FromByteSlice for Rs485Configuration {
405    fn bytes_expected() -> usize {
406        6
407    }
408    fn from_le_byte_slice(bytes: &[u8]) -> Rs485Configuration {
409        Rs485Configuration {
410            speed: <u32>::from_le_byte_slice(&bytes[0..4]),
411            parity: <char>::from_le_byte_slice(&bytes[4..5]),
412            stopbits: <u8>::from_le_byte_slice(&bytes[5..6]),
413        }
414    }
415}
416
417#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
418pub struct WifiConfiguration {
419    pub ssid: String,
420    pub connection: u8,
421    pub ip: [u8; 4],
422    pub subnet_mask: [u8; 4],
423    pub gateway: [u8; 4],
424    pub port: u16,
425}
426impl FromByteSlice for WifiConfiguration {
427    fn bytes_expected() -> usize {
428        47
429    }
430    fn from_le_byte_slice(bytes: &[u8]) -> WifiConfiguration {
431        WifiConfiguration {
432            ssid: <String>::from_le_byte_slice(&bytes[0..32]),
433            connection: <u8>::from_le_byte_slice(&bytes[32..33]),
434            ip: <[u8; 4]>::from_le_byte_slice(&bytes[33..37]),
435            subnet_mask: <[u8; 4]>::from_le_byte_slice(&bytes[37..41]),
436            gateway: <[u8; 4]>::from_le_byte_slice(&bytes[41..45]),
437            port: <u16>::from_le_byte_slice(&bytes[45..47]),
438        }
439    }
440}
441
442#[derive(Clone)]
443pub struct WifiEncryption {
444    pub encryption: u8,
445    pub key: String,
446    pub key_index: u8,
447    pub eap_options: u8,
448    pub ca_certificate_length: u16,
449    pub client_certificate_length: u16,
450    pub private_key_length: u16,
451}
452impl FromByteSlice for WifiEncryption {
453    fn bytes_expected() -> usize {
454        59
455    }
456    fn from_le_byte_slice(bytes: &[u8]) -> WifiEncryption {
457        WifiEncryption {
458            encryption: <u8>::from_le_byte_slice(&bytes[0..1]),
459            key: <String>::from_le_byte_slice(&bytes[1..51]),
460            key_index: <u8>::from_le_byte_slice(&bytes[51..52]),
461            eap_options: <u8>::from_le_byte_slice(&bytes[52..53]),
462            ca_certificate_length: <u16>::from_le_byte_slice(&bytes[53..55]),
463            client_certificate_length: <u16>::from_le_byte_slice(&bytes[55..57]),
464            private_key_length: <u16>::from_le_byte_slice(&bytes[57..59]),
465        }
466    }
467}
468
469#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
470pub struct WifiStatus {
471    pub mac_address: [u8; 6],
472    pub bssid: [u8; 6],
473    pub channel: u8,
474    pub rssi: i16,
475    pub ip: [u8; 4],
476    pub subnet_mask: [u8; 4],
477    pub gateway: [u8; 4],
478    pub rx_count: u32,
479    pub tx_count: u32,
480    pub state: u8,
481}
482impl FromByteSlice for WifiStatus {
483    fn bytes_expected() -> usize {
484        36
485    }
486    fn from_le_byte_slice(bytes: &[u8]) -> WifiStatus {
487        WifiStatus {
488            mac_address: <[u8; 6]>::from_le_byte_slice(&bytes[0..6]),
489            bssid: <[u8; 6]>::from_le_byte_slice(&bytes[6..12]),
490            channel: <u8>::from_le_byte_slice(&bytes[12..13]),
491            rssi: <i16>::from_le_byte_slice(&bytes[13..15]),
492            ip: <[u8; 4]>::from_le_byte_slice(&bytes[15..19]),
493            subnet_mask: <[u8; 4]>::from_le_byte_slice(&bytes[19..23]),
494            gateway: <[u8; 4]>::from_le_byte_slice(&bytes[23..27]),
495            rx_count: <u32>::from_le_byte_slice(&bytes[27..31]),
496            tx_count: <u32>::from_le_byte_slice(&bytes[31..35]),
497            state: <u8>::from_le_byte_slice(&bytes[35..36]),
498        }
499    }
500}
501
502#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
503pub struct WifiCertificate {
504    pub data: [u8; 32],
505    pub data_length: u8,
506}
507impl FromByteSlice for WifiCertificate {
508    fn bytes_expected() -> usize {
509        33
510    }
511    fn from_le_byte_slice(bytes: &[u8]) -> WifiCertificate {
512        WifiCertificate { data: <[u8; 32]>::from_le_byte_slice(&bytes[0..32]), data_length: <u8>::from_le_byte_slice(&bytes[32..33]) }
513    }
514}
515
516#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
517pub struct WifiBufferInfo {
518    pub overflow: u32,
519    pub low_watermark: u16,
520    pub used: u16,
521}
522impl FromByteSlice for WifiBufferInfo {
523    fn bytes_expected() -> usize {
524        8
525    }
526    fn from_le_byte_slice(bytes: &[u8]) -> WifiBufferInfo {
527        WifiBufferInfo {
528            overflow: <u32>::from_le_byte_slice(&bytes[0..4]),
529            low_watermark: <u16>::from_le_byte_slice(&bytes[4..6]),
530            used: <u16>::from_le_byte_slice(&bytes[6..8]),
531        }
532    }
533}
534
535#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
536pub struct StackCurrentCallbackThreshold {
537    pub option: char,
538    pub min: u16,
539    pub max: u16,
540}
541impl FromByteSlice for StackCurrentCallbackThreshold {
542    fn bytes_expected() -> usize {
543        5
544    }
545    fn from_le_byte_slice(bytes: &[u8]) -> StackCurrentCallbackThreshold {
546        StackCurrentCallbackThreshold {
547            option: <char>::from_le_byte_slice(&bytes[0..1]),
548            min: <u16>::from_le_byte_slice(&bytes[1..3]),
549            max: <u16>::from_le_byte_slice(&bytes[3..5]),
550        }
551    }
552}
553
554#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
555pub struct StackVoltageCallbackThreshold {
556    pub option: char,
557    pub min: u16,
558    pub max: u16,
559}
560impl FromByteSlice for StackVoltageCallbackThreshold {
561    fn bytes_expected() -> usize {
562        5
563    }
564    fn from_le_byte_slice(bytes: &[u8]) -> StackVoltageCallbackThreshold {
565        StackVoltageCallbackThreshold {
566            option: <char>::from_le_byte_slice(&bytes[0..1]),
567            min: <u16>::from_le_byte_slice(&bytes[1..3]),
568            max: <u16>::from_le_byte_slice(&bytes[3..5]),
569        }
570    }
571}
572
573#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
574pub struct UsbVoltageCallbackThreshold {
575    pub option: char,
576    pub min: u16,
577    pub max: u16,
578}
579impl FromByteSlice for UsbVoltageCallbackThreshold {
580    fn bytes_expected() -> usize {
581        5
582    }
583    fn from_le_byte_slice(bytes: &[u8]) -> UsbVoltageCallbackThreshold {
584        UsbVoltageCallbackThreshold {
585            option: <char>::from_le_byte_slice(&bytes[0..1]),
586            min: <u16>::from_le_byte_slice(&bytes[1..3]),
587            max: <u16>::from_le_byte_slice(&bytes[3..5]),
588        }
589    }
590}
591
592#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
593pub struct EthernetConfiguration {
594    pub connection: u8,
595    pub ip: [u8; 4],
596    pub subnet_mask: [u8; 4],
597    pub gateway: [u8; 4],
598    pub port: u16,
599}
600impl FromByteSlice for EthernetConfiguration {
601    fn bytes_expected() -> usize {
602        15
603    }
604    fn from_le_byte_slice(bytes: &[u8]) -> EthernetConfiguration {
605        EthernetConfiguration {
606            connection: <u8>::from_le_byte_slice(&bytes[0..1]),
607            ip: <[u8; 4]>::from_le_byte_slice(&bytes[1..5]),
608            subnet_mask: <[u8; 4]>::from_le_byte_slice(&bytes[5..9]),
609            gateway: <[u8; 4]>::from_le_byte_slice(&bytes[9..13]),
610            port: <u16>::from_le_byte_slice(&bytes[13..15]),
611        }
612    }
613}
614
615#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
616pub struct EthernetStatus {
617    pub mac_address: [u8; 6],
618    pub ip: [u8; 4],
619    pub subnet_mask: [u8; 4],
620    pub gateway: [u8; 4],
621    pub rx_count: u32,
622    pub tx_count: u32,
623    pub hostname: String,
624}
625impl FromByteSlice for EthernetStatus {
626    fn bytes_expected() -> usize {
627        58
628    }
629    fn from_le_byte_slice(bytes: &[u8]) -> EthernetStatus {
630        EthernetStatus {
631            mac_address: <[u8; 6]>::from_le_byte_slice(&bytes[0..6]),
632            ip: <[u8; 4]>::from_le_byte_slice(&bytes[6..10]),
633            subnet_mask: <[u8; 4]>::from_le_byte_slice(&bytes[10..14]),
634            gateway: <[u8; 4]>::from_le_byte_slice(&bytes[14..18]),
635            rx_count: <u32>::from_le_byte_slice(&bytes[18..22]),
636            tx_count: <u32>::from_le_byte_slice(&bytes[22..26]),
637            hostname: <String>::from_le_byte_slice(&bytes[26..58]),
638        }
639    }
640}
641
642#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
643pub struct EthernetWebsocketConfiguration {
644    pub sockets: u8,
645    pub port: u16,
646}
647impl FromByteSlice for EthernetWebsocketConfiguration {
648    fn bytes_expected() -> usize {
649        3
650    }
651    fn from_le_byte_slice(bytes: &[u8]) -> EthernetWebsocketConfiguration {
652        EthernetWebsocketConfiguration { sockets: <u8>::from_le_byte_slice(&bytes[0..1]), port: <u16>::from_le_byte_slice(&bytes[1..3]) }
653    }
654}
655
656#[derive(Clone, Copy)]
657pub struct ReadWifi2SerialPort {
658    pub data: [u8; 60],
659    pub result: u8,
660}
661impl FromByteSlice for ReadWifi2SerialPort {
662    fn bytes_expected() -> usize {
663        61
664    }
665    fn from_le_byte_slice(bytes: &[u8]) -> ReadWifi2SerialPort {
666        ReadWifi2SerialPort { data: <[u8; 60]>::from_le_byte_slice(&bytes[0..60]), result: <u8>::from_le_byte_slice(&bytes[60..61]) }
667    }
668}
669
670#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
671pub struct Wifi2Configuration {
672    pub port: u16,
673    pub websocket_port: u16,
674    pub website_port: u16,
675    pub phy_mode: u8,
676    pub sleep_mode: u8,
677    pub website: u8,
678}
679impl FromByteSlice for Wifi2Configuration {
680    fn bytes_expected() -> usize {
681        9
682    }
683    fn from_le_byte_slice(bytes: &[u8]) -> Wifi2Configuration {
684        Wifi2Configuration {
685            port: <u16>::from_le_byte_slice(&bytes[0..2]),
686            websocket_port: <u16>::from_le_byte_slice(&bytes[2..4]),
687            website_port: <u16>::from_le_byte_slice(&bytes[4..6]),
688            phy_mode: <u8>::from_le_byte_slice(&bytes[6..7]),
689            sleep_mode: <u8>::from_le_byte_slice(&bytes[7..8]),
690            website: <u8>::from_le_byte_slice(&bytes[8..9]),
691        }
692    }
693}
694
695#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
696pub struct Wifi2Status {
697    pub client_enabled: bool,
698    pub client_status: u8,
699    pub client_ip: [u8; 4],
700    pub client_subnet_mask: [u8; 4],
701    pub client_gateway: [u8; 4],
702    pub client_mac_address: [u8; 6],
703    pub client_rx_count: u32,
704    pub client_tx_count: u32,
705    pub client_rssi: i8,
706    pub ap_enabled: bool,
707    pub ap_ip: [u8; 4],
708    pub ap_subnet_mask: [u8; 4],
709    pub ap_gateway: [u8; 4],
710    pub ap_mac_address: [u8; 6],
711    pub ap_rx_count: u32,
712    pub ap_tx_count: u32,
713    pub ap_connected_count: u8,
714}
715impl FromByteSlice for Wifi2Status {
716    fn bytes_expected() -> usize {
717        57
718    }
719    fn from_le_byte_slice(bytes: &[u8]) -> Wifi2Status {
720        Wifi2Status {
721            client_enabled: <bool>::from_le_byte_slice(&bytes[0..1]),
722            client_status: <u8>::from_le_byte_slice(&bytes[1..2]),
723            client_ip: <[u8; 4]>::from_le_byte_slice(&bytes[2..6]),
724            client_subnet_mask: <[u8; 4]>::from_le_byte_slice(&bytes[6..10]),
725            client_gateway: <[u8; 4]>::from_le_byte_slice(&bytes[10..14]),
726            client_mac_address: <[u8; 6]>::from_le_byte_slice(&bytes[14..20]),
727            client_rx_count: <u32>::from_le_byte_slice(&bytes[20..24]),
728            client_tx_count: <u32>::from_le_byte_slice(&bytes[24..28]),
729            client_rssi: <i8>::from_le_byte_slice(&bytes[28..29]),
730            ap_enabled: <bool>::from_le_byte_slice(&bytes[29..30]),
731            ap_ip: <[u8; 4]>::from_le_byte_slice(&bytes[30..34]),
732            ap_subnet_mask: <[u8; 4]>::from_le_byte_slice(&bytes[34..38]),
733            ap_gateway: <[u8; 4]>::from_le_byte_slice(&bytes[38..42]),
734            ap_mac_address: <[u8; 6]>::from_le_byte_slice(&bytes[42..48]),
735            ap_rx_count: <u32>::from_le_byte_slice(&bytes[48..52]),
736            ap_tx_count: <u32>::from_le_byte_slice(&bytes[52..56]),
737            ap_connected_count: <u8>::from_le_byte_slice(&bytes[56..57]),
738        }
739    }
740}
741
742#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
743pub struct Wifi2ClientConfiguration {
744    pub enable: bool,
745    pub ssid: String,
746    pub ip: [u8; 4],
747    pub subnet_mask: [u8; 4],
748    pub gateway: [u8; 4],
749    pub mac_address: [u8; 6],
750    pub bssid: [u8; 6],
751}
752impl FromByteSlice for Wifi2ClientConfiguration {
753    fn bytes_expected() -> usize {
754        57
755    }
756    fn from_le_byte_slice(bytes: &[u8]) -> Wifi2ClientConfiguration {
757        Wifi2ClientConfiguration {
758            enable: <bool>::from_le_byte_slice(&bytes[0..1]),
759            ssid: <String>::from_le_byte_slice(&bytes[1..33]),
760            ip: <[u8; 4]>::from_le_byte_slice(&bytes[33..37]),
761            subnet_mask: <[u8; 4]>::from_le_byte_slice(&bytes[37..41]),
762            gateway: <[u8; 4]>::from_le_byte_slice(&bytes[41..45]),
763            mac_address: <[u8; 6]>::from_le_byte_slice(&bytes[45..51]),
764            bssid: <[u8; 6]>::from_le_byte_slice(&bytes[51..57]),
765        }
766    }
767}
768
769#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
770pub struct Wifi2ApConfiguration {
771    pub enable: bool,
772    pub ssid: String,
773    pub ip: [u8; 4],
774    pub subnet_mask: [u8; 4],
775    pub gateway: [u8; 4],
776    pub encryption: u8,
777    pub hidden: bool,
778    pub channel: u8,
779    pub mac_address: [u8; 6],
780}
781impl FromByteSlice for Wifi2ApConfiguration {
782    fn bytes_expected() -> usize {
783        54
784    }
785    fn from_le_byte_slice(bytes: &[u8]) -> Wifi2ApConfiguration {
786        Wifi2ApConfiguration {
787            enable: <bool>::from_le_byte_slice(&bytes[0..1]),
788            ssid: <String>::from_le_byte_slice(&bytes[1..33]),
789            ip: <[u8; 4]>::from_le_byte_slice(&bytes[33..37]),
790            subnet_mask: <[u8; 4]>::from_le_byte_slice(&bytes[37..41]),
791            gateway: <[u8; 4]>::from_le_byte_slice(&bytes[41..45]),
792            encryption: <u8>::from_le_byte_slice(&bytes[45..46]),
793            hidden: <bool>::from_le_byte_slice(&bytes[46..47]),
794            channel: <u8>::from_le_byte_slice(&bytes[47..48]),
795            mac_address: <[u8; 6]>::from_le_byte_slice(&bytes[48..54]),
796        }
797    }
798}
799
800#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
801pub struct Wifi2MeshConfiguration {
802    pub enable: bool,
803    pub root_ip: [u8; 4],
804    pub root_subnet_mask: [u8; 4],
805    pub root_gateway: [u8; 4],
806    pub router_bssid: [u8; 6],
807    pub group_id: [u8; 6],
808    pub group_ssid_prefix: String,
809    pub gateway_ip: [u8; 4],
810    pub gateway_port: u16,
811}
812impl FromByteSlice for Wifi2MeshConfiguration {
813    fn bytes_expected() -> usize {
814        47
815    }
816    fn from_le_byte_slice(bytes: &[u8]) -> Wifi2MeshConfiguration {
817        Wifi2MeshConfiguration {
818            enable: <bool>::from_le_byte_slice(&bytes[0..1]),
819            root_ip: <[u8; 4]>::from_le_byte_slice(&bytes[1..5]),
820            root_subnet_mask: <[u8; 4]>::from_le_byte_slice(&bytes[5..9]),
821            root_gateway: <[u8; 4]>::from_le_byte_slice(&bytes[9..13]),
822            router_bssid: <[u8; 6]>::from_le_byte_slice(&bytes[13..19]),
823            group_id: <[u8; 6]>::from_le_byte_slice(&bytes[19..25]),
824            group_ssid_prefix: <String>::from_le_byte_slice(&bytes[25..41]),
825            gateway_ip: <[u8; 4]>::from_le_byte_slice(&bytes[41..45]),
826            gateway_port: <u16>::from_le_byte_slice(&bytes[45..47]),
827        }
828    }
829}
830
831#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
832pub struct Wifi2MeshCommonStatus {
833    pub status: u8,
834    pub root_node: bool,
835    pub root_candidate: bool,
836    pub connected_nodes: u16,
837    pub rx_count: u32,
838    pub tx_count: u32,
839}
840impl FromByteSlice for Wifi2MeshCommonStatus {
841    fn bytes_expected() -> usize {
842        13
843    }
844    fn from_le_byte_slice(bytes: &[u8]) -> Wifi2MeshCommonStatus {
845        Wifi2MeshCommonStatus {
846            status: <u8>::from_le_byte_slice(&bytes[0..1]),
847            root_node: <bool>::from_le_byte_slice(&bytes[1..2]),
848            root_candidate: <bool>::from_le_byte_slice(&bytes[2..3]),
849            connected_nodes: <u16>::from_le_byte_slice(&bytes[3..5]),
850            rx_count: <u32>::from_le_byte_slice(&bytes[5..9]),
851            tx_count: <u32>::from_le_byte_slice(&bytes[9..13]),
852        }
853    }
854}
855
856#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
857pub struct Wifi2MeshClientStatus {
858    pub hostname: String,
859    pub ip: [u8; 4],
860    pub subnet_mask: [u8; 4],
861    pub gateway: [u8; 4],
862    pub mac_address: [u8; 6],
863}
864impl FromByteSlice for Wifi2MeshClientStatus {
865    fn bytes_expected() -> usize {
866        50
867    }
868    fn from_le_byte_slice(bytes: &[u8]) -> Wifi2MeshClientStatus {
869        Wifi2MeshClientStatus {
870            hostname: <String>::from_le_byte_slice(&bytes[0..32]),
871            ip: <[u8; 4]>::from_le_byte_slice(&bytes[32..36]),
872            subnet_mask: <[u8; 4]>::from_le_byte_slice(&bytes[36..40]),
873            gateway: <[u8; 4]>::from_le_byte_slice(&bytes[40..44]),
874            mac_address: <[u8; 6]>::from_le_byte_slice(&bytes[44..50]),
875        }
876    }
877}
878
879#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
880pub struct Wifi2MeshApStatus {
881    pub ssid: String,
882    pub ip: [u8; 4],
883    pub subnet_mask: [u8; 4],
884    pub gateway: [u8; 4],
885    pub mac_address: [u8; 6],
886}
887impl FromByteSlice for Wifi2MeshApStatus {
888    fn bytes_expected() -> usize {
889        50
890    }
891    fn from_le_byte_slice(bytes: &[u8]) -> Wifi2MeshApStatus {
892        Wifi2MeshApStatus {
893            ssid: <String>::from_le_byte_slice(&bytes[0..32]),
894            ip: <[u8; 4]>::from_le_byte_slice(&bytes[32..36]),
895            subnet_mask: <[u8; 4]>::from_le_byte_slice(&bytes[36..40]),
896            gateway: <[u8; 4]>::from_le_byte_slice(&bytes[40..44]),
897            mac_address: <[u8; 6]>::from_le_byte_slice(&bytes[44..50]),
898        }
899    }
900}
901
902#[derive(Clone, Copy)]
903pub struct SetBrickletXmcFlashConfig {
904    pub return_value: u32,
905    pub return_data: [u8; 60],
906}
907impl FromByteSlice for SetBrickletXmcFlashConfig {
908    fn bytes_expected() -> usize {
909        64
910    }
911    fn from_le_byte_slice(bytes: &[u8]) -> SetBrickletXmcFlashConfig {
912        SetBrickletXmcFlashConfig {
913            return_value: <u32>::from_le_byte_slice(&bytes[0..4]),
914            return_data: <[u8; 60]>::from_le_byte_slice(&bytes[4..64]),
915        }
916    }
917}
918
919#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
920pub struct SpitfpBaudrateConfig {
921    pub enable_dynamic_baudrate: bool,
922    pub minimum_dynamic_baudrate: u32,
923}
924impl FromByteSlice for SpitfpBaudrateConfig {
925    fn bytes_expected() -> usize {
926        5
927    }
928    fn from_le_byte_slice(bytes: &[u8]) -> SpitfpBaudrateConfig {
929        SpitfpBaudrateConfig {
930            enable_dynamic_baudrate: <bool>::from_le_byte_slice(&bytes[0..1]),
931            minimum_dynamic_baudrate: <u32>::from_le_byte_slice(&bytes[1..5]),
932        }
933    }
934}
935
936#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
937pub struct SpitfpErrorCount {
938    pub error_count_ack_checksum: u32,
939    pub error_count_message_checksum: u32,
940    pub error_count_frame: u32,
941    pub error_count_overflow: u32,
942}
943impl FromByteSlice for SpitfpErrorCount {
944    fn bytes_expected() -> usize {
945        16
946    }
947    fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
948        SpitfpErrorCount {
949            error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
950            error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
951            error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
952            error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
953        }
954    }
955}
956
957#[derive(Clone)]
958pub struct Protocol1BrickletName {
959    pub protocol_version: u8,
960    pub firmware_version: [u8; 3],
961    pub name: String,
962}
963impl FromByteSlice for Protocol1BrickletName {
964    fn bytes_expected() -> usize {
965        44
966    }
967    fn from_le_byte_slice(bytes: &[u8]) -> Protocol1BrickletName {
968        Protocol1BrickletName {
969            protocol_version: <u8>::from_le_byte_slice(&bytes[0..1]),
970            firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[1..4]),
971            name: <String>::from_le_byte_slice(&bytes[4..44]),
972        }
973    }
974}
975
976#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
977pub struct Identity {
978    pub uid: String,
979    pub connected_uid: String,
980    pub position: char,
981    pub hardware_version: [u8; 3],
982    pub firmware_version: [u8; 3],
983    pub device_identifier: u16,
984}
985impl FromByteSlice for Identity {
986    fn bytes_expected() -> usize {
987        25
988    }
989    fn from_le_byte_slice(bytes: &[u8]) -> Identity {
990        Identity {
991            uid: <String>::from_le_byte_slice(&bytes[0..8]),
992            connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
993            position: <char>::from_le_byte_slice(&bytes[16..17]),
994            hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
995            firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
996            device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
997        }
998    }
999}
1000
1001/// Basis to build stacks and has 4 Bricklet ports
1002#[derive(Clone)]
1003pub struct MasterBrick {
1004    device: Device,
1005}
1006impl MasterBrick {
1007    pub const DEVICE_IDENTIFIER: u16 = 13;
1008    pub const DEVICE_DISPLAY_NAME: &'static str = "Master Brick";
1009    /// Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ip_connection` is connected.
1010    pub fn new(uid: Uid, connection: AsyncIpConnection) -> MasterBrick {
1011        let mut result = MasterBrick { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
1012        result.device.response_expected[u8::from(MasterBrickFunction::GetStackVoltage) as usize] = ResponseExpectedFlag::AlwaysTrue;
1013        result.device.response_expected[u8::from(MasterBrickFunction::GetStackCurrent) as usize] = ResponseExpectedFlag::AlwaysTrue;
1014        result.device.response_expected[u8::from(MasterBrickFunction::SetExtensionType) as usize] = ResponseExpectedFlag::False;
1015        result.device.response_expected[u8::from(MasterBrickFunction::GetExtensionType) as usize] = ResponseExpectedFlag::AlwaysTrue;
1016        result.device.response_expected[u8::from(MasterBrickFunction::IsChibiPresent) as usize] = ResponseExpectedFlag::AlwaysTrue;
1017        result.device.response_expected[u8::from(MasterBrickFunction::SetChibiAddress) as usize] = ResponseExpectedFlag::False;
1018        result.device.response_expected[u8::from(MasterBrickFunction::GetChibiAddress) as usize] = ResponseExpectedFlag::AlwaysTrue;
1019        result.device.response_expected[u8::from(MasterBrickFunction::SetChibiMasterAddress) as usize] = ResponseExpectedFlag::False;
1020        result.device.response_expected[u8::from(MasterBrickFunction::GetChibiMasterAddress) as usize] = ResponseExpectedFlag::AlwaysTrue;
1021        result.device.response_expected[u8::from(MasterBrickFunction::SetChibiSlaveAddress) as usize] = ResponseExpectedFlag::False;
1022        result.device.response_expected[u8::from(MasterBrickFunction::GetChibiSlaveAddress) as usize] = ResponseExpectedFlag::AlwaysTrue;
1023        result.device.response_expected[u8::from(MasterBrickFunction::GetChibiSignalStrength) as usize] = ResponseExpectedFlag::AlwaysTrue;
1024        result.device.response_expected[u8::from(MasterBrickFunction::GetChibiErrorLog) as usize] = ResponseExpectedFlag::AlwaysTrue;
1025        result.device.response_expected[u8::from(MasterBrickFunction::SetChibiFrequency) as usize] = ResponseExpectedFlag::False;
1026        result.device.response_expected[u8::from(MasterBrickFunction::GetChibiFrequency) as usize] = ResponseExpectedFlag::AlwaysTrue;
1027        result.device.response_expected[u8::from(MasterBrickFunction::SetChibiChannel) as usize] = ResponseExpectedFlag::False;
1028        result.device.response_expected[u8::from(MasterBrickFunction::GetChibiChannel) as usize] = ResponseExpectedFlag::AlwaysTrue;
1029        result.device.response_expected[u8::from(MasterBrickFunction::IsRs485Present) as usize] = ResponseExpectedFlag::AlwaysTrue;
1030        result.device.response_expected[u8::from(MasterBrickFunction::SetRs485Address) as usize] = ResponseExpectedFlag::False;
1031        result.device.response_expected[u8::from(MasterBrickFunction::GetRs485Address) as usize] = ResponseExpectedFlag::AlwaysTrue;
1032        result.device.response_expected[u8::from(MasterBrickFunction::SetRs485SlaveAddress) as usize] = ResponseExpectedFlag::False;
1033        result.device.response_expected[u8::from(MasterBrickFunction::GetRs485SlaveAddress) as usize] = ResponseExpectedFlag::AlwaysTrue;
1034        result.device.response_expected[u8::from(MasterBrickFunction::GetRs485ErrorLog) as usize] = ResponseExpectedFlag::AlwaysTrue;
1035        result.device.response_expected[u8::from(MasterBrickFunction::SetRs485Configuration) as usize] = ResponseExpectedFlag::False;
1036        result.device.response_expected[u8::from(MasterBrickFunction::GetRs485Configuration) as usize] = ResponseExpectedFlag::AlwaysTrue;
1037        result.device.response_expected[u8::from(MasterBrickFunction::IsWifiPresent) as usize] = ResponseExpectedFlag::AlwaysTrue;
1038        result.device.response_expected[u8::from(MasterBrickFunction::SetWifiConfiguration) as usize] = ResponseExpectedFlag::False;
1039        result.device.response_expected[u8::from(MasterBrickFunction::GetWifiConfiguration) as usize] = ResponseExpectedFlag::AlwaysTrue;
1040        result.device.response_expected[u8::from(MasterBrickFunction::SetWifiEncryption) as usize] = ResponseExpectedFlag::False;
1041        result.device.response_expected[u8::from(MasterBrickFunction::GetWifiEncryption) as usize] = ResponseExpectedFlag::AlwaysTrue;
1042        result.device.response_expected[u8::from(MasterBrickFunction::GetWifiStatus) as usize] = ResponseExpectedFlag::AlwaysTrue;
1043        result.device.response_expected[u8::from(MasterBrickFunction::RefreshWifiStatus) as usize] = ResponseExpectedFlag::False;
1044        result.device.response_expected[u8::from(MasterBrickFunction::SetWifiCertificate) as usize] = ResponseExpectedFlag::False;
1045        result.device.response_expected[u8::from(MasterBrickFunction::GetWifiCertificate) as usize] = ResponseExpectedFlag::AlwaysTrue;
1046        result.device.response_expected[u8::from(MasterBrickFunction::SetWifiPowerMode) as usize] = ResponseExpectedFlag::False;
1047        result.device.response_expected[u8::from(MasterBrickFunction::GetWifiPowerMode) as usize] = ResponseExpectedFlag::AlwaysTrue;
1048        result.device.response_expected[u8::from(MasterBrickFunction::GetWifiBufferInfo) as usize] = ResponseExpectedFlag::AlwaysTrue;
1049        result.device.response_expected[u8::from(MasterBrickFunction::SetWifiRegulatoryDomain) as usize] = ResponseExpectedFlag::False;
1050        result.device.response_expected[u8::from(MasterBrickFunction::GetWifiRegulatoryDomain) as usize] = ResponseExpectedFlag::AlwaysTrue;
1051        result.device.response_expected[u8::from(MasterBrickFunction::GetUsbVoltage) as usize] = ResponseExpectedFlag::AlwaysTrue;
1052        result.device.response_expected[u8::from(MasterBrickFunction::SetLongWifiKey) as usize] = ResponseExpectedFlag::False;
1053        result.device.response_expected[u8::from(MasterBrickFunction::GetLongWifiKey) as usize] = ResponseExpectedFlag::AlwaysTrue;
1054        result.device.response_expected[u8::from(MasterBrickFunction::SetWifiHostname) as usize] = ResponseExpectedFlag::False;
1055        result.device.response_expected[u8::from(MasterBrickFunction::GetWifiHostname) as usize] = ResponseExpectedFlag::AlwaysTrue;
1056        result.device.response_expected[u8::from(MasterBrickFunction::SetStackCurrentCallbackPeriod) as usize] = ResponseExpectedFlag::True;
1057        result.device.response_expected[u8::from(MasterBrickFunction::GetStackCurrentCallbackPeriod) as usize] =
1058            ResponseExpectedFlag::AlwaysTrue;
1059        result.device.response_expected[u8::from(MasterBrickFunction::SetStackVoltageCallbackPeriod) as usize] = ResponseExpectedFlag::True;
1060        result.device.response_expected[u8::from(MasterBrickFunction::GetStackVoltageCallbackPeriod) as usize] =
1061            ResponseExpectedFlag::AlwaysTrue;
1062        result.device.response_expected[u8::from(MasterBrickFunction::SetUsbVoltageCallbackPeriod) as usize] = ResponseExpectedFlag::True;
1063        result.device.response_expected[u8::from(MasterBrickFunction::GetUsbVoltageCallbackPeriod) as usize] =
1064            ResponseExpectedFlag::AlwaysTrue;
1065        result.device.response_expected[u8::from(MasterBrickFunction::SetStackCurrentCallbackThreshold) as usize] =
1066            ResponseExpectedFlag::True;
1067        result.device.response_expected[u8::from(MasterBrickFunction::GetStackCurrentCallbackThreshold) as usize] =
1068            ResponseExpectedFlag::AlwaysTrue;
1069        result.device.response_expected[u8::from(MasterBrickFunction::SetStackVoltageCallbackThreshold) as usize] =
1070            ResponseExpectedFlag::True;
1071        result.device.response_expected[u8::from(MasterBrickFunction::GetStackVoltageCallbackThreshold) as usize] =
1072            ResponseExpectedFlag::AlwaysTrue;
1073        result.device.response_expected[u8::from(MasterBrickFunction::SetUsbVoltageCallbackThreshold) as usize] =
1074            ResponseExpectedFlag::True;
1075        result.device.response_expected[u8::from(MasterBrickFunction::GetUsbVoltageCallbackThreshold) as usize] =
1076            ResponseExpectedFlag::AlwaysTrue;
1077        result.device.response_expected[u8::from(MasterBrickFunction::SetDebouncePeriod) as usize] = ResponseExpectedFlag::True;
1078        result.device.response_expected[u8::from(MasterBrickFunction::GetDebouncePeriod) as usize] = ResponseExpectedFlag::AlwaysTrue;
1079        result.device.response_expected[u8::from(MasterBrickFunction::IsEthernetPresent) as usize] = ResponseExpectedFlag::AlwaysTrue;
1080        result.device.response_expected[u8::from(MasterBrickFunction::SetEthernetConfiguration) as usize] = ResponseExpectedFlag::False;
1081        result.device.response_expected[u8::from(MasterBrickFunction::GetEthernetConfiguration) as usize] =
1082            ResponseExpectedFlag::AlwaysTrue;
1083        result.device.response_expected[u8::from(MasterBrickFunction::GetEthernetStatus) as usize] = ResponseExpectedFlag::AlwaysTrue;
1084        result.device.response_expected[u8::from(MasterBrickFunction::SetEthernetHostname) as usize] = ResponseExpectedFlag::False;
1085        result.device.response_expected[u8::from(MasterBrickFunction::SetEthernetMacAddress) as usize] = ResponseExpectedFlag::False;
1086        result.device.response_expected[u8::from(MasterBrickFunction::SetEthernetWebsocketConfiguration) as usize] =
1087            ResponseExpectedFlag::False;
1088        result.device.response_expected[u8::from(MasterBrickFunction::GetEthernetWebsocketConfiguration) as usize] =
1089            ResponseExpectedFlag::AlwaysTrue;
1090        result.device.response_expected[u8::from(MasterBrickFunction::SetEthernetAuthenticationSecret) as usize] =
1091            ResponseExpectedFlag::False;
1092        result.device.response_expected[u8::from(MasterBrickFunction::GetEthernetAuthenticationSecret) as usize] =
1093            ResponseExpectedFlag::AlwaysTrue;
1094        result.device.response_expected[u8::from(MasterBrickFunction::SetWifiAuthenticationSecret) as usize] = ResponseExpectedFlag::False;
1095        result.device.response_expected[u8::from(MasterBrickFunction::GetWifiAuthenticationSecret) as usize] =
1096            ResponseExpectedFlag::AlwaysTrue;
1097        result.device.response_expected[u8::from(MasterBrickFunction::GetConnectionType) as usize] = ResponseExpectedFlag::AlwaysTrue;
1098        result.device.response_expected[u8::from(MasterBrickFunction::IsWifi2Present) as usize] = ResponseExpectedFlag::AlwaysTrue;
1099        result.device.response_expected[u8::from(MasterBrickFunction::StartWifi2Bootloader) as usize] = ResponseExpectedFlag::AlwaysTrue;
1100        result.device.response_expected[u8::from(MasterBrickFunction::WriteWifi2SerialPort) as usize] = ResponseExpectedFlag::AlwaysTrue;
1101        result.device.response_expected[u8::from(MasterBrickFunction::ReadWifi2SerialPort) as usize] = ResponseExpectedFlag::AlwaysTrue;
1102        result.device.response_expected[u8::from(MasterBrickFunction::SetWifi2AuthenticationSecret) as usize] = ResponseExpectedFlag::False;
1103        result.device.response_expected[u8::from(MasterBrickFunction::GetWifi2AuthenticationSecret) as usize] =
1104            ResponseExpectedFlag::AlwaysTrue;
1105        result.device.response_expected[u8::from(MasterBrickFunction::SetWifi2Configuration) as usize] = ResponseExpectedFlag::False;
1106        result.device.response_expected[u8::from(MasterBrickFunction::GetWifi2Configuration) as usize] = ResponseExpectedFlag::AlwaysTrue;
1107        result.device.response_expected[u8::from(MasterBrickFunction::GetWifi2Status) as usize] = ResponseExpectedFlag::AlwaysTrue;
1108        result.device.response_expected[u8::from(MasterBrickFunction::SetWifi2ClientConfiguration) as usize] = ResponseExpectedFlag::False;
1109        result.device.response_expected[u8::from(MasterBrickFunction::GetWifi2ClientConfiguration) as usize] =
1110            ResponseExpectedFlag::AlwaysTrue;
1111        result.device.response_expected[u8::from(MasterBrickFunction::SetWifi2ClientHostname) as usize] = ResponseExpectedFlag::False;
1112        result.device.response_expected[u8::from(MasterBrickFunction::GetWifi2ClientHostname) as usize] = ResponseExpectedFlag::AlwaysTrue;
1113        result.device.response_expected[u8::from(MasterBrickFunction::SetWifi2ClientPassword) as usize] = ResponseExpectedFlag::False;
1114        result.device.response_expected[u8::from(MasterBrickFunction::GetWifi2ClientPassword) as usize] = ResponseExpectedFlag::AlwaysTrue;
1115        result.device.response_expected[u8::from(MasterBrickFunction::SetWifi2ApConfiguration) as usize] = ResponseExpectedFlag::False;
1116        result.device.response_expected[u8::from(MasterBrickFunction::GetWifi2ApConfiguration) as usize] = ResponseExpectedFlag::AlwaysTrue;
1117        result.device.response_expected[u8::from(MasterBrickFunction::SetWifi2ApPassword) as usize] = ResponseExpectedFlag::False;
1118        result.device.response_expected[u8::from(MasterBrickFunction::GetWifi2ApPassword) as usize] = ResponseExpectedFlag::AlwaysTrue;
1119        result.device.response_expected[u8::from(MasterBrickFunction::SaveWifi2Configuration) as usize] = ResponseExpectedFlag::AlwaysTrue;
1120        result.device.response_expected[u8::from(MasterBrickFunction::GetWifi2FirmwareVersion) as usize] = ResponseExpectedFlag::AlwaysTrue;
1121        result.device.response_expected[u8::from(MasterBrickFunction::EnableWifi2StatusLed) as usize] = ResponseExpectedFlag::False;
1122        result.device.response_expected[u8::from(MasterBrickFunction::DisableWifi2StatusLed) as usize] = ResponseExpectedFlag::False;
1123        result.device.response_expected[u8::from(MasterBrickFunction::IsWifi2StatusLedEnabled) as usize] = ResponseExpectedFlag::AlwaysTrue;
1124        result.device.response_expected[u8::from(MasterBrickFunction::SetWifi2MeshConfiguration) as usize] = ResponseExpectedFlag::False;
1125        result.device.response_expected[u8::from(MasterBrickFunction::GetWifi2MeshConfiguration) as usize] =
1126            ResponseExpectedFlag::AlwaysTrue;
1127        result.device.response_expected[u8::from(MasterBrickFunction::SetWifi2MeshRouterSsid) as usize] = ResponseExpectedFlag::False;
1128        result.device.response_expected[u8::from(MasterBrickFunction::GetWifi2MeshRouterSsid) as usize] = ResponseExpectedFlag::AlwaysTrue;
1129        result.device.response_expected[u8::from(MasterBrickFunction::SetWifi2MeshRouterPassword) as usize] = ResponseExpectedFlag::False;
1130        result.device.response_expected[u8::from(MasterBrickFunction::GetWifi2MeshRouterPassword) as usize] =
1131            ResponseExpectedFlag::AlwaysTrue;
1132        result.device.response_expected[u8::from(MasterBrickFunction::GetWifi2MeshCommonStatus) as usize] =
1133            ResponseExpectedFlag::AlwaysTrue;
1134        result.device.response_expected[u8::from(MasterBrickFunction::GetWifi2MeshClientStatus) as usize] =
1135            ResponseExpectedFlag::AlwaysTrue;
1136        result.device.response_expected[u8::from(MasterBrickFunction::GetWifi2MeshApStatus) as usize] = ResponseExpectedFlag::AlwaysTrue;
1137        result.device.response_expected[u8::from(MasterBrickFunction::SetBrickletXmcFlashConfig) as usize] =
1138            ResponseExpectedFlag::AlwaysTrue;
1139        result.device.response_expected[u8::from(MasterBrickFunction::SetBrickletXmcFlashData) as usize] = ResponseExpectedFlag::AlwaysTrue;
1140        result.device.response_expected[u8::from(MasterBrickFunction::SetBrickletsEnabled) as usize] = ResponseExpectedFlag::False;
1141        result.device.response_expected[u8::from(MasterBrickFunction::GetBrickletsEnabled) as usize] = ResponseExpectedFlag::AlwaysTrue;
1142        result.device.response_expected[u8::from(MasterBrickFunction::SetSpitfpBaudrateConfig) as usize] = ResponseExpectedFlag::False;
1143        result.device.response_expected[u8::from(MasterBrickFunction::GetSpitfpBaudrateConfig) as usize] = ResponseExpectedFlag::AlwaysTrue;
1144        result.device.response_expected[u8::from(MasterBrickFunction::GetSendTimeoutCount) as usize] = ResponseExpectedFlag::AlwaysTrue;
1145        result.device.response_expected[u8::from(MasterBrickFunction::SetSpitfpBaudrate) as usize] = ResponseExpectedFlag::False;
1146        result.device.response_expected[u8::from(MasterBrickFunction::GetSpitfpBaudrate) as usize] = ResponseExpectedFlag::AlwaysTrue;
1147        result.device.response_expected[u8::from(MasterBrickFunction::GetSpitfpErrorCount) as usize] = ResponseExpectedFlag::AlwaysTrue;
1148        result.device.response_expected[u8::from(MasterBrickFunction::EnableStatusLed) as usize] = ResponseExpectedFlag::False;
1149        result.device.response_expected[u8::from(MasterBrickFunction::DisableStatusLed) as usize] = ResponseExpectedFlag::False;
1150        result.device.response_expected[u8::from(MasterBrickFunction::IsStatusLedEnabled) as usize] = ResponseExpectedFlag::AlwaysTrue;
1151        result.device.response_expected[u8::from(MasterBrickFunction::GetProtocol1BrickletName) as usize] =
1152            ResponseExpectedFlag::AlwaysTrue;
1153        result.device.response_expected[u8::from(MasterBrickFunction::GetChipTemperature) as usize] = ResponseExpectedFlag::AlwaysTrue;
1154        result.device.response_expected[u8::from(MasterBrickFunction::Reset) as usize] = ResponseExpectedFlag::False;
1155        result.device.response_expected[u8::from(MasterBrickFunction::WriteBrickletPlugin) as usize] = ResponseExpectedFlag::False;
1156        result.device.response_expected[u8::from(MasterBrickFunction::ReadBrickletPlugin) as usize] = ResponseExpectedFlag::AlwaysTrue;
1157        result.device.response_expected[u8::from(MasterBrickFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
1158        result
1159    }
1160
1161    /// Returns the response expected flag for the function specified by the function ID parameter.
1162    /// It is true if the function is expected to send a response, false otherwise.
1163    ///
1164    /// For getter functions this is enabled by default and cannot be disabled, because those
1165    /// functions will always send a response. For callback configuration functions it is enabled
1166    /// by default too, but can be disabled by [`set_response_expected`](crate::master_brick::MasterBrick::set_response_expected).
1167    /// For setter functions it is disabled by default and can be enabled.
1168    ///
1169    /// Enabling the response expected flag for a setter function allows to detect timeouts
1170    /// and other error conditions calls of this setter as well. The device will then send a response
1171    /// for this purpose. If this flag is disabled for a setter function then no response is sent
1172    /// and errors are silently ignored, because they cannot be detected.
1173    ///
1174    /// See [`set_response_expected`](crate::master_brick::MasterBrick::set_response_expected) for the list of function ID constants available for this function.
1175    pub fn get_response_expected(&mut self, fun: MasterBrickFunction) -> Result<bool, GetResponseExpectedError> {
1176        self.device.get_response_expected(u8::from(fun))
1177    }
1178
1179    /// Changes the response expected flag of the function specified by the function ID parameter.
1180    /// This flag can only be changed for setter (default value: false) and callback configuration
1181    /// functions (default value: true). For getter functions it is always enabled.
1182    ///
1183    /// Enabling the response expected flag for a setter function allows to detect timeouts and
1184    /// other error conditions calls of this setter as well. The device will then send a response
1185    /// for this purpose. If this flag is disabled for a setter function then no response is sent
1186    /// and errors are silently ignored, because they cannot be detected.
1187    pub fn set_response_expected(&mut self, fun: MasterBrickFunction, response_expected: bool) -> Result<(), SetResponseExpectedError> {
1188        self.device.set_response_expected(u8::from(fun), response_expected)
1189    }
1190
1191    /// Changes the response expected flag for all setter and callback configuration functions of this device at once.
1192    pub fn set_response_expected_all(&mut self, response_expected: bool) {
1193        self.device.set_response_expected_all(response_expected)
1194    }
1195
1196    /// Returns the version of the API definition (major, minor, revision) implemented by this API bindings.
1197    /// This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
1198    pub fn get_api_version(&self) -> [u8; 3] {
1199        self.device.api_version
1200    }
1201
1202    /// This receiver is triggered periodically with the period that is set by
1203    /// [`set_stack_current_callback_period`]. The parameter is the current
1204    /// of the sensor.
1205    ///
1206    /// The [`get_stack_current_callback_receiver`] receiver is only triggered if the current has changed
1207    /// since the last triggering.
1208    ///
1209    /// [`set_stack_current_callback_period`]: #method.set_stack_current_callback_period
1210    /// [`get_stack_current_callback_receiver`]: #method.get_stack_current_callback_receiver
1211    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
1212    pub async fn get_stack_current_callback_receiver(&mut self) -> impl Stream<Item = u16> {
1213        self.device
1214            .get_callback_receiver(u8::from(MasterBrickFunction::CallbackStackCurrent))
1215            .await
1216            .map(|p| u16::from_le_byte_slice(p.body()))
1217    }
1218
1219    /// This receiver is triggered periodically with the period that is set by
1220    /// [`set_stack_voltage_callback_period`]. The parameter is the voltage
1221    /// of the sensor.
1222    ///
1223    /// The [`get_stack_voltage_callback_receiver`] receiver is only triggered if the voltage has changed
1224    /// since the last triggering.
1225    ///
1226    ///
1227    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
1228    pub async fn get_stack_voltage_callback_receiver(&mut self) -> impl Stream<Item = u16> {
1229        self.device
1230            .get_callback_receiver(u8::from(MasterBrickFunction::CallbackStackVoltage))
1231            .await
1232            .map(|p| u16::from_le_byte_slice(p.body()))
1233    }
1234
1235    /// This receiver is triggered periodically with the period that is set by
1236    /// [`set_usb_voltage_callback_period`]. The parameter is the USB
1237    /// voltage.
1238    ///
1239    /// The [`get_usb_voltage_callback_receiver`] receiver is only triggered if the USB voltage has changed
1240    /// since the last triggering.
1241    ///
1242    /// Does not work with hardware version 2.1 or newer.
1243    ///
1244    ///
1245    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
1246    pub async fn get_usb_voltage_callback_receiver(&mut self) -> impl Stream<Item = u16> {
1247        self.device
1248            .get_callback_receiver(u8::from(MasterBrickFunction::CallbackUsbVoltage))
1249            .await
1250            .map(|p| u16::from_le_byte_slice(p.body()))
1251    }
1252
1253    /// This receiver is triggered when the threshold as set by
1254    /// [`set_stack_current_callback_threshold`] is reached.
1255    /// The parameter is the stack current.
1256    ///
1257    /// If the threshold keeps being reached, the receiver is triggered periodically
1258    /// with the period as set by [`set_debounce_period`].
1259    ///
1260    ///
1261    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
1262    pub async fn get_stack_current_reached_callback_receiver(&mut self) -> impl Stream<Item = u16> {
1263        self.device
1264            .get_callback_receiver(u8::from(MasterBrickFunction::CallbackStackCurrentReached))
1265            .await
1266            .map(|p| u16::from_le_byte_slice(p.body()))
1267    }
1268
1269    /// This receiver is triggered when the threshold as set by
1270    /// [`set_stack_voltage_callback_threshold`] is reached.
1271    /// The parameter is the stack voltage.
1272    ///
1273    /// If the threshold keeps being reached, the receiver is triggered periodically
1274    /// with the period as set by [`set_debounce_period`].
1275    ///
1276    ///
1277    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
1278    pub async fn get_stack_voltage_reached_callback_receiver(&mut self) -> impl Stream<Item = u16> {
1279        self.device
1280            .get_callback_receiver(u8::from(MasterBrickFunction::CallbackStackVoltageReached))
1281            .await
1282            .map(|p| u16::from_le_byte_slice(p.body()))
1283    }
1284
1285    /// This receiver is triggered when the threshold as set by
1286    /// [`set_usb_voltage_callback_threshold`] is reached.
1287    /// The parameter is the voltage of the sensor.
1288    ///
1289    /// If the threshold keeps being reached, the receiver is triggered periodically
1290    /// with the period as set by [`set_debounce_period`].
1291    ///
1292    ///
1293    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
1294    pub async fn get_usb_voltage_reached_callback_receiver(&mut self) -> impl Stream<Item = u16> {
1295        self.device
1296            .get_callback_receiver(u8::from(MasterBrickFunction::CallbackUsbVoltageReached))
1297            .await
1298            .map(|p| u16::from_le_byte_slice(p.body()))
1299    }
1300
1301    /// Returns the stack voltage. The stack voltage is the
1302    /// voltage that is supplied via the stack, i.e. it is given by a
1303    /// Step-Down or Step-Up Power Supply.
1304    ///
1305    /// # Note
1306    ///  It is not possible to measure voltages supplied per PoE or USB with this function.
1307    pub async fn get_stack_voltage(&mut self) -> Result<u16, TinkerforgeError> {
1308        let payload = [0; 0];
1309
1310        #[allow(unused_variables)]
1311        let result = self.device.get(u8::from(MasterBrickFunction::GetStackVoltage), &payload).await?;
1312        Ok(u16::from_le_byte_slice(result.body()))
1313    }
1314
1315    /// Returns the stack current. The stack current is the
1316    /// current that is drawn via the stack, i.e. it is given by a
1317    /// Step-Down or Step-Up Power Supply.
1318    ///
1319    /// # Note
1320    ///  It is not possible to measure the current drawn via PoE or USB with this function.
1321    pub async fn get_stack_current(&mut self) -> Result<u16, TinkerforgeError> {
1322        let payload = [0; 0];
1323
1324        #[allow(unused_variables)]
1325        let result = self.device.get(u8::from(MasterBrickFunction::GetStackCurrent), &payload).await?;
1326        Ok(u16::from_le_byte_slice(result.body()))
1327    }
1328
1329    /// Writes the extension type to the EEPROM of a specified extension.
1330    /// The extension is either 0 or 1 (0 is the lower one, 1 is the upper one,
1331    /// if only one extension is present use 0).
1332    ///
1333    /// Possible extension types:
1334    ///
1335    ///  Type| Description
1336    ///  --- | ---
1337    ///  1|    Chibi
1338    ///  2|    RS485
1339    ///  3|    WIFI
1340    ///  4|    Ethernet
1341    ///  5|    WIFI 2.0
1342    ///
1343    /// The extension type is already set when bought and it can be set with the
1344    /// Brick Viewer, it is unlikely that you need this function.
1345    ///
1346    /// Associated constants:
1347    /// * MASTER_BRICK_EXTENSION_TYPE_CHIBI
1348    ///	* MASTER_BRICK_EXTENSION_TYPE_RS485
1349    ///	* MASTER_BRICK_EXTENSION_TYPE_WIFI
1350    ///	* MASTER_BRICK_EXTENSION_TYPE_ETHERNET
1351    ///	* MASTER_BRICK_EXTENSION_TYPE_WIFI2
1352    pub async fn set_extension_type(&mut self, extension: u8, exttype: u32) -> Result<(), TinkerforgeError> {
1353        let mut payload = [0; 5];
1354        extension.write_to_slice(&mut payload[0..1]);
1355        exttype.write_to_slice(&mut payload[1..5]);
1356
1357        #[allow(unused_variables)]
1358        let result = self.device.set(u8::from(MasterBrickFunction::SetExtensionType), &payload).await?;
1359        Ok(())
1360    }
1361
1362    /// Returns the type for a given extension as set by [`set_extension_type`].
1363    ///
1364    /// Associated constants:
1365    /// * MASTER_BRICK_EXTENSION_TYPE_CHIBI
1366    ///	* MASTER_BRICK_EXTENSION_TYPE_RS485
1367    ///	* MASTER_BRICK_EXTENSION_TYPE_WIFI
1368    ///	* MASTER_BRICK_EXTENSION_TYPE_ETHERNET
1369    ///	* MASTER_BRICK_EXTENSION_TYPE_WIFI2
1370    pub async fn get_extension_type(&mut self, extension: u8) -> Result<u32, TinkerforgeError> {
1371        let mut payload = [0; 1];
1372        extension.write_to_slice(&mut payload[0..1]);
1373
1374        #[allow(unused_variables)]
1375        let result = self.device.get(u8::from(MasterBrickFunction::GetExtensionType), &payload).await?;
1376        Ok(u32::from_le_byte_slice(result.body()))
1377    }
1378
1379    /// Returns *true* if the Master Brick is at position 0 in the stack and a Chibi
1380    /// Extension is available.
1381    pub async fn is_chibi_present(&mut self) -> Result<bool, TinkerforgeError> {
1382        let payload = [0; 0];
1383
1384        #[allow(unused_variables)]
1385        let result = self.device.get(u8::from(MasterBrickFunction::IsChibiPresent), &payload).await?;
1386        Ok(bool::from_le_byte_slice(result.body()))
1387    }
1388
1389    /// Sets the address belonging to the Chibi Extension.
1390    ///
1391    /// It is possible to set the address with the Brick Viewer and it will be
1392    /// saved in the EEPROM of the Chibi Extension, it does not
1393    /// have to be set on every startup.
1394    pub async fn set_chibi_address(&mut self, address: u8) -> Result<(), TinkerforgeError> {
1395        let mut payload = [0; 1];
1396        address.write_to_slice(&mut payload[0..1]);
1397
1398        #[allow(unused_variables)]
1399        let result = self.device.set(u8::from(MasterBrickFunction::SetChibiAddress), &payload).await?;
1400        Ok(())
1401    }
1402
1403    /// Returns the address as set by [`set_chibi_address`].
1404    pub async fn get_chibi_address(&mut self) -> Result<u8, TinkerforgeError> {
1405        let payload = [0; 0];
1406
1407        #[allow(unused_variables)]
1408        let result = self.device.get(u8::from(MasterBrickFunction::GetChibiAddress), &payload).await?;
1409        Ok(u8::from_le_byte_slice(result.body()))
1410    }
1411
1412    /// Sets the address of the Chibi Master. This address is used if the
1413    /// Chibi Extension is used as slave (i.e. it does not have a USB connection).
1414    ///
1415    /// It is possible to set the address with the Brick Viewer and it will be
1416    /// saved in the EEPROM of the Chibi Extension, it does not
1417    /// have to be set on every startup.
1418    pub async fn set_chibi_master_address(&mut self, address: u8) -> Result<(), TinkerforgeError> {
1419        let mut payload = [0; 1];
1420        address.write_to_slice(&mut payload[0..1]);
1421
1422        #[allow(unused_variables)]
1423        let result = self.device.set(u8::from(MasterBrickFunction::SetChibiMasterAddress), &payload).await?;
1424        Ok(())
1425    }
1426
1427    /// Returns the address as set by [`set_chibi_master_address`].
1428    pub async fn get_chibi_master_address(&mut self) -> Result<u8, TinkerforgeError> {
1429        let payload = [0; 0];
1430
1431        #[allow(unused_variables)]
1432        let result = self.device.get(u8::from(MasterBrickFunction::GetChibiMasterAddress), &payload).await?;
1433        Ok(u8::from_le_byte_slice(result.body()))
1434    }
1435
1436    /// Sets up to 254 slave addresses. 0 has a
1437    /// special meaning, it is used as list terminator and not allowed as normal slave
1438    /// address. The address numeration (via \c num parameter) has to be used
1439    /// ascending from 0. For example: If you use the Chibi Extension in Master mode
1440    /// (i.e. the stack has an USB connection) and you want to talk to three other
1441    /// Chibi stacks with the slave addresses 17, 23, and 42, you should call with
1442    /// ``(0, 17)``, ``(1, 23)``, ``(2, 42)`` and ``(3, 0)``. The last call with
1443    /// ``(3, 0)`` is a list terminator and indicates that the Chibi slave address
1444    /// list contains 3 addresses in this case.
1445    ///
1446    /// It is possible to set the addresses with the Brick Viewer, that will take care
1447    /// of correct address numeration and list termination.
1448    ///
1449    /// The slave addresses will be saved in the EEPROM of the Chibi Extension, they
1450    /// don't have to be set on every startup.
1451    pub async fn set_chibi_slave_address(&mut self, num: u8, address: u8) -> Result<(), TinkerforgeError> {
1452        let mut payload = [0; 2];
1453        num.write_to_slice(&mut payload[0..1]);
1454        address.write_to_slice(&mut payload[1..2]);
1455
1456        #[allow(unused_variables)]
1457        let result = self.device.set(u8::from(MasterBrickFunction::SetChibiSlaveAddress), &payload).await?;
1458        Ok(())
1459    }
1460
1461    /// Returns the slave address for a given \c num as set by
1462    /// [`set_chibi_slave_address`].
1463    pub async fn get_chibi_slave_address(&mut self, num: u8) -> Result<u8, TinkerforgeError> {
1464        let mut payload = [0; 1];
1465        num.write_to_slice(&mut payload[0..1]);
1466
1467        #[allow(unused_variables)]
1468        let result = self.device.get(u8::from(MasterBrickFunction::GetChibiSlaveAddress), &payload).await?;
1469        Ok(u8::from_le_byte_slice(result.body()))
1470    }
1471
1472    /// Returns the signal strength in dBm. The signal strength updates every time a
1473    /// packet is received.
1474    pub async fn get_chibi_signal_strength(&mut self) -> Result<u8, TinkerforgeError> {
1475        let payload = [0; 0];
1476
1477        #[allow(unused_variables)]
1478        let result = self.device.get(u8::from(MasterBrickFunction::GetChibiSignalStrength), &payload).await?;
1479        Ok(u8::from_le_byte_slice(result.body()))
1480    }
1481
1482    /// Returns underrun, CRC error, no ACK and overflow error counts of the Chibi
1483    /// communication. If these errors start rising, it is likely that either the
1484    /// distance between two Chibi stacks is becoming too big or there are
1485    /// interferences.
1486    pub async fn get_chibi_error_log(&mut self) -> Result<ChibiErrorLog, TinkerforgeError> {
1487        let payload = [0; 0];
1488
1489        #[allow(unused_variables)]
1490        let result = self.device.get(u8::from(MasterBrickFunction::GetChibiErrorLog), &payload).await?;
1491        Ok(ChibiErrorLog::from_le_byte_slice(result.body()))
1492    }
1493
1494    /// Sets the Chibi frequency range for the Chibi Extension. Possible values are:
1495    ///
1496    ///  Type| Description
1497    ///  --- | ---
1498    ///  0|    OQPSK 868MHz (Europe)
1499    ///  1|    OQPSK 915MHz (US)
1500    ///  2|    OQPSK 780MHz (China)
1501    ///  3|    BPSK40 915MHz
1502    ///
1503    /// It is possible to set the frequency with the Brick Viewer and it will be
1504    /// saved in the EEPROM of the Chibi Extension, it does not
1505    /// have to be set on every startup.
1506    ///
1507    /// Associated constants:
1508    /// * MASTER_BRICK_CHIBI_FREQUENCY_OQPSK_868_MHZ
1509    ///	* MASTER_BRICK_CHIBI_FREQUENCY_OQPSK_915_MHZ
1510    ///	* MASTER_BRICK_CHIBI_FREQUENCY_OQPSK_780_MHZ
1511    ///	* MASTER_BRICK_CHIBI_FREQUENCY_BPSK40_915_MHZ
1512    pub async fn set_chibi_frequency(&mut self, frequency: u8) -> Result<(), TinkerforgeError> {
1513        let mut payload = [0; 1];
1514        frequency.write_to_slice(&mut payload[0..1]);
1515
1516        #[allow(unused_variables)]
1517        let result = self.device.set(u8::from(MasterBrickFunction::SetChibiFrequency), &payload).await?;
1518        Ok(())
1519    }
1520
1521    /// Returns the frequency value as set by [`set_chibi_frequency`].
1522    ///
1523    /// Associated constants:
1524    /// * MASTER_BRICK_CHIBI_FREQUENCY_OQPSK_868_MHZ
1525    ///	* MASTER_BRICK_CHIBI_FREQUENCY_OQPSK_915_MHZ
1526    ///	* MASTER_BRICK_CHIBI_FREQUENCY_OQPSK_780_MHZ
1527    ///	* MASTER_BRICK_CHIBI_FREQUENCY_BPSK40_915_MHZ
1528    pub async fn get_chibi_frequency(&mut self) -> Result<u8, TinkerforgeError> {
1529        let payload = [0; 0];
1530
1531        #[allow(unused_variables)]
1532        let result = self.device.get(u8::from(MasterBrickFunction::GetChibiFrequency), &payload).await?;
1533        Ok(u8::from_le_byte_slice(result.body()))
1534    }
1535
1536    /// Sets the channel used by the Chibi Extension. Possible channels are
1537    /// different for different frequencies:
1538    ///
1539    ///  Frequency| Possible Channels
1540    ///  --- | ---
1541    ///  OQPSK 868MHz (Europe)| 0
1542    ///  OQPSK 915MHz (US)|     1| 2| 3| 4| 5| 6| 7| 8| 9| 10
1543    ///  OQPSK 780MHz (China)|  0| 1| 2| 3
1544    ///  BPSK40 915MHz|         1| 2| 3| 4| 5| 6| 7| 8| 9| 10
1545    ///
1546    /// It is possible to set the channel with the Brick Viewer and it will be
1547    /// saved in the EEPROM of the Chibi Extension, it does not
1548    /// have to be set on every startup.
1549    pub async fn set_chibi_channel(&mut self, channel: u8) -> Result<(), TinkerforgeError> {
1550        let mut payload = [0; 1];
1551        channel.write_to_slice(&mut payload[0..1]);
1552
1553        #[allow(unused_variables)]
1554        let result = self.device.set(u8::from(MasterBrickFunction::SetChibiChannel), &payload).await?;
1555        Ok(())
1556    }
1557
1558    /// Returns the channel as set by [`set_chibi_channel`].
1559    pub async fn get_chibi_channel(&mut self) -> Result<u8, TinkerforgeError> {
1560        let payload = [0; 0];
1561
1562        #[allow(unused_variables)]
1563        let result = self.device.get(u8::from(MasterBrickFunction::GetChibiChannel), &payload).await?;
1564        Ok(u8::from_le_byte_slice(result.body()))
1565    }
1566
1567    /// Returns *true* if the Master Brick is at position 0 in the stack and a RS485
1568    /// Extension is available.
1569    pub async fn is_rs485_present(&mut self) -> Result<bool, TinkerforgeError> {
1570        let payload = [0; 0];
1571
1572        #[allow(unused_variables)]
1573        let result = self.device.get(u8::from(MasterBrickFunction::IsRs485Present), &payload).await?;
1574        Ok(bool::from_le_byte_slice(result.body()))
1575    }
1576
1577    /// Sets the address (0-255) belonging to the RS485 Extension.
1578    ///
1579    /// Set to 0 if the RS485 Extension should be the RS485 Master (i.e.
1580    /// connected to a PC via USB).
1581    ///
1582    /// It is possible to set the address with the Brick Viewer and it will be
1583    /// saved in the EEPROM of the RS485 Extension, it does not
1584    /// have to be set on every startup.
1585    pub async fn set_rs485_address(&mut self, address: u8) -> Result<(), TinkerforgeError> {
1586        let mut payload = [0; 1];
1587        address.write_to_slice(&mut payload[0..1]);
1588
1589        #[allow(unused_variables)]
1590        let result = self.device.set(u8::from(MasterBrickFunction::SetRs485Address), &payload).await?;
1591        Ok(())
1592    }
1593
1594    /// Returns the address as set by [`set_rs485_address`].
1595    pub async fn get_rs485_address(&mut self) -> Result<u8, TinkerforgeError> {
1596        let payload = [0; 0];
1597
1598        #[allow(unused_variables)]
1599        let result = self.device.get(u8::from(MasterBrickFunction::GetRs485Address), &payload).await?;
1600        Ok(u8::from_le_byte_slice(result.body()))
1601    }
1602
1603    /// Sets up to 255 slave addresses. Valid addresses are in range 1-255. 0 has a
1604    /// special meaning, it is used as list terminator and not allowed as normal slave
1605    /// address. The address numeration (via ``num`` parameter) has to be used
1606    /// ascending from 0. For example: If you use the RS485 Extension in Master mode
1607    /// (i.e. the stack has an USB connection) and you want to talk to three other
1608    /// RS485 stacks with the addresses 17, 23, and 42, you should call with
1609    /// ``(0, 17)``, ``(1, 23)``, ``(2, 42)`` and ``(3, 0)``. The last call with
1610    /// ``(3, 0)`` is a list terminator and indicates that the RS485 slave address list
1611    /// contains 3 addresses in this case.
1612    ///
1613    /// It is possible to set the addresses with the Brick Viewer, that will take care
1614    /// of correct address numeration and list termination.
1615    ///
1616    /// The slave addresses will be saved in the EEPROM of the Chibi Extension, they
1617    /// don't have to be set on every startup.
1618    pub async fn set_rs485_slave_address(&mut self, num: u8, address: u8) -> Result<(), TinkerforgeError> {
1619        let mut payload = [0; 2];
1620        num.write_to_slice(&mut payload[0..1]);
1621        address.write_to_slice(&mut payload[1..2]);
1622
1623        #[allow(unused_variables)]
1624        let result = self.device.set(u8::from(MasterBrickFunction::SetRs485SlaveAddress), &payload).await?;
1625        Ok(())
1626    }
1627
1628    /// Returns the slave address for a given ``num`` as set by
1629    /// [`set_rs485_slave_address`].
1630    pub async fn get_rs485_slave_address(&mut self, num: u8) -> Result<u8, TinkerforgeError> {
1631        let mut payload = [0; 1];
1632        num.write_to_slice(&mut payload[0..1]);
1633
1634        #[allow(unused_variables)]
1635        let result = self.device.get(u8::from(MasterBrickFunction::GetRs485SlaveAddress), &payload).await?;
1636        Ok(u8::from_le_byte_slice(result.body()))
1637    }
1638
1639    /// Returns CRC error counts of the RS485 communication.
1640    /// If this counter starts rising, it is likely that the distance
1641    /// between the RS485 nodes is too big or there is some kind of
1642    /// interference.
1643    pub async fn get_rs485_error_log(&mut self) -> Result<u16, TinkerforgeError> {
1644        let payload = [0; 0];
1645
1646        #[allow(unused_variables)]
1647        let result = self.device.get(u8::from(MasterBrickFunction::GetRs485ErrorLog), &payload).await?;
1648        Ok(u16::from_le_byte_slice(result.body()))
1649    }
1650
1651    /// Sets the configuration of the RS485 Extension. The
1652    /// Master Brick will try to match the given baud rate as exactly as possible.
1653    /// The maximum recommended baud rate is 2000000 (2MBd).
1654    /// Possible values for parity are 'n' (none), 'e' (even) and 'o' (odd).
1655    ///
1656    /// If your RS485 is unstable (lost messages etc.), the first thing you should
1657    /// try is to decrease the speed. On very large bus (e.g. 1km), you probably
1658    /// should use a value in the range of 100000 (100kBd).
1659    ///
1660    /// The values are stored in the EEPROM and only applied on startup. That means
1661    /// you have to restart the Master Brick after configuration.
1662    ///
1663    /// Associated constants:
1664    /// * MASTER_BRICK_RS485_PARITY_NONE
1665    ///	* MASTER_BRICK_RS485_PARITY_EVEN
1666    ///	* MASTER_BRICK_RS485_PARITY_ODD
1667    pub async fn set_rs485_configuration(&mut self, speed: u32, parity: char, stopbits: u8) -> Result<(), TinkerforgeError> {
1668        let mut payload = [0; 6];
1669        speed.write_to_slice(&mut payload[0..4]);
1670        parity.write_to_slice(&mut payload[4..5]);
1671        stopbits.write_to_slice(&mut payload[5..6]);
1672
1673        #[allow(unused_variables)]
1674        let result = self.device.set(u8::from(MasterBrickFunction::SetRs485Configuration), &payload).await?;
1675        Ok(())
1676    }
1677
1678    /// Returns the configuration as set by [`set_rs485_configuration`].
1679    ///
1680    /// Associated constants:
1681    /// * MASTER_BRICK_RS485_PARITY_NONE
1682    ///	* MASTER_BRICK_RS485_PARITY_EVEN
1683    ///	* MASTER_BRICK_RS485_PARITY_ODD
1684    pub async fn get_rs485_configuration(&mut self) -> Result<Rs485Configuration, TinkerforgeError> {
1685        let payload = [0; 0];
1686
1687        #[allow(unused_variables)]
1688        let result = self.device.get(u8::from(MasterBrickFunction::GetRs485Configuration), &payload).await?;
1689        Ok(Rs485Configuration::from_le_byte_slice(result.body()))
1690    }
1691
1692    /// Returns *true* if the Master Brick is at position 0 in the stack and a WIFI
1693    /// Extension is available.
1694    pub async fn is_wifi_present(&mut self) -> Result<bool, TinkerforgeError> {
1695        let payload = [0; 0];
1696
1697        #[allow(unused_variables)]
1698        let result = self.device.get(u8::from(MasterBrickFunction::IsWifiPresent), &payload).await?;
1699        Ok(bool::from_le_byte_slice(result.body()))
1700    }
1701
1702    /// Sets the configuration of the WIFI Extension. The ``ssid`` can have a max length
1703    /// of 32 characters. Possible values for ``connection`` are:
1704    ///
1705    ///  Value| Description
1706    ///  --- | ---
1707    ///  0| DHCP
1708    ///  1| Static IP
1709    ///  2| Access Point: DHCP
1710    ///  3| Access Point: Static IP
1711    ///  4| Ad Hoc: DHCP
1712    ///  5| Ad Hoc: Static IP
1713    ///
1714    /// If you set ``connection`` to one of the static IP options then you have to
1715    /// supply ``ip``, ``subnet_mask`` and ``gateway`` as an array of size 4 (first
1716    /// element of the array is the least significant byte of the address). If
1717    /// ``connection`` is set to one of the DHCP options then ``ip``, ``subnet_mask``
1718    /// and ``gateway`` are ignored, you can set them to 0.
1719    ///
1720    /// The last parameter is the port that your program will connect to.
1721    ///
1722    /// The values are stored in the EEPROM and only applied on startup. That means
1723    /// you have to restart the Master Brick after configuration.
1724    ///
1725    /// It is recommended to use the Brick Viewer to set the WIFI configuration.
1726    ///
1727    /// Associated constants:
1728    /// * MASTER_BRICK_WIFI_CONNECTION_DHCP
1729    ///	* MASTER_BRICK_WIFI_CONNECTION_STATIC_IP
1730    ///	* MASTER_BRICK_WIFI_CONNECTION_ACCESS_POINT_DHCP
1731    ///	* MASTER_BRICK_WIFI_CONNECTION_ACCESS_POINT_STATIC_IP
1732    ///	* MASTER_BRICK_WIFI_CONNECTION_AD_HOC_DHCP
1733    ///	* MASTER_BRICK_WIFI_CONNECTION_AD_HOC_STATIC_IP
1734    pub async fn set_wifi_configuration(
1735        &mut self,
1736        ssid: String,
1737        connection: u8,
1738        ip: &[u8; 4],
1739        subnet_mask: &[u8; 4],
1740        gateway: &[u8; 4],
1741        port: u16,
1742    ) -> Result<(), TinkerforgeError> {
1743        let mut payload = [0; 47];
1744        ssid.try_write_to_slice(32, &mut payload)?;
1745        connection.write_to_slice(&mut payload[32..33]);
1746        ip.write_to_slice(&mut payload[33..37]);
1747        subnet_mask.write_to_slice(&mut payload[37..41]);
1748        gateway.write_to_slice(&mut payload[41..45]);
1749        port.write_to_slice(&mut payload[45..47]);
1750
1751        #[allow(unused_variables)]
1752        let result = self.device.set(u8::from(MasterBrickFunction::SetWifiConfiguration), &payload).await?;
1753        Ok(())
1754    }
1755
1756    /// Returns the configuration as set by [`set_wifi_configuration`].
1757    ///
1758    /// Associated constants:
1759    /// * MASTER_BRICK_WIFI_CONNECTION_DHCP
1760    ///	* MASTER_BRICK_WIFI_CONNECTION_STATIC_IP
1761    ///	* MASTER_BRICK_WIFI_CONNECTION_ACCESS_POINT_DHCP
1762    ///	* MASTER_BRICK_WIFI_CONNECTION_ACCESS_POINT_STATIC_IP
1763    ///	* MASTER_BRICK_WIFI_CONNECTION_AD_HOC_DHCP
1764    ///	* MASTER_BRICK_WIFI_CONNECTION_AD_HOC_STATIC_IP
1765    pub async fn get_wifi_configuration(&mut self) -> Result<WifiConfiguration, TinkerforgeError> {
1766        let payload = [0; 0];
1767
1768        #[allow(unused_variables)]
1769        let result = self.device.get(u8::from(MasterBrickFunction::GetWifiConfiguration), &payload).await?;
1770        Ok(WifiConfiguration::from_le_byte_slice(result.body()))
1771    }
1772
1773    /// Sets the encryption of the WIFI Extension. The first parameter is the
1774    /// type of the encryption. Possible values are:
1775    ///
1776    ///  Value| Description
1777    ///  --- | ---
1778    ///  0| WPA/WPA2
1779    ///  1| WPA Enterprise (EAP-FAST| EAP-TLS| EAP-TTLS| PEAP)
1780    ///  2| WEP
1781    ///  3| No Encryption
1782    ///
1783    /// The ``key`` has a max length of 50 characters and is used if ``encryption``
1784    /// is set to 0 or 2 (WPA/WPA2 or WEP). Otherwise the value is ignored.
1785    ///
1786    /// For WPA/WPA2 the key has to be at least 8 characters long. If you want to set
1787    /// a key with more than 50 characters, see [`set_long_wifi_key`].
1788    ///
1789    /// For WEP the key has to be either 10 or 26 hexadecimal digits long. It is
1790    /// possible to set the WEP ``key_index`` (1-4). If you don't know your
1791    /// ``key_index``, it is likely 1.
1792    ///
1793    /// If you choose WPA Enterprise as encryption, you have to set ``eap_options`` and
1794    /// the length of the certificates (for other encryption types these parameters
1795    /// are ignored). The certificates
1796    /// themselves can be set with [`set_wifi_certificate`]. ``eap_options`` consist
1797    /// of the outer authentication (bits 1-2), inner authentication (bit 3) and
1798    /// certificate type (bits 4-5):
1799    ///
1800    ///  Option| Bits| Description
1801    ///  --- | --- | ---
1802    ///  outer authentication| 1-2| 0=EAP-FAST| 1=EAP-TLS| 2=EAP-TTLS| 3=EAP-PEAP
1803    ///  inner authentication| 3| 0=EAP-MSCHAP| 1=EAP-GTC
1804    ///  certificate type| 4-5| 0=CA Certificate| 1=Client Certificate| 2=Private Key
1805    ///
1806    /// Example for EAP-TTLS + EAP-GTC + Private Key: ``option = 2 | (1 << 2) | (2 << 3)``.
1807    ///
1808    /// The values are stored in the EEPROM and only applied on startup. That means
1809    /// you have to restart the Master Brick after configuration.
1810    ///
1811    /// It is recommended to use the Brick Viewer to set the Wi-Fi encryption.
1812    ///
1813    /// Associated constants:
1814    /// * MASTER_BRICK_WIFI_ENCRYPTION_WPA_WPA2
1815    ///	* MASTER_BRICK_WIFI_ENCRYPTION_WPA_ENTERPRISE
1816    ///	* MASTER_BRICK_WIFI_ENCRYPTION_WEP
1817    ///	* MASTER_BRICK_WIFI_ENCRYPTION_NO_ENCRYPTION
1818    ///	* MASTER_BRICK_WIFI_EAP_OPTION_OUTER_AUTH_EAP_FAST
1819    ///	* MASTER_BRICK_WIFI_EAP_OPTION_OUTER_AUTH_EAP_TLS
1820    ///	* MASTER_BRICK_WIFI_EAP_OPTION_OUTER_AUTH_EAP_TTLS
1821    ///	* MASTER_BRICK_WIFI_EAP_OPTION_OUTER_AUTH_EAP_PEAP
1822    ///	* MASTER_BRICK_WIFI_EAP_OPTION_INNER_AUTH_EAP_MSCHAP
1823    ///	* MASTER_BRICK_WIFI_EAP_OPTION_INNER_AUTH_EAP_GTC
1824    ///	* MASTER_BRICK_WIFI_EAP_OPTION_CERT_TYPE_CA_CERT
1825    ///	* MASTER_BRICK_WIFI_EAP_OPTION_CERT_TYPE_CLIENT_CERT
1826    ///	* MASTER_BRICK_WIFI_EAP_OPTION_CERT_TYPE_PRIVATE_KEY
1827    pub async fn set_wifi_encryption(
1828        &mut self,
1829        encryption: u8,
1830        key: String,
1831        key_index: u8,
1832        eap_options: u8,
1833        ca_certificate_length: u16,
1834        client_certificate_length: u16,
1835        private_key_length: u16,
1836    ) -> Result<(), TinkerforgeError> {
1837        let mut payload = [0; 59];
1838        encryption.write_to_slice(&mut payload[0..1]);
1839        key.try_write_to_slice(50, &mut payload)?;
1840        key_index.write_to_slice(&mut payload[51..52]);
1841        eap_options.write_to_slice(&mut payload[52..53]);
1842        ca_certificate_length.write_to_slice(&mut payload[53..55]);
1843        client_certificate_length.write_to_slice(&mut payload[55..57]);
1844        private_key_length.write_to_slice(&mut payload[57..59]);
1845
1846        #[allow(unused_variables)]
1847        let result = self.device.set(u8::from(MasterBrickFunction::SetWifiEncryption), &payload).await?;
1848        Ok(())
1849    }
1850
1851    /// Returns the encryption as set by [`set_wifi_encryption`].
1852    ///
1853    /// # Note
1854    ///  Since Master Brick Firmware version 2.4.4 the key is not returned anymore.
1855    ///
1856    /// Associated constants:
1857    /// * MASTER_BRICK_WIFI_ENCRYPTION_WPA_WPA2
1858    ///	* MASTER_BRICK_WIFI_ENCRYPTION_WPA_ENTERPRISE
1859    ///	* MASTER_BRICK_WIFI_ENCRYPTION_WEP
1860    ///	* MASTER_BRICK_WIFI_ENCRYPTION_NO_ENCRYPTION
1861    ///	* MASTER_BRICK_WIFI_EAP_OPTION_OUTER_AUTH_EAP_FAST
1862    ///	* MASTER_BRICK_WIFI_EAP_OPTION_OUTER_AUTH_EAP_TLS
1863    ///	* MASTER_BRICK_WIFI_EAP_OPTION_OUTER_AUTH_EAP_TTLS
1864    ///	* MASTER_BRICK_WIFI_EAP_OPTION_OUTER_AUTH_EAP_PEAP
1865    ///	* MASTER_BRICK_WIFI_EAP_OPTION_INNER_AUTH_EAP_MSCHAP
1866    ///	* MASTER_BRICK_WIFI_EAP_OPTION_INNER_AUTH_EAP_GTC
1867    ///	* MASTER_BRICK_WIFI_EAP_OPTION_CERT_TYPE_CA_CERT
1868    ///	* MASTER_BRICK_WIFI_EAP_OPTION_CERT_TYPE_CLIENT_CERT
1869    ///	* MASTER_BRICK_WIFI_EAP_OPTION_CERT_TYPE_PRIVATE_KEY
1870    pub async fn get_wifi_encryption(&mut self) -> Result<WifiEncryption, TinkerforgeError> {
1871        let payload = [0; 0];
1872
1873        #[allow(unused_variables)]
1874        let result = self.device.get(u8::from(MasterBrickFunction::GetWifiEncryption), &payload).await?;
1875        Ok(WifiEncryption::from_le_byte_slice(result.body()))
1876    }
1877
1878    /// Returns the status of the WIFI Extension. The ``state`` is updated automatically,
1879    /// all of the other parameters are updated on startup and every time
1880    /// [`refresh_wifi_status`] is called.
1881    ///
1882    /// Possible states are:
1883    ///
1884    ///  State| Description
1885    ///  --- | ---
1886    ///  0| Disassociated
1887    ///  1| Associated
1888    ///  2| Associating
1889    ///  3| Error
1890    ///  255| Not initialized yet
1891    ///
1892    /// Associated constants:
1893    /// * MASTER_BRICK_WIFI_STATE_DISASSOCIATED
1894    ///	* MASTER_BRICK_WIFI_STATE_ASSOCIATED
1895    ///	* MASTER_BRICK_WIFI_STATE_ASSOCIATING
1896    ///	* MASTER_BRICK_WIFI_STATE_ERROR
1897    ///	* MASTER_BRICK_WIFI_STATE_NOT_INITIALIZED_YET
1898    pub async fn get_wifi_status(&mut self) -> Result<WifiStatus, TinkerforgeError> {
1899        let payload = [0; 0];
1900
1901        #[allow(unused_variables)]
1902        let result = self.device.get(u8::from(MasterBrickFunction::GetWifiStatus), &payload).await?;
1903        Ok(WifiStatus::from_le_byte_slice(result.body()))
1904    }
1905
1906    /// Refreshes the Wi-Fi status (see [`get_wifi_status`]). To read the status
1907    /// of the Wi-Fi module, the Master Brick has to change from data mode to
1908    /// command mode and back. This transaction and the readout itself is
1909    /// unfortunately time consuming. This means, that it might take some ms
1910    /// until the stack with attached WIFI Extension reacts again after this
1911    /// function is called.
1912    pub async fn refresh_wifi_status(&mut self) -> Result<(), TinkerforgeError> {
1913        let payload = [0; 0];
1914
1915        #[allow(unused_variables)]
1916        let result = self.device.set(u8::from(MasterBrickFunction::RefreshWifiStatus), &payload).await?;
1917        Ok(())
1918    }
1919
1920    /// This function is used to set the certificate as well as password and username
1921    /// for WPA Enterprise. To set the username use index 0xFFFF,
1922    /// to set the password use index 0xFFFE. The max length of username and
1923    /// password is 32.
1924    ///
1925    /// The certificate is written in chunks of size 32 and the index is used as
1926    /// the index of the chunk. ``data_length`` should nearly always be 32. Only
1927    /// the last chunk can have a length that is not equal to 32.
1928    ///
1929    /// The starting index of the CA Certificate is 0, of the Client Certificate
1930    /// 10000 and for the Private Key 20000. Maximum sizes are 1312, 1312 and
1931    /// 4320 byte respectively.
1932    ///
1933    /// The values are stored in the EEPROM and only applied on startup. That means
1934    /// you have to restart the Master Brick after uploading the certificate.
1935    ///
1936    /// It is recommended to use the Brick Viewer to set the certificate, username
1937    /// and password.
1938    pub async fn set_wifi_certificate(&mut self, index: u16, data: &[u8; 32], data_length: u8) -> Result<(), TinkerforgeError> {
1939        let mut payload = [0; 35];
1940        index.write_to_slice(&mut payload[0..2]);
1941        data.write_to_slice(&mut payload[2..34]);
1942        data_length.write_to_slice(&mut payload[34..35]);
1943
1944        #[allow(unused_variables)]
1945        let result = self.device.set(u8::from(MasterBrickFunction::SetWifiCertificate), &payload).await?;
1946        Ok(())
1947    }
1948
1949    /// Returns the certificate for a given index as set by [`set_wifi_certificate`].
1950    pub async fn get_wifi_certificate(&mut self, index: u16) -> Result<WifiCertificate, TinkerforgeError> {
1951        let mut payload = [0; 2];
1952        index.write_to_slice(&mut payload[0..2]);
1953
1954        #[allow(unused_variables)]
1955        let result = self.device.get(u8::from(MasterBrickFunction::GetWifiCertificate), &payload).await?;
1956        Ok(WifiCertificate::from_le_byte_slice(result.body()))
1957    }
1958
1959    /// Sets the power mode of the WIFI Extension. Possible modes are:
1960    ///
1961    ///  Mode| Description
1962    ///  --- | ---
1963    ///  0| Full Speed (high power consumption| high throughput)
1964    ///  1| Low Power (low power consumption| low throughput)
1965    ///
1966    /// Associated constants:
1967    /// * MASTER_BRICK_WIFI_POWER_MODE_FULL_SPEED
1968    ///	* MASTER_BRICK_WIFI_POWER_MODE_LOW_POWER
1969    pub async fn set_wifi_power_mode(&mut self, mode: u8) -> Result<(), TinkerforgeError> {
1970        let mut payload = [0; 1];
1971        mode.write_to_slice(&mut payload[0..1]);
1972
1973        #[allow(unused_variables)]
1974        let result = self.device.set(u8::from(MasterBrickFunction::SetWifiPowerMode), &payload).await?;
1975        Ok(())
1976    }
1977
1978    /// Returns the power mode as set by [`set_wifi_power_mode`].
1979    ///
1980    /// Associated constants:
1981    /// * MASTER_BRICK_WIFI_POWER_MODE_FULL_SPEED
1982    ///	* MASTER_BRICK_WIFI_POWER_MODE_LOW_POWER
1983    pub async fn get_wifi_power_mode(&mut self) -> Result<u8, TinkerforgeError> {
1984        let payload = [0; 0];
1985
1986        #[allow(unused_variables)]
1987        let result = self.device.get(u8::from(MasterBrickFunction::GetWifiPowerMode), &payload).await?;
1988        Ok(u8::from_le_byte_slice(result.body()))
1989    }
1990
1991    /// Returns informations about the Wi-Fi receive buffer. The Wi-Fi
1992    /// receive buffer has a max size of 1500 byte and if data is transfered
1993    /// too fast, it might overflow.
1994    ///
1995    /// The return values are the number of overflows, the low watermark
1996    /// (i.e. the smallest number of bytes that were free in the buffer) and
1997    /// the bytes that are currently used.
1998    ///
1999    /// You should always try to keep the buffer empty, otherwise you will
2000    /// have a permanent latency. A good rule of thumb is, that you can transfer
2001    /// 1000 messages per second without problems.
2002    ///
2003    /// Try to not send more then 50 messages at a time without any kind of
2004    /// break between them.
2005    pub async fn get_wifi_buffer_info(&mut self) -> Result<WifiBufferInfo, TinkerforgeError> {
2006        let payload = [0; 0];
2007
2008        #[allow(unused_variables)]
2009        let result = self.device.get(u8::from(MasterBrickFunction::GetWifiBufferInfo), &payload).await?;
2010        Ok(WifiBufferInfo::from_le_byte_slice(result.body()))
2011    }
2012
2013    /// Sets the regulatory domain of the WIFI Extension. Possible domains are:
2014    ///
2015    ///  Domain| Description
2016    ///  --- | ---
2017    ///  0| FCC: Channel 1-11 (N/S America| Australia| New Zealand)
2018    ///  1| ETSI: Channel 1-13 (Europe| Middle East| Africa)
2019    ///  2| TELEC: Channel 1-14 (Japan)
2020    ///
2021    /// Associated constants:
2022    /// * MASTER_BRICK_WIFI_DOMAIN_CHANNEL_1TO11
2023    ///	* MASTER_BRICK_WIFI_DOMAIN_CHANNEL_1TO13
2024    ///	* MASTER_BRICK_WIFI_DOMAIN_CHANNEL_1TO14
2025    pub async fn set_wifi_regulatory_domain(&mut self, domain: u8) -> Result<(), TinkerforgeError> {
2026        let mut payload = [0; 1];
2027        domain.write_to_slice(&mut payload[0..1]);
2028
2029        #[allow(unused_variables)]
2030        let result = self.device.set(u8::from(MasterBrickFunction::SetWifiRegulatoryDomain), &payload).await?;
2031        Ok(())
2032    }
2033
2034    /// Returns the regulatory domain as set by [`set_wifi_regulatory_domain`].
2035    ///
2036    /// Associated constants:
2037    /// * MASTER_BRICK_WIFI_DOMAIN_CHANNEL_1TO11
2038    ///	* MASTER_BRICK_WIFI_DOMAIN_CHANNEL_1TO13
2039    ///	* MASTER_BRICK_WIFI_DOMAIN_CHANNEL_1TO14
2040    pub async fn get_wifi_regulatory_domain(&mut self) -> Result<u8, TinkerforgeError> {
2041        let payload = [0; 0];
2042
2043        #[allow(unused_variables)]
2044        let result = self.device.get(u8::from(MasterBrickFunction::GetWifiRegulatoryDomain), &payload).await?;
2045        Ok(u8::from_le_byte_slice(result.body()))
2046    }
2047
2048    /// Returns the USB voltage. Does not work with hardware version 2.1 or newer.
2049    pub async fn get_usb_voltage(&mut self) -> Result<u16, TinkerforgeError> {
2050        let payload = [0; 0];
2051
2052        #[allow(unused_variables)]
2053        let result = self.device.get(u8::from(MasterBrickFunction::GetUsbVoltage), &payload).await?;
2054        Ok(u16::from_le_byte_slice(result.body()))
2055    }
2056
2057    /// Sets a long Wi-Fi key (up to 63 chars, at least 8 chars) for WPA encryption.
2058    /// This key will be used
2059    /// if the key in [`set_wifi_encryption`] is set to -. In the old protocol,
2060    /// a payload of size 63 was not possible, so the maximum key length was 50 chars.
2061    ///
2062    /// With the new protocol this is possible, since we didn't want to break API,
2063    /// this function was added additionally.
2064    ///
2065    ///
2066    /// .. versionadded:: 2.0.2$nbsp;(Firmware)
2067    pub async fn set_long_wifi_key(&mut self, key: String) -> Result<(), TinkerforgeError> {
2068        let mut payload = [0; 64];
2069        key.try_write_to_slice(64, &mut payload)?;
2070
2071        #[allow(unused_variables)]
2072        let result = self.device.set(u8::from(MasterBrickFunction::SetLongWifiKey), &payload).await?;
2073        Ok(())
2074    }
2075
2076    /// Returns the encryption key as set by [`set_long_wifi_key`].
2077    ///
2078    /// # Note
2079    ///  Since Master Brick firmware version 2.4.4 the key is not returned anymore.
2080    ///
2081    ///
2082    /// .. versionadded:: 2.0.2$nbsp;(Firmware)
2083    pub async fn get_long_wifi_key(&mut self) -> Result<String, TinkerforgeError> {
2084        let payload = [0; 0];
2085
2086        #[allow(unused_variables)]
2087        let result = self.device.get(u8::from(MasterBrickFunction::GetLongWifiKey), &payload).await?;
2088        Ok(String::from_le_byte_slice(result.body()))
2089    }
2090
2091    /// Sets the hostname of the WIFI Extension. The hostname will be displayed
2092    /// by access points as the hostname in the DHCP clients table.
2093    ///
2094    /// Setting an empty String will restore the default hostname.
2095    ///
2096    ///
2097    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2098    pub async fn set_wifi_hostname(&mut self, hostname: String) -> Result<(), TinkerforgeError> {
2099        let mut payload = [0; 16];
2100        hostname.try_write_to_slice(16, &mut payload)?;
2101
2102        #[allow(unused_variables)]
2103        let result = self.device.set(u8::from(MasterBrickFunction::SetWifiHostname), &payload).await?;
2104        Ok(())
2105    }
2106
2107    /// Returns the hostname as set by [`set_wifi_hostname`].
2108    ///
2109    /// An empty String means, that the default hostname is used.
2110    ///
2111    ///
2112    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2113    pub async fn get_wifi_hostname(&mut self) -> Result<String, TinkerforgeError> {
2114        let payload = [0; 0];
2115
2116        #[allow(unused_variables)]
2117        let result = self.device.get(u8::from(MasterBrickFunction::GetWifiHostname), &payload).await?;
2118        Ok(String::from_le_byte_slice(result.body()))
2119    }
2120
2121    /// Sets the period with which the [`get_stack_current_callback_receiver`] receiver is triggered
2122    /// periodically. A value of 0 turns the receiver off.
2123    ///
2124    /// The [`get_stack_current_callback_receiver`] receiver is only triggered if the current has changed
2125    /// since the last triggering.
2126    ///
2127    ///
2128    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2129    pub async fn set_stack_current_callback_period(&mut self, period: u32) -> Result<(), TinkerforgeError> {
2130        let mut payload = [0; 4];
2131        period.write_to_slice(&mut payload[0..4]);
2132
2133        #[allow(unused_variables)]
2134        let result = self.device.set(u8::from(MasterBrickFunction::SetStackCurrentCallbackPeriod), &payload).await?;
2135        Ok(())
2136    }
2137
2138    /// Returns the period as set by [`set_stack_current_callback_period`].
2139    ///
2140    ///
2141    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2142    pub async fn get_stack_current_callback_period(&mut self) -> Result<u32, TinkerforgeError> {
2143        let payload = [0; 0];
2144
2145        #[allow(unused_variables)]
2146        let result = self.device.get(u8::from(MasterBrickFunction::GetStackCurrentCallbackPeriod), &payload).await?;
2147        Ok(u32::from_le_byte_slice(result.body()))
2148    }
2149
2150    /// Sets the period with which the [`get_stack_voltage_callback_receiver`] receiver is triggered
2151    /// periodically. A value of 0 turns the receiver off.
2152    ///
2153    /// The [`get_stack_voltage_callback_receiver`] receiver is only triggered if the voltage has changed
2154    /// since the last triggering.
2155    ///
2156    ///
2157    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2158    pub async fn set_stack_voltage_callback_period(&mut self, period: u32) -> Result<(), TinkerforgeError> {
2159        let mut payload = [0; 4];
2160        period.write_to_slice(&mut payload[0..4]);
2161
2162        #[allow(unused_variables)]
2163        let result = self.device.set(u8::from(MasterBrickFunction::SetStackVoltageCallbackPeriod), &payload).await?;
2164        Ok(())
2165    }
2166
2167    /// Returns the period as set by [`set_stack_voltage_callback_period`].
2168    ///
2169    ///
2170    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2171    pub async fn get_stack_voltage_callback_period(&mut self) -> Result<u32, TinkerforgeError> {
2172        let payload = [0; 0];
2173
2174        #[allow(unused_variables)]
2175        let result = self.device.get(u8::from(MasterBrickFunction::GetStackVoltageCallbackPeriod), &payload).await?;
2176        Ok(u32::from_le_byte_slice(result.body()))
2177    }
2178
2179    /// Sets the period with which the [`get_usb_voltage_callback_receiver`] receiver is triggered
2180    /// periodically. A value of 0 turns the receiver off.
2181    ///
2182    /// The [`get_usb_voltage_callback_receiver`] receiver is only triggered if the voltage has changed
2183    /// since the last triggering.
2184    ///
2185    ///
2186    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2187    pub async fn set_usb_voltage_callback_period(&mut self, period: u32) -> Result<(), TinkerforgeError> {
2188        let mut payload = [0; 4];
2189        period.write_to_slice(&mut payload[0..4]);
2190
2191        #[allow(unused_variables)]
2192        let result = self.device.set(u8::from(MasterBrickFunction::SetUsbVoltageCallbackPeriod), &payload).await?;
2193        Ok(())
2194    }
2195
2196    /// Returns the period as set by [`set_usb_voltage_callback_period`].
2197    ///
2198    ///
2199    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2200    pub async fn get_usb_voltage_callback_period(&mut self) -> Result<u32, TinkerforgeError> {
2201        let payload = [0; 0];
2202
2203        #[allow(unused_variables)]
2204        let result = self.device.get(u8::from(MasterBrickFunction::GetUsbVoltageCallbackPeriod), &payload).await?;
2205        Ok(u32::from_le_byte_slice(result.body()))
2206    }
2207
2208    /// Sets the thresholds for the [`get_stack_current_reached_callback_receiver`] receiver.
2209    ///
2210    /// The following options are possible:
2211    ///
2212    ///  Option| Description
2213    ///  --- | ---
2214    ///  'x'|    Receiver is turned off
2215    ///  'o'|    Receiver is triggered when the current is *outside* the min and max values
2216    ///  'i'|    Receiver is triggered when the current is *inside* the min and max values
2217    ///  '<'|    Receiver is triggered when the current is smaller than the min value (max is ignored)
2218    ///  '>'|    Receiver is triggered when the current is greater than the min value (max is ignored)
2219    ///
2220    ///
2221    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2222    ///
2223    /// Associated constants:
2224    /// * MASTER_BRICK_THRESHOLD_OPTION_OFF
2225    ///	* MASTER_BRICK_THRESHOLD_OPTION_OUTSIDE
2226    ///	* MASTER_BRICK_THRESHOLD_OPTION_INSIDE
2227    ///	* MASTER_BRICK_THRESHOLD_OPTION_SMALLER
2228    ///	* MASTER_BRICK_THRESHOLD_OPTION_GREATER
2229    pub async fn set_stack_current_callback_threshold(&mut self, option: char, min: u16, max: u16) -> Result<(), TinkerforgeError> {
2230        let mut payload = [0; 5];
2231        option.write_to_slice(&mut payload[0..1]);
2232        min.write_to_slice(&mut payload[1..3]);
2233        max.write_to_slice(&mut payload[3..5]);
2234
2235        #[allow(unused_variables)]
2236        let result = self.device.set(u8::from(MasterBrickFunction::SetStackCurrentCallbackThreshold), &payload).await?;
2237        Ok(())
2238    }
2239
2240    /// Returns the threshold as set by [`set_stack_current_callback_threshold`].
2241    ///
2242    ///
2243    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2244    ///
2245    /// Associated constants:
2246    /// * MASTER_BRICK_THRESHOLD_OPTION_OFF
2247    ///	* MASTER_BRICK_THRESHOLD_OPTION_OUTSIDE
2248    ///	* MASTER_BRICK_THRESHOLD_OPTION_INSIDE
2249    ///	* MASTER_BRICK_THRESHOLD_OPTION_SMALLER
2250    ///	* MASTER_BRICK_THRESHOLD_OPTION_GREATER
2251    pub async fn get_stack_current_callback_threshold(&mut self) -> Result<StackCurrentCallbackThreshold, TinkerforgeError> {
2252        let payload = [0; 0];
2253
2254        #[allow(unused_variables)]
2255        let result = self.device.get(u8::from(MasterBrickFunction::GetStackCurrentCallbackThreshold), &payload).await?;
2256        Ok(StackCurrentCallbackThreshold::from_le_byte_slice(result.body()))
2257    }
2258
2259    /// Sets the thresholds for the [`get_stack_voltage_reached_callback_receiver`] receiver.
2260    ///
2261    /// The following options are possible:
2262    ///
2263    ///  Option| Description
2264    ///  --- | ---
2265    ///  'x'|    Receiver is turned off
2266    ///  'o'|    Receiver is triggered when the voltage is *outside* the min and max values
2267    ///  'i'|    Receiver is triggered when the voltage is *inside* the min and max values
2268    ///  '<'|    Receiver is triggered when the voltage is smaller than the min value (max is ignored)
2269    ///  '>'|    Receiver is triggered when the voltage is greater than the min value (max is ignored)
2270    ///
2271    ///
2272    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2273    ///
2274    /// Associated constants:
2275    /// * MASTER_BRICK_THRESHOLD_OPTION_OFF
2276    ///	* MASTER_BRICK_THRESHOLD_OPTION_OUTSIDE
2277    ///	* MASTER_BRICK_THRESHOLD_OPTION_INSIDE
2278    ///	* MASTER_BRICK_THRESHOLD_OPTION_SMALLER
2279    ///	* MASTER_BRICK_THRESHOLD_OPTION_GREATER
2280    pub async fn set_stack_voltage_callback_threshold(&mut self, option: char, min: u16, max: u16) -> Result<(), TinkerforgeError> {
2281        let mut payload = [0; 5];
2282        option.write_to_slice(&mut payload[0..1]);
2283        min.write_to_slice(&mut payload[1..3]);
2284        max.write_to_slice(&mut payload[3..5]);
2285
2286        #[allow(unused_variables)]
2287        let result = self.device.set(u8::from(MasterBrickFunction::SetStackVoltageCallbackThreshold), &payload).await?;
2288        Ok(())
2289    }
2290
2291    /// Returns the threshold as set by [`set_stack_voltage_callback_threshold`].
2292    ///
2293    ///
2294    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2295    ///
2296    /// Associated constants:
2297    /// * MASTER_BRICK_THRESHOLD_OPTION_OFF
2298    ///	* MASTER_BRICK_THRESHOLD_OPTION_OUTSIDE
2299    ///	* MASTER_BRICK_THRESHOLD_OPTION_INSIDE
2300    ///	* MASTER_BRICK_THRESHOLD_OPTION_SMALLER
2301    ///	* MASTER_BRICK_THRESHOLD_OPTION_GREATER
2302    pub async fn get_stack_voltage_callback_threshold(&mut self) -> Result<StackVoltageCallbackThreshold, TinkerforgeError> {
2303        let payload = [0; 0];
2304
2305        #[allow(unused_variables)]
2306        let result = self.device.get(u8::from(MasterBrickFunction::GetStackVoltageCallbackThreshold), &payload).await?;
2307        Ok(StackVoltageCallbackThreshold::from_le_byte_slice(result.body()))
2308    }
2309
2310    /// Sets the thresholds for the [`get_usb_voltage_reached_callback_receiver`] receiver.
2311    ///
2312    /// The following options are possible:
2313    ///
2314    ///  Option| Description
2315    ///  --- | ---
2316    ///  'x'|    Receiver is turned off
2317    ///  'o'|    Receiver is triggered when the voltage is *outside* the min and max values
2318    ///  'i'|    Receiver is triggered when the voltage is *inside* the min and max values
2319    ///  '<'|    Receiver is triggered when the voltage is smaller than the min value (max is ignored)
2320    ///  '>'|    Receiver is triggered when the voltage is greater than the min value (max is ignored)
2321    ///
2322    ///
2323    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2324    ///
2325    /// Associated constants:
2326    /// * MASTER_BRICK_THRESHOLD_OPTION_OFF
2327    ///	* MASTER_BRICK_THRESHOLD_OPTION_OUTSIDE
2328    ///	* MASTER_BRICK_THRESHOLD_OPTION_INSIDE
2329    ///	* MASTER_BRICK_THRESHOLD_OPTION_SMALLER
2330    ///	* MASTER_BRICK_THRESHOLD_OPTION_GREATER
2331    pub async fn set_usb_voltage_callback_threshold(&mut self, option: char, min: u16, max: u16) -> Result<(), TinkerforgeError> {
2332        let mut payload = [0; 5];
2333        option.write_to_slice(&mut payload[0..1]);
2334        min.write_to_slice(&mut payload[1..3]);
2335        max.write_to_slice(&mut payload[3..5]);
2336
2337        #[allow(unused_variables)]
2338        let result = self.device.set(u8::from(MasterBrickFunction::SetUsbVoltageCallbackThreshold), &payload).await?;
2339        Ok(())
2340    }
2341
2342    /// Returns the threshold as set by [`set_usb_voltage_callback_threshold`].
2343    ///
2344    ///
2345    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2346    ///
2347    /// Associated constants:
2348    /// * MASTER_BRICK_THRESHOLD_OPTION_OFF
2349    ///	* MASTER_BRICK_THRESHOLD_OPTION_OUTSIDE
2350    ///	* MASTER_BRICK_THRESHOLD_OPTION_INSIDE
2351    ///	* MASTER_BRICK_THRESHOLD_OPTION_SMALLER
2352    ///	* MASTER_BRICK_THRESHOLD_OPTION_GREATER
2353    pub async fn get_usb_voltage_callback_threshold(&mut self) -> Result<UsbVoltageCallbackThreshold, TinkerforgeError> {
2354        let payload = [0; 0];
2355
2356        #[allow(unused_variables)]
2357        let result = self.device.get(u8::from(MasterBrickFunction::GetUsbVoltageCallbackThreshold), &payload).await?;
2358        Ok(UsbVoltageCallbackThreshold::from_le_byte_slice(result.body()))
2359    }
2360
2361    /// Sets the period with which the threshold receivers
2362    ///
2363    /// * [`get_stack_current_reached_callback_receiver`],
2364    /// * [`get_stack_voltage_reached_callback_receiver`],
2365    /// * [`get_usb_voltage_reached_callback_receiver`]
2366    ///
2367    /// are triggered, if the thresholds
2368    ///
2369    /// * [`set_stack_current_callback_threshold`],
2370    /// * [`set_stack_voltage_callback_threshold`],
2371    /// * [`set_usb_voltage_callback_threshold`]
2372    ///
2373    /// keep being reached.
2374    ///
2375    ///
2376    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2377    pub async fn set_debounce_period(&mut self, debounce: u32) -> Result<(), TinkerforgeError> {
2378        let mut payload = [0; 4];
2379        debounce.write_to_slice(&mut payload[0..4]);
2380
2381        #[allow(unused_variables)]
2382        let result = self.device.set(u8::from(MasterBrickFunction::SetDebouncePeriod), &payload).await?;
2383        Ok(())
2384    }
2385
2386    /// Returns the debounce period as set by [`set_debounce_period`].
2387    ///
2388    ///
2389    /// .. versionadded:: 2.0.5$nbsp;(Firmware)
2390    pub async fn get_debounce_period(&mut self) -> Result<u32, TinkerforgeError> {
2391        let payload = [0; 0];
2392
2393        #[allow(unused_variables)]
2394        let result = self.device.get(u8::from(MasterBrickFunction::GetDebouncePeriod), &payload).await?;
2395        Ok(u32::from_le_byte_slice(result.body()))
2396    }
2397
2398    /// Returns *true* if the Master Brick is at position 0 in the stack and an Ethernet
2399    /// Extension is available.
2400    ///
2401    ///
2402    /// .. versionadded:: 2.1.0$nbsp;(Firmware)
2403    pub async fn is_ethernet_present(&mut self) -> Result<bool, TinkerforgeError> {
2404        let payload = [0; 0];
2405
2406        #[allow(unused_variables)]
2407        let result = self.device.get(u8::from(MasterBrickFunction::IsEthernetPresent), &payload).await?;
2408        Ok(bool::from_le_byte_slice(result.body()))
2409    }
2410
2411    /// Sets the configuration of the Ethernet Extension. Possible values for
2412    /// ``connection`` are:
2413    ///
2414    ///  Value| Description
2415    ///  --- | ---
2416    ///  0| DHCP
2417    ///  1| Static IP
2418    ///
2419    /// If you set ``connection`` to static IP options then you have to supply ``ip``,
2420    /// ``subnet_mask`` and ``gateway`` as an array of size 4 (first element of the
2421    /// array is the least significant byte of the address). If ``connection`` is set
2422    /// to the DHCP options then ``ip``, ``subnet_mask`` and ``gateway`` are ignored,
2423    /// you can set them to 0.
2424    ///
2425    /// The last parameter is the port that your program will connect to.
2426    ///
2427    /// The values are stored in the EEPROM and only applied on startup. That means
2428    /// you have to restart the Master Brick after configuration.
2429    ///
2430    /// It is recommended to use the Brick Viewer to set the Ethernet configuration.
2431    ///
2432    ///
2433    /// .. versionadded:: 2.1.0$nbsp;(Firmware)
2434    ///
2435    /// Associated constants:
2436    /// * MASTER_BRICK_ETHERNET_CONNECTION_DHCP
2437    ///	* MASTER_BRICK_ETHERNET_CONNECTION_STATIC_IP
2438    pub async fn set_ethernet_configuration(
2439        &mut self,
2440        connection: u8,
2441        ip: &[u8; 4],
2442        subnet_mask: &[u8; 4],
2443        gateway: &[u8; 4],
2444        port: u16,
2445    ) -> Result<(), TinkerforgeError> {
2446        let mut payload = [0; 15];
2447        connection.write_to_slice(&mut payload[0..1]);
2448        ip.write_to_slice(&mut payload[1..5]);
2449        subnet_mask.write_to_slice(&mut payload[5..9]);
2450        gateway.write_to_slice(&mut payload[9..13]);
2451        port.write_to_slice(&mut payload[13..15]);
2452
2453        #[allow(unused_variables)]
2454        let result = self.device.set(u8::from(MasterBrickFunction::SetEthernetConfiguration), &payload).await?;
2455        Ok(())
2456    }
2457
2458    /// Returns the configuration as set by [`set_ethernet_configuration`].
2459    ///
2460    ///
2461    /// .. versionadded:: 2.1.0$nbsp;(Firmware)
2462    ///
2463    /// Associated constants:
2464    /// * MASTER_BRICK_ETHERNET_CONNECTION_DHCP
2465    ///	* MASTER_BRICK_ETHERNET_CONNECTION_STATIC_IP
2466    pub async fn get_ethernet_configuration(&mut self) -> Result<EthernetConfiguration, TinkerforgeError> {
2467        let payload = [0; 0];
2468
2469        #[allow(unused_variables)]
2470        let result = self.device.get(u8::from(MasterBrickFunction::GetEthernetConfiguration), &payload).await?;
2471        Ok(EthernetConfiguration::from_le_byte_slice(result.body()))
2472    }
2473
2474    /// Returns the status of the Ethernet Extension.
2475    ///
2476    /// ``mac_address``, ``ip``, ``subnet_mask`` and ``gateway`` are given as an array.
2477    /// The first element of the array is the least significant byte of the address.
2478    ///
2479    /// ``rx_count`` and ``tx_count`` are the number of bytes that have been
2480    /// received/send since last restart.
2481    ///
2482    /// ``hostname`` is the currently used hostname.
2483    ///
2484    ///
2485    /// .. versionadded:: 2.1.0$nbsp;(Firmware)
2486    pub async fn get_ethernet_status(&mut self) -> Result<EthernetStatus, TinkerforgeError> {
2487        let payload = [0; 0];
2488
2489        #[allow(unused_variables)]
2490        let result = self.device.get(u8::from(MasterBrickFunction::GetEthernetStatus), &payload).await?;
2491        Ok(EthernetStatus::from_le_byte_slice(result.body()))
2492    }
2493
2494    /// Sets the hostname of the Ethernet Extension. The hostname will be displayed
2495    /// by access points as the hostname in the DHCP clients table.
2496    ///
2497    /// Setting an empty String will restore the default hostname.
2498    ///
2499    /// The current hostname can be discovered with [`get_ethernet_status`].
2500    ///
2501    ///
2502    /// .. versionadded:: 2.1.0$nbsp;(Firmware)
2503    pub async fn set_ethernet_hostname(&mut self, hostname: String) -> Result<(), TinkerforgeError> {
2504        let mut payload = [0; 32];
2505        hostname.try_write_to_slice(32, &mut payload)?;
2506
2507        #[allow(unused_variables)]
2508        let result = self.device.set(u8::from(MasterBrickFunction::SetEthernetHostname), &payload).await?;
2509        Ok(())
2510    }
2511
2512    /// Sets the MAC address of the Ethernet Extension. The Ethernet Extension should
2513    /// come configured with a valid MAC address, that is also written on a
2514    /// sticker of the extension itself.
2515    ///
2516    /// The MAC address can be read out again with [`get_ethernet_status`].
2517    ///
2518    ///
2519    /// .. versionadded:: 2.1.0$nbsp;(Firmware)
2520    pub async fn set_ethernet_mac_address(&mut self, mac_address: &[u8; 6]) -> Result<(), TinkerforgeError> {
2521        let mut payload = [0; 6];
2522        mac_address.write_to_slice(&mut payload[0..6]);
2523
2524        #[allow(unused_variables)]
2525        let result = self.device.set(u8::from(MasterBrickFunction::SetEthernetMacAddress), &payload).await?;
2526        Ok(())
2527    }
2528
2529    /// Sets the Ethernet WebSocket configuration. The first parameter sets the number of socket
2530    /// connections that are reserved for WebSockets. The range is 0-7. The connections
2531    /// are shared with the plain sockets. Example: If you set the connections to 3,
2532    /// there will be 3 WebSocket and 4 plain socket connections available.
2533    ///
2534    /// The second parameter is the port for the WebSocket connections. The port can
2535    /// not be the same as the port for the plain socket connections.
2536    ///
2537    /// The values are stored in the EEPROM and only applied on startup. That means
2538    /// you have to restart the Master Brick after configuration.
2539    ///
2540    /// It is recommended to use the Brick Viewer to set the Ethernet configuration.
2541    ///
2542    ///
2543    /// .. versionadded:: 2.2.0$nbsp;(Firmware)
2544    pub async fn set_ethernet_websocket_configuration(&mut self, sockets: u8, port: u16) -> Result<(), TinkerforgeError> {
2545        let mut payload = [0; 3];
2546        sockets.write_to_slice(&mut payload[0..1]);
2547        port.write_to_slice(&mut payload[1..3]);
2548
2549        #[allow(unused_variables)]
2550        let result = self.device.set(u8::from(MasterBrickFunction::SetEthernetWebsocketConfiguration), &payload).await?;
2551        Ok(())
2552    }
2553
2554    /// Returns the configuration as set by [`set_ethernet_configuration`].
2555    ///
2556    ///
2557    /// .. versionadded:: 2.2.0$nbsp;(Firmware)
2558    pub async fn get_ethernet_websocket_configuration(&mut self) -> Result<EthernetWebsocketConfiguration, TinkerforgeError> {
2559        let payload = [0; 0];
2560
2561        #[allow(unused_variables)]
2562        let result = self.device.get(u8::from(MasterBrickFunction::GetEthernetWebsocketConfiguration), &payload).await?;
2563        Ok(EthernetWebsocketConfiguration::from_le_byte_slice(result.body()))
2564    }
2565
2566    /// Sets the Ethernet authentication secret. The secret can be a string of up to 64
2567    /// characters. An empty string disables the authentication.
2568    ///
2569    /// See the [authentication tutorial](tutorial_authentication) for more
2570    /// information.
2571    ///
2572    /// The secret is stored in the EEPROM and only applied on startup. That means
2573    /// you have to restart the Master Brick after configuration.
2574    ///
2575    /// It is recommended to use the Brick Viewer to set the Ethernet authentication secret.
2576    ///
2577    /// The default value is an empty string (authentication disabled).
2578    ///
2579    ///
2580    /// .. versionadded:: 2.2.0$nbsp;(Firmware)
2581    pub async fn set_ethernet_authentication_secret(&mut self, secret: String) -> Result<(), TinkerforgeError> {
2582        let mut payload = [0; 64];
2583        secret.try_write_to_slice(64, &mut payload)?;
2584
2585        #[allow(unused_variables)]
2586        let result = self.device.set(u8::from(MasterBrickFunction::SetEthernetAuthenticationSecret), &payload).await?;
2587        Ok(())
2588    }
2589
2590    /// Returns the authentication secret as set by
2591    /// [`set_ethernet_authentication_secret`].
2592    ///
2593    ///
2594    /// .. versionadded:: 2.2.0$nbsp;(Firmware)
2595    pub async fn get_ethernet_authentication_secret(&mut self) -> Result<String, TinkerforgeError> {
2596        let payload = [0; 0];
2597
2598        #[allow(unused_variables)]
2599        let result = self.device.get(u8::from(MasterBrickFunction::GetEthernetAuthenticationSecret), &payload).await?;
2600        Ok(String::from_le_byte_slice(result.body()))
2601    }
2602
2603    /// Sets the WIFI authentication secret. The secret can be a string of up to 64
2604    /// characters. An empty string disables the authentication.
2605    ///
2606    /// See the [authentication tutorial](tutorial_authentication) for more
2607    /// information.
2608    ///
2609    /// The secret is stored in the EEPROM and only applied on startup. That means
2610    /// you have to restart the Master Brick after configuration.
2611    ///
2612    /// It is recommended to use the Brick Viewer to set the WIFI authentication secret.
2613    ///
2614    /// The default value is an empty string (authentication disabled).
2615    ///
2616    ///
2617    /// .. versionadded:: 2.2.0$nbsp;(Firmware)
2618    pub async fn set_wifi_authentication_secret(&mut self, secret: String) -> Result<(), TinkerforgeError> {
2619        let mut payload = [0; 64];
2620        secret.try_write_to_slice(64, &mut payload)?;
2621
2622        #[allow(unused_variables)]
2623        let result = self.device.set(u8::from(MasterBrickFunction::SetWifiAuthenticationSecret), &payload).await?;
2624        Ok(())
2625    }
2626
2627    /// Returns the authentication secret as set by
2628    /// [`set_wifi_authentication_secret`].
2629    ///
2630    ///
2631    /// .. versionadded:: 2.2.0$nbsp;(Firmware)
2632    pub async fn get_wifi_authentication_secret(&mut self) -> Result<String, TinkerforgeError> {
2633        let payload = [0; 0];
2634
2635        #[allow(unused_variables)]
2636        let result = self.device.get(u8::from(MasterBrickFunction::GetWifiAuthenticationSecret), &payload).await?;
2637        Ok(String::from_le_byte_slice(result.body()))
2638    }
2639
2640    /// Returns the type of the connection over which this function was called.
2641    ///
2642    ///
2643    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2644    ///
2645    /// Associated constants:
2646    /// * MASTER_BRICK_CONNECTION_TYPE_NONE
2647    ///	* MASTER_BRICK_CONNECTION_TYPE_USB
2648    ///	* MASTER_BRICK_CONNECTION_TYPE_SPI_STACK
2649    ///	* MASTER_BRICK_CONNECTION_TYPE_CHIBI
2650    ///	* MASTER_BRICK_CONNECTION_TYPE_RS485
2651    ///	* MASTER_BRICK_CONNECTION_TYPE_WIFI
2652    ///	* MASTER_BRICK_CONNECTION_TYPE_ETHERNET
2653    ///	* MASTER_BRICK_CONNECTION_TYPE_WIFI2
2654    pub async fn get_connection_type(&mut self) -> Result<u8, TinkerforgeError> {
2655        let payload = [0; 0];
2656
2657        #[allow(unused_variables)]
2658        let result = self.device.get(u8::from(MasterBrickFunction::GetConnectionType), &payload).await?;
2659        Ok(u8::from_le_byte_slice(result.body()))
2660    }
2661
2662    /// Returns *true* if the Master Brick is at position 0 in the stack and a WIFI
2663    /// Extension 2.0 is available.
2664    ///
2665    ///
2666    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2667    pub async fn is_wifi2_present(&mut self) -> Result<bool, TinkerforgeError> {
2668        let payload = [0; 0];
2669
2670        #[allow(unused_variables)]
2671        let result = self.device.get(u8::from(MasterBrickFunction::IsWifi2Present), &payload).await?;
2672        Ok(bool::from_le_byte_slice(result.body()))
2673    }
2674
2675    /// Starts the bootloader of the WIFI Extension 2.0. Returns 0 on success.
2676    /// Afterwards the [`write_wifi2_serial_port`] and [`read_wifi2_serial_port`]
2677    /// functions can be used to communicate with the bootloader to flash a new
2678    /// firmware.
2679    ///
2680    /// The bootloader should only be started over a USB connection. It cannot be
2681    /// started over a WIFI2 connection, see the [`get_connection_type`] function.
2682    ///
2683    /// It is recommended to use the Brick Viewer to update the firmware of the WIFI
2684    /// Extension 2.0.
2685    ///
2686    ///
2687    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2688    pub async fn start_wifi2_bootloader(&mut self) -> Result<i8, TinkerforgeError> {
2689        let payload = [0; 0];
2690
2691        #[allow(unused_variables)]
2692        let result = self.device.get(u8::from(MasterBrickFunction::StartWifi2Bootloader), &payload).await?;
2693        Ok(i8::from_le_byte_slice(result.body()))
2694    }
2695
2696    /// Writes up to 60 bytes (number of bytes to be written specified by ``length``)
2697    /// to the serial port of the bootloader of the WIFI Extension 2.0. Returns 0 on
2698    /// success.
2699    ///
2700    /// Before this function can be used the bootloader has to be started using the
2701    /// [`start_wifi2_bootloader`] function.
2702    ///
2703    /// It is recommended to use the Brick Viewer to update the firmware of the WIFI
2704    /// Extension 2.0.
2705    ///
2706    ///
2707    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2708    pub async fn write_wifi2_serial_port(&mut self, data: &[u8; 60], length: u8) -> Result<i8, TinkerforgeError> {
2709        let mut payload = [0; 61];
2710        data.write_to_slice(&mut payload[0..60]);
2711        length.write_to_slice(&mut payload[60..61]);
2712
2713        #[allow(unused_variables)]
2714        let result = self.device.get(u8::from(MasterBrickFunction::WriteWifi2SerialPort), &payload).await?;
2715        Ok(i8::from_le_byte_slice(result.body()))
2716    }
2717
2718    /// Reads up to 60 bytes (number of bytes to be read specified by ``length``)
2719    /// from the serial port of the bootloader of the WIFI Extension 2.0.
2720    /// Returns the number of actually read bytes.
2721    ///
2722    /// Before this function can be used the bootloader has to be started using the
2723    /// [`start_wifi2_bootloader`] function.
2724    ///
2725    /// It is recommended to use the Brick Viewer to update the firmware of the WIFI
2726    /// Extension 2.0.
2727    ///
2728    ///
2729    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2730    pub async fn read_wifi2_serial_port(&mut self, length: u8) -> Result<ReadWifi2SerialPort, TinkerforgeError> {
2731        let mut payload = [0; 1];
2732        length.write_to_slice(&mut payload[0..1]);
2733
2734        #[allow(unused_variables)]
2735        let result = self.device.get(u8::from(MasterBrickFunction::ReadWifi2SerialPort), &payload).await?;
2736        Ok(ReadWifi2SerialPort::from_le_byte_slice(result.body()))
2737    }
2738
2739    /// Sets the WIFI authentication secret. The secret can be a string of up to 64
2740    /// characters. An empty string disables the authentication. The default value is
2741    /// an empty string (authentication disabled).
2742    ///
2743    /// See the [authentication tutorial](tutorial_authentication) for more
2744    /// information.
2745    ///
2746    /// To apply configuration changes to the WIFI Extension 2.0 the
2747    /// [`save_wifi2_configuration`] function has to be called and the Master Brick
2748    /// has to be restarted afterwards.
2749    ///
2750    /// It is recommended to use the Brick Viewer to configure the WIFI Extension 2.0.
2751    ///
2752    ///
2753    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2754    pub async fn set_wifi2_authentication_secret(&mut self, secret: String) -> Result<(), TinkerforgeError> {
2755        let mut payload = [0; 64];
2756        secret.try_write_to_slice(64, &mut payload)?;
2757
2758        #[allow(unused_variables)]
2759        let result = self.device.set(u8::from(MasterBrickFunction::SetWifi2AuthenticationSecret), &payload).await?;
2760        Ok(())
2761    }
2762
2763    /// Returns the WIFI authentication secret as set by
2764    /// [`set_wifi2_authentication_secret`].
2765    ///
2766    ///
2767    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2768    pub async fn get_wifi2_authentication_secret(&mut self) -> Result<String, TinkerforgeError> {
2769        let payload = [0; 0];
2770
2771        #[allow(unused_variables)]
2772        let result = self.device.get(u8::from(MasterBrickFunction::GetWifi2AuthenticationSecret), &payload).await?;
2773        Ok(String::from_le_byte_slice(result.body()))
2774    }
2775
2776    /// Sets the general configuration of the WIFI Extension 2.0.
2777    ///
2778    /// The ``port`` parameter sets the port number that your programm will connect
2779    /// to.
2780    ///
2781    /// The ``websocket_port`` parameter sets the WebSocket port number that your
2782    /// JavaScript programm will connect to.
2783    ///
2784    /// The ``website_port`` parameter sets the port number for the website of the
2785    /// WIFI Extension 2.0.
2786    ///
2787    /// The ``phy_mode`` parameter sets the specific wireless network mode to be used.
2788    /// Possible values are B, G and N.
2789    ///
2790    /// The ``sleep_mode`` parameter is currently unused.
2791    ///
2792    /// The ``website`` parameter is used to enable or disable the web interface of
2793    /// the WIFI Extension 2.0, which is available from firmware version 2.0.1. Note
2794    /// that, for firmware version 2.0.3 and older, to disable the the web interface
2795    /// the ``website_port`` parameter must be set to 1 and greater than 1 to enable
2796    /// the web interface. For firmware version 2.0.4 and later, setting this parameter
2797    /// to 1 will enable the web interface and setting it to 0 will disable the web
2798    /// interface.
2799    ///
2800    /// To apply configuration changes to the WIFI Extension 2.0 the
2801    /// [`save_wifi2_configuration`] function has to be called and the Master Brick
2802    /// has to be restarted afterwards.
2803    ///
2804    /// It is recommended to use the Brick Viewer to configure the WIFI Extension 2.0.
2805    ///
2806    ///
2807    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2808    ///
2809    /// Associated constants:
2810    /// * MASTER_BRICK_WIFI2_PHY_MODE_B
2811    ///	* MASTER_BRICK_WIFI2_PHY_MODE_G
2812    ///	* MASTER_BRICK_WIFI2_PHY_MODE_N
2813    pub async fn set_wifi2_configuration(
2814        &mut self,
2815        port: u16,
2816        websocket_port: u16,
2817        website_port: u16,
2818        phy_mode: u8,
2819        sleep_mode: u8,
2820        website: u8,
2821    ) -> Result<(), TinkerforgeError> {
2822        let mut payload = [0; 9];
2823        port.write_to_slice(&mut payload[0..2]);
2824        websocket_port.write_to_slice(&mut payload[2..4]);
2825        website_port.write_to_slice(&mut payload[4..6]);
2826        phy_mode.write_to_slice(&mut payload[6..7]);
2827        sleep_mode.write_to_slice(&mut payload[7..8]);
2828        website.write_to_slice(&mut payload[8..9]);
2829
2830        #[allow(unused_variables)]
2831        let result = self.device.set(u8::from(MasterBrickFunction::SetWifi2Configuration), &payload).await?;
2832        Ok(())
2833    }
2834
2835    /// Returns the general configuration as set by [`set_wifi2_configuration`].
2836    ///
2837    ///
2838    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2839    ///
2840    /// Associated constants:
2841    /// * MASTER_BRICK_WIFI2_PHY_MODE_B
2842    ///	* MASTER_BRICK_WIFI2_PHY_MODE_G
2843    ///	* MASTER_BRICK_WIFI2_PHY_MODE_N
2844    pub async fn get_wifi2_configuration(&mut self) -> Result<Wifi2Configuration, TinkerforgeError> {
2845        let payload = [0; 0];
2846
2847        #[allow(unused_variables)]
2848        let result = self.device.get(u8::from(MasterBrickFunction::GetWifi2Configuration), &payload).await?;
2849        Ok(Wifi2Configuration::from_le_byte_slice(result.body()))
2850    }
2851
2852    /// Returns the client and access point status of the WIFI Extension 2.0.
2853    ///
2854    ///
2855    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2856    ///
2857    /// Associated constants:
2858    /// * MASTER_BRICK_WIFI2_CLIENT_STATUS_IDLE
2859    ///	* MASTER_BRICK_WIFI2_CLIENT_STATUS_CONNECTING
2860    ///	* MASTER_BRICK_WIFI2_CLIENT_STATUS_WRONG_PASSWORD
2861    ///	* MASTER_BRICK_WIFI2_CLIENT_STATUS_NO_AP_FOUND
2862    ///	* MASTER_BRICK_WIFI2_CLIENT_STATUS_CONNECT_FAILED
2863    ///	* MASTER_BRICK_WIFI2_CLIENT_STATUS_GOT_IP
2864    ///	* MASTER_BRICK_WIFI2_CLIENT_STATUS_UNKNOWN
2865    pub async fn get_wifi2_status(&mut self) -> Result<Wifi2Status, TinkerforgeError> {
2866        let payload = [0; 0];
2867
2868        #[allow(unused_variables)]
2869        let result = self.device.get(u8::from(MasterBrickFunction::GetWifi2Status), &payload).await?;
2870        Ok(Wifi2Status::from_le_byte_slice(result.body()))
2871    }
2872
2873    /// Sets the client specific configuration of the WIFI Extension 2.0.
2874    ///
2875    /// The ``enable`` parameter enables or disables the client part of the
2876    /// WIFI Extension 2.0.
2877    ///
2878    /// The ``ssid`` parameter sets the SSID (up to 32 characters) of the access point
2879    /// to connect to.
2880    ///
2881    /// If the ``ip`` parameter is set to all zero then ``subnet_mask`` and ``gateway``
2882    /// parameters are also set to all zero and DHCP is used for IP address configuration.
2883    /// Otherwise those three parameters can be used to configure a static IP address.
2884    /// The default configuration is DHCP.
2885    ///
2886    /// If the ``mac_address`` parameter is set to all zero then the factory MAC
2887    /// address is used. Otherwise this parameter can be used to set a custom MAC
2888    /// address.
2889    ///
2890    /// If the ``bssid`` parameter is set to all zero then WIFI Extension 2.0 will
2891    /// connect to any access point that matches the configured SSID. Otherwise this
2892    /// parameter can be used to make the WIFI Extension 2.0 only connect to an
2893    /// access point if SSID and BSSID match.
2894    ///
2895    /// To apply configuration changes to the WIFI Extension 2.0 the
2896    /// [`save_wifi2_configuration`] function has to be called and the Master Brick
2897    /// has to be restarted afterwards.
2898    ///
2899    /// It is recommended to use the Brick Viewer to configure the WIFI Extension 2.0.
2900    ///
2901    ///
2902    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2903    pub async fn set_wifi2_client_configuration(
2904        &mut self,
2905        enable: bool,
2906        ssid: String,
2907        ip: &[u8; 4],
2908        subnet_mask: &[u8; 4],
2909        gateway: &[u8; 4],
2910        mac_address: &[u8; 6],
2911        bssid: &[u8; 6],
2912    ) -> Result<(), TinkerforgeError> {
2913        let mut payload = [0; 57];
2914        enable.write_to_slice(&mut payload[0..1]);
2915        ssid.try_write_to_slice(32, &mut payload)?;
2916        ip.write_to_slice(&mut payload[33..37]);
2917        subnet_mask.write_to_slice(&mut payload[37..41]);
2918        gateway.write_to_slice(&mut payload[41..45]);
2919        mac_address.write_to_slice(&mut payload[45..51]);
2920        bssid.write_to_slice(&mut payload[51..57]);
2921
2922        #[allow(unused_variables)]
2923        let result = self.device.set(u8::from(MasterBrickFunction::SetWifi2ClientConfiguration), &payload).await?;
2924        Ok(())
2925    }
2926
2927    /// Returns the client configuration as set by [`set_wifi2_client_configuration`].
2928    ///
2929    ///
2930    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2931    pub async fn get_wifi2_client_configuration(&mut self) -> Result<Wifi2ClientConfiguration, TinkerforgeError> {
2932        let payload = [0; 0];
2933
2934        #[allow(unused_variables)]
2935        let result = self.device.get(u8::from(MasterBrickFunction::GetWifi2ClientConfiguration), &payload).await?;
2936        Ok(Wifi2ClientConfiguration::from_le_byte_slice(result.body()))
2937    }
2938
2939    /// Sets the client hostname (up to 32 characters) of the WIFI Extension 2.0. The
2940    /// hostname will be displayed by access points as the hostname in the DHCP clients
2941    /// table.
2942    ///
2943    /// To apply configuration changes to the WIFI Extension 2.0 the
2944    /// [`save_wifi2_configuration`] function has to be called and the Master Brick
2945    /// has to be restarted afterwards.
2946    ///
2947    /// It is recommended to use the Brick Viewer to configure the WIFI Extension 2.0.
2948    ///
2949    ///
2950    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2951    pub async fn set_wifi2_client_hostname(&mut self, hostname: String) -> Result<(), TinkerforgeError> {
2952        let mut payload = [0; 32];
2953        hostname.try_write_to_slice(32, &mut payload)?;
2954
2955        #[allow(unused_variables)]
2956        let result = self.device.set(u8::from(MasterBrickFunction::SetWifi2ClientHostname), &payload).await?;
2957        Ok(())
2958    }
2959
2960    /// Returns the client hostname as set by [`set_wifi2_client_hostname`].
2961    ///
2962    ///
2963    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2964    pub async fn get_wifi2_client_hostname(&mut self) -> Result<String, TinkerforgeError> {
2965        let payload = [0; 0];
2966
2967        #[allow(unused_variables)]
2968        let result = self.device.get(u8::from(MasterBrickFunction::GetWifi2ClientHostname), &payload).await?;
2969        Ok(String::from_le_byte_slice(result.body()))
2970    }
2971
2972    /// Sets the client password (up to 63 chars) for WPA/WPA2 encryption.
2973    ///
2974    /// To apply configuration changes to the WIFI Extension 2.0 the
2975    /// [`save_wifi2_configuration`] function has to be called and the Master Brick
2976    /// has to be restarted afterwards.
2977    ///
2978    /// It is recommended to use the Brick Viewer to configure the WIFI Extension 2.0.
2979    ///
2980    ///
2981    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2982    pub async fn set_wifi2_client_password(&mut self, password: String) -> Result<(), TinkerforgeError> {
2983        let mut payload = [0; 64];
2984        password.try_write_to_slice(64, &mut payload)?;
2985
2986        #[allow(unused_variables)]
2987        let result = self.device.set(u8::from(MasterBrickFunction::SetWifi2ClientPassword), &payload).await?;
2988        Ok(())
2989    }
2990
2991    /// Returns the client password as set by [`set_wifi2_client_password`].
2992    ///
2993    /// # Note
2994    ///  Since WIFI Extension 2.0 firmware version 2.1.3 the password is not
2995    ///  returned anymore.
2996    ///
2997    ///
2998    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
2999    pub async fn get_wifi2_client_password(&mut self) -> Result<String, TinkerforgeError> {
3000        let payload = [0; 0];
3001
3002        #[allow(unused_variables)]
3003        let result = self.device.get(u8::from(MasterBrickFunction::GetWifi2ClientPassword), &payload).await?;
3004        Ok(String::from_le_byte_slice(result.body()))
3005    }
3006
3007    /// Sets the access point specific configuration of the WIFI Extension 2.0.
3008    ///
3009    /// The ``enable`` parameter enables or disables the access point part of the
3010    /// WIFI Extension 2.0.
3011    ///
3012    /// The ``ssid`` parameter sets the SSID (up to 32 characters) of the access point.
3013    ///
3014    /// If the ``ip`` parameter is set to all zero then ``subnet_mask`` and ``gateway``
3015    /// parameters are also set to all zero and DHCP is used for IP address configuration.
3016    /// Otherwise those three parameters can be used to configure a static IP address.
3017    /// The default configuration is DHCP.
3018    ///
3019    /// The ``encryption`` parameter sets the encryption mode to be used. Possible
3020    /// values are Open (no encryption), WEP or WPA/WPA2 PSK.
3021    /// Use the [`set_wifi2_ap_password`] function to set the encryption
3022    /// password.
3023    ///
3024    /// The ``hidden`` parameter makes the access point hide or show its SSID.
3025    ///
3026    /// The ``channel`` parameter sets the channel (1 to 13) of the access point.
3027    ///
3028    /// If the ``mac_address`` parameter is set to all zero then the factory MAC
3029    /// address is used. Otherwise this parameter can be used to set a custom MAC
3030    /// address.
3031    ///
3032    /// To apply configuration changes to the WIFI Extension 2.0 the
3033    /// [`save_wifi2_configuration`] function has to be called and the Master Brick
3034    /// has to be restarted afterwards.
3035    ///
3036    /// It is recommended to use the Brick Viewer to configure the WIFI Extension 2.0.
3037    ///
3038    ///
3039    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
3040    ///
3041    /// Associated constants:
3042    /// * MASTER_BRICK_WIFI2_AP_ENCRYPTION_OPEN
3043    ///	* MASTER_BRICK_WIFI2_AP_ENCRYPTION_WEP
3044    ///	* MASTER_BRICK_WIFI2_AP_ENCRYPTION_WPA_PSK
3045    ///	* MASTER_BRICK_WIFI2_AP_ENCRYPTION_WPA2_PSK
3046    ///	* MASTER_BRICK_WIFI2_AP_ENCRYPTION_WPA_WPA2_PSK
3047    pub async fn set_wifi2_ap_configuration(
3048        &mut self,
3049        enable: bool,
3050        ssid: String,
3051        ip: &[u8; 4],
3052        subnet_mask: &[u8; 4],
3053        gateway: &[u8; 4],
3054        encryption: u8,
3055        hidden: bool,
3056        channel: u8,
3057        mac_address: &[u8; 6],
3058    ) -> Result<(), TinkerforgeError> {
3059        let mut payload = [0; 54];
3060        enable.write_to_slice(&mut payload[0..1]);
3061        ssid.try_write_to_slice(32, &mut payload)?;
3062        ip.write_to_slice(&mut payload[33..37]);
3063        subnet_mask.write_to_slice(&mut payload[37..41]);
3064        gateway.write_to_slice(&mut payload[41..45]);
3065        encryption.write_to_slice(&mut payload[45..46]);
3066        hidden.write_to_slice(&mut payload[46..47]);
3067        channel.write_to_slice(&mut payload[47..48]);
3068        mac_address.write_to_slice(&mut payload[48..54]);
3069
3070        #[allow(unused_variables)]
3071        let result = self.device.set(u8::from(MasterBrickFunction::SetWifi2ApConfiguration), &payload).await?;
3072        Ok(())
3073    }
3074
3075    /// Returns the access point configuration as set by [`set_wifi2_ap_configuration`].
3076    ///
3077    ///
3078    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
3079    ///
3080    /// Associated constants:
3081    /// * MASTER_BRICK_WIFI2_AP_ENCRYPTION_OPEN
3082    ///	* MASTER_BRICK_WIFI2_AP_ENCRYPTION_WEP
3083    ///	* MASTER_BRICK_WIFI2_AP_ENCRYPTION_WPA_PSK
3084    ///	* MASTER_BRICK_WIFI2_AP_ENCRYPTION_WPA2_PSK
3085    ///	* MASTER_BRICK_WIFI2_AP_ENCRYPTION_WPA_WPA2_PSK
3086    pub async fn get_wifi2_ap_configuration(&mut self) -> Result<Wifi2ApConfiguration, TinkerforgeError> {
3087        let payload = [0; 0];
3088
3089        #[allow(unused_variables)]
3090        let result = self.device.get(u8::from(MasterBrickFunction::GetWifi2ApConfiguration), &payload).await?;
3091        Ok(Wifi2ApConfiguration::from_le_byte_slice(result.body()))
3092    }
3093
3094    /// Sets the access point password (at least 8 and up to 63 chars) for the configured encryption
3095    /// mode, see [`set_wifi2_ap_configuration`].
3096    ///
3097    /// To apply configuration changes to the WIFI Extension 2.0 the
3098    /// [`save_wifi2_configuration`] function has to be called and the Master Brick
3099    /// has to be restarted afterwards.
3100    ///
3101    /// It is recommended to use the Brick Viewer to configure the WIFI Extension 2.0.
3102    ///
3103    ///
3104    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
3105    pub async fn set_wifi2_ap_password(&mut self, password: String) -> Result<(), TinkerforgeError> {
3106        let mut payload = [0; 64];
3107        password.try_write_to_slice(64, &mut payload)?;
3108
3109        #[allow(unused_variables)]
3110        let result = self.device.set(u8::from(MasterBrickFunction::SetWifi2ApPassword), &payload).await?;
3111        Ok(())
3112    }
3113
3114    /// Returns the access point password as set by [`set_wifi2_ap_password`].
3115    ///
3116    /// # Note
3117    ///  Since WIFI Extension 2.0 firmware version 2.1.3 the password is not
3118    ///  returned anymore.
3119    ///
3120    ///
3121    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
3122    pub async fn get_wifi2_ap_password(&mut self) -> Result<String, TinkerforgeError> {
3123        let payload = [0; 0];
3124
3125        #[allow(unused_variables)]
3126        let result = self.device.get(u8::from(MasterBrickFunction::GetWifi2ApPassword), &payload).await?;
3127        Ok(String::from_le_byte_slice(result.body()))
3128    }
3129
3130    /// All configuration functions for the WIFI Extension 2.0 do not change the
3131    /// values permanently. After configuration this function has to be called to
3132    /// permanently store the values.
3133    ///
3134    /// The values are stored in the EEPROM and only applied on startup. That means
3135    /// you have to restart the Master Brick after configuration.
3136    ///
3137    ///
3138    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
3139    pub async fn save_wifi2_configuration(&mut self) -> Result<u8, TinkerforgeError> {
3140        let payload = [0; 0];
3141
3142        #[allow(unused_variables)]
3143        let result = self.device.get(u8::from(MasterBrickFunction::SaveWifi2Configuration), &payload).await?;
3144        Ok(u8::from_le_byte_slice(result.body()))
3145    }
3146
3147    /// Returns the current version of the WIFI Extension 2.0 firmware.
3148    ///
3149    ///
3150    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
3151    pub async fn get_wifi2_firmware_version(&mut self) -> Result<Box<[u8; 3]>, TinkerforgeError> {
3152        let payload = [0; 0];
3153
3154        #[allow(unused_variables)]
3155        let result = self.device.get(u8::from(MasterBrickFunction::GetWifi2FirmwareVersion), &payload).await?;
3156        Ok(Box::<[u8; 3]>::from_le_byte_slice(result.body()))
3157    }
3158
3159    /// Turns the green status LED of the WIFI Extension 2.0 on.
3160    ///
3161    ///
3162    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
3163    pub async fn enable_wifi2_status_led(&mut self) -> Result<(), TinkerforgeError> {
3164        let payload = [0; 0];
3165
3166        #[allow(unused_variables)]
3167        let result = self.device.set(u8::from(MasterBrickFunction::EnableWifi2StatusLed), &payload).await?;
3168        Ok(())
3169    }
3170
3171    /// Turns the green status LED of the WIFI Extension 2.0 off.
3172    ///
3173    ///
3174    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
3175    pub async fn disable_wifi2_status_led(&mut self) -> Result<(), TinkerforgeError> {
3176        let payload = [0; 0];
3177
3178        #[allow(unused_variables)]
3179        let result = self.device.set(u8::from(MasterBrickFunction::DisableWifi2StatusLed), &payload).await?;
3180        Ok(())
3181    }
3182
3183    /// Returns *true* if the green status LED of the WIFI Extension 2.0 is turned on.
3184    ///
3185    ///
3186    /// .. versionadded:: 2.4.0$nbsp;(Firmware)
3187    pub async fn is_wifi2_status_led_enabled(&mut self) -> Result<bool, TinkerforgeError> {
3188        let payload = [0; 0];
3189
3190        #[allow(unused_variables)]
3191        let result = self.device.get(u8::from(MasterBrickFunction::IsWifi2StatusLedEnabled), &payload).await?;
3192        Ok(bool::from_le_byte_slice(result.body()))
3193    }
3194
3195    /// Requires WIFI Extension 2.0 firmware 2.1.0.
3196    ///
3197    /// Sets the mesh specific configuration of the WIFI Extension 2.0.
3198    ///
3199    /// The ``enable`` parameter enables or disables the mesh part of the
3200    /// WIFI Extension 2.0. The mesh part cannot be
3201    /// enabled together with the client and access-point part.
3202    ///
3203    /// If the ``root_ip`` parameter is set to all zero then ``root_subnet_mask``
3204    /// and ``root_gateway`` parameters are also set to all zero and DHCP is used for
3205    /// IP address configuration. Otherwise those three parameters can be used to
3206    /// configure a static IP address. The default configuration is DHCP.
3207    ///
3208    /// If the ``router_bssid`` parameter is set to all zero then the information is
3209    /// taken from Wi-Fi scan when connecting the SSID as set by
3210    /// [`set_wifi2_mesh_router_ssid`]. This only works if the the SSID is not hidden.
3211    /// In case the router has hidden SSID this parameter must be specified, otherwise
3212    /// the node will not be able to reach the mesh router.
3213    ///
3214    /// The ``group_id`` and the ``group_ssid_prefix`` parameters identifies a
3215    /// particular mesh network and nodes configured with same ``group_id`` and the
3216    /// ``group_ssid_prefix`` are considered to be in the same mesh network.
3217    ///
3218    /// The ``gateway_ip`` and the ``gateway_port`` parameters specifies the location
3219    /// of the brickd that supports mesh feature.
3220    ///
3221    /// To apply configuration changes to the WIFI Extension 2.0 the
3222    /// [`save_wifi2_configuration`] function has to be called and the Master Brick
3223    /// has to be restarted afterwards.
3224    ///
3225    /// It is recommended to use the Brick Viewer to configure the WIFI Extension 2.0.
3226    ///
3227    ///
3228    /// .. versionadded:: 2.4.2$nbsp;(Firmware)
3229    pub async fn set_wifi2_mesh_configuration(
3230        &mut self,
3231        enable: bool,
3232        root_ip: &[u8; 4],
3233        root_subnet_mask: &[u8; 4],
3234        root_gateway: &[u8; 4],
3235        router_bssid: &[u8; 6],
3236        group_id: &[u8; 6],
3237        group_ssid_prefix: String,
3238        gateway_ip: &[u8; 4],
3239        gateway_port: u16,
3240    ) -> Result<(), TinkerforgeError> {
3241        let mut payload = [0; 47];
3242        enable.write_to_slice(&mut payload[0..1]);
3243        root_ip.write_to_slice(&mut payload[1..5]);
3244        root_subnet_mask.write_to_slice(&mut payload[5..9]);
3245        root_gateway.write_to_slice(&mut payload[9..13]);
3246        router_bssid.write_to_slice(&mut payload[13..19]);
3247        group_id.write_to_slice(&mut payload[19..25]);
3248        group_ssid_prefix.try_write_to_slice(16, &mut payload)?;
3249        gateway_ip.write_to_slice(&mut payload[41..45]);
3250        gateway_port.write_to_slice(&mut payload[45..47]);
3251
3252        #[allow(unused_variables)]
3253        let result = self.device.set(u8::from(MasterBrickFunction::SetWifi2MeshConfiguration), &payload).await?;
3254        Ok(())
3255    }
3256
3257    /// Requires WIFI Extension 2.0 firmware 2.1.0.
3258    ///
3259    /// Returns the mesh configuration as set by [`set_wifi2_mesh_configuration`].
3260    ///
3261    ///
3262    /// .. versionadded:: 2.4.2$nbsp;(Firmware)
3263    pub async fn get_wifi2_mesh_configuration(&mut self) -> Result<Wifi2MeshConfiguration, TinkerforgeError> {
3264        let payload = [0; 0];
3265
3266        #[allow(unused_variables)]
3267        let result = self.device.get(u8::from(MasterBrickFunction::GetWifi2MeshConfiguration), &payload).await?;
3268        Ok(Wifi2MeshConfiguration::from_le_byte_slice(result.body()))
3269    }
3270
3271    /// Requires WIFI Extension 2.0 firmware 2.1.0.
3272    ///
3273    /// Sets the mesh router SSID of the WIFI Extension 2.0.
3274    /// It is used to specify the mesh router to connect to.
3275    ///
3276    /// Note that even though in the argument of this function a 32 characters long SSID
3277    /// is allowed, in practice valid SSID should have a maximum of 31 characters. This
3278    /// is due to a bug in the mesh library that we use in the firmware of the extension.
3279    ///
3280    /// To apply configuration changes to the WIFI Extension 2.0 the
3281    /// [`save_wifi2_configuration`] function has to be called and the Master Brick
3282    /// has to be restarted afterwards.
3283    ///
3284    /// It is recommended to use the Brick Viewer to configure the WIFI Extension 2.0.
3285    ///
3286    ///
3287    /// .. versionadded:: 2.4.2$nbsp;(Firmware)
3288    pub async fn set_wifi2_mesh_router_ssid(&mut self, ssid: String) -> Result<(), TinkerforgeError> {
3289        let mut payload = [0; 32];
3290        ssid.try_write_to_slice(32, &mut payload)?;
3291
3292        #[allow(unused_variables)]
3293        let result = self.device.set(u8::from(MasterBrickFunction::SetWifi2MeshRouterSsid), &payload).await?;
3294        Ok(())
3295    }
3296
3297    /// Requires WIFI Extension 2.0 firmware 2.1.0.
3298    ///
3299    /// Returns the mesh router SSID as set by [`set_wifi2_mesh_router_ssid`].
3300    ///
3301    ///
3302    /// .. versionadded:: 2.4.2$nbsp;(Firmware)
3303    pub async fn get_wifi2_mesh_router_ssid(&mut self) -> Result<String, TinkerforgeError> {
3304        let payload = [0; 0];
3305
3306        #[allow(unused_variables)]
3307        let result = self.device.get(u8::from(MasterBrickFunction::GetWifi2MeshRouterSsid), &payload).await?;
3308        Ok(String::from_le_byte_slice(result.body()))
3309    }
3310
3311    /// Requires WIFI Extension 2.0 firmware 2.1.0.
3312    ///
3313    /// Sets the mesh router password (up to 64 characters) for WPA/WPA2 encryption.
3314    /// The password will be used to connect to the mesh router.
3315    ///
3316    /// To apply configuration changes to the WIFI Extension 2.0 the
3317    /// [`save_wifi2_configuration`] function has to be called and the Master Brick
3318    /// has to be restarted afterwards.
3319    ///
3320    /// It is recommended to use the Brick Viewer to configure the WIFI Extension 2.0.
3321    ///
3322    ///
3323    /// .. versionadded:: 2.4.2$nbsp;(Firmware)
3324    pub async fn set_wifi2_mesh_router_password(&mut self, password: String) -> Result<(), TinkerforgeError> {
3325        let mut payload = [0; 64];
3326        password.try_write_to_slice(64, &mut payload)?;
3327
3328        #[allow(unused_variables)]
3329        let result = self.device.set(u8::from(MasterBrickFunction::SetWifi2MeshRouterPassword), &payload).await?;
3330        Ok(())
3331    }
3332
3333    /// Requires WIFI Extension 2.0 firmware 2.1.0.
3334    ///
3335    /// Returns the mesh router password as set by [`set_wifi2_mesh_router_password`].
3336    ///
3337    ///
3338    /// .. versionadded:: 2.4.2$nbsp;(Firmware)
3339    pub async fn get_wifi2_mesh_router_password(&mut self) -> Result<String, TinkerforgeError> {
3340        let payload = [0; 0];
3341
3342        #[allow(unused_variables)]
3343        let result = self.device.get(u8::from(MasterBrickFunction::GetWifi2MeshRouterPassword), &payload).await?;
3344        Ok(String::from_le_byte_slice(result.body()))
3345    }
3346
3347    /// Requires WIFI Extension 2.0 firmware 2.1.0.
3348    ///
3349    /// Returns the common mesh status of the WIFI Extension 2.0.
3350    ///
3351    ///
3352    /// .. versionadded:: 2.4.2$nbsp;(Firmware)
3353    ///
3354    /// Associated constants:
3355    /// * MASTER_BRICK_WIFI2_MESH_STATUS_DISABLED
3356    ///	* MASTER_BRICK_WIFI2_MESH_STATUS_WIFI_CONNECTING
3357    ///	* MASTER_BRICK_WIFI2_MESH_STATUS_GOT_IP
3358    ///	* MASTER_BRICK_WIFI2_MESH_STATUS_MESH_LOCAL
3359    ///	* MASTER_BRICK_WIFI2_MESH_STATUS_MESH_ONLINE
3360    ///	* MASTER_BRICK_WIFI2_MESH_STATUS_AP_AVAILABLE
3361    ///	* MASTER_BRICK_WIFI2_MESH_STATUS_AP_SETUP
3362    ///	* MASTER_BRICK_WIFI2_MESH_STATUS_LEAF_AVAILABLE
3363    pub async fn get_wifi2_mesh_common_status(&mut self) -> Result<Wifi2MeshCommonStatus, TinkerforgeError> {
3364        let payload = [0; 0];
3365
3366        #[allow(unused_variables)]
3367        let result = self.device.get(u8::from(MasterBrickFunction::GetWifi2MeshCommonStatus), &payload).await?;
3368        Ok(Wifi2MeshCommonStatus::from_le_byte_slice(result.body()))
3369    }
3370
3371    /// Requires WIFI Extension 2.0 firmware 2.1.0.
3372    ///
3373    /// Returns the mesh client status of the WIFI Extension 2.0.
3374    ///
3375    ///
3376    /// .. versionadded:: 2.4.2$nbsp;(Firmware)
3377    pub async fn get_wifi2_mesh_client_status(&mut self) -> Result<Wifi2MeshClientStatus, TinkerforgeError> {
3378        let payload = [0; 0];
3379
3380        #[allow(unused_variables)]
3381        let result = self.device.get(u8::from(MasterBrickFunction::GetWifi2MeshClientStatus), &payload).await?;
3382        Ok(Wifi2MeshClientStatus::from_le_byte_slice(result.body()))
3383    }
3384
3385    /// Requires WIFI Extension 2.0 firmware 2.1.0.
3386    ///
3387    /// Returns the mesh AP status of the WIFI Extension 2.0.
3388    ///
3389    ///
3390    /// .. versionadded:: 2.4.2$nbsp;(Firmware)
3391    pub async fn get_wifi2_mesh_ap_status(&mut self) -> Result<Wifi2MeshApStatus, TinkerforgeError> {
3392        let payload = [0; 0];
3393
3394        #[allow(unused_variables)]
3395        let result = self.device.get(u8::from(MasterBrickFunction::GetWifi2MeshApStatus), &payload).await?;
3396        Ok(Wifi2MeshApStatus::from_le_byte_slice(result.body()))
3397    }
3398
3399    /// This function is for internal use to flash the initial
3400    /// bootstrapper and bootloader to the Bricklets.
3401    ///
3402    /// If you need to flash a boostrapper/bootloader (for exmaple
3403    /// because you made your own Bricklet from scratch) please
3404    /// take a look at our open source flash and test tool at
3405    /// [https://github.com/Tinkerforge/flash-test](https://github.com/Tinkerforge/flash-test)__
3406    ///
3407    /// Don't use this function directly.
3408    ///
3409    ///
3410    /// .. versionadded:: 2.5.0$nbsp;(Firmware)
3411    pub async fn set_bricklet_xmc_flash_config(
3412        &mut self,
3413        config: u32,
3414        parameter1: u32,
3415        parameter2: u32,
3416        data: &[u8; 52],
3417    ) -> Result<SetBrickletXmcFlashConfig, TinkerforgeError> {
3418        let mut payload = [0; 64];
3419        config.write_to_slice(&mut payload[0..4]);
3420        parameter1.write_to_slice(&mut payload[4..8]);
3421        parameter2.write_to_slice(&mut payload[8..12]);
3422        data.write_to_slice(&mut payload[12..64]);
3423
3424        #[allow(unused_variables)]
3425        let result = self.device.get(u8::from(MasterBrickFunction::SetBrickletXmcFlashConfig), &payload).await?;
3426        Ok(SetBrickletXmcFlashConfig::from_le_byte_slice(result.body()))
3427    }
3428
3429    /// This function is for internal use to flash the initial
3430    /// bootstrapper and bootloader to the Bricklets.
3431    ///
3432    /// If you need to flash a boostrapper/bootloader (for exmaple
3433    /// because you made your own Bricklet from scratch) please
3434    /// take a look at our open source flash and test tool at
3435    /// [https://github.com/Tinkerforge/flash-test](https://github.com/Tinkerforge/flash-test)__
3436    ///
3437    /// Don't use this function directly.
3438    ///
3439    ///
3440    /// .. versionadded:: 2.5.0$nbsp;(Firmware)
3441    pub async fn set_bricklet_xmc_flash_data(&mut self, data: &[u8; 64]) -> Result<u32, TinkerforgeError> {
3442        let mut payload = [0; 64];
3443        data.write_to_slice(&mut payload[0..64]);
3444
3445        #[allow(unused_variables)]
3446        let result = self.device.get(u8::from(MasterBrickFunction::SetBrickletXmcFlashData), &payload).await?;
3447        Ok(u32::from_le_byte_slice(result.body()))
3448    }
3449
3450    /// This function is only available in Master Brick hardware version >= 3.0.
3451    ///
3452    /// Enables/disables all four Bricklets if set to true/false.
3453    ///
3454    /// If you disable the Bricklets the power supply to the Bricklets will be disconnected.
3455    /// The Bricklets will lose all configurations if disabled.
3456    ///
3457    ///
3458    /// .. versionadded:: 2.5.0$nbsp;(Firmware)
3459    pub async fn set_bricklets_enabled(&mut self, bricklets_enabled: bool) -> Result<(), TinkerforgeError> {
3460        let mut payload = [0; 1];
3461        bricklets_enabled.write_to_slice(&mut payload[0..1]);
3462
3463        #[allow(unused_variables)]
3464        let result = self.device.set(u8::from(MasterBrickFunction::SetBrickletsEnabled), &payload).await?;
3465        Ok(())
3466    }
3467
3468    /// Returns *true* if the Bricklets are enabled, *false* otherwise.
3469    ///
3470    ///
3471    /// .. versionadded:: 2.5.0$nbsp;(Firmware)
3472    pub async fn get_bricklets_enabled(&mut self) -> Result<bool, TinkerforgeError> {
3473        let payload = [0; 0];
3474
3475        #[allow(unused_variables)]
3476        let result = self.device.get(u8::from(MasterBrickFunction::GetBrickletsEnabled), &payload).await?;
3477        Ok(bool::from_le_byte_slice(result.body()))
3478    }
3479
3480    /// The SPITF protocol can be used with a dynamic baudrate. If the dynamic baudrate is
3481    /// enabled, the Brick will try to adapt the baudrate for the communication
3482    /// between Bricks and Bricklets according to the amount of data that is transferred.
3483    ///
3484    /// The baudrate will be increased exponentially if lots of data is sent/received and
3485    /// decreased linearly if little data is sent/received.
3486    ///
3487    /// This lowers the baudrate in applications where little data is transferred (e.g.
3488    /// a weather station) and increases the robustness. If there is lots of data to transfer
3489    /// (e.g. Thermal Imaging Bricklet) it automatically increases the baudrate as needed.
3490    ///
3491    /// In cases where some data has to transferred as fast as possible every few seconds
3492    /// (e.g. RS485 Bricklet with a high baudrate but small payload) you may want to turn
3493    /// the dynamic baudrate off to get the highest possible performance.
3494    ///
3495    /// The maximum value of the baudrate can be set per port with the function
3496    /// [`set_spitfp_baudrate`]. If the dynamic baudrate is disabled, the baudrate
3497    /// as set by [`set_spitfp_baudrate`] will be used statically.
3498    ///
3499    ///
3500    /// .. versionadded:: 2.4.6$nbsp;(Firmware)
3501    pub async fn set_spitfp_baudrate_config(
3502        &mut self,
3503        enable_dynamic_baudrate: bool,
3504        minimum_dynamic_baudrate: u32,
3505    ) -> Result<(), TinkerforgeError> {
3506        let mut payload = [0; 5];
3507        enable_dynamic_baudrate.write_to_slice(&mut payload[0..1]);
3508        minimum_dynamic_baudrate.write_to_slice(&mut payload[1..5]);
3509
3510        #[allow(unused_variables)]
3511        let result = self.device.set(u8::from(MasterBrickFunction::SetSpitfpBaudrateConfig), &payload).await?;
3512        Ok(())
3513    }
3514
3515    /// Returns the baudrate config, see [`set_spitfp_baudrate_config`].
3516    ///
3517    ///
3518    /// .. versionadded:: 2.4.6$nbsp;(Firmware)
3519    pub async fn get_spitfp_baudrate_config(&mut self) -> Result<SpitfpBaudrateConfig, TinkerforgeError> {
3520        let payload = [0; 0];
3521
3522        #[allow(unused_variables)]
3523        let result = self.device.get(u8::from(MasterBrickFunction::GetSpitfpBaudrateConfig), &payload).await?;
3524        Ok(SpitfpBaudrateConfig::from_le_byte_slice(result.body()))
3525    }
3526
3527    /// Returns the timeout count for the different communication methods.
3528    ///
3529    /// The methods 0-2 are available for all Bricks, 3-7 only for Master Bricks.
3530    ///
3531    /// This function is mostly used for debugging during development, in normal operation
3532    /// the counters should nearly always stay at 0.
3533    ///
3534    ///
3535    /// .. versionadded:: 2.4.3$nbsp;(Firmware)
3536    ///
3537    /// Associated constants:
3538    /// * MASTER_BRICK_COMMUNICATION_METHOD_NONE
3539    ///	* MASTER_BRICK_COMMUNICATION_METHOD_USB
3540    ///	* MASTER_BRICK_COMMUNICATION_METHOD_SPI_STACK
3541    ///	* MASTER_BRICK_COMMUNICATION_METHOD_CHIBI
3542    ///	* MASTER_BRICK_COMMUNICATION_METHOD_RS485
3543    ///	* MASTER_BRICK_COMMUNICATION_METHOD_WIFI
3544    ///	* MASTER_BRICK_COMMUNICATION_METHOD_ETHERNET
3545    ///	* MASTER_BRICK_COMMUNICATION_METHOD_WIFI_V2
3546    pub async fn get_send_timeout_count(&mut self, communication_method: u8) -> Result<u32, TinkerforgeError> {
3547        let mut payload = [0; 1];
3548        communication_method.write_to_slice(&mut payload[0..1]);
3549
3550        #[allow(unused_variables)]
3551        let result = self.device.get(u8::from(MasterBrickFunction::GetSendTimeoutCount), &payload).await?;
3552        Ok(u32::from_le_byte_slice(result.body()))
3553    }
3554
3555    /// Sets the baudrate for a specific Bricklet port.
3556    ///
3557    /// If you want to increase the throughput of Bricklets you can increase
3558    /// the baudrate. If you get a high error count because of high
3559    /// interference (see [`get_spitfp_error_count`]) you can decrease the
3560    /// baudrate.
3561    ///
3562    /// If the dynamic baudrate feature is enabled, the baudrate set by this
3563    /// function corresponds to the maximum baudrate (see [`set_spitfp_baudrate_config`]).
3564    ///
3565    /// Regulatory testing is done with the default baudrate. If CE compatibility
3566    /// or similar is necessary in your applications we recommend to not change
3567    /// the baudrate.
3568    ///
3569    ///
3570    /// .. versionadded:: 2.4.3$nbsp;(Firmware)
3571    pub async fn set_spitfp_baudrate(&mut self, bricklet_port: char, baudrate: u32) -> Result<(), TinkerforgeError> {
3572        let mut payload = [0; 5];
3573        bricklet_port.write_to_slice(&mut payload[0..1]);
3574        baudrate.write_to_slice(&mut payload[1..5]);
3575
3576        #[allow(unused_variables)]
3577        let result = self.device.set(u8::from(MasterBrickFunction::SetSpitfpBaudrate), &payload).await?;
3578        Ok(())
3579    }
3580
3581    /// Returns the baudrate for a given Bricklet port, see [`set_spitfp_baudrate`].
3582    ///
3583    ///
3584    /// .. versionadded:: 2.4.3$nbsp;(Firmware)
3585    pub async fn get_spitfp_baudrate(&mut self, bricklet_port: char) -> Result<u32, TinkerforgeError> {
3586        let mut payload = [0; 1];
3587        bricklet_port.write_to_slice(&mut payload[0..1]);
3588
3589        #[allow(unused_variables)]
3590        let result = self.device.get(u8::from(MasterBrickFunction::GetSpitfpBaudrate), &payload).await?;
3591        Ok(u32::from_le_byte_slice(result.body()))
3592    }
3593
3594    /// Returns the error count for the communication between Brick and Bricklet.
3595    ///
3596    /// The errors are divided into
3597    ///
3598    /// * ACK checksum errors,
3599    /// * message checksum errors,
3600    /// * framing errors and
3601    /// * overflow errors.
3602    ///
3603    /// The errors counts are for errors that occur on the Brick side. All
3604    /// Bricklets have a similar function that returns the errors on the Bricklet side.
3605    ///
3606    ///
3607    /// .. versionadded:: 2.4.3$nbsp;(Firmware)
3608    pub async fn get_spitfp_error_count(&mut self, bricklet_port: char) -> Result<SpitfpErrorCount, TinkerforgeError> {
3609        let mut payload = [0; 1];
3610        bricklet_port.write_to_slice(&mut payload[0..1]);
3611
3612        #[allow(unused_variables)]
3613        let result = self.device.get(u8::from(MasterBrickFunction::GetSpitfpErrorCount), &payload).await?;
3614        Ok(SpitfpErrorCount::from_le_byte_slice(result.body()))
3615    }
3616
3617    /// Enables the status LED.
3618    ///
3619    /// The status LED is the blue LED next to the USB connector. If enabled is is
3620    /// on and it flickers if data is transfered. If disabled it is always off.
3621    ///
3622    /// The default state is enabled.
3623    ///
3624    ///
3625    /// .. versionadded:: 2.3.2$nbsp;(Firmware)
3626    pub async fn enable_status_led(&mut self) -> Result<(), TinkerforgeError> {
3627        let payload = [0; 0];
3628
3629        #[allow(unused_variables)]
3630        let result = self.device.set(u8::from(MasterBrickFunction::EnableStatusLed), &payload).await?;
3631        Ok(())
3632    }
3633
3634    /// Disables the status LED.
3635    ///
3636    /// The status LED is the blue LED next to the USB connector. If enabled is is
3637    /// on and it flickers if data is transfered. If disabled it is always off.
3638    ///
3639    /// The default state is enabled.
3640    ///
3641    ///
3642    /// .. versionadded:: 2.3.2$nbsp;(Firmware)
3643    pub async fn disable_status_led(&mut self) -> Result<(), TinkerforgeError> {
3644        let payload = [0; 0];
3645
3646        #[allow(unused_variables)]
3647        let result = self.device.set(u8::from(MasterBrickFunction::DisableStatusLed), &payload).await?;
3648        Ok(())
3649    }
3650
3651    /// Returns *true* if the status LED is enabled, *false* otherwise.
3652    ///
3653    ///
3654    /// .. versionadded:: 2.3.2$nbsp;(Firmware)
3655    pub async fn is_status_led_enabled(&mut self) -> Result<bool, TinkerforgeError> {
3656        let payload = [0; 0];
3657
3658        #[allow(unused_variables)]
3659        let result = self.device.get(u8::from(MasterBrickFunction::IsStatusLedEnabled), &payload).await?;
3660        Ok(bool::from_le_byte_slice(result.body()))
3661    }
3662
3663    /// Returns the firmware and protocol version and the name of the Bricklet for a
3664    /// given port.
3665    ///
3666    /// This functions sole purpose is to allow automatic flashing of v1.x.y Bricklet
3667    /// plugins.
3668    pub async fn get_protocol1_bricklet_name(&mut self, port: char) -> Result<Protocol1BrickletName, TinkerforgeError> {
3669        let mut payload = [0; 1];
3670        port.write_to_slice(&mut payload[0..1]);
3671
3672        #[allow(unused_variables)]
3673        let result = self.device.get(u8::from(MasterBrickFunction::GetProtocol1BrickletName), &payload).await?;
3674        Ok(Protocol1BrickletName::from_le_byte_slice(result.body()))
3675    }
3676
3677    /// Returns the temperature as measured inside the microcontroller. The
3678    /// value returned is not the ambient temperature!
3679    ///
3680    /// The temperature is only proportional to the real temperature and it has an
3681    /// accuracy of ±15%. Practically it is only useful as an indicator for
3682    /// temperature changes.
3683    pub async fn get_chip_temperature(&mut self) -> Result<i16, TinkerforgeError> {
3684        let payload = [0; 0];
3685
3686        #[allow(unused_variables)]
3687        let result = self.device.get(u8::from(MasterBrickFunction::GetChipTemperature), &payload).await?;
3688        Ok(i16::from_le_byte_slice(result.body()))
3689    }
3690
3691    /// Calling this function will reset the Brick. Calling this function
3692    /// on a Brick inside of a stack will reset the whole stack.
3693    ///
3694    /// After a reset you have to create new device objects,
3695    /// calling functions on the existing ones will result in
3696    /// undefined behavior!
3697    pub async fn reset(&mut self) -> Result<(), TinkerforgeError> {
3698        let payload = [0; 0];
3699
3700        #[allow(unused_variables)]
3701        let result = self.device.set(u8::from(MasterBrickFunction::Reset), &payload).await?;
3702        Ok(())
3703    }
3704
3705    /// Writes 32 bytes of firmware to the bricklet attached at the given port.
3706    /// The bytes are written to the position offset * 32.
3707    ///
3708    /// This function is used by Brick Viewer during flashing. It should not be
3709    /// necessary to call it in a normal user program.
3710    pub async fn write_bricklet_plugin(&mut self, port: char, offset: u8, chunk: &[u8; 32]) -> Result<(), TinkerforgeError> {
3711        let mut payload = [0; 34];
3712        port.write_to_slice(&mut payload[0..1]);
3713        offset.write_to_slice(&mut payload[1..2]);
3714        chunk.write_to_slice(&mut payload[2..34]);
3715
3716        #[allow(unused_variables)]
3717        let result = self.device.set(u8::from(MasterBrickFunction::WriteBrickletPlugin), &payload).await?;
3718        Ok(())
3719    }
3720
3721    /// Reads 32 bytes of firmware from the bricklet attached at the given port.
3722    /// The bytes are read starting at the position offset * 32.
3723    ///
3724    /// This function is used by Brick Viewer during flashing. It should not be
3725    /// necessary to call it in a normal user program.
3726    pub async fn read_bricklet_plugin(&mut self, port: char, offset: u8) -> Result<Box<[u8; 32]>, TinkerforgeError> {
3727        let mut payload = [0; 2];
3728        port.write_to_slice(&mut payload[0..1]);
3729        offset.write_to_slice(&mut payload[1..2]);
3730
3731        #[allow(unused_variables)]
3732        let result = self.device.get(u8::from(MasterBrickFunction::ReadBrickletPlugin), &payload).await?;
3733        Ok(Box::<[u8; 32]>::from_le_byte_slice(result.body()))
3734    }
3735
3736    /// Returns the UID, the UID where the Brick is connected to,
3737    /// the position, the hardware and firmware version as well as the
3738    /// device identifier.
3739    ///
3740    /// The position is the position in the stack from '0' (bottom) to '8' (top).
3741    ///
3742    /// The device identifier numbers can be found [here](device_identifier).
3743    /// |device_identifier_constant|
3744    pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
3745        let payload = [0; 0];
3746
3747        #[allow(unused_variables)]
3748        let result = self.device.get(u8::from(MasterBrickFunction::GetIdentity), &payload).await?;
3749        Ok(Identity::from_le_byte_slice(result.body()))
3750    }
3751}