22//!
33//! Add your own ssid and password
44
5- use std:: thread:: ScopedJoinHandle ;
5+ use std:: { thread:: ScopedJoinHandle , time :: Duration } ;
66
77use embedded_svc:: {
88 http:: { client:: Client as HttpClient , Method } ,
@@ -14,8 +14,8 @@ use esp_idf_hal::gpio;
1414use esp_idf_hal:: uart:: UartDriver ;
1515use esp_idf_hal:: units:: Hertz ;
1616use esp_idf_svc:: log:: EspLogger ;
17- use esp_idf_svc:: modem:: modem :: sim7600:: SIM7600 ;
18- use esp_idf_svc:: modem:: modem :: SimModem ;
17+ use esp_idf_svc:: modem:: sim :: sim7600:: SIM7600 ;
18+ use esp_idf_svc:: modem:: sim :: SimModem ;
1919use esp_idf_svc:: modem:: EspModem ;
2020use esp_idf_svc:: { eventloop:: EspSystemEventLoop , nvs:: EspDefaultNvsPartition } ;
2121use esp_idf_svc:: { hal:: prelude:: Peripherals , http:: client:: EspHttpConnection } ;
@@ -63,14 +63,21 @@ fn main() -> anyhow::Result<()> {
6363 } ;
6464 Ok ( ( ) )
6565 } ) ;
66+ std:: thread:: sleep ( Duration :: from_secs ( 10 ) ) ;
6667
68+ // while !modem.netif().is_up()? {}
6769 // while !(modem.is_connected()?) {}
6870
6971 let mut client = HttpClient :: wrap ( EspHttpConnection :: new ( & Default :: default ( ) ) ?) ;
7072
7173 // GET
72- get_request ( & mut client) ?;
73-
74+ loop {
75+ std:: thread:: sleep ( Duration :: from_secs ( 10 ) ) ;
76+ match get_request ( & mut client) {
77+ Err ( x) => log:: error!( "Failed, reason = {}" , x) ,
78+ Ok ( _) => break ,
79+ }
80+ }
7481 my_thread. join ( ) . unwrap ( ) ?;
7582 Ok ( ( ) )
7683 } ) ;
0 commit comments