From f83751cc8086df07f38e7a11f65d068968ce8fc0 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Tue, 23 Jan 2024 07:32:03 +0100 Subject: [PATCH] removed data formatter --- modem/arq_data_formatter.py | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 modem/arq_data_formatter.py diff --git a/modem/arq_data_formatter.py b/modem/arq_data_formatter.py deleted file mode 100644 index d81b1fd6..00000000 --- a/modem/arq_data_formatter.py +++ /dev/null @@ -1,24 +0,0 @@ -# File: arq_data_formatter.py - -import json - -class ARQDataFormatter: - def __init__(self): - pass - - def encapsulate(self, data, type_key="p2pmsg"): - """Encapsulate data into the specified format with the given type key.""" - formatted_data = {type_key: data} - return json.dumps(formatted_data) - - def decapsulate(self, byte_data): - """Decapsulate data from the specified format, returning both the data and the type.""" - try: - json_data = byte_data.decode('utf-8') # Decode byte array to string - parsed_data = json.loads(json_data) - if parsed_data and isinstance(parsed_data, dict): - for key, value in parsed_data.items(): - return key, value - return "raw", byte_data - except (json.JSONDecodeError, UnicodeDecodeError): - return "raw", byte_data