Initial commit
This commit is contained in:
13
scripts/http_diagnosis.py
Normal file
13
scripts/http_diagnosis.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import requests
|
||||
|
||||
r = requests.get("http://wordclock.local/cmd?diag=reset_info")
|
||||
print(r.status_code)
|
||||
print(r.text)
|
||||
|
||||
r = requests.get("http://wordclock.local/cmd?diag=sketch_info")
|
||||
print(r.status_code)
|
||||
print(r.text)
|
||||
|
||||
r = requests.get("http://wordclock.local/cmd?diag=device_info")
|
||||
print(r.status_code)
|
||||
print(r.text)
|
||||
52
scripts/multicastUDP_receiver.py
Normal file
52
scripts/multicastUDP_receiver.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from datetime import datetime
|
||||
import logging
|
||||
import queue
|
||||
import socket
|
||||
import struct
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
LOG_PATH = Path("C:/temp/wordclock_log.txt")
|
||||
|
||||
def setup_logging():
|
||||
FORMAT = "%(asctime)s %(message)s"
|
||||
logging.basicConfig(format=FORMAT, level=logging.INFO)
|
||||
logger = logging.getLogger()
|
||||
handler = logging.FileHandler(LOG_PATH)
|
||||
handler.setLevel(logging.INFO)
|
||||
logger.addHandler(handler)
|
||||
return logger
|
||||
|
||||
|
||||
def get_ip_address():
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.connect(("1.1.1.1", 80))
|
||||
return s.getsockname()[0]
|
||||
|
||||
|
||||
logger = setup_logging()
|
||||
|
||||
multicast_group = "230.120.10.2"
|
||||
server_address = ("", 8123)
|
||||
|
||||
# Create the socket
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
|
||||
# Bind to the server address
|
||||
sock.bind(server_address)
|
||||
|
||||
logging.info("Start")
|
||||
|
||||
# Tell the operating system to add the socket to the multicast group
|
||||
# on all interfaces.
|
||||
group = socket.inet_aton(multicast_group)
|
||||
mreq = struct.pack("4s4s", group, socket.inet_aton(get_ip_address()))
|
||||
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
|
||||
|
||||
logger.info("Ready")
|
||||
|
||||
# Receive/respond loop
|
||||
while True:
|
||||
data, address = sock.recvfrom(1024)
|
||||
data_str = data.decode("utf-8").strip()
|
||||
logger.info(data_str)
|
||||
BIN
scripts/requirements.txt
Normal file
BIN
scripts/requirements.txt
Normal file
Binary file not shown.
Reference in New Issue
Block a user