Skip to content

Commit

Permalink
fix: using edge mqtt to send message (#224)
Browse files Browse the repository at this point in the history
closes #220

Co-authored-by: 99cloud <qiao.lei@99cloud.net>
  • Loading branch information
qiaolei1 and 99cloud committed May 10, 2023
1 parent 5b913b4 commit 7e4fb36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dandelion/api/api_v1/endpoints/system_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from dandelion import crud, models, schemas
from dandelion.api import deps
from dandelion.api.deps import OpenV2XHTTPException as HTTPException
from dandelion.mqtt import cloud_server as mqtt_cloud_server, topic
from dandelion.mqtt import cloud_server as mqtt_cloud_server, server, topic

router = APIRouter()
CONF: cfg = cfg.CONF
Expand Down Expand Up @@ -67,7 +67,7 @@ def create(
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, detail="Cloud MQTT Connection failed"
)
mqtt_cloud_server.MQTT_CLIENT.publish(topic=topic.V2X_EDGE_SITE_CHANGE)
server.MQTT_CLIENT.publish(topic=topic.V2X_EDGE_SITE_CHANGE)

return system_config.to_dict()

Expand Down
6 changes: 3 additions & 3 deletions dandelion/mqtt/service/rsu/rsu_algo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
from sqlalchemy.orm import Session

from dandelion import crud
from dandelion.mqtt import cloud_server as mqtt_cloud_server, topic
from dandelion.mqtt import server, topic
from dandelion.util import get_all_algo_config

LOG: LoggerAdapter = log.getLogger(__name__)


def algo_publish(db: Session):
if mqtt_cloud_server.MQTT_CLIENT is not None:
if server.MQTT_CLIENT is not None:
redis_info: Dict = {}
algo_in_db = crud.algo_name.get_multi_all(db=db)
response_data = get_all_algo_config(data=algo_in_db)
for algo in response_data.values():
algo_name = algo.get("algo")
redis_info[algo_name] = algo.get("inUse") if algo.get("enable") else "disable"
payload = json.dumps({"redis_info": redis_info})
mqtt_cloud_server.get_mqtt_client().publish(
server.get_mqtt_client().publish(
topic=topic.V2X_RSU_PIP_CFG,
payload=payload,
qos=0,
Expand Down

0 comments on commit 7e4fb36

Please sign in to comment.