diff --git a/.gitmodules b/.gitmodules index 5ffec2f..d022aaa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "localsettings"] path = localsettings url = https://github.com/victronenergy/localsettings.git -[submodule "dbus-mqtt"] - path = dbus-mqtt - url = https://github.com/victronenergy/dbus-mqtt.git [submodule "dbus-recorder"] path = dbus-recorder url = https://github.com/victronenergy/dbus-recorder.git @@ -19,3 +16,9 @@ [submodule "dbus_generator"] path = dbus_generator url = https://github.com/victronenergy/dbus_generator.git +[submodule "dbus-flashmq"] + path = dbus-flashmq + url = https://github.com/victronenergy/dbus-flashmq.git +[submodule "flashmq"] + path = flashmq + url = https://github.com/halfgaar/FlashMQ.git diff --git a/dbus-flashmq b/dbus-flashmq new file mode 160000 index 0000000..2f0197f --- /dev/null +++ b/dbus-flashmq @@ -0,0 +1 @@ +Subproject commit 2f0197ff388f4ccfb88f7ac029676a1acce41421 diff --git a/dbus-mqtt b/dbus-mqtt deleted file mode 160000 index b6fe5b4..0000000 --- a/dbus-mqtt +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b6fe5b49e67848b0b86aeac755bcf2f228e75ea8 diff --git a/dockerfile b/dockerfile index a198dd9..43b5621 100644 --- a/dockerfile +++ b/dockerfile @@ -8,6 +8,22 @@ ENV PUBLIC_URL=/ ENV REACT_APP_ENABLE_LANG_OVERRIDE=true RUN npm run build +# Build flashmq +FROM ubuntu:20.04 as flashmq +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update +RUN apt-get install -y g++ make cmake libssl-dev file docbook2x +COPY flashmq . +RUN cmake -DCMAKE_BUILD_TYPE=Release && make + +# Build dbus-flashmq +FROM ubuntu:20.04 as dbus-flashmq +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update +RUN apt-get install -y g++ make cmake pkg-config libdbus-1-dev +COPY dbus-flashmq . +RUN cmake -DCMAKE_BUILD_TYPE=Release && make + # Venus-docker build FROM ubuntu:20.04 WORKDIR /root @@ -15,10 +31,15 @@ WORKDIR /root RUN apt-get update RUN apt-get install -y python3 python3-gi RUN apt-get install -y python3-lxml python3-requests python3-dbus python3-paho-mqtt -RUN apt-get install -y mosquitto mosquitto-clients vim daemontools +RUN apt-get install -y vim daemontools RUN apt-get install -y libqt5core5a libqt5dbus5 libqt5xml5 libncurses6 RUN apt-get install -y nginx +# flashmq +COPY --from=flashmq flashmq /usr/bin/flashmq +COPY --from=dbus-flashmq libflashmq-dbus-plugin.so /usr/libexec/flashmq/libflashmq-dbus-plugin.so +COPY flashmq.conf /etc/flashmq/flashmq.conf + # dbus COPY dbus-tools/dbus /usr/bin/dbus COPY dbus-system.conf /etc/dbus-1/system.d/victron.conf @@ -33,19 +54,12 @@ COPY service /service # Service code COPY localsettings /opt/victronenergy/localsettings COPY dbus-systemcalc-py /opt/victronenergy/dbus-systemcalc-py -COPY dbus-mqtt /opt/victronenergy/dbus-mqtt COPY dbus-recorder /opt/victronenergy/dbus-recorder COPY dbus_generator /opt/victronenergy/dbus-generator-starter COPY settings.xml /data/conf/settings.xml COPY settings.xml /data/conf/settings.xml.orig COPY version /opt/victronenergy/version -# System service config -RUN echo 'listener 9001' >> /etc/mosquitto/mosquitto.conf -RUN echo 'protocol websockets' >> /etc/mosquitto/mosquitto.conf -RUN echo 'listener 1883' >> /etc/mosquitto/mosquitto.conf -RUN echo 'protocol mqtt' >> /etc/mosquitto/mosquitto.conf - # Run config COPY scripts/start_services.sh /root COPY scripts/run_with_simulation.sh /root diff --git a/flashmq b/flashmq new file mode 160000 index 0000000..91bc903 --- /dev/null +++ b/flashmq @@ -0,0 +1 @@ +Subproject commit 91bc903e7d963001829d16631241374e7652a439 diff --git a/flashmq.conf b/flashmq.conf new file mode 100644 index 0000000..8628890 --- /dev/null +++ b/flashmq.conf @@ -0,0 +1,15 @@ +thread_count 1 + +plugin /usr/libexec/flashmq/libflashmq-dbus-plugin.so + +max_packet_size 65536 + +listen { + protocol mqtt + port 1883 +} + +listen { + protocol websockets + port 9001 +} diff --git a/scripts/start_services.sh b/scripts/start_services.sh index 1eef7fe..f2cc9dd 100644 --- a/scripts/start_services.sh +++ b/scripts/start_services.sh @@ -3,12 +3,10 @@ # Create dummy relays before systemcalc is started mkdir -p /dev/gpio/relay_1 && touch /dev/gpio/relay_1/value +cd /opt/victronenergy/dbus-systemcalc-py/ || exit +vrmid=$(python3 -c 'from ext.velib_python.ve_utils import get_vrm_portal_id; print(get_vrm_portal_id())') +mkdir -p /data/venus && echo "$vrmid" > /data/venus/unique-id + service dbus start service mosquitto start svscan /service & - -# wait that messaging is initialized -sleep 2 - -# subscribe to the system/0/Serial to get the portal ID and then issue a read to that ID -mosquitto_pub -t R/"$(mosquitto_sub -v -C 1 -t 'N/+/system/0/Serial' | cut -d'"' -f4)"/system/0/Serial -m "dummy" diff --git a/service/dbus-mqtt/log/run b/service/dbus-mqtt/log/run deleted file mode 100755 index 9e8d7a8..0000000 --- a/service/dbus-mqtt/log/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -exec 2>&1 -exec multilog t s99999 n8 /log/dbus-mqtt diff --git a/service/dbus-mqtt/run b/service/dbus-mqtt/run deleted file mode 100755 index 74fcdab..0000000 --- a/service/dbus-mqtt/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -exec 2>&1 -exec /opt/victronenergy/dbus-mqtt/dbus_mqtt.py -k 60 diff --git a/service/flashmq/log/run b/service/flashmq/log/run new file mode 100755 index 0000000..6646142 --- /dev/null +++ b/service/flashmq/log/run @@ -0,0 +1,3 @@ +#!/bin/sh +exec 2>&1 +exec multilog t s99999 n8 /log/flashmq diff --git a/service/flashmq/run b/service/flashmq/run new file mode 100755 index 0000000..09b3d7e --- /dev/null +++ b/service/flashmq/run @@ -0,0 +1,3 @@ +#!/bin/sh +exec 2>&1 +exec /usr/bin/flashmq