Skip to content

Instantly share code, notes, and snippets.

View machinekoder's full-sized avatar
💻
view-source

Alexander Poss machinekoder

💻
view-source
View GitHub Profile
@machinekoder
machinekoder / gist:3ba0e8a7172c0804bc3e68e25ec49bed
Last active October 6, 2023 14:34
MQTT Retain Flag and Potential Problems

MQTT Retain Flag and potential Problems

This document summarizes my findings in potential problems using the MQTT retain flag as a default for every topic in an MQTT application. MQTT retain is a useful feature if used properly. However, the risks of using it (as developer and for users of the software) are rarely warned about in many guides. Only when working with IoT applications for some time and reading through user forums, the MQTT specs and with a bit experience using other middleware projects potential risks may surface. I write this document mainly for myself for future implementation of MQTT application so I can make better decision when to use and when not use the MQTT retain flag.

Note that I'm only considering the MQTT 5 specs here. This document is not a writeup in prosa (except for this section here maybe) and should be used more as a sheet of notes with links for making your own decisions. It's by no means complete and comments helping me improve this document are welcome.

Expected Beha

@machinekoder
machinekoder / description.md
Last active June 14, 2023 08:29
Valetudo MQTT Map Segment issue

Issue

According to https://valetudo.cloud/pages/integrations/mqtt.html#mapsegmentssegments map segment ids should be reported on the topic <TOPIC PREFIX>/<IDENTIFIER>/MapData/segments.

This works well if "Provide map data" is checked in the Valetudo settings and this in line with the description in the docs.

However, when "Provide map data" is unchecked an empty JSON object is published to that topic. This undefined or at least undocumented behavior. Citing from the documentation This handle groups access to map data. It is only enabled if provideMapData is enabled in the MQTT config.

Note that <TOPIC PREFIX>/<IDENTIFIER>/MapData/map-data is still retained in this case if it was previously published.

UPDATE: When pressing "Save Configuration" in the UI switching "Provide map data" to "On" there is a ~30s delay until the segments are published on the topic. When switching from "On" to "Off" state, the message is received almost instantly. This can lead to perception of an intermittend issue if th

@machinekoder
machinekoder / fix_rosinstall.py
Created February 7, 2019 09:34
Fix .rosinstall file for the time the GitHub is around (see https://github.com/vcstools/vcstools/issues/147)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import shutil
import sys
import tarfile
import tempfile
from sh import wget
import os
import yaml
@machinekoder
machinekoder / SimpleTweak.py
Created December 3, 2018 16:25
Cura PostProcessingPlugin for my 3D printer
from ..Script import Script
class SimpleTweak(Script):
def __init__(self):
super().__init__()
def getSettingDataString(self):
return """{
"name":"SimpleTweak (for Alex Uni-Print-3D)",
"key": "SimpleTweak",
"metadata":{},
@machinekoder
machinekoder / btrfs_cleanup.sh
Created November 8, 2018 11:29
Cleanup Docker Btrfs
sudo su
service docker stop
ls -d -1 /var/lib/docker/btrfs/subvolumes/* | xargs btrfs subvolume delete
rm -rf /var/lib/docker
@machinekoder
machinekoder / rc_servo_machinekit.py
Last active August 22, 2018 21:41
Controlling an RC servo with Machinekit (untested)
# Turn commanded position -5 to +5 into 1-2 mS pulse for RC (hobby) servo
# gain = 1 mS (range) / 50 mS (PWM period) / 10 (units)= 0.002
# offset = 1.5 mS (value) / 50 mS (PWM period) = 0.03
# Resulting PWM values should be between 0.02 and 0.04, representing a
# 1 mS to 2 mS wide pulse
def rc_servo(thread, name, range_ms, offset_ms, period_ms, min_step, max_step, in_signal, out_signal):
gain = range_ms / pwm_ms / (max_step - min_step)
offset = value_ms / pwm_ms
@machinekoder
machinekoder / ros-bb-stretch.sh
Last active January 21, 2019 20:44 — forked from mhaberler/ros-bb-jessie.sh
installing ROS kinetic ROS-comm on beaglebone stretch
# derived from http://wiki.ros.org/ROSberryPi/Installing%20ROS%20Kinetic%20on%20Raspberry%20Pi
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu stretch main" > /etc/apt/sources.list.d/ros-latest.list'
wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
@machinekoder
machinekoder / Hotspot
Created June 7, 2018 18:27
place in /etc/NetworkManager/system-connections/ to create a AP hotspot under Linux
[connection]
id=Hotspot
uuid=bd4058b4-f99e-48f9-ac88-26513b9ac517
type=wifi
autoconnect=true
permissions=
[wifi]
hidden=false
mac-address=00:0F:60:06:EE:BE
@machinekoder
machinekoder / dxf_postpro.cfg
Created March 27, 2018 19:35
DXF Postprocessor for Dxf2GCode
[Number format]
post_decimals = 3
pre_decimal_zero_padding = 0
signed_values = 0
pre_decimals = 4
decimal_seperator = .
post_decimal_zero_padding = 1
[Program]
cutter_comp_left =
@machinekoder
machinekoder / gdrive_download.sh
Created August 16, 2017 06:29
Download huge files from Google Drive from https://stackoverflow.com/a/43478623
#!/usr/bin/env bash
fileid="$1"
destination="$2"
# try to download the file
curl -c /tmp/cookie -L -o /tmp/probe.bin "https://drive.google.com/uc?export=download&id=${fileid}"
probeSize=`du -b /tmp/probe.bin | cut -f1`
# did we get a virus message?
# this will be the first line we get when trying to retrive a large file