use esp_idf_hal::prelude::*;
use esp_idf_svc::nvs;
use esp_idf_svc::wifi;
use std::time::Duration;

#[no_mangle]
fn app_main() {
    // Initialize NVS flash
    nvs::init().unwrap();

    // Connect to WiFi
    let wifi = wifi::init_default();
    wifi.connect("Wokwi-GUEST", "").unwrap();

    // Create a reqwest client
    let client = reqwest::blocking::ClientBuilder::new()
        .timeout(Duration::from_secs(10))
        .build()
        .unwrap();

    // Make a GET request
    let response = client.get("http://example.org").send().unwrap();

    // Print the status and body
    println!("Status: {}", response.status());
    println!("Body: {}", response.text().unwrap());
}