diff --git a/app/device_manager.py b/app/device_manager.py index 6123639..f26d0e9 100644 --- a/app/device_manager.py +++ b/app/device_manager.py @@ -2026,14 +2026,11 @@ class DeviceManager: return {'success': True, 'data': event.payload} return {'success': False, 'error': 'No custom vars response'} elif param == 'path_hash_mode': - event = self.execute(self.mc.commands.get_path_hash_mode(), timeout=5) - if event and hasattr(event, 'payload'): - return {'success': True, 'data': event.payload} - return {'success': False, 'error': 'No response'} + # get_path_hash_mode() returns int, not Event + value = self.execute(self.mc.commands.get_path_hash_mode(), timeout=5) + return {'success': True, 'data': {'path_hash_mode': value}} elif param == 'help': - return {'success': True, 'data': { - 'Available params': 'name, tx, coords, lat, lon, bat, radio, stats, custom, path_hash_mode' - }} + return {'success': True, 'help': 'get'} else: return {'success': False, 'error': f"Unknown param: {param}. Type 'get help' for list."} except Exception as e: @@ -2095,11 +2092,7 @@ class DeviceManager: self.execute(self.mc.commands.set_path_hash_mode(int(value)), timeout=5) return {'success': True, 'message': f'Path hash mode set to: {value}'} elif param == 'help': - return {'success': True, 'data': { - 'Available params': 'name, tx, coords, lat, lon, pin, telemetry_mode_base, ' - 'telemetry_mode_loc, telemetry_mode_env, advert_loc_policy, ' - 'manual_add_contacts, multi_acks, path_hash_mode, ' - }} + return {'success': True, 'help': 'set'} else: # Try as custom variable self.execute(self.mc.commands.set_custom_var(param, value), timeout=5) diff --git a/app/main.py b/app/main.py index 0b27879..1c0a1a5 100644 --- a/app/main.py +++ b/app/main.py @@ -698,6 +698,20 @@ def _execute_console_command(args: list) -> str: elif cmd == 'get' and len(args) >= 2: param = args[1] result = device_manager.get_param(param) + if result.get('help') == 'get': + return ( + "Get parameters from device:\n" + " name — node name\n" + " tx — TX power\n" + " coords — adv coordinates (lat, lon)\n" + " lat — latitude\n" + " lon — longitude\n" + " bat — battery level in mV\n" + " radio — radio parameters (freq, bw, sf, cr)\n" + " stats — device status/statistics\n" + " custom — all custom variables (JSON)\n" + " path_hash_mode — path hash mode" + ) if result.get('success'): data = result.get('data', {}) lines = [] @@ -728,6 +742,28 @@ def _execute_console_command(args: list) -> str: return result.get('message', 'OK') return f"Error: {result.get('error')}" + elif cmd == 'set' and len(args) == 2 and args[1] == 'help': + result = device_manager.set_param('help', '') + return ( + "Set device parameters:\n" + " Device:\n" + " name — node name\n" + " tx — TX power\n" + " coords , — coordinates\n" + " lat — latitude\n" + " lon — longitude\n" + " pin — BLE pin\n" + " radio — radio params\n" + " multi_acks — multi-acks feature\n" + " manual_add_contacts — manual contact approval\n" + " telemetry_mode_base — basic telemetry (all/selected/off)\n" + " telemetry_mode_loc — location telemetry\n" + " telemetry_mode_env — environment telemetry\n" + " advert_loc_policy — location in adverts\n" + " path_hash_mode — path hash mode\n" + " — set custom variable" + ) + elif cmd == 'set': return "Usage: set \n Type 'set help' for available params"