Skip to content

Commit

Permalink
migrate to flashmq
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbosma committed Sep 27, 2023
1 parent a4810f6 commit 0447f25
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 24 deletions.
9 changes: 6 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions dbus-flashmq
Submodule dbus-flashmq added at 2f0197
1 change: 0 additions & 1 deletion dbus-mqtt
Submodule dbus-mqtt deleted from b6fe5b
30 changes: 22 additions & 8 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,38 @@ 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

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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions flashmq
Submodule flashmq added at 91bc90
15 changes: 15 additions & 0 deletions flashmq.conf
Original file line number Diff line number Diff line change
@@ -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
}
10 changes: 4 additions & 6 deletions scripts/start_services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 0 additions & 3 deletions service/dbus-mqtt/log/run

This file was deleted.

3 changes: 0 additions & 3 deletions service/dbus-mqtt/run

This file was deleted.

3 changes: 3 additions & 0 deletions service/flashmq/log/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
exec 2>&1
exec multilog t s99999 n8 /log/flashmq
3 changes: 3 additions & 0 deletions service/flashmq/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
exec 2>&1
exec /usr/bin/flashmq

0 comments on commit 0447f25

Please sign in to comment.