2018-01-03 14:18:06 +01:00
|
|
|
/*
|
2018-02-28 14:46:02 +01:00
|
|
|
* This file is part of the MicroPython ESP32 project, https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo
|
2018-01-03 14:18:06 +01:00
|
|
|
*
|
|
|
|
|
* The MIT License (MIT)
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2017 "Eric Poulsen" <eric@zyxod.com>
|
2018-02-28 14:46:02 +01:00
|
|
|
* Copyright (c) 2018 LoBo (https://github.com/loboris)
|
2018-01-03 14:18:06 +01:00
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
* THE SOFTWARE.
|
|
|
|
|
*/
|
2018-12-04 14:06:15 +08:00
|
|
|
|
2018-01-03 14:18:06 +01:00
|
|
|
#ifndef MICROPY_INCLUDED_ESP32_MODNETWORK_H
|
|
|
|
|
#define MICROPY_INCLUDED_ESP32_MODNETWORK_H
|
|
|
|
|
|
2018-12-04 14:06:15 +08:00
|
|
|
#include "esp_wifi_types.h"
|
|
|
|
|
#include "esp_eth.h"
|
|
|
|
|
#include "tcpip_adapter.h"
|
|
|
|
|
|
|
|
|
|
#define WIFI_STATE_NOTINIT -1
|
|
|
|
|
#define WIFI_STATE_INIT 0
|
|
|
|
|
#define WIFI_STATE_STOPPED 1
|
|
|
|
|
#define WIFI_STATE_STARTED 2
|
|
|
|
|
#define MAX_ACTIVE_INTERFACES 3
|
|
|
|
|
|
2018-01-03 14:18:06 +01:00
|
|
|
enum { PHY_LAN8720, PHY_TLK110 };
|
|
|
|
|
|
|
|
|
|
typedef struct _wlan_if_obj_t {
|
|
|
|
|
mp_obj_base_t base;
|
|
|
|
|
int if_id;
|
2018-12-04 14:06:15 +08:00
|
|
|
wifi_mode_t wifi_mode;
|
2018-01-03 14:18:06 +01:00
|
|
|
} wlan_if_obj_t;
|
|
|
|
|
|
2018-02-04 20:19:15 +01:00
|
|
|
typedef void (*wifi_sta_rx_probe_req_t)(const uint8_t *frame, int len, int rssi);
|
|
|
|
|
extern esp_err_t esp_wifi_set_sta_rx_probe_req(wifi_sta_rx_probe_req_t cb);
|
|
|
|
|
|
2018-01-03 14:18:06 +01:00
|
|
|
extern const mp_obj_type_t wlan_if_type;
|
2018-12-04 14:06:15 +08:00
|
|
|
tcpip_adapter_if_t tcpip_if[3];
|
2018-01-03 14:18:06 +01:00
|
|
|
|
2018-12-04 14:06:15 +08:00
|
|
|
#ifdef CONFIG_MICROPY_USE_ETHERNET
|
|
|
|
|
extern bool lan_eth_active;
|
|
|
|
|
//extern eth_phy_check_link_func lan_eth_link_func;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
extern int wifi_network_state;
|
2018-02-28 14:46:02 +01:00
|
|
|
extern bool wifi_sta_isconnected;
|
|
|
|
|
extern bool wifi_sta_has_ipaddress;
|
|
|
|
|
extern bool wifi_sta_changed_ipaddress;
|
|
|
|
|
extern bool wifi_ap_isconnected;
|
2018-12-04 14:06:15 +08:00
|
|
|
extern bool wifi_ap_sta_isconnected;
|
|
|
|
|
|
|
|
|
|
int network_get_active_interfaces();
|
|
|
|
|
uint32_t network_hasip();
|
|
|
|
|
uint32_t network_has_staip();
|
|
|
|
|
void network_checkConnection();
|
|
|
|
|
|
2018-02-28 14:46:02 +01:00
|
|
|
|
2018-01-18 09:44:18 +01:00
|
|
|
#ifdef CONFIG_MICROPY_USE_ETHERNET
|
2018-01-03 14:18:06 +01:00
|
|
|
MP_DECLARE_CONST_FUN_OBJ_KW(get_lan_obj);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(esp_ifconfig_obj);
|
|
|
|
|
|
|
|
|
|
#endif
|