RPi Avahi Configuration Setup
Avahi on Raspbian.
Turn dbus integration on:
sudo nano /etc/avahi/avahi-daemon.conf
Uncomment enable-dbus=yues
.
If you man avahi-daemon.conf
you will see the following:
enable-dbus= Takes either "yes", "no" or "warn". If set to "yes" avahi-daemon connects to D-Bus, offering an object oriented client API. It is only available if Avahi has been compiled with --enable-dbus in which case it defaults to "yes". "warn" behaves like "yes", but the daemon starts up even when it fails to connect to a D-Bus daemon. In addition, if the connection to the D-Bus daemon is terminated we try to reconnect. (Unless we are in a chroot() environment where this definitely will fail.)
This stackoverflow question goes over how to update dbus.
Example service
Create a service file in /etc/avahi/services/myservice.service
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">myservice</name>
<service>
<type>_mqtt._tcp</type>
<port>1883</port>
</service>
</service-group>
This would be the equivalent of doing:
$ avahi-publish -s myservice _mqtt._tcp 1883
Note that if it does not work you might have a bug. Solution is to reload the avahi-daemon
on boot. Add this to rc.local
:
systemctl reload avahi-daemon
Resources
Referenct to build from source