Refactored some logs
This commit is contained in:
@@ -351,7 +351,6 @@ async def process_messages_task():
|
|||||||
print(f"[LoRa] Microwave {mw_id} state changed to: {n_state}")
|
print(f"[LoRa] Microwave {mw_id} state changed to: {n_state}")
|
||||||
|
|
||||||
if n_state in (CookingStates.DONE, CookingStates.STIRRING_REQUIRED, CookingStates.ALERT):
|
if n_state in (CookingStates.DONE, CookingStates.STIRRING_REQUIRED, CookingStates.ALERT):
|
||||||
print("buzzer alert triggered!")
|
|
||||||
beats = 5 if n_state == CookingStates.ALERT else (1 if n_state == CookingStates.STIRRING_REQUIRED else 3)
|
beats = 5 if n_state == CookingStates.ALERT else (1 if n_state == CookingStates.STIRRING_REQUIRED else 3)
|
||||||
buzzer.buzzer_siren(beatsNb=beats)
|
buzzer.buzzer_siren(beatsNb=beats)
|
||||||
if n_state == CookingStates.IDLE and microwave_states.get(mw_id) == MicrowaveState.COOKING:
|
if n_state == CookingStates.IDLE and microwave_states.get(mw_id) == MicrowaveState.COOKING:
|
||||||
@@ -430,15 +429,14 @@ async def handle_telemetry_request(endpoint: str):
|
|||||||
connected_components=get_connected_components(),
|
connected_components=get_connected_components(),
|
||||||
logs=logs_list
|
logs=logs_list
|
||||||
)
|
)
|
||||||
|
|
||||||
print(f"[Telemetry] Sending payload with {len(logs_list)} log entries...")
|
|
||||||
|
|
||||||
# 4. Wait for he microwave turn to send the telemetry data to the cloud endpoint
|
# 4. Wait for he microwave turn to send the telemetry data to the cloud endpoint
|
||||||
timeout = int(DEVICE_ID.split("_")[-1]) * config.TELEMETRY_SEND_INTERVAL
|
timeout = int(DEVICE_ID.split("_")[-1]) * config.TELEMETRY_SEND_INTERVAL
|
||||||
print(f"[Telemetry] Waiting for {timeout}s before sending telemetry to avoid collisions...")
|
print(f"[Telemetry] Waiting for {timeout}s before sending telemetry to avoid collisions...")
|
||||||
await asyncio.sleep(timeout)
|
await asyncio.sleep(timeout)
|
||||||
|
|
||||||
# 5. Offload blocking HTTP POST to thread pool
|
# 5. Offload blocking HTTP POST to thread pool
|
||||||
|
print(f"[Telemetry] Sending payload with {len(logs_list)} log entries...")
|
||||||
response = await asyncio.to_thread(
|
response = await asyncio.to_thread(
|
||||||
requests.post,
|
requests.post,
|
||||||
endpoint,
|
endpoint,
|
||||||
@@ -521,7 +519,7 @@ async def monitor_dish_height_task():
|
|||||||
# --- BOOTSTRAP ---
|
# --- BOOTSTRAP ---
|
||||||
async def main():
|
async def main():
|
||||||
global async_event_queue
|
global async_event_queue
|
||||||
print("🚀 Orchestrateur Asyncio prêt. Lancement des tâches...")
|
print("Orchestrateur prêt. Lancement des tâches...")
|
||||||
|
|
||||||
# Initialize SQLite database table
|
# Initialize SQLite database table
|
||||||
init_db()
|
init_db()
|
||||||
|
|||||||
Reference in New Issue
Block a user