use crate::{
byte_converter::*, converting_callback_receiver::ConvertingCallbackReceiver, converting_receiver::ConvertingReceiver, device::*,
ip_connection::GetRequestSender,
};
pub enum RemoteSwitchV2BrickletFunction {
GetSwitchingState,
SetRepeats,
GetRepeats,
SwitchSocketA,
SwitchSocketB,
DimSocketB,
SwitchSocketC,
SetRemoteConfiguration,
GetRemoteConfiguration,
GetRemoteStatusA,
GetRemoteStatusB,
GetRemoteStatusC,
GetSpitfpErrorCount,
SetBootloaderMode,
GetBootloaderMode,
SetWriteFirmwarePointer,
WriteFirmware,
SetStatusLedConfig,
GetStatusLedConfig,
GetChipTemperature,
Reset,
WriteUid,
ReadUid,
GetIdentity,
CallbackSwitchingDone,
CallbackRemoteStatusA,
CallbackRemoteStatusB,
CallbackRemoteStatusC,
}
impl From<RemoteSwitchV2BrickletFunction> for u8 {
fn from(fun: RemoteSwitchV2BrickletFunction) -> Self {
match fun {
RemoteSwitchV2BrickletFunction::GetSwitchingState => 1,
RemoteSwitchV2BrickletFunction::SetRepeats => 3,
RemoteSwitchV2BrickletFunction::GetRepeats => 4,
RemoteSwitchV2BrickletFunction::SwitchSocketA => 5,
RemoteSwitchV2BrickletFunction::SwitchSocketB => 6,
RemoteSwitchV2BrickletFunction::DimSocketB => 7,
RemoteSwitchV2BrickletFunction::SwitchSocketC => 8,
RemoteSwitchV2BrickletFunction::SetRemoteConfiguration => 9,
RemoteSwitchV2BrickletFunction::GetRemoteConfiguration => 10,
RemoteSwitchV2BrickletFunction::GetRemoteStatusA => 11,
RemoteSwitchV2BrickletFunction::GetRemoteStatusB => 12,
RemoteSwitchV2BrickletFunction::GetRemoteStatusC => 13,
RemoteSwitchV2BrickletFunction::GetSpitfpErrorCount => 234,
RemoteSwitchV2BrickletFunction::SetBootloaderMode => 235,
RemoteSwitchV2BrickletFunction::GetBootloaderMode => 236,
RemoteSwitchV2BrickletFunction::SetWriteFirmwarePointer => 237,
RemoteSwitchV2BrickletFunction::WriteFirmware => 238,
RemoteSwitchV2BrickletFunction::SetStatusLedConfig => 239,
RemoteSwitchV2BrickletFunction::GetStatusLedConfig => 240,
RemoteSwitchV2BrickletFunction::GetChipTemperature => 242,
RemoteSwitchV2BrickletFunction::Reset => 243,
RemoteSwitchV2BrickletFunction::WriteUid => 248,
RemoteSwitchV2BrickletFunction::ReadUid => 249,
RemoteSwitchV2BrickletFunction::GetIdentity => 255,
RemoteSwitchV2BrickletFunction::CallbackSwitchingDone => 2,
RemoteSwitchV2BrickletFunction::CallbackRemoteStatusA => 14,
RemoteSwitchV2BrickletFunction::CallbackRemoteStatusB => 15,
RemoteSwitchV2BrickletFunction::CallbackRemoteStatusC => 16,
}
}
}
pub const REMOTE_SWITCH_V2_BRICKLET_SWITCHING_STATE_READY: u8 = 0;
pub const REMOTE_SWITCH_V2_BRICKLET_SWITCHING_STATE_BUSY: u8 = 1;
pub const REMOTE_SWITCH_V2_BRICKLET_SWITCH_TO_OFF: u8 = 0;
pub const REMOTE_SWITCH_V2_BRICKLET_SWITCH_TO_ON: u8 = 1;
pub const REMOTE_SWITCH_V2_BRICKLET_REMOTE_TYPE_A: u8 = 0;
pub const REMOTE_SWITCH_V2_BRICKLET_REMOTE_TYPE_B: u8 = 1;
pub const REMOTE_SWITCH_V2_BRICKLET_REMOTE_TYPE_C: u8 = 2;
pub const REMOTE_SWITCH_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
pub const REMOTE_SWITCH_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
pub const REMOTE_SWITCH_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
pub const REMOTE_SWITCH_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
pub const REMOTE_SWITCH_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
pub const REMOTE_SWITCH_V2_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
pub const REMOTE_SWITCH_V2_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
pub const REMOTE_SWITCH_V2_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
pub const REMOTE_SWITCH_V2_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
pub const REMOTE_SWITCH_V2_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
pub const REMOTE_SWITCH_V2_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
pub const REMOTE_SWITCH_V2_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
pub const REMOTE_SWITCH_V2_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
pub const REMOTE_SWITCH_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
pub const REMOTE_SWITCH_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct RemoteConfiguration {
pub remote_type: u8,
pub minimum_repeats: u16,
pub callback_enabled: bool,
}
impl FromByteSlice for RemoteConfiguration {
fn bytes_expected() -> usize { 4 }
fn from_le_byte_slice(bytes: &[u8]) -> RemoteConfiguration {
RemoteConfiguration {
remote_type: <u8>::from_le_byte_slice(&bytes[0..1]),
minimum_repeats: <u16>::from_le_byte_slice(&bytes[1..3]),
callback_enabled: <bool>::from_le_byte_slice(&bytes[3..4]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct RemoteStatusA {
pub house_code: u8,
pub receiver_code: u8,
pub switch_to: u8,
pub repeats: u16,
}
impl FromByteSlice for RemoteStatusA {
fn bytes_expected() -> usize { 5 }
fn from_le_byte_slice(bytes: &[u8]) -> RemoteStatusA {
RemoteStatusA {
house_code: <u8>::from_le_byte_slice(&bytes[0..1]),
receiver_code: <u8>::from_le_byte_slice(&bytes[1..2]),
switch_to: <u8>::from_le_byte_slice(&bytes[2..3]),
repeats: <u16>::from_le_byte_slice(&bytes[3..5]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct RemoteStatusB {
pub address: u32,
pub unit: u8,
pub switch_to: u8,
pub dim_value: u8,
pub repeats: u16,
}
impl FromByteSlice for RemoteStatusB {
fn bytes_expected() -> usize { 9 }
fn from_le_byte_slice(bytes: &[u8]) -> RemoteStatusB {
RemoteStatusB {
address: <u32>::from_le_byte_slice(&bytes[0..4]),
unit: <u8>::from_le_byte_slice(&bytes[4..5]),
switch_to: <u8>::from_le_byte_slice(&bytes[5..6]),
dim_value: <u8>::from_le_byte_slice(&bytes[6..7]),
repeats: <u16>::from_le_byte_slice(&bytes[7..9]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct RemoteStatusC {
pub system_code: char,
pub device_code: u8,
pub switch_to: u8,
pub repeats: u16,
}
impl FromByteSlice for RemoteStatusC {
fn bytes_expected() -> usize { 5 }
fn from_le_byte_slice(bytes: &[u8]) -> RemoteStatusC {
RemoteStatusC {
system_code: <char>::from_le_byte_slice(&bytes[0..1]),
device_code: <u8>::from_le_byte_slice(&bytes[1..2]),
switch_to: <u8>::from_le_byte_slice(&bytes[2..3]),
repeats: <u16>::from_le_byte_slice(&bytes[3..5]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct RemoteStatusAEvent {
pub house_code: u8,
pub receiver_code: u8,
pub switch_to: u8,
pub repeats: u16,
}
impl FromByteSlice for RemoteStatusAEvent {
fn bytes_expected() -> usize { 5 }
fn from_le_byte_slice(bytes: &[u8]) -> RemoteStatusAEvent {
RemoteStatusAEvent {
house_code: <u8>::from_le_byte_slice(&bytes[0..1]),
receiver_code: <u8>::from_le_byte_slice(&bytes[1..2]),
switch_to: <u8>::from_le_byte_slice(&bytes[2..3]),
repeats: <u16>::from_le_byte_slice(&bytes[3..5]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct RemoteStatusBEvent {
pub address: u32,
pub unit: u8,
pub switch_to: u8,
pub dim_value: u8,
pub repeats: u16,
}
impl FromByteSlice for RemoteStatusBEvent {
fn bytes_expected() -> usize { 9 }
fn from_le_byte_slice(bytes: &[u8]) -> RemoteStatusBEvent {
RemoteStatusBEvent {
address: <u32>::from_le_byte_slice(&bytes[0..4]),
unit: <u8>::from_le_byte_slice(&bytes[4..5]),
switch_to: <u8>::from_le_byte_slice(&bytes[5..6]),
dim_value: <u8>::from_le_byte_slice(&bytes[6..7]),
repeats: <u16>::from_le_byte_slice(&bytes[7..9]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct RemoteStatusCEvent {
pub system_code: char,
pub device_code: u8,
pub switch_to: u8,
pub repeats: u16,
}
impl FromByteSlice for RemoteStatusCEvent {
fn bytes_expected() -> usize { 5 }
fn from_le_byte_slice(bytes: &[u8]) -> RemoteStatusCEvent {
RemoteStatusCEvent {
system_code: <char>::from_le_byte_slice(&bytes[0..1]),
device_code: <u8>::from_le_byte_slice(&bytes[1..2]),
switch_to: <u8>::from_le_byte_slice(&bytes[2..3]),
repeats: <u16>::from_le_byte_slice(&bytes[3..5]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct SpitfpErrorCount {
pub error_count_ack_checksum: u32,
pub error_count_message_checksum: u32,
pub error_count_frame: u32,
pub error_count_overflow: u32,
}
impl FromByteSlice for SpitfpErrorCount {
fn bytes_expected() -> usize { 16 }
fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
SpitfpErrorCount {
error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
}
}
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct Identity {
pub uid: String,
pub connected_uid: String,
pub position: char,
pub hardware_version: [u8; 3],
pub firmware_version: [u8; 3],
pub device_identifier: u16,
}
impl FromByteSlice for Identity {
fn bytes_expected() -> usize { 25 }
fn from_le_byte_slice(bytes: &[u8]) -> Identity {
Identity {
uid: <String>::from_le_byte_slice(&bytes[0..8]),
connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
position: <char>::from_le_byte_slice(&bytes[16..17]),
hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
}
}
}
#[derive(Clone)]
pub struct RemoteSwitchV2Bricklet {
device: Device,
}
impl RemoteSwitchV2Bricklet {
pub const DEVICE_IDENTIFIER: u16 = 289;
pub const DEVICE_DISPLAY_NAME: &'static str = "Remote Switch Bricklet 2.0";
pub fn new<T: GetRequestSender>(uid: &str, req_sender: T) -> RemoteSwitchV2Bricklet {
let mut result = RemoteSwitchV2Bricklet { device: Device::new([2, 0, 0], uid, req_sender, 0) };
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::GetSwitchingState) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::SetRepeats) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::GetRepeats) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::SwitchSocketA) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::SwitchSocketB) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::DimSocketB) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::SwitchSocketC) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::SetRemoteConfiguration) as usize] =
ResponseExpectedFlag::False;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::GetRemoteConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::GetRemoteStatusA) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::GetRemoteStatusB) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::GetRemoteStatusC) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::GetSpitfpErrorCount) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::SetBootloaderMode) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::GetBootloaderMode) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::SetWriteFirmwarePointer) as usize] =
ResponseExpectedFlag::False;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::WriteFirmware) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::SetStatusLedConfig) as usize] =
ResponseExpectedFlag::False;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::GetStatusLedConfig) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::GetChipTemperature) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(RemoteSwitchV2BrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
result
}
pub fn get_response_expected(&mut self, fun: RemoteSwitchV2BrickletFunction) -> Result<bool, GetResponseExpectedError> {
self.device.get_response_expected(u8::from(fun))
}
pub fn set_response_expected(
&mut self,
fun: RemoteSwitchV2BrickletFunction,
response_expected: bool,
) -> Result<(), SetResponseExpectedError> {
self.device.set_response_expected(u8::from(fun), response_expected)
}
pub fn set_response_expected_all(&mut self, response_expected: bool) { self.device.set_response_expected_all(response_expected) }
pub fn get_api_version(&self) -> [u8; 3] { self.device.api_version }
pub fn get_switching_done_callback_receiver(&self) -> ConvertingCallbackReceiver<()> {
self.device.get_callback_receiver(u8::from(RemoteSwitchV2BrickletFunction::CallbackSwitchingDone))
}
pub fn get_remote_status_a_callback_receiver(&self) -> ConvertingCallbackReceiver<RemoteStatusAEvent> {
self.device.get_callback_receiver(u8::from(RemoteSwitchV2BrickletFunction::CallbackRemoteStatusA))
}
pub fn get_remote_status_b_callback_receiver(&self) -> ConvertingCallbackReceiver<RemoteStatusBEvent> {
self.device.get_callback_receiver(u8::from(RemoteSwitchV2BrickletFunction::CallbackRemoteStatusB))
}
pub fn get_remote_status_c_callback_receiver(&self) -> ConvertingCallbackReceiver<RemoteStatusCEvent> {
self.device.get_callback_receiver(u8::from(RemoteSwitchV2BrickletFunction::CallbackRemoteStatusC))
}
pub fn get_switching_state(&self) -> ConvertingReceiver<u8> {
let payload = vec![0; 0];
self.device.get(u8::from(RemoteSwitchV2BrickletFunction::GetSwitchingState), payload)
}
pub fn set_repeats(&self, repeats: u8) -> ConvertingReceiver<()> {
let mut payload = vec![0; 1];
payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(repeats));
self.device.set(u8::from(RemoteSwitchV2BrickletFunction::SetRepeats), payload)
}
pub fn get_repeats(&self) -> ConvertingReceiver<u8> {
let payload = vec![0; 0];
self.device.get(u8::from(RemoteSwitchV2BrickletFunction::GetRepeats), payload)
}
pub fn switch_socket_a(&self, house_code: u8, receiver_code: u8, switch_to: u8) -> ConvertingReceiver<()> {
let mut payload = vec![0; 3];
payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(house_code));
payload[1..2].copy_from_slice(&<u8>::to_le_byte_vec(receiver_code));
payload[2..3].copy_from_slice(&<u8>::to_le_byte_vec(switch_to));
self.device.set(u8::from(RemoteSwitchV2BrickletFunction::SwitchSocketA), payload)
}
pub fn switch_socket_b(&self, address: u32, unit: u8, switch_to: u8) -> ConvertingReceiver<()> {
let mut payload = vec![0; 6];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(address));
payload[4..5].copy_from_slice(&<u8>::to_le_byte_vec(unit));
payload[5..6].copy_from_slice(&<u8>::to_le_byte_vec(switch_to));
self.device.set(u8::from(RemoteSwitchV2BrickletFunction::SwitchSocketB), payload)
}
pub fn dim_socket_b(&self, address: u32, unit: u8, dim_value: u8) -> ConvertingReceiver<()> {
let mut payload = vec![0; 6];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(address));
payload[4..5].copy_from_slice(&<u8>::to_le_byte_vec(unit));
payload[5..6].copy_from_slice(&<u8>::to_le_byte_vec(dim_value));
self.device.set(u8::from(RemoteSwitchV2BrickletFunction::DimSocketB), payload)
}
pub fn switch_socket_c(&self, system_code: char, device_code: u8, switch_to: u8) -> ConvertingReceiver<()> {
let mut payload = vec![0; 3];
payload[0..1].copy_from_slice(&<char>::to_le_byte_vec(system_code));
payload[1..2].copy_from_slice(&<u8>::to_le_byte_vec(device_code));
payload[2..3].copy_from_slice(&<u8>::to_le_byte_vec(switch_to));
self.device.set(u8::from(RemoteSwitchV2BrickletFunction::SwitchSocketC), payload)
}
pub fn set_remote_configuration(&self, remote_type: u8, minimum_repeats: u16, callback_enabled: bool) -> ConvertingReceiver<()> {
let mut payload = vec![0; 4];
payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(remote_type));
payload[1..3].copy_from_slice(&<u16>::to_le_byte_vec(minimum_repeats));
payload[3..4].copy_from_slice(&<bool>::to_le_byte_vec(callback_enabled));
self.device.set(u8::from(RemoteSwitchV2BrickletFunction::SetRemoteConfiguration), payload)
}
pub fn get_remote_configuration(&self) -> ConvertingReceiver<RemoteConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(RemoteSwitchV2BrickletFunction::GetRemoteConfiguration), payload)
}
pub fn get_remote_status_a(&self) -> ConvertingReceiver<RemoteStatusA> {
let payload = vec![0; 0];
self.device.get(u8::from(RemoteSwitchV2BrickletFunction::GetRemoteStatusA), payload)
}
pub fn get_remote_status_b(&self) -> ConvertingReceiver<RemoteStatusB> {
let payload = vec![0; 0];
self.device.get(u8::from(RemoteSwitchV2BrickletFunction::GetRemoteStatusB), payload)
}
pub fn get_remote_status_c(&self) -> ConvertingReceiver<RemoteStatusC> {
let payload = vec![0; 0];
self.device.get(u8::from(RemoteSwitchV2BrickletFunction::GetRemoteStatusC), payload)
}
pub fn get_spitfp_error_count(&self) -> ConvertingReceiver<SpitfpErrorCount> {
let payload = vec![0; 0];
self.device.get(u8::from(RemoteSwitchV2BrickletFunction::GetSpitfpErrorCount), payload)
}
pub fn set_bootloader_mode(&self, mode: u8) -> ConvertingReceiver<u8> {
let mut payload = vec![0; 1];
payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(mode));
self.device.get(u8::from(RemoteSwitchV2BrickletFunction::SetBootloaderMode), payload)
}
pub fn get_bootloader_mode(&self) -> ConvertingReceiver<u8> {
let payload = vec![0; 0];
self.device.get(u8::from(RemoteSwitchV2BrickletFunction::GetBootloaderMode), payload)
}
pub fn set_write_firmware_pointer(&self, pointer: u32) -> ConvertingReceiver<()> {
let mut payload = vec![0; 4];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(pointer));
self.device.set(u8::from(RemoteSwitchV2BrickletFunction::SetWriteFirmwarePointer), payload)
}
pub fn write_firmware(&self, data: [u8; 64]) -> ConvertingReceiver<u8> {
let mut payload = vec![0; 64];
payload[0..64].copy_from_slice(&<[u8; 64]>::to_le_byte_vec(data));
self.device.get(u8::from(RemoteSwitchV2BrickletFunction::WriteFirmware), payload)
}
pub fn set_status_led_config(&self, config: u8) -> ConvertingReceiver<()> {
let mut payload = vec![0; 1];
payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(config));
self.device.set(u8::from(RemoteSwitchV2BrickletFunction::SetStatusLedConfig), payload)
}
pub fn get_status_led_config(&self) -> ConvertingReceiver<u8> {
let payload = vec![0; 0];
self.device.get(u8::from(RemoteSwitchV2BrickletFunction::GetStatusLedConfig), payload)
}
pub fn get_chip_temperature(&self) -> ConvertingReceiver<i16> {
let payload = vec![0; 0];
self.device.get(u8::from(RemoteSwitchV2BrickletFunction::GetChipTemperature), payload)
}
pub fn reset(&self) -> ConvertingReceiver<()> {
let payload = vec![0; 0];
self.device.set(u8::from(RemoteSwitchV2BrickletFunction::Reset), payload)
}
pub fn write_uid(&self, uid: u32) -> ConvertingReceiver<()> {
let mut payload = vec![0; 4];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(uid));
self.device.set(u8::from(RemoteSwitchV2BrickletFunction::WriteUid), payload)
}
pub fn read_uid(&self) -> ConvertingReceiver<u32> {
let payload = vec![0; 0];
self.device.get(u8::from(RemoteSwitchV2BrickletFunction::ReadUid), payload)
}
pub fn get_identity(&self) -> ConvertingReceiver<Identity> {
let payload = vec![0; 0];
self.device.get(u8::from(RemoteSwitchV2BrickletFunction::GetIdentity), payload)
}
}