Skip to content

Instantly share code, notes, and snippets.

View Leo-PL's full-sized avatar

Lech Perczak Leo-PL

View GitHub Profile
@Leo-PL
Leo-PL / intel_x520_patcher.py
Last active August 27, 2023 19:57 — forked from ixs/intel_x520_patcher.py
Intel x520 EEPROM Patcher allows to unlock the x520 network card to work with non-intel branded SFP modules.
#!/usr/bin/env python3
#
# Simple Intel x520 EEPROM patcher
# Modifies the EEPROM to unlock the card for non-intel branded SFP modules.
#
# Copyright 2020,2021,2022 Andreas Thienemann <andreas@bawue.net>
#
# Licensed under the GPLv3
#
# Based on research described at https://forums.servethehome.com/index.php?threads/patching-intel-x520-eeprom-to-unlock-all-sfp-transceivers.24634/
@Leo-PL
Leo-PL / mobile-usb-gadget
Last active June 27, 2023 01:43
Better mobile USB gadget for Mobian, with dual RNDIS/ECM configurations and added ACM function with login shell.
#!/bin/sh
CONFIGFS=/sys/kernel/config/usb_gadget/g1
USB_VENDORID="0x1D6B" # Linux Foundation
USB_PRODUCTID="0x0104" # Multifunction composite gadget
USB_MANUF="Debian"
USB_PRODUCT="Mobile USB Gadget"
USB_SERIAL=$(sha256sum < /etc/machine-id | cut -d' ' -f1)
USB_ATTRIBUTES="0x80" # Bus-powered
USB_MAX_POWER="500" # mA
@Leo-PL
Leo-PL / 10-persistent-serial.sh
Last active May 21, 2024 14:25
[DEPRECATED - see https://github.com/Leo-PL/my-openwrt-packages/tree/master/utils/persistent-serial} Persistent serial port names for USB-serial on OpenWrt hotplugd
[ "${ACTION}" = "add" -o "${ACTION}" = "remove" ] || exit 0
[ "${SUBSYSTEM}" = "tty" ] || exit 0
[ -n "${DEVNAME}" -a -n "${DEVPATH}" ] || exit 1
if [ "${ACTION}" = "add" ]; then
subsystem="$(basename $(readlink /sys${DEVPATH}/../../../subsystem))"
[ "$subsystem" = "usb" ] || exit 0
manufacturer="$(cat /sys${DEVPATH}/../../../../manufacturer)" || manufacturer="$(cat /sys${DEVPATH}/../../../../idVendor)"
@Leo-PL
Leo-PL / nut-driver@.service
Last active August 26, 2023 15:00
[OBSOLETE] nut-driver.service, template version to control UPS driver instances separately of each other
[Unit]
Description=Network UPS Tools - power device driver controller
After=local-fs.target network.target systemd-udev-settle.service
Wants=systemd-udev-settle.service
StopWhenUnneeded=yes
[Service]
ExecStart=/sbin/upsdrvctl start %i
ExecStop=/sbin/upsdrvctl stop %i
Type=forking
@Leo-PL
Leo-PL / rtl_tcp@.service
Last active March 20, 2023 05:55 — forked from alex27riva/rtl_tcp.service
Systemd service template for running rtl_tcp on startup
[Unit]
Description=Software Defined Radio TCP Server
Requires=network.target
After=network.target
[Service]
ExecStart=/bin/sh -c "/usr/bin/rtl_tcp -a 0.0.0.0 -d %i -p $$((1234+%i))"
Restart=on-failure
KillMode=control-group
@Leo-PL
Leo-PL / mf28x_find_deltas.py
Last active June 15, 2024 15:53
Delta update finder for ZTE MF283+, MF286, MF286A and MF286D routers
#!/usr/bin/python3
# Original script by frutis, mods by Leo-PL
# Usage:
# 1. uncomment proper section for your router (MF283+, MF286, MF286A, MF286D).
# 2. set correct IME if you have one
# 3. Set correct version ID (the integrate_version from NVRAM) for your device if not already found here
# 4. Run the script - it shall return the URL of data update, if available for the set base version.
from base64 import b64decode, b64encode
@Leo-PL
Leo-PL / tasmota_luftdaten_integration
Last active December 12, 2021 16:18
Example rule to push data from BME280 and PMS7003 sensors to Luftdaten directly from Tasmota
README
A simple rule to push sensor data to Luftdaten directly off of sensor running Tasmota. Assumes configured BME280 and PMS5003 sensors.
Replace <CHIP_ID> and <VERSION> by ESP8266 chip ID (available on info page) and Tasmota version, respectively.
Rule1
ON Tele-BME280#Temperature DO Backlog Var1 %value% ENDON
ON Tele-BME280#Humidity DO Backlog Var2 %value% ENDON
ON Tele-BME280#Pressure DO Backlog Var3 %value% ENDON
ON Tele-PMS5003#PM10 DO Backlog Var4 %value% ENDON
ON Tele-PMS5003#PM2.5 DO
@Leo-PL
Leo-PL / 10-persistent-serial.sh
Created July 28, 2021 22:48
OpenWrt persistent serial port symlinks
# Creates persistent serial port symlinks for USB devices,
# like mobile broadband modems, USB-UART bridges, etc,
# with layout very similar to udev symlinks
# Put under /etc/hotplug.d/tty
[ "${ACTION}" = "add" -o "${ACTION}" = "remove" ] || exit 0
[ "${SUBSYSTEM}" = "tty" ] || exit 0
[ -n "${DEVNAME}" -a -n "${DEVPATH}" ] || exit 1
if [ "${ACTION}" = "add" ]; then
#!/bin/bash
# Simple script to check if remote host behind a jump host is up. If not - wake it up using etherwake.
# Usage: invoke the script through ProxyCommand directive from your ssh_config.
# "nc" must be available on your host. "etherwake" must be available on jump host.
# Example:
# Host <target_hostname>
# ProxyCommand ~/.ssh/ssh-wakeup.sh <jumphost_address> <wol_interface> <wol_mac_address> %h %p
function wait_for_host() {
@Leo-PL
Leo-PL / lte_mbim_from_scratch.md
Created May 22, 2021 13:23 — forked from Juul/lte_mbim_from_scratch.md
How to use 4G LTE modems like the MC7455 on both Debian/Ubuntu and OpenWRT using MBIM

The purpose of this document is to get you familiar with the concepts and command line tools involved with connecting to the internet using modern 4G LTE modems on both Debian/Ubuntu and OpenWRT.

This writeup is based on my experiences with the Sierra Wireless AirPrime MC7455 modem and a Calyx (Sprint) SIM card, but it should apply to most modern 4G LTE modems.

High level overview

These are the steps required:

  • Physically connect antennas