mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
extmod/modnetwork: Consolidate definition of common drivers.
Most extmod network drivers were being defined on a per-port basis, duplicating code and making enabling a driver on a new port harder. This consolidates extmod driver declarations and removes the existing per-port definitions of them. This commit has been verified to be a no-op in terms of firmware change. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
This commit is contained in:
committed by
Damien George
parent
95203ab88b
commit
fffaf8a41f
@@ -40,6 +40,19 @@
|
||||
#if MICROPY_PY_NETWORK_CYW43
|
||||
// So that CYW43_LINK_xxx constants are available to MICROPY_PORT_NETWORK_INTERFACES.
|
||||
#include "lib/cyw43-driver/src/cyw43.h"
|
||||
extern const struct _mp_obj_type_t mp_network_cyw43_type;
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_NETWORK_WIZNET5K
|
||||
extern const struct _mp_obj_type_t mod_network_nic_type_wiznet5k;
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_NETWORK_NINAW10
|
||||
extern const struct _mp_obj_type_t mod_network_nic_type_nina;
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_NETWORK_ESP_HOSTED
|
||||
extern const struct _mp_obj_type_t mod_network_esp_hosted_type;
|
||||
#endif
|
||||
|
||||
#ifdef MICROPY_PY_NETWORK_INCLUDEFILE
|
||||
@@ -166,6 +179,32 @@ static const mp_rom_map_elem_t mp_module_network_globals_table[] = {
|
||||
MICROPY_PORT_NETWORK_INTERFACES
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_NETWORK_CYW43
|
||||
{ MP_ROM_QSTR(MP_QSTR_WLAN), MP_ROM_PTR(&mp_network_cyw43_type) },
|
||||
// CYW43 status constants, currently for rp2 port only.
|
||||
// TODO move these to WIFI module for all ports.
|
||||
#if defined(PICO_PROGRAM_NAME) && defined(CYW43_LINK_DOWN)
|
||||
{ MP_ROM_QSTR(MP_QSTR_STAT_IDLE), MP_ROM_INT(CYW43_LINK_DOWN) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_STAT_CONNECTING), MP_ROM_INT(CYW43_LINK_JOIN) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_STAT_WRONG_PASSWORD), MP_ROM_INT(CYW43_LINK_BADAUTH) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_STAT_NO_AP_FOUND), MP_ROM_INT(CYW43_LINK_NONET) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_STAT_CONNECT_FAIL), MP_ROM_INT(CYW43_LINK_FAIL) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_STAT_GOT_IP), MP_ROM_INT(CYW43_LINK_UP) },
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_NETWORK_WIZNET5K
|
||||
{ MP_ROM_QSTR(MP_QSTR_WIZNET5K), MP_ROM_PTR(&mod_network_nic_type_wiznet5k) },
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_NETWORK_NINAW10
|
||||
{ MP_ROM_QSTR(MP_QSTR_WLAN), MP_ROM_PTR(&mod_network_nic_type_nina) },
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_NETWORK_ESP_HOSTED
|
||||
{ MP_ROM_QSTR(MP_QSTR_WLAN), MP_ROM_PTR(&mod_network_esp_hosted_type) },
|
||||
#endif
|
||||
|
||||
// Allow a port to take mostly full control of the network module.
|
||||
#ifdef MICROPY_PY_NETWORK_MODULE_GLOBALS_INCLUDEFILE
|
||||
#include MICROPY_PY_NETWORK_MODULE_GLOBALS_INCLUDEFILE
|
||||
|
||||
@@ -60,6 +60,11 @@ extern char mod_network_country_code[2];
|
||||
#define MICROPY_PY_NETWORK_HOSTNAME_MAX_LEN (32)
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_NETWORK_NINAW10
|
||||
// This Network interface requires the extended socket state.
|
||||
#define MICROPY_PY_SOCKET_EXTENDED_STATE (1)
|
||||
#endif
|
||||
|
||||
// This is a null-terminated string.
|
||||
extern char mod_network_hostname_data[MICROPY_PY_NETWORK_HOSTNAME_MAX_LEN + 1];
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
#include "esp_hosted_wifi.h"
|
||||
#include "esp_hosted_hal.h"
|
||||
|
||||
extern const mp_obj_type_t mod_network_esp_hosted_type;
|
||||
|
||||
typedef struct _esp_hosted_obj_t {
|
||||
mp_obj_base_t base;
|
||||
uint32_t itf;
|
||||
|
||||
@@ -78,6 +78,8 @@
|
||||
|
||||
#endif
|
||||
|
||||
extern const mp_obj_type_t mod_network_nic_type_wiznet5k;
|
||||
|
||||
#ifndef printf
|
||||
#define printf(...) mp_printf(MP_PYTHON_PRINTER, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user