Description
The ESP8266 port gives a Python REPL over UART, but there is currently no interface to the wifi capabilities of the chip. This issue is intended to point potential contibutors in the right direction for implementing wifi.
Wifi bindings will be most useful if they fit in the standard POSIX mould of socket, connect, accept, bind listen, send, recv, etc. These functions can then be made available in the standard Python socket library.
Configuration functions, like list-access-points, and set-wpa-password, need to go in a dedicated ESP wifi driver, which is available to Python scripts from the network module.
Before any Python bindings are made, there are 2 main categories of C functions that need to be written:
- Functions to configure the wifi, set IP, etc.
- Functions to mimic the POSIX socket, connect, accept, bind, listen, send, recv functions.
Once these C functions exist, bindings to Python scripts is straight forward (and can be copied from stmhal port).
Usage of the wifi within a script will then look something like:
import network
wifi = network.ESP8266() # create wifi driver
wifi.listap() # list access points
wifi.connect('ssid', 'password') # connect to an access point
import socket
s = socket.socket()
s.connect(('192.168.0.1', 8080))
s.send('some data')
See issue #876 for background on this scheme.