#!/bin/sh

sudo systemctl start mosquitto.service

topic='maison/is_connecté'


(
    echo "[application] listening"
    mosquitto_sub -v -t $topic
) & listener_pid=$!

(
    echo "[maison] up"
    while true
    do
        echo "[maison] publishing"
        mosquitto_pub -t $topic -m 'oui'
        sleep 1s
    done
) &

sleep 5s
kill $listener_pid


sudo systemctl start mosquitto.service
