This commit is contained in:
Your Name
2025-02-20 15:30:34 +01:00
parent d5f1acc025
commit 725ee971c7
38 changed files with 405 additions and 84 deletions

View File

@@ -15,15 +15,15 @@ Main loop to gather data from sensor inside SQLite database:
and send it to AirCarto servers via SARA R4 HTTP post requests
also send the timestamp (already stored inside the DB) !
/usr/bin/python3 /var/www/nebuleair_pro_4g/loop/SARA_send_data_v2.py
/usr/bin/python3 /var/www/moduleair_pro_4g/loop/SARA_send_data_v2.py
ATTENTION:
# This script is triggered every minutes by /var/www/nebuleair_pro_4g/master.py (as a service)
# This script is triggered every minutes by /var/www/moduleair_pro_4g/master.py (as a service)
CSV PAYLOAD (AirCarto Servers)
Endpoint:
data.nebuleair.fr
data.moduleair.fr
/pro_4G/data.php?sensor_id={device_id}&timestamp={rtc_module_time}
ATTENTION : do not change order !
@@ -51,13 +51,13 @@ CSV PAYLOAD (AirCarto Servers)
19 -> NPM hum inside
JSON PAYLOAD (Micro-Spot Servers)
Same as NebuleAir wifi
Same as moduleair wifi
Endpoint:
api-prod.uspot.probesys.net
nebuleair?token=2AFF6dQk68daFZ
moduleair?token=2AFF6dQk68daFZ
port 443
{"nebuleairid": "82D25549434",
{"moduleairid": "82D25549434",
"software_version": "ModuleAirV2-V1-042022",
"sensordatavalues":
[
@@ -113,11 +113,11 @@ if uptime_seconds < 120:
print(f"System just booted ({uptime_seconds:.2f} seconds uptime), skipping execution.")
sys.exit()
#Payload CSV to be sent to data.nebuleair.fr
#Payload CSV to be sent to data.moduleair.fr
payload_csv = [None] * 25
#Payload JSON to be sent to uSpot
payload_json = {
"nebuleairid": "XXX",
"moduleairid": "XXX",
"software_version": "ModuleAirV2-V1-042022",
"sensordatavalues": [] # Empty list to start with
}
@@ -127,7 +127,7 @@ aircarto_profile_id = 0
uSpot_profile_id = 1
# database connection
conn = sqlite3.connect("/var/www/nebuleair_pro_4g/sqlite/sensors.db")
conn = sqlite3.connect("/var/www/moduleair_pro_4g/sqlite/sensors.db")
cursor = conn.cursor()
def blink_led(pin, blink_count, delay=1):
@@ -196,7 +196,7 @@ def update_json_key(file_path, key, value):
print(f"Error updating the JSON file: {e}")
# Define the config file path
config_file = '/var/www/nebuleair_pro_4g/config.json'
config_file = '/var/www/moduleair_pro_4g/config.json'
# Load the configuration data
config = load_config(config_file)
@@ -204,7 +204,7 @@ baudrate = config.get('SaraR4_baudrate', 115200) #baudrate du sara R4
device_id = config.get('deviceID', '').upper() #device ID en maj
bme_280_config = config.get('BME280/get_data_v2.py', False) #présence du BME280
envea_cairsens= config.get('envea/read_value_v2.py', False)
send_aircarto = config.get('send_aircarto', True) #envoi sur AirCarto (data.nebuleair.fr)
send_aircarto = config.get('send_aircarto', True) #envoi sur AirCarto (data.moduleair.fr)
send_uSpot = config.get('send_uSpot', False) #envoi sur MicroSpot ()
selected_networkID = config.get('SARA_R4_neworkID', '')
npm_5channel = config.get('NextPM_5channels', False) #5 canaux du NPM
@@ -212,7 +212,7 @@ npm_5channel = config.get('NextPM_5channels', False) #5 canaux du NPM
modem_config_mode = config.get('modem_config_mode', False) #modem 4G en mode configuration
#update device id in the payload json
payload_json["nebuleairid"] = device_id
payload_json["moduleairid"] = device_id
# Skip execution if modem_config_mode is true
if modem_config_mode:
@@ -555,7 +555,7 @@ try:
#Pas forcément un moyen de résoudre le soucis
#print("resetting the URL (domain name):")
#command = f'AT+UHTTP={aircarto_profile_id},1,"{url_nebuleair}"\r'
#command = f'AT+UHTTP={aircarto_profile_id},1,"{url_moduleair}"\r'
#ser_sara.write(command.encode('utf-8'))
#response_SARA_31 = read_complete_response(ser_sara)
#print(response_SARA_31)
@@ -610,7 +610,7 @@ try:
# Handle "Operation not allowed" error
if error_message == "Operation not allowed":
print('<span style="color: orange;font-weight: bold;">❓Try Resetting the HTTP Profile❓</span>')
command = f'AT+UHTTP={aircarto_profile_id},1,"data.nebuleair.fr"\r'
command = f'AT+UHTTP={aircarto_profile_id},1,"data.moduleair.fr"\r'
ser_sara.write(command.encode('utf-8'))
responseResetHTTP_profile = read_complete_response(ser_sara, timeout=5, end_of_response_timeout=5, wait_for_lines=["OK", "+CME ERROR"], debug=True)
print('<p class="text-danger-emphasis">')