Skip to main content

FirmwareManager

Struct FirmwareManager 

Source
pub struct FirmwareManager { /* private fields */ }
Expand description

The firmware management package running on a device, TS006-1.0.0.

It reports the versions the device was built with, the upgrade image it is holding, and keeps the one programmed reboot the specification allows. It owns no clock: the caller passes the time into FirmwareManager::heard when the device knows it, and a device that does not know the time refuses a reboot set for a moment in time, as section 3.3 asks.

Implementations§

Source§

impl FirmwareManager

Source

pub const fn new(firmware: u32, hardware: u32) -> FirmwareManager

Starts the package on a device.

§Arguments
  • firmware - the version the device is running, as its manufacturer numbers it.
  • hardware - the platform it runs on.
§Returns

The package, holding no image and no programmed reboot.

Source

pub const fn with_image(self, image: Image) -> FirmwareManager

Returns it holding a firmware upgrade image.

§Arguments
  • image - the image the device is holding.
§Returns

The package, for chaining.

Source

pub const fn image(&self) -> Option<Image>

The image the device is holding, if it holds one.

§Returns

The image.

Source

pub const fn set_image(&mut self, image: Option<Image>)

Puts an image in the device’s store, replacing whatever was there.

§Arguments
  • image - the image, or None once one has been installed or deleted.
Source

pub const fn reboot_at_s(&self) -> Option<u32>

The moment the device is to reboot, where one was programmed as a time.

§Returns

Seconds since the GPS epoch, and None when the reboot is a countdown, immediate, or not programmed at all.

Source

pub const fn reboot_in_s(&self) -> Option<u32>

How long until the device is to reboot, where one was programmed as a countdown.

§Returns

The seconds left, and None when the reboot is a moment in time, immediate, or not programmed at all.

Source

pub const fn reboot_now(&self) -> bool

Whether the device was told to reboot at once.

§Returns

true when it should reboot as soon as it can, in which case it sends no answer.

Source

pub const fn rebooted(&mut self)

Forgets the programmed reboot, for a device that has carried it out.

Source

pub fn heard_at( &mut self, payload: &[u8], now_s: Option<u32>, out: &mut [u8], ) -> Result<usize, LorawanError>

Reads a downlink on the firmware port and writes the answers it calls for.

Commands run in the order they arrive, and each writes its answer after the one before it, as section 3 asks. A reboot the device was told to do at once is recorded on FirmwareManager::reboot_now and answered with nothing, because the device will be gone.

§Arguments
  • payload - what arrived on port PORT.
  • now_s - what the device believes the time is, in seconds since the GPS epoch, or None when it does not know.
  • out - where to write the answers.
§Returns

How many bytes of answer were written.

§Errors

The first error a command raised, or LorawanError::PayloadTooLong when the answers do not fit.

Source

pub fn heard( &mut self, payload: &[u8], out: &mut [u8], ) -> Result<usize, LorawanError>

Reads a downlink on the firmware port from a device that does not know the time.

§Arguments
  • payload - what arrived on port PORT.
  • out - where to write the answers.
§Returns

How many bytes of answer were written.

§Errors

As FirmwareManager::heard_at.

Trait Implementations§

Source§

impl Clone for FirmwareManager

Source§

fn clone(&self) -> FirmwareManager

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for FirmwareManager

Source§

impl Debug for FirmwareManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.