Skip to content

Instantly share code, notes, and snippets.

@RoganDawes
RoganDawes / external_pitm.yaml
Created March 11, 2024 06:44
ESPHome YAML to configure an ESP32 for UART PitM duties, both with local relay and external relay using socat.
esphome:
name: serial-pitm
friendly_name: Serial Person in the Middle
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
@RoganDawes
RoganDawes / socat-x-process.py
Created March 8, 2024 16:45
A python script to coalesce output from `socat -x` hexdumps.
#!/usr/bin/env python3
import sys
import argparse
import datetime
import datetime
import re
class TimeDeltaType(object):
@RoganDawes
RoganDawes / 0001-WIP-Add-support-for-the-Wink-Hub-v1.patch
Last active July 7, 2023 09:20
WIP OpenWrt patch for the Wink Hub v1.
From 12e6d1413b975a3d94d9492f0c27966abd3ebba4 Mon Sep 17 00:00:00 2001
From: Rogan Dawes <rogan@dawes.za.net>
Date: Thu, 6 Jul 2023 19:39:28 +0200
Subject: [PATCH] WIP: Add support for the Wink Hub v1
---
package/kernel/mac80211/broadcom.mk | 1 +
target/linux/mxs/config-5.15 | 4 +
target/linux/mxs/image/Makefile | 25 ++++
...-imx28-Add-alternate-DUART-pinmuxing.patch | 41 ++++++
@RoganDawes
RoganDawes / Wink Hub V2 boot.txt
Last active May 30, 2023 07:54
Wink Hub V2 files
U-Boot 2015.04 (Sep 02 2016 - 20:09:54)
CPU: Freescale i.MX6UL rev1.1 at 396 MHz
CPU: Temperature 30 C
Reset cause: POR
Board: MX6UL Flex Wink Hub V2
I2C: ready
DRAM: 512 MiB
NAND: 128 MiB
In: serial
@RoganDawes
RoganDawes / fud.c
Created June 23, 2022 07:40
C code implementing Singe's Fear Uncertainty and Doubt protocol
#include <stdio.h>
int main() {
int i, n, m ;
scanf("%d", &n);
int o = n;
while ( n - o < 999999999 ) {
char c = '2';
if ((n%3) == 0) {
c = '0';
@RoganDawes
RoganDawes / dnsmasq_log.pl
Last active November 16, 2021 20:45
Script to ingest operwrt syslogs, build up a map of DNS name lookups to the resulting IP address, and then replace the IP address in subsequent log entries with the corresponding name that was queried. This currently focuses specifically on log entries that match the expression "REJECT wan out", but could certainly be adjusted to work with other…
#!/usr/bin/perl -w
# Script to process router log file to list dnsmasq DNS lookup entries and
# Kernel DROP entries to correlate which DNS names are being dropped by the
# firewall.
#
# dnsmasq correlates multiple log entries using a random key, and these can
# be interleaved with other log entries.
#
# The idea is to sort the entries according to the key, but in order of time
#
@RoganDawes
RoganDawes / currentcost.h
Created April 8, 2021 07:41
ESPHome configuration for CurrentCost Envi XML parsing and reporting. Uses the RapidXML Header-only library to parse the XML. Works on an ESP32, ESP8266 seems insufficient for the task.
#include <string>
#include "esphome.h"
#include "rapidxml/rapidxml.hpp"
static const char *TAG = "currentcost";
class CurrentCostSensor : public Component, public UARTDevice {
public:
Sensor *ch1 = new Sensor();
Sensor *ch2 = new Sensor();
@RoganDawes
RoganDawes / TeensyMonitor.ino
Last active October 23, 2020 13:56
Some Quick and Dirty python code for reading from two serial ports at once. Also, a Teensy sketch for doing the same using actual simultaneous UARTs.
#include <elapsedMillis.h>
#define PIN_D2 2
#define MAX_BUFFER 16
uint8_t buffer1[MAX_BUFFER], buffer1pos = 0, buffer3[MAX_BUFFER], buffer3pos = 0;
char buffer1prefix[] = "E> ", buffer3prefix[] = "A> ";
elapsedMillis TimeSinceRead;
@RoganDawes
RoganDawes / 2001:ac01
Last active February 25, 2024 11:43
Updates to /etc/usb-mode.json to support DLink DWM222 model A2
# /usr/share/usb_modeswitch/2001:ac01
# Run manually if required using:
# usb_modeswitch -v 0x2001 -p 0xac01 -c /usr/share/usb_modeswitch/2001:ac01
# D-Link DWM-222 A2
TargetVendor=0x2001
TargetProduct=0x7e3d
StandardEject=1
@RoganDawes
RoganDawes / pre-commit-mvn.sh
Last active May 7, 2019 08:18
Run maven on a clean directory, reflecting ONLY what will be in the commit, and excluding any other files in the working directory that might affect the build
#!/bin/bash
echo "running pre-commit hooks"
STAGED_FILES_CMD=`git diff --cached --name-only | grep -E "(\.java$)|(pom.xml)"`
# Determine if a file list is passed
echo "INPUT: $#"
if [ "$#" -eq 1 ] ; then
oIFS=$IFS
IFS='
'