removed socket tmp

master
Ebbe Baß 2022-03-27 16:48:53 +02:00
parent e2024579a6
commit 4f439dc340
1 changed files with 10 additions and 14 deletions

24
main.py
View File

@ -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))