diff --git a/daemon/core/emulator/coreemu.py b/daemon/core/emulator/coreemu.py index 51a5caa6..d687366a 100644 --- a/daemon/core/emulator/coreemu.py +++ b/daemon/core/emulator/coreemu.py @@ -581,6 +581,7 @@ class EmuSession(Session): has_lat_lon_alt = all(i is not None for i in [lat, lon, alt]) using_lat_lon_alt = has_empty_position and has_lat_lon_alt if using_lat_lon_alt: + logger.debug("updating node(%s) location using geo: %s, %s, %s", node.name, lat, lon, alt) x, y, _ = self.location.getxyz(lat, lon, alt) # set position and broadcast @@ -588,6 +589,7 @@ class EmuSession(Session): # broadcast updated location when using lat/lon/alt if using_lat_lon_alt: + logger.debug("broadcasting node(%s) location", node.name) self.broadcast_node_location(node) def broadcast_node_location(self, node): diff --git a/webapp/node_routes.py b/webapp/node_routes.py index 71d8b83e..6ee50823 100644 --- a/webapp/node_routes.py +++ b/webapp/node_routes.py @@ -56,14 +56,15 @@ def edit_node(session_id, node_id): data = request.get_json() or {} node_options = NodeOptions() - node_position = data["position"] - x = node_position["x"] - y = node_position["y"] + node_position = data.get("position", {}) + x = node_position.get("x") + y = node_position.get("y") node_options.set_position(x, y) lat = data.get("lat") lon = data.get("lon") alt = data.get("alt") node_options.set_location(lat, lon, alt) + logger.debug("updating node(%s) - pos(%s, %s) geo(%s, %s, %s)", node_id, x, y, lat, lon, alt) result = session.update_node(node_id, node_options) if result: diff --git a/webapp/websocket_routes.py b/webapp/websocket_routes.py index e9e57dbf..d6079fef 100644 --- a/webapp/websocket_routes.py +++ b/webapp/websocket_routes.py @@ -114,25 +114,26 @@ def broadcast_config(config_data): }) -def broadcast_event(event): +def broadcast_event(event_data): socketio.emit("event", { - "node": event.node, - "event_type": event.event_type, - "name": event.name, - "data": event.data, - "time": event.time, - "session": event.session + "node": event_data.node, + "event_type": event_data.event_type, + "name": event_data.name, + "data": event_data.data, + "time": event_data.time, + "session": event_data.session }) -def broadcast_node(node): +def broadcast_node(node_data): + services = node_data.services or "" socketio.emit("node", { - "id": node.id, - "name": node.name, - "model": node.model, + "id": node_data.id, + "name": node_data.name, + "model": node_data.model, "position": { - "x": node.x_position, - "y": node.y_position, + "x": node_data.x_position, + "y": node_data.y_position, }, - "services": node.services.split("|"), + "services": services.split("|"), })