| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
The External Server is a component of the Fleet Protocol. It communicates with an External Client, which is part of the Module Gateway.
It handles communication between a cloud instance and multiple cars registered under a single company.
First, update the fleet protocol submodule
git submodule update --init lib/fleet-protocolInstall the required Python packages in a virtual environment by running the following (run pip3 install in the project root):
python3 -m venv .venv && \
source .venv/bin/activate && \
pip3 install -r requirements.txtPrepare your config file for the External Server. The config file can be found in config/config.json.
As an example of a filled-up config file, see the config/config.json. Before running the server, update the config/config.json accordingly.
Set up the logging, the MQTT connection parameters and company name and the External server behavior.
One of the last items in the config file is common_modules, represented by key-value pairs. The key is the module ID (a module number), the value contains following
[!WARNING] A common module will be used for all cars. No such module can be defined in the car configuration. See the config/config.json for an example of modules configuration.
The last item in the config file is cars, represented by key-value pairs. The key is the name of the car, the value is a dictionary containing car-specific modules keyed as specific_modules.
The structure of the specific_modules is the same as the common_modules structure.
See the config/config.json for an example of car configuration.
Warning
Configuring a module with the same ID both in common_modules and specific_modules is invalid and the server will not start.
Important
For each car, at least one module has to be defined, either in common_modules or specific_modules.
After configuration and installation of the dependencies, run External Server with this command:
python3 -m external_server <config> [--tls] [--ca <str>] [--cert <str>] [--key <str>]Following arguments are used if argument tls is set:
The External Server can be packaged as a standalone .pyz file using shiv. This is useful for deployment or integration testing.
shiv -e external_server.__main__:main -o external_server.pyz . -r requirements.txt --compressedThis creates external_server.pyz which bundles the application with all dependencies. Run it with:
python3 external_server.pyz <config> [--tls] [--ca <str>] [--cert <str>] [--key <str>]Do the steps from the Install dependencies section.
Install the package in editable mode and install test requirements (assuming you already installed the requirements for the server):
pip install -e .
pip install -r tests/requirements.txtUpdate submodules
git submodule update --init --recursiveCompile a shared library for the Example Module. This requires
Run the following
pushd tests/utils/example_module && \
mkdir -p _build && \
cd _build && \
cmake .. -DCMLIB_DIR=<path-to-cmakelib-dir> && \
make
popdcmakelib directory is absolute path to this repo root directory.
In the root folder, run the following
python -m tests [-h] [PATH1] [PATH2] ...Each PATH is specified relative to the tests folder. If no PATH is specified, all the tests will run. Otherwise
The -h flag makes the script display tests' coverage in an HTML format, for example in your web browser.
The External Server is ready to use with Docker. You can build a Docker image with docker build . in this directory. The Dockerfile also describes compiling these Bringauto modules:
These compiled modules are inserted into the image and are ready to use with the External Server in a Docker container.
The External Server can also be used with Docker Compose. In the docker-compose.yml is example of External Server service, which can't be used alone and should be inserted into another docker-compose.yml with MQTT service and defined network (the etna is an example). This specific example assumes that MQTT broker is service named mosquitto and defined network is bring-emulator.
To allow for type checking of the classes from compiler protobuf of Fleet Protocol, run the code below.
Warning
After you update the Fleet Protocol submodule, ensure that all imports in the generated files are correct. The generated files are located in lib/fleet-protocol/protobuf/compiled/python/fleet_protocol_protobuf_files.
pushd lib/fleet-protocol/protobuf && \
find ./definition -name "*.proto" -exec protoc -I=./definition --python_out=./compiled/python/fleet_protocol_protobuf_files --pyi_out=./compiled/python/fleet_protocol_protobuf_files {} +
popdThen reinstall the requirements.
| Back | FazBrowse Home | New Git URL |