http post - not working because sim800l supports tlsv1.0 only

This commit is contained in:
Vladan Popovic 2022-07-03 02:27:36 +02:00
parent edf427dcb1
commit a215c628a7
3 changed files with 179 additions and 107 deletions

View file

@ -71,14 +71,6 @@ impl Command {
}
}
pub fn gprs_open() -> Command {
Command {
text: "AT+SAPBR=1,1".to_string(),
timeout: Duration::from_millis(3000),
contains: Some("OK".to_string()),
}
}
pub fn gprs_set_apn(apn: &str) -> Command {
Command {
text: format!("AT+SAPBR=3,1,\"APN\",\"{}\"", apn),
@ -103,7 +95,7 @@ impl Command {
}
}
pub fn getbear() -> Command {
pub fn gprs_bearer_status() -> Command {
Command {
text: "AT+SAPBR=2,1".to_string(),
timeout: Duration::from_millis(3000),
@ -111,6 +103,22 @@ impl Command {
}
}
pub fn gprs_bearer_open() -> Command {
Command {
text: "AT+SAPBR=1,1".to_string(),
timeout: Duration::from_millis(3000),
contains: Some("OK".to_string()),
}
}
pub fn gprs_bearer_close() -> Command {
Command {
text: "AT+SAPBR=0,1".to_string(),
timeout: Duration::from_millis(3000),
contains: Some("OK".to_string()),
}
}
pub fn get_local_ip_addr() -> Command {
Command {
text: "AT+CIFSR".to_string(),
@ -135,7 +143,7 @@ impl Command {
}
}
pub fn http_set() -> Command {
pub fn http_set_cid() -> Command {
Command {
text: "AT+HTTPPARA=\"CID\",1".to_string(),
timeout: Duration::from_millis(3000),
@ -159,9 +167,25 @@ impl Command {
}
}
pub fn http_init_url() -> Command {
pub fn http_init_url(url: &str) -> Command {
Command {
text: "AT+HTTPPARA=\"URL\",\"{}\"".to_string(),
text: format!("AT+HTTPPARA=\"URL\",\"{}\"", url),
timeout: Duration::from_millis(3000),
contains: Some("OK".to_string()),
}
}
pub fn http_set_ssl(enabled: bool) -> Command {
Command {
text: format!("AT+HTTPSSL={}", enabled as u8),
timeout: Duration::from_millis(1000),
contains: Some("OK".to_string()),
}
}
pub fn http_set_header(header: &str, value: &str) -> Command {
Command {
text: format!("AT+HTTPPARA=\"USERDATA\",\"{}: {}\"", header, value),
timeout: Duration::from_millis(3000),
contains: Some("OK".to_string()),
}
@ -175,31 +199,31 @@ impl Command {
}
}
pub fn http_set_content() -> Command {
pub fn http_set_content(content: &str) -> Command {
Command {
text: "AT+HTTPPARA=\"CONTENT\",\"{}\"".to_string(),
text: format!("AT+HTTPPARA=\"CONTENT\",\"{}\"", content),
timeout: Duration::from_millis(3000),
contains: Some("OK".to_string()),
}
}
pub fn http_post_len() -> Command {
pub fn http_post_len(size: usize, time: usize) -> Command {
Command {
text: "AT+HTTPDATA={}5000".to_string(),
timeout: Duration::from_millis(3000),
contains: Some("DOWNLOAD".to_string()),
text: format!("AT+HTTPDATA={},{}", size, time),
timeout: Duration::from_millis(5000),
contains: Some("OK".to_string()),
}
}
pub fn http_post() -> Command {
Command {
text: "AT+HTTPACTION=1".to_string(),
timeout: Duration::from_millis(3000),
contains: Some("+HTTPACTION".to_string()),
timeout: Duration::from_millis(10000),
contains: Some("HTTPACTION".to_string()),
}
}
pub fn http_get_data() -> Command {
pub fn http_response() -> Command {
Command {
text: "AT+HTTPREAD".to_string(),
timeout: Duration::from_millis(3000),
@ -207,7 +231,7 @@ impl Command {
}
}
pub fn closehttp() -> Command {
pub fn http_close() -> Command {
Command {
text: "AT+HTTPTERM".to_string(),
timeout: Duration::from_millis(3000),
@ -215,19 +239,11 @@ impl Command {
}
}
pub fn closebear() -> Command {
Command {
text: "AT+SAPBR=0,1".to_string(),
timeout: Duration::from_millis(3000),
contains: Some("OK".to_string()),
}
}
pub fn probe() -> Command {
Command {
text: "AT".to_string(),
timeout: Duration::from_millis(3000),
contains: Some("+CIEV".to_string()),
contains: Some("OK".to_string()),
}
}
@ -247,14 +263,6 @@ impl Command {
}
}
pub fn tcp_ssl_enable() -> Command {
Command {
text: "AT+CIPSSL=1".to_string(),
timeout: Duration::from_millis(3000),
contains: Some("OK".to_string()),
}
}
pub fn tcp_ssl_check() -> Command {
Command {
text: "AT+CIPSSL=?".to_string(),
@ -342,4 +350,44 @@ impl Command {
contains: Some("CLOSE OK".to_string()),
}
}
pub fn manufacturer_id() -> Command {
Command {
text: "AT+GMI".to_string(),
timeout: Duration::from_millis(3000),
contains: Some("OK".to_string()),
}
}
pub fn model_id() -> Command {
Command {
text: "AT+GMM".to_string(),
timeout: Duration::from_millis(3000),
contains: Some("OK".to_string()),
}
}
pub fn release_id() -> Command {
Command {
text: "AT+GMR".to_string(),
timeout: Duration::from_millis(3000),
contains: Some("OK".to_string()),
}
}
pub fn get_location() -> Command {
Command {
text: "AT+CLBS=1,1".to_string(),
timeout: Duration::from_millis(10000),
contains: Some("OK".to_string()),
}
}
pub fn ssl_opt() -> Command {
Command {
text: "AT+SSLOPT=1,1".to_string(),
timeout: Duration::from_millis(3000),
contains: Some("OK".to_string()),
}
}
}