'''
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/request.py

'''
import requests
import logging
import http.client as http_client

# Enable HTTP and HTTPS verbose logging
http_client.HTTPConnection.debuglevel = 1

logging.basicConfig(level=logging.DEBUG)
logging.getLogger("http.client").setLevel(logging.DEBUG)
logging.getLogger("urllib3").setLevel(logging.DEBUG)
logging.getLogger("requests").setLevel(logging.DEBUG)

# Suppress logging from unrelated libraries
logging.getLogger("chardet").setLevel(logging.INFO)
logging.getLogger("urllib3.connectionpool").setLevel(logging.INFO)

url_microSpot = "https://api-prod.uspot.probesys.net/nebuleair?token=2AFF6dQk68daFZ"
url_aircarto = "https://aircarto.fr/tests/test.php"

payload = {
    "nebuleairid": "C04F8B8D3A08",
    "software_version": "ModuleAir-V1-012023",
    "sensordatavalues": [
        {"value_type": "NPM_P0", "value": "2.3"},
        {"value_type": "NPM_P0", "value": "3.30"},
        {"value_type": "NPM_P1", "value": "9.05"},
        {"value_type": "NPM_P2", "value": "20.60"},
        {"value_type": "NPM_N1", "value": "49.00"},
        {"value_type": "NPM_N10", "value": "49.00"},
        {"value_type": "NPM_N25", "value": "49.00"}
    ]
}
cert_path = "/var/www/nebuleair_pro_4g/SARA/SSL/isrgrootx1.pem"


try:
    response = requests.post(url_aircarto, json=payload, verify=cert_path)
    print("Response Status Code:", response.status_code)
    print("Response Text:", response.text)
except requests.exceptions.RequestException as e:
    print("An error occurred:", e)
