Commit Graph

35 Commits

Author SHA1 Message Date
Chris Popp
52df2f889e esp8266/modnetwork.c: Expose configuration for station DHCP hostname.
The ESP SDK supports configuring the hostname that is
reported when doing a DHCP request in station mode.  This commit
exposes that under network.WLAN(network.STA_IF).config('dhcp_hostname')
as a read/write value similar to other parameters.
2016-11-09 00:33:13 +03:00
puuu
b97c17e125 esp8266/modnetwork.c: Allows AP reconnection without WiFi credentials
There is no automatic reconnect after wlan.active(False);
wlan.active(True). This commit provide the possibility to run
wlan.connect() without parameter, to reconnect to the previously
connected AP.

resolve #2493
2016-11-01 06:59:41 +03:00
Paul Sokolovsky
e377f3cb40 esp8266/modnetwork: config(): Fix copy-paste error in setting "mac". 2016-10-31 00:30:26 +03:00
Damien George
93c4a6a3f7 all: Remove 'name' member from mp_obj_module_t struct.
One can instead lookup __name__ in the modules dict to get the value.
2016-09-22 00:23:16 +10:00
Damien George
b4be5a8f34 esp8266/modnetwork: Fix wlan.scan() method so it returns all networks.
According to the Arduino ESP8266 implementation the first argument to the
wifi scan callback is actually a bss_info pointer.  This patch fixes the
iteration over this data so the first 2 entries are no longer skipped.

Fixes issue #2372.
2016-09-06 15:30:39 +10:00
Mark
822e9ca8f3 esp8266/modnetwork: Use struct bss_info::ssid_len for ESSID length.
Instead of calling strlen(), which won't work if there're 32 chars in
returned ESSID. struct bss_info::ssid_len is not documented in SDK API
Guide, but is present in SDK headers since 1.4.0. Just in case, previous
code is left commented.
2016-06-04 22:02:01 +03:00
Damien George
6707fc94ae esp8266/modnetwork: Allow to press ctrl-C while scan() is running.
Ctrl-C will raise a KeyboardInterrupt and stop the scan (although it will
continue to run in the background, it won't report anything).  If
interrupted, and another scan() is started before the old one completes
in the background, then the second scan will fail with an OSError.
2016-05-29 09:53:04 +01:00
Damien George
84381fa0fc esp8266/modnetwork: Protect scan() callback against memory errors.
scan() allocates memory so may cause an exception to be raised.
2016-05-29 09:52:07 +01:00
Damien George
55df14f1a4 esp8266/modnetwork: scan() is only supported by STA when it's enabled. 2016-05-29 00:35:24 +01:00
Damien George
4f2ba9fbdc esp8266: Convert to use new MP_Exxx errno symbols.
These symbols are still defined in terms of the system Exxx symbols, and
can be switched to internal numeric definitions at a later stage.

Note that extmod/modlwip still uses many system Exxx symbols.
2016-05-10 23:30:39 +01:00
Paul Sokolovsky
35e63f0007 esp8266/modnetwork: Remove .mac() method, move to .config("mac").
Querying/setting MAC address is pretty adhoc operation to belong to
.config() instead of taking a whole method on its own.
2016-05-03 01:02:14 +03:00
Paul Sokolovsky
7b7c99fec1 esp8266/modnetwork: Remove deprecated wifi_mode().
Network interfaces are now controlled individually using .active() method.
2016-05-03 00:09:23 +03:00
Aex Aey
af554b4ba2 esp8266/modnetwork: Make WLAN.ifconfig() read/write.
Allow setting ip, netmask, gw and dns server (also, allows getting dns).
For docs see: https://github.com/micropython/micropython/commit/06deec9
2016-04-28 23:51:04 +03:00
Paul Sokolovsky
4fa1731b6e esp8266/modnetwork: .config(): Add "hidden ESSID" param. 2016-04-21 00:42:45 +03:00
Paul Sokolovsky
46f0641fba esp8266/modnetwork: .config(): Add "channel" param. 2016-04-20 00:25:31 +03:00
Paul Sokolovsky
54b89665fc esp8266/modnetwork: .config(): Add "password" param (W/O). 2016-04-12 00:18:40 +03:00
Paul Sokolovsky
7acc252e93 esp8266/modnetwork: .config(): Add "authmode" param. 2016-04-12 00:17:31 +03:00
Paul Sokolovsky
6f3fc9bfa1 esp8266/modnetwork: .config(): Check interface whose config is requested. 2016-04-12 00:16:16 +03:00
Paul Sokolovsky
2c8356c482 esp8266/modnetwork: require_if(): Report the actual interface required. 2016-04-05 16:09:03 +03:00
Paul Sokolovsky
5531437941 esp8266: Move PHY mode constants from modesp to modnetwork. 2016-04-01 12:10:11 +03:00
Damien George
9475cc59e6 esp8266: Support synchronous wifi scanning.
That is: aps = if0.scan()

TODO: make sure that returned list has tuple with values in "standard"
order (whatever that standard is).
2016-03-30 11:35:03 +03:00
Paul Sokolovsky
5239a8a82b esp8266/modnetwork: Add symbolic names for network interfaces: STA_IF & AP_IF.
These are expected to be passed to network.WLAN() to instantiate network
interface objects.
2016-03-10 10:44:15 +07:00
Paul Sokolovsky
a49c16069c esp8266/modnetwork: Introduce interface .config() method.
Allows to set (in case keyword args are given) or query (in case a single
"symbolic keyword" (a string, value is the same as keyword)) arbitrary
interface paramters (i.e. extensible and adaptable to various hardware).

Example usage:

ap_if = network.WLAN(1)
ap_if.config(essid="MicroPython on Air")
print(ap_if.config("essid"))
2016-03-10 10:41:55 +07:00
Paul Sokolovsky
d5a12a6608 esp8266/modnetwork: Move config defines to the top. 2016-03-10 10:39:52 +07:00
Paul Sokolovsky
1c43a0fbf8 esp8266/modnetwork: Add per-interface .active() method.
Allows to up/down interface when called with a boolean, or query current
state if called without args. This per-interface method is intended to
supersede adhoc network.wifi_mode() function.
2016-03-10 09:31:23 +07:00
Paul Sokolovsky
7378c50b2f esp8266: Move wifi_mode() and phy_mode() to network module. 2016-03-10 09:29:21 +07:00
Paul Sokolovsky
9e8396accb esp8266/modnetwork: Allow to configure STA and AP interfaces separately.
On ESP8266, there're 2 different interfaces. Pretending it's not the case
desn't make sense. So, network.WLAN() now takes interface id, and returns
interface object. Individual operations are then methods of interface
object. Some operations require i/f of specific type (e.g. .connect()
makes sense only for STA), other are defined for any (e.g. .ifconfig(),
.mac()).
2016-03-10 09:24:54 +07:00
Damien George
02ea74d8f5 esp8266: Add network.ifconfig(). 2016-03-02 23:04:21 +02:00
Paul Sokolovsky
fce0036a67 esp8266: mac() function belongs to network module per the latest API. 2015-12-27 10:03:32 +02:00
Paul Sokolovsky
abd0fcfc86 esp8266: Remove superfluous includes. 2015-12-21 22:08:06 +02:00
Bill Owens
e2bfa471fa esp8266: Added wlan.isconnected() to maintain parity with other ports. 2015-09-15 20:07:50 +03:00
Bill Owens
60ccb41fac esp8266: Move status() from esp module to network 2015-06-20 23:35:55 +03:00
Bill Owens
686516f90a esp8266: Move scan from esp module to network 2015-06-17 23:13:12 +03:00
Paul Sokolovsky
32eb4b9055 esp8266: Move connect/disconnect from "esp" module to network. 2015-06-12 17:45:28 +03:00
Paul Sokolovsky
ee3fec3167 esp8266: Add skeleton "network" module.
MicroPython "network" module interface requires it to contains classes
to instantiate. But as we have a static network interace, make WLAN()
"constructor" just return module itself, and just make all methods
module-global functions.
2015-06-12 17:45:20 +03:00