Skip to content

Instantly share code, notes, and snippets.

View tomasinouk's full-sized avatar

Tomas Blaha tomasinouk

View GitHub Profile
@tomasinouk
tomasinouk / snat_dnat_advantech.md
Last active April 11, 2024 03:50
examples of SNAT, DNAT with iptables for Advantech, Conel routers, with comments (probably will work on other routers where iptables can be manipulated, care needs to be taken on applying these commands after reboot).

Some examples of SNAT, DNAT with iptables with comments

mainly used in start-up script

How to test 'safely'

When we play with iptables aka firewall we might end up in situation, where we execute rule, which has unforseen impact - lock yourself out. Recovering from this situation is necessity.

How to:

  • Enable reboot via SMS.
  • Test all commands in shell first before putting them into Start-up script. This way the command will be wiped out, when unit is rebooted.

masquarade all outgoing packets to be WLAN0 IP

I have done this on Challenger LTE board link, which is RP2040 based.

You need to enable data serial at boot (boot.py), this is disabled by default. When the board boots you need to run file serial_passthrough.py the program.

Your computer will report new COM/Serial port. Use that to talk with the device connected to uart of the CircuitPython board.

Create files on CIRCUITPY

file: boot.py

@tomasinouk
tomasinouk / SMS_commands.sh
Created October 26, 2023 05:29
Implementing SMS commands from multiple phone numbers and notifications to multiple phone numbers for Advantech cellular routers such as ICR-3232, ICR-2432, etc.
PHONE1=+61423207744
PHONE2=+6141038#####
BIN0_TEXT_OUT_OFF="OUT_0 is set to 1"
BIN0_TEXT_OUT_ON="OUT_0 is set to 0"
for i in $PHONE1 $PHONE2; do
logger -t "SMS_COMMAND" "Have these phone no $i"
done
@tomasinouk
tomasinouk / ffmpeg_examples.md
Created November 30, 2015 04:21
ffmpeg examples for streaming full screen

ffmpeg -f avfoundation -i "1" -vcodec libx264 -r 10 -tune zerolatency -b:v 500k -bufsize 300k -f rtp rtp://localhost:1234

ffmpeg -f avfoundation -i "1" -vcodec libx264 -r 10 -tune zerolatency -b:v 500k -bufsize 300k -f rtp udp://127.0.0.1:1234

ffmpeg -f avfoundation -i "1" -vcodec libx264 -r 10 -tune zerolatency -b:v 500k -bufsize 300k -f mpegts udp://127.0.0.1:1234

ffmpeg -f avfoundation -i "1" -vcodec libx264 -r 10 -pix_fmt uyvy422 -tune zerolatency -b:v 500k -bufsize 300k -f mpegts udp://192.168.88.38:1234

@tomasinouk
tomasinouk / CORS_on_OpenWRT_UCI.md
Last active October 11, 2022 08:39
CORS on OpenWRT UCI

To implement Cross-Origin Resource Sharing (CORS) on OpenWRT within Luci is actually simple.

After very long search, I have found code in uHTTPd on gitlab, which clearly shows option for CORS. I haven't found anything, which would describe how to actually configure it.

There is nothing in uHTTPd documentation describing this functionally, /etc/config/uhttpd does not mention anything either.

Luckily, you can have a look into how the process is starting and what parameters is checking.

doing

@tomasinouk
tomasinouk / test_coms_with_SARA_R4.py
Created January 8, 2022 04:32
Testing communication with SARA R410M on iLab Challenger Board
import board
import busio
import digitalio
import time
uart = busio.UART(board.SARA_TX,board.SARA_RX,rts=board.SARA_RTS, cts=board.SARA_CTS, baudrate=115200,timeout=5)
@tomasinouk
tomasinouk / reset_poe_smartflex.sh
Created March 28, 2018 04:06
Reset PoE if ping fails on SmartFlex - PoE unit
# created by Tomas Blaha - Dureco
# script check camera IP via ping every 30s
# if cannot ping it turn Off/On PoE for this camera only
# it does not cycle PoE on second PoE port
CAMERA_PING=192.168.1.22
while true
do
ping -c 1 $CAMERA_PING
NTP_ENABLED=0
NTP_PRIMARY_SERVER=pool3.ntp.org
@tomasinouk
tomasinouk / tabbed-description.liquid
Created June 26, 2019 05:04 — forked from tairli/tabbed-description.liquid
Tabbed Product description snippet for Shopify
{% comment %}
if combine_pretext is false, the text before the first <h6> will be shown above all tabs, otherwise added to the first tab
{% endcomment %}
{% assign combine_pretext = false %}
{% assign description = tabbed-description | default: product.description %}
{% if description contains "<h6>" %}
{% assign tab_heads = '' %}
{% assign tab_texts = '' %}
{% assign pretext = '' %}
@tomasinouk
tomasinouk / SmartWorkx,Conel_check_connection_2_IP.md
Created October 27, 2016 22:43
Script for SmartWorkx, Conel routers to check connection against 2 IP addresses. Good solution, to engage failover after both servers are not reachable.

Here is the start-up script, which in effect does check of 2 IP addresses

#!/bin/sh
#
# This script will be executed when PPP/WAN connection is established.
#
# Script for checking connection by two ping ip addresses
#
# Put checking ip addresses