From 5935c4d27094b280e3ded3dcfdfbed46bdc2e6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TC=C2=B2?= <130875305+TheCommsChannel@users.noreply.github.com> Date: Tue, 2 Jul 2024 08:11:16 -0400 Subject: [PATCH 1/2] Change group_chat_id to use BROADCAST_NUM This change is to use BROADCAST_NUM from the Meshtastic Python lib instead of broadcast address "4294967295" in the code --- db_operations.py | 5 +++-- message_processing.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/db_operations.py b/db_operations.py index e613ffa..2325bb7 100644 --- a/db_operations.py +++ b/db_operations.py @@ -4,6 +4,8 @@ import threading import uuid from datetime import datetime +from meshtastic import BROADCAST_NUM + from utils import ( send_bulletin_to_bbs_nodes, send_delete_bulletin_to_bbs_nodes, @@ -78,9 +80,8 @@ def add_bulletin(board, sender_short_name, subject, content, bbs_nodes, interfac # New logic to send group chat notification for urgent bulletins if board.lower() == "urgent": - group_chat_id = 4294967295 # Default group chat ID (0xFFFFFFFF) notification_message = f"💥NEW URGENT BULLETIN💥\nFrom: {sender_short_name}\nTitle: {subject}" - send_message(notification_message, group_chat_id, interface) + send_message(notification_message, BROADCAST_NUM, interface) return unique_id diff --git a/message_processing.py b/message_processing.py index 49dd1b0..88a18ce 100644 --- a/message_processing.py +++ b/message_processing.py @@ -1,5 +1,7 @@ import logging +from meshtastic import BROADCAST_NUM + from command_handlers import ( handle_mail_command, handle_bulletin_command, handle_exit_command, handle_help_command, handle_stats_command, handle_fortune_command, @@ -33,9 +35,8 @@ def process_message(sender_id, message, interface, is_sync_message=False): add_bulletin(board, sender_short_name, subject, content, [], interface, unique_id=unique_id) if board.lower() == "urgent": - group_chat_id = 4294967295 notification_message = f"💥NEW URGENT BULLETIN💥\nFrom: {sender_short_name}\nTitle: {subject}" - send_message(notification_message, group_chat_id, interface) + send_message(notification_message, BROADCAST_NUM, interface) elif message.startswith("MAIL|"): parts = message.split("|") sender_id, sender_short_name, recipient_id, subject, content, unique_id = parts[1], parts[2], parts[3], parts[4], parts[5], parts[6] From 02b0351cff2f54634ee5bdacdb51674be7c7b596 Mon Sep 17 00:00:00 2001 From: Blergo Date: Tue, 2 Jul 2024 20:00:15 +0100 Subject: [PATCH 2/2] Fix cpu usage --- command_handlers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/command_handlers.py b/command_handlers.py index ac30d57..fa2a290 100644 --- a/command_handlers.py +++ b/command_handlers.py @@ -1,7 +1,7 @@ import logging import random import time -import psutil +import psutil # type: ignore from db_operations import ( add_bulletin, add_mail, delete_mail, @@ -103,6 +103,7 @@ def handle_stats_steps(sender_id, message, step, interface, bbs_nodes): update_user_state(sender_id, {'command': 'STATS', 'step': 2}) if choice == 1: psutil.cpu_percent() + psutil.cpu_count() time.sleep(0.1) cpu = str(psutil.cpu_percent()/psutil.cpu_count()) ramu = str(psutil.virtual_memory().percent)