mqtt works ... connect + publish
This commit is contained in:
parent
a215c628a7
commit
d023f5db76
3 changed files with 202 additions and 87 deletions
|
@ -151,23 +151,7 @@ impl Command {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn http_enable_ssl() -> Command {
|
||||
Command {
|
||||
text: "AT+HTTPSSL=1".to_string(),
|
||||
timeout: Duration::from_millis(3000),
|
||||
contains: Some("OK".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn http_disable_ssl() -> Command {
|
||||
Command {
|
||||
text: "AT+HTTPSSL=0".to_string(),
|
||||
timeout: Duration::from_millis(3000),
|
||||
contains: Some("OK".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn http_init_url(url: &str) -> Command {
|
||||
pub fn http_set_url(url: &str) -> Command {
|
||||
Command {
|
||||
text: format!("AT+HTTPPARA=\"URL\",\"{}\"", url),
|
||||
timeout: Duration::from_millis(3000),
|
||||
|
@ -199,6 +183,14 @@ impl Command {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn http_post() -> Command {
|
||||
Command {
|
||||
text: "AT+HTTPACTION=1".to_string(),
|
||||
timeout: Duration::from_millis(10000),
|
||||
contains: Some("HTTPACTION".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn http_set_content(content: &str) -> Command {
|
||||
Command {
|
||||
text: format!("AT+HTTPPARA=\"CONTENT\",\"{}\"", content),
|
||||
|
@ -207,6 +199,14 @@ impl Command {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn http_set_redirect(redirect: bool) -> Command {
|
||||
Command {
|
||||
text: format!("AT+HTTPPARA=\"REDIR\",\"{}\"", redirect as u8),
|
||||
timeout: Duration::from_millis(3000),
|
||||
contains: Some("OK".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn http_post_len(size: usize, time: usize) -> Command {
|
||||
Command {
|
||||
text: format!("AT+HTTPDATA={},{}", size, time),
|
||||
|
@ -215,15 +215,7 @@ impl Command {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn http_post() -> Command {
|
||||
Command {
|
||||
text: "AT+HTTPACTION=1".to_string(),
|
||||
timeout: Duration::from_millis(10000),
|
||||
contains: Some("HTTPACTION".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn http_response() -> Command {
|
||||
pub fn http_read_response() -> Command {
|
||||
Command {
|
||||
text: "AT+HTTPREAD".to_string(),
|
||||
timeout: Duration::from_millis(3000),
|
||||
|
@ -243,7 +235,7 @@ impl Command {
|
|||
Command {
|
||||
text: "AT".to_string(),
|
||||
timeout: Duration::from_millis(3000),
|
||||
contains: Some("OK".to_string()),
|
||||
contains: Some("+CIEV".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -335,9 +327,9 @@ impl Command {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn tcp_set_manual_receive() -> Command {
|
||||
pub fn tcp_set_manual_receive(is_manual: bool) -> Command {
|
||||
Command {
|
||||
text: "AT+CIPRXGET=1".to_string(),
|
||||
text: format!("AT+CIPRXGET={}", is_manual as u8),
|
||||
timeout: Duration::from_millis(3000),
|
||||
contains: Some("OK".to_string()),
|
||||
}
|
||||
|
@ -390,4 +382,52 @@ impl Command {
|
|||
contains: Some("OK".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ssl_set_client_cert(path: &str, password: &str) -> Command {
|
||||
Command {
|
||||
text: format!("AT+SSLSETCERT={},{}", path, password),
|
||||
timeout: Duration::from_millis(2000),
|
||||
contains: Some("SSLSETCERT".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ssl_set_root_cert(path: &str, size: usize) -> Command {
|
||||
Command {
|
||||
text: format!("AT+SSLSETROOT={},{}", path, size),
|
||||
timeout: Duration::from_millis(2000),
|
||||
contains: Some("SSLSETCERT".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fs_file_create(path: &str) -> Command {
|
||||
Command {
|
||||
text: format!("AT+FSCREATE={}", path),
|
||||
timeout: Duration::from_millis(2000),
|
||||
contains: Some("OK".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fs_file_write(path: &str, append: bool, size: usize, input_time_sec: usize) -> Command {
|
||||
Command {
|
||||
text: format!("AT+FSWRITE={},{},{},{}", path, append as u8, size, input_time_sec),
|
||||
timeout: Duration::from_millis(20000),
|
||||
contains: Some("OK".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fs_list(path: &str) -> Command {
|
||||
Command {
|
||||
text: format!("AT+FSLS={}", path),
|
||||
timeout: Duration::from_millis(2000),
|
||||
contains: Some("OK".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fs_free_size() -> Command {
|
||||
Command {
|
||||
text: "AT+FSMEM".to_string(),
|
||||
timeout: Duration::from_millis(2000),
|
||||
contains: Some("OK".to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue