From 4f439dc340461f168bd28d7a9bbd6933f0cd08b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Sun, 27 Mar 2022 16:48:53 +0200 Subject: [PATCH] removed socket tmp --- main.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/main.py b/main.py index 8a39804..6a0c2af 100644 --- a/main.py +++ b/main.py @@ -6,7 +6,6 @@ try: from rpi_ws281x import * import RPi.GPIO as GPIO import socket - import threading except ImportError: print('Some modules are missing. Try to install them with "pip3 install -r requirements.txt"') exit() @@ -16,6 +15,9 @@ idle_mode = 1 global power_button_pressed power_button_pressed = False +SOCKET_BIND_IP = '0.0.0.0' +SOCKET_BIND_PORT = 5760 + # LED strip configuration: LED_COUNT = 60 # Number of LED pixels. LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!). @@ -90,14 +92,6 @@ def power_toggle(channel): led_power = True debug_print('LED Power ON') -def socket_listener(): - SOCKET_BIND_IP = '0.0.0.0' - SOCKET_BIND_PORT = 5760 - with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - s.bind((SOCKET_BIND_IP, SOCKET_BIND_PORT)) - s.listen() - return s.accept() - if __name__ == '__main__': strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL) strip.begin() @@ -107,14 +101,16 @@ if __name__ == '__main__': GPIO.add_event_detect(13, GPIO.RISING, callback=power_toggle, bouncetime=300) GPIO.add_event_detect(19, GPIO.RISING, callback=change_idle_mode, bouncetime=300) - threading.Thread(target=socket_listener).start() + # with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + # s.bind((SOCKET_BIND_IP, SOCKET_BIND_PORT)) + # s.listen() + # conn, addr = s.accept() try: while True: - conn, addr = socket_listener() - socket_data = conn.recv(1024) - print(socket_data) - print(type(socket_data)) + # socket_data = conn.recv(1024) + # print(socket_data) + # print(type(socket_data)) if led_power == True: if check_internet() == False: blink(strip, Color(255,0,0), Color(255,255,255))