Skip to content

Commit

Permalink
add mqtt status query
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrMuellerluedenscheid committed Jan 8, 2025
1 parent fe1ebde commit e252d8c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/at_command/mqtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,33 @@ impl AtRequest for MQTTSessionSettings<'_> {
}
}

pub struct GetMQTTSession {}

impl AtRequest for GetMQTTSession {
type Response = ();

fn get_command<'a>(&'a self, buffer: &'a mut BufferType) -> Result<&'a [u8], usize> {
CommandBuilder::create_query(buffer, true)
.named("+CMQNEW")
.finish()
}

fn parse_response(&self, data: &[u8]) -> Result<AtResponse, AtError> {
let (mqtt_id, used_state, server) = at_commands::parser::CommandParser::parse(data)
.expect_identifier(b"\r\n+CMQNEW: ")
.expect_int_parameter()
.expect_int_parameter()
.expect_raw_string()
.expect_identifier(b"\r\n\r\nOK")
.finish()?;
info!(
" mqtt_id: {} used_state {}, server{}",
mqtt_id, used_state, server
);
Ok(AtResponse::MQTTSessionCreated(mqtt_id as u8))
}
}

#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct CloseMQTTConnection {
pub mqtt_id: u8,
Expand Down

0 comments on commit e252d8c

Please sign in to comment.