pub trait RobotNetworkBehavior {
type Error: Debug;
type Socket<'a>: Read + Write
where Self: 'a;
Show 14 methods
// Required methods
async fn mac_address(&mut self) -> [u8; 6];
async fn wifi_is_connected(&self) -> Option<[u8; 4]>;
async fn list_networks<const C: usize>(&mut self) -> Vec<NetworkScanInfo, C>;
async fn connect_wifi(
&mut self,
network: &str,
password: Option<&str>,
) -> Result<(), Self::Error>;
async fn disconnect_wifi(&mut self);
async fn tcp_accept<'a>(
&mut self,
port: u16,
tx_buffer: &'a mut [u8; 5192],
rx_buffer: &'a mut [u8; 5192],
) -> Result<Self::Socket<'a>, Self::Error>
where Self: 'a;
async fn tcp_close<'a>(&mut self, socket: &mut Self::Socket<'a>);
async fn prepare_firmware_update(&mut self);
async fn write_firmware(
&mut self,
offset: usize,
data: &[u8],
) -> Result<(), Self::Error>;
async fn hash_firmware(&mut self, update_len: u32, output: &mut [u8; 32]);
async fn mark_firmware_updated(&mut self);
async fn firmware_swapped(&mut self) -> bool;
async fn reboot(&mut self);
async fn mark_firmware_booted(&mut self);
}
Expand description
Functionality that robots with networking must support
Required Associated Types§
Required Methods§
Sourceasync fn mac_address(&mut self) -> [u8; 6]
async fn mac_address(&mut self) -> [u8; 6]
Get the device’s mac address
Sourceasync fn wifi_is_connected(&self) -> Option<[u8; 4]>
async fn wifi_is_connected(&self) -> Option<[u8; 4]>
If the device is currently connected to a wifi network, its IP, else None
Sourceasync fn list_networks<const C: usize>(&mut self) -> Vec<NetworkScanInfo, C>
async fn list_networks<const C: usize>(&mut self) -> Vec<NetworkScanInfo, C>
List information for up to C
networks
Sourceasync fn connect_wifi(
&mut self,
network: &str,
password: Option<&str>,
) -> Result<(), Self::Error>
async fn connect_wifi( &mut self, network: &str, password: Option<&str>, ) -> Result<(), Self::Error>
Connect to a network with the given username/password. This method shouldn’t return until the connection either completes or fails, but it shouldn’t do any retries.
This will only be called if RobotNetworkBehavior::wifi_is_connected
is false
Sourceasync fn disconnect_wifi(&mut self)
async fn disconnect_wifi(&mut self)
Disconnect from any active wifi network
Sourceasync fn tcp_accept<'a>(
&mut self,
port: u16,
tx_buffer: &'a mut [u8; 5192],
rx_buffer: &'a mut [u8; 5192],
) -> Result<Self::Socket<'a>, Self::Error>where
Self: 'a,
async fn tcp_accept<'a>(
&mut self,
port: u16,
tx_buffer: &'a mut [u8; 5192],
rx_buffer: &'a mut [u8; 5192],
) -> Result<Self::Socket<'a>, Self::Error>where
Self: 'a,
Accept a socket that meets the requirements. Close the previous one if one exists
async fn prepare_firmware_update(&mut self)
Sourceasync fn write_firmware(
&mut self,
offset: usize,
data: &[u8],
) -> Result<(), Self::Error>
async fn write_firmware( &mut self, offset: usize, data: &[u8], ) -> Result<(), Self::Error>
See https://docs.embassy.dev/embassy-boot/git/default/struct.FirmwareUpdater.html#method.write_firmware
Sourceasync fn hash_firmware(&mut self, update_len: u32, output: &mut [u8; 32])
async fn hash_firmware(&mut self, update_len: u32, output: &mut [u8; 32])
See https://docs.embassy.dev/embassy-boot/git/default/struct.FirmwareUpdater.html#method.hash
Sourceasync fn mark_firmware_updated(&mut self)
async fn mark_firmware_updated(&mut self)
See https://docs.embassy.dev/embassy-boot/git/default/struct.FirmwareUpdater.html#method.mark_updated
Sourceasync fn firmware_swapped(&mut self) -> bool
async fn firmware_swapped(&mut self) -> bool
See https://docs.embassy.dev/embassy-boot/git/default/struct.FirmwareUpdater.html#method.get_state
Sourceasync fn mark_firmware_booted(&mut self)
async fn mark_firmware_booted(&mut self)
See https://docs.embassy.dev/embassy-boot/git/default/struct.FirmwareUpdater.html#method.mark_booted
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.