I've wrote a litte http server just for testing and after a while it simply stops responding. Could someone look over my code and point me in the right direction? Maybe it has something to do with memory ect... how do I debug this? Thanks.
Init CC3000 module
Code: Select all
p1 = pyb.Pin('X5')
p2 = pyb.Pin('X4')
p3 = pyb.Pin('X3')
wlan = ""
print( "initializing interface..." )
try:
wlan = network.CC3K(pyb.SPI(1), p1, p2, p3)
wlan.connect("my wlan","my password")
except:
print( "Could not initialize CC3000 module. Try hard reset.")
sys.exit(0)
print( "connecting..." )
while not wlan.isconnected():
pyb.delay(50)
ifconfig = wlan.ifconfig()
print( "connected as: %s (%s)" % (ifconfig[0], ifconfig[5]) )
Code: Select all
sock = ""
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except:
print( "Failed to create socket" )
sys.exit()
sock.bind(("", 8080))
sock.listen(5)
print( "Sever listening..." )
while True:
try:
csock, caddr = sock.accept()
print("Connection from:", caddr[0])
csock.send("Server running on the pyboard!!!\n")
data = csock.recv(128)
data = data.decode('utf-8')
print("Query", data)
csock.close()
pyb.delay(10)
print("Connection closed form", caddr[0])
except OSError as er:
print ("OSError", err)
pyb.delay(500
Thanks for your help.