The agent reads all configuration from aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/AngelAmoSanchez/TFG-RaspberryPi-BLE/llms.txt
Use this file to discover all available pages before exploring further.
.env file (or from actual environment variables) at startup. The load_config_from_file function in src/config.py calls python-dotenv to load the file and then validates every value before the agent starts. If any required variable is missing or invalid the process exits with a descriptive error.
Complete .env example
The file below is drawn directly from.env.example in the repository. Copy it to .env and fill in the values for your deployment.
.env
Device identity
Unique identifier for this Raspberry Pi. Included in every published message so the backend can distinguish between multiple counters. Must be at least three characters long.Example:
rpi-entrance-01Human-readable label for the device. Optional. When set it is forwarded as
name in the published payload.Example: Main entrance counterPhysical location description. Optional. When set it is forwarded as
location in the published payload.Example: ETSII, SevillaCommunication mode
Selects the transport used to send detection data to the backend. Accepted values:
mqtt or http. The agent validates this at startup and raises a ValueError for any other value.- MQTT
- HTTP
Used when
COMMUNICATION_MODE=mqtt. The agent connects to the broker with paho-mqtt, publishes detection batches at QoS 1, and buffers messages locally when offline.Hostname or IP of the MQTT broker.Example:
abc123.eu-central-1.emqxsl.comTCP port for the broker connection. Use
8883 for TLS. When port 8883 is set the client enables TLS automatically.Topic to publish detection messages to.Example:
building/floor1/detectionsMQTT broker username. Optional for open brokers; required for authenticated deployments.
MQTT broker password. Optional for open brokers.
Maximum number of detection batches to hold in the in-memory buffer while the broker is unreachable. When the buffer is full the oldest message is dropped to make room for the newest. Set to
0 to disable buffering.If
MQTT_BROKER is missing or left as the default broker.emqx.io, the agent logs a warning and switches to MockMQTTClient, which prints detections locally instead of sending them over the network.BLE scanner
How many seconds each passive BLE scan lasts. Valid range: 1–60 seconds. Longer scans detect more devices but reduce the reporting frequency.
Seconds to wait between the end of one scan and the start of the next. Must be at least 5 seconds.
RSSI boundary (dBm) above which a device is classified as
NEAR. Must be a negative integer. Devices with RSSI ≥ this value fall in the near zone (roughly 0–2 m).RSSI boundary (dBm) above which a device is classified as
MEDIUM. Must be less than NEAR_THRESHOLD. Devices between this value and NEAR_THRESHOLD fall in the medium zone (roughly 2–5 m). All others are FAR.When set to
true the agent uses MockBLEScanner instead of the real Bleak-based scanner. The mock generates a randomised set of up to 8 simulated devices each cycle, which is useful for development and CI environments that have no Bluetooth hardware.Logging
Python logging level applied to the root logger. Accepted values:
DEBUG, INFO, WARNING, ERROR, CRITICAL. Use DEBUG to see per-device RSSI lines in the log output.