diff --git a/zk/Debian_package_management.md b/zk/Debian_package_management.md index c312caa..68f50bb 100644 --- a/zk/Debian_package_management.md +++ b/zk/Debian_package_management.md @@ -6,6 +6,8 @@ tags: # Debian package management +> Can now actually do away with `apt-get` and just use `apt` + ## Update and install package ```sh @@ -23,4 +25,12 @@ sudo apt-get update ```sh sudo apt autoremove +` + +``` + +## List installed packages + +``` +apt list --installed ``` diff --git a/zk/mosquitto_mqtt_client.md b/zk/mosquitto_mqtt_client.md new file mode 100644 index 0000000..5bfc802 --- /dev/null +++ b/zk/mosquitto_mqtt_client.md @@ -0,0 +1,67 @@ +--- +tags: + - Linux + - Debian + - mqtt +--- + +## Config + +At `/etc/mosquitto/mosquitto.conf`. + +Most important lines: + +``` +listener 1883 +allow_anonymous true +``` + +This means `mosquitto` will run on port:1883 and that I am not using +authentication with requests to the broker. + +### Websockets + +In order to enable [websockets](./Web_sockets.md), must create a config file at +`/etc/mosquitto/mosquitto.conf/websockets.conf`: + +``` +# /etc/mosquitto/mosquitto.conf/websockets.conf` +listener 8083 +protocol websockets +``` + +This is only relevant if you require access from outside of the local network. + +## Basic usage + +## Create a topic + +```sh +mosquitto_sub -d -t test_topic +``` + +This then enters listening mode and takes control of terminal: + +``` +$ mosquitto_sub -d -t test_topic +Client (null) sending CONNECT +Client (null) received CONNACK (0) +Client (null) sending SUBSCRIBE (Mid: 1, Topic: test_topic, QoS: 0, Options: 0x00) +Client (null) received SUBACK +Subscribed (mid: 1): 0 +``` + +## Publish to a topic + +From my other machine I install `mosquitto` and: + +```sh +mosquitto_pub --host 192.168.68.53 --port 1883 --topic test_topic --message 'hello world' +``` + +This registers on the broker device: + +``` +Client (null) received PUBLISH (d0, q0, r0, m0, 'test_topic', ... (11 bytes)) +hello world +```