pub fn new(
        stack: Stack,
        client_id: &str,
        device_prefix: &str,
        broker: IpAddr,
        clock: Clock,
    ) -> Result<Self, Error<Stack::Error>> {
        let mut mqtt = minimq::Minimq::new(broker, client_id, stack, clock)?;

        // Note(unwrap): The client was just created, so it's valid to set a keepalive interval
        // now, since we're not yet connected to the broker.
        mqtt.client
            .set_keepalive_interval(KEEPALIVE_INTERVAL_SECONDS)
            .unwrap();

        // Note(unwrap): The user must provide a prefix of the correct size.
        let mut prefix: String<MAX_TOPIC_LENGTH> = String::new();
        write!(&mut prefix, "{}/command", device_prefix).map_err(|_| Error::PrefixTooLong)?;

        let context = MinireqContext {
            handlers: heapless::LinearMap::default(),
            mqtt,
            prefix,
        };

        Ok(Self {
            machine: sm::StateMachine::new(context),
        })
    }
/// Construct a new MQTT request handler.
///
/// # Args
/// * `stack` - The network stack to use for communication.
/// * `client_id` - The ID of the MQTT client. May be an empty string for auto-assigning.
/// * `device_prefix` - The MQTT device prefix to use for this device.
/// * `broker` - The IP address of the MQTT broker to use.
/// * `clock` - The clock for managing the MQTT connection.
Construct a new MQTT request handler.
Construct a new MQTT request handler .
pub fn new(
        stack: Stack,
        client_id: &str,
        device_prefix: &str,
        broker: IpAddr,
        clock: Clock,
    ) -> Result<Self, Error<Stack::Error>> {
        let mut mqtt = minimq::Minimq::new(broker, client_id, stack, clock)?;
        // Note(unwrap): The client was just created, so it's valid to set a keepalive interval
        // now, since we're not yet connected to the broker.
        mqtt.client
            .set_keepalive_interval(KEEPALIVE_INTERVAL_SECONDS)
            .unwrap();
        // Note(unwrap): The user must provide a prefix of the correct size.
        let mut prefix: String<MAX_TOPIC_LENGTH> = String::new();
        write!(&mut prefix, "{}/command", device_prefix).map_err(|_| Error::PrefixTooLong)?;
        let context = MinireqContext {
            handlers: heapless::LinearMap::default(),
            mqtt,
            prefix,
        };
        Ok(Self {
            machine: sm::StateMachine::new(context),
        })
    }
pub fn new ( stack : Stack , client_id : & str , device_prefix : & str , broker : IpAddr , clock : Clock , ) -> Result < Self , Error < Stack :: Error > > { let mut mqtt = minimq :: Minimq :: new ( broker , client_id , stack , clock ) ? ; // Note(unwrap): The client was just created, so it's valid to set a keepalive interval // now, since we're not yet connected to the broker. mqtt . client . set_keepalive_interval ( KEEPALIVE_INTERVAL_SECONDS ) . unwrap ( ) ; // Note(unwrap): The user must provide a prefix of the correct size. let mut prefix : String < MAX_TOPIC_LENGTH > = String :: new ( ) ; write ! ( mut prefix " " device_prefix ) . map_err ( | _ | Error :: PrefixTooLong ) ? ; let context = MinireqContext { handlers : heapless :: LinearMap :: default ( ) , mqtt , prefix , } ; Ok ( Self { machine : sm :: StateMachine :: new ( context ) , } ) }
Construct a new MQTT request handler.
Construct a new MQTT request handler .
stack
Stack
client_id
&str
device_prefix
&str
broker
IpAddr
clock
Clock
stack
Stack
client_id
&str
device_prefix
&str
broker
IpAddr
clock
Clock
args
`stack` - The network stack to use for communication.
`client_id` - The ID of the MQTT client. May be an empty string for auto-assigning.
`device_prefix` - The MQTT device prefix to use for this device.
`broker` - The IP address of the MQTT broker to use.
`clock` - The clock for managing the MQTT connection.
` stack ` - The network stack to use for communication . ` client_id ` - The ID of the MQTT client . May be an empty string for auto - assigning . ` device_prefix ` - The MQTT device prefix to use for this device . ` broker ` - The IP address of the MQTT broker to use . ` clock ` - The clock for managing the MQTT connection .