Skip to content

Instantly share code, notes, and snippets.

@amin-is
amin-is / ESP32Send.ino
Created April 1, 2023 17:48 — forked from santolucito/ESP32Send.ino
Sending UDP on ESP32 in Station Mode
#include <WebServer.h>
#include <WiFi.h>
#include <WiFiUdp.h>
//set up to connect to an existing network (e.g. mobile hotspot from laptop that will run the python code)
const char* ssid = "ssid";
const char* password = "password";
WiFiUDP Udp;
unsigned int localUdpPort = 4210; // port to listen on
char incomingPacket[255]; // buffer for incoming packets
@amin-is
amin-is / ESP32_UDP_AP.ino
Created April 1, 2023 17:48 — forked from santolucito/ESP32_UDP_AP.ino
Sending UDP on ESP32 in AP mode
#include <WebServer.h>
#include <WiFi.h>
#include <WiFiUdp.h>
// the IP of the machine to which you send msgs - this should be the correct IP in most cases (see note in python code)
#define CONSOLE_IP "192.168.1.2"
#define CONSOLE_PORT 4210
const char* ssid = "ESP32";
const char* password = "12345678";
WiFiUDP Udp;
@amin-is
amin-is / change-ssh-port.sh
Created January 18, 2023 14:11 — forked from worldadventurer/change-ssh-port.sh
Change SSH Port - prompts on command line for new port number
#!/bin/bash
# Copied from https://github.com/FreePBXHosting/freepbx-scripts/tree/master/sshport
#
# To run the script, login as root via SSH and run the following command:
# bash <(curl -Ls https://gist.github.com/worldadventurer/842f1a10762cba0ce27dc8f99a835377/raw)
#
#############################################
# FreePBXHosting.com - @freepbxhosting #
# VERSION 1.6 UPDATED JUN 25 2015 #
# DESC: CHANGES SSH PORT AND RESTARTS SSH #
@amin-is
amin-is / MQTTService.java
Created September 20, 2022 17:23 — forked from FaisalJamil/MQTTService.java
Push notification using MQTT message broker
package com.earthlinktele.faisaljamil.cinemana.push_notification;
import android.app.Notification;
import android.app.Notification.Builder;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
/*
control app https://x.thunkable.com/copy/e8f633a8a9a3e979025112e18446d3b4
Video: https://www.youtube.com/watch?v=oCMOYS71NIU
Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleNotify.cpp
Ported to Arduino ESP32 by Evandro Copercini
Create a BLE server that, once we receive a connection, will send periodic notifications.
The service advertises itself as: 6E400001-B5A3-F393-E0A9-E50E24DCCA9E
Has a characteristic of: 6E400002-B5A3-F393-E0A9-E50E24DCCA9E - used for receiving data with "WRITE"
Has a characteristic of: 6E400003-B5A3-F393-E0A9-E50E24DCCA9E - used to send data with "NOTIFY"
@amin-is
amin-is / AccessPoint.ino
Created July 27, 2022 18:34 — forked from Cyclenerd/AccessPoint.ino
ESP8266 : Create a WiFi access point and provide a DNS and web server on it, catch all traffic
/* Create a WiFi access point and provide a web server on it. */
#include <ESP8266WiFi.h>
#include "./DNSServer.h" // Patched lib
#include <ESP8266WebServer.h>
const byte DNS_PORT = 53; // Capture DNS requests on port 53
IPAddress apIP(10, 10, 10, 1); // Private network for server
DNSServer dnsServer; // Create the DNS object
ESP8266WebServer webServer(80); // HTTP server
@amin-is
amin-is / mqttitudeTOmysql.py
Created February 25, 2022 06:23 — forked from matbor/mqttitudeTOmysql.py
Simple Python script (v2.7x) that subscribes to a MQTT broker topic and inserts the data into a mysql database for later querying. This is designed to be used with the http://mqttitude.org/
#!/usr/bin/env python
# September 2013
# by Matthew Bordignon, @bordignon on Twitter
#
# Simple Python script (v2.7x) that subscribes to a MQTT broker topic and inserts the topic into a mysql database
# This is designed for the http://mqttitude.org/ project backend
#
import MySQLdb
import mosquitto
@amin-is
amin-is / ESP8266httpsUpdate.ino
Created June 8, 2021 08:26 — forked from igrr/ESP8266httpsUpdate.ino
ESP8266 ota over HTTPS
/*
OTA update over HTTPS
As an example, we download and install ESP8266Basic firmware from github.
Requires latest git version of the core (November 17, 2015)
Created by Ivan Grokhotkov, 2015.
This example is in public domain.
*/
@amin-is
amin-is / cloudflare.sh
Created May 28, 2021 17:46 — forked from Manouchehri/cloudflare.sh
Allow CloudFlare only
# Source:
# https://www.cloudflare.com/ips
# https://support.cloudflare.com/hc/en-us/articles/200169166-How-do-I-whitelist-CloudFlare-s-IP-addresses-in-iptables-
for i in `curl https://www.cloudflare.com/ips-v4`; do iptables -I INPUT -p tcp -m multiport --dports http,https -s $i -j ACCEPT; done
for i in `curl https://www.cloudflare.com/ips-v6`; do ip6tables -I INPUT -p tcp -m multiport --dports http,https -s $i -j ACCEPT; done
# Avoid racking up billing/attacks
# WARNING: If you get attacked and CloudFlare drops you, your site(s) will be unreachable.
iptables -A INPUT -p tcp -m multiport --dports http,https -j DROP