diff --git a/.env b/.env index 8b3f27c..5d98ba8 100644 --- a/.env +++ b/.env @@ -21,3 +21,6 @@ KEYCLOAK_TOKEN_URL=${KEYCLOAK_PROTOCOL_ENDPOINT}/token #CORE info CORE_API_URL=http://localhost:1902 + +#BLE AI infer CSV +BLE_AI_INFER_CSV=/data/service/ble-ai-localizer/data/infer/infer.csv diff --git a/app.py b/app.py index 4475dc1..919664d 100644 --- a/app.py +++ b/app.py @@ -17,6 +17,7 @@ from tempfile import NamedTemporaryFile from typing import Callable import base64 from datetime import datetime, timedelta +import csv from api_utils import api_utils, coerce_methods from collections import OrderedDict @@ -191,6 +192,31 @@ async def get_documentation(): return get_swagger_ui_html(openapi_url="/openapi.json", title="docs") +@app.get("/ble-ai/infer", tags=["BLE-AI"]) +async def get_ble_ai_infer(): + path = config_env.BLE_AI_INFER_CSV + if not os.path.isfile(path): + raise HTTPException(status_code=404, detail="CSV not found") + + items = [] + with open(path, newline="") as f: + reader = csv.DictReader(f, delimiter=";") + for row in reader: + try: + items.append( + { + "mac": row.get("mac"), + "z": int(row["z"]) if row.get("z") not in (None, "") else None, + "x": int(row["x"]) if row.get("x") not in (None, "") else None, + "y": int(row["y"]) if row.get("y") not in (None, "") else None, + } + ) + except (KeyError, ValueError): + continue + + return {"items": items, "count": len(items)} + + @app.post("/majortel/call/", tags=["Majortel"]) async def route_call(active_user=Depends(manager),callerNumber=None, calledNumber=None): try: diff --git a/config_env.py b/config_env.py index cf91b24..4f69128 100644 --- a/config_env.py +++ b/config_env.py @@ -22,3 +22,8 @@ MQTT_VERSION = os.getenv("MQTT_VERSION", "mqttv311") MQTT_STATUS_INTERVAL = int(os.getenv("MQTT_STATUS_INTERVAL", "30")) MQTT_STALE_AFTER = int(os.getenv("MQTT_STALE_AFTER", "30")) +BLE_AI_INFER_CSV = os.getenv( + "BLE_AI_INFER_CSV", + "/data/service/ble-ai-localizer/data/infer/infer.csv", +) + diff --git a/fastapi-realworld-example-app-master.zip b/fastapi-realworld-example-app-master.zip deleted file mode 100644 index 23de0dc..0000000 Binary files a/fastapi-realworld-example-app-master.zip and /dev/null differ