Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

AP mode Socket Server not working #141

@0xDBFB7

Description

@0xDBFB7

I'm having a little trouble with AP_IF mode. I'm trying to make a WiFi setup page, such that the user connects to an AP and gets served a configuration page. If I do

ap = network.WLAN(network.AP_IF)
ap.active(True)
ap.config(essid="Setup")

The AP gets created, and the client can connect to it. However, if I then use one of the socket http server examples:

import socket
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
s = socket.socket()
s.bind(addr)
s.listen(1)
while True:
    cl, addr = s.accept()
    print('client connected from', addr)
    cl_file = cl.makefile('rwb', 0)
    while True:
        line = cl_file.readline()
        if not line or line == b'\r\n':
            break
    rows = ['<tr><td>%s</td><td>%d</td></tr>' % (str(p), p.value()) for p in pins]
    response = html % '\n'.join(rows)
    cl.send(response)
    cl.close()

And try to connect to 0.0.0.0:80 over the softAP, no client connection attempt is registered, and nothing gets sent to the client. In addition, ap.isconnected() gives an OSError: STA required, instead of the behavior documented here.

There's probably something I'm missing in AP/Socket setup - or is AP currently incompatible with the socket module?

Thanks for this incredible project, by the way, it makes my life a lot easier :>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions