kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'feature/add_event_SYSTEM_EVENT_AP_STAIPASSIGNED' into 'master'
add event SYSTEM_EVENT_AP_STAIPASSIGNED See merge request idf/esp-idf!2202pull/1979/head
commit
1f7b41e206
|
@ -334,6 +334,10 @@ static esp_err_t esp_system_event_debug(system_event_t *event)
|
|||
MAC2STR(stadisconnected->mac), stadisconnected->aid);
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_AP_STAIPASSIGNED: {
|
||||
ESP_LOGD(TAG, "SYSTEM_EVENT_AP_STAIPASSIGNED");
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_AP_PROBEREQRECVED: {
|
||||
system_event_ap_probe_req_rx_t *ap_probereqrecved = &event->event_info.ap_probereqrecved;
|
||||
ESP_LOGD(TAG, "SYSTEM_EVENT_AP_PROBEREQRECVED, rssi:%d, mac:" MACSTR, \
|
||||
|
|
|
@ -44,6 +44,7 @@ typedef enum {
|
|||
SYSTEM_EVENT_AP_STOP, /**< ESP32 soft-AP stop */
|
||||
SYSTEM_EVENT_AP_STACONNECTED, /**< a station connected to ESP32 soft-AP */
|
||||
SYSTEM_EVENT_AP_STADISCONNECTED, /**< a station disconnected from ESP32 soft-AP */
|
||||
SYSTEM_EVENT_AP_STAIPASSIGNED, /**< ESP32 soft-AP assign an IP to a connected station */
|
||||
SYSTEM_EVENT_AP_PROBEREQRECVED, /**< Receive probe request packet in soft-AP interface */
|
||||
SYSTEM_EVENT_GOT_IP6, /**< ESP32 station or ap or ethernet interface v6IP addr is preferred */
|
||||
SYSTEM_EVENT_ETH_START, /**< ESP32 ethernet start */
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 04e656c303d129c479b5c019ea364e11c6f96f4d
|
||||
Subproject commit c1d0ac3625db5da98d1e9c64b8cd0d1261443810
|
|
@ -95,6 +95,7 @@ static dhcps_lease_t dhcps_poll;
|
|||
static dhcps_time_t dhcps_lease_time = DHCPS_LEASE_TIME_DEF; //minute
|
||||
static dhcps_offer_t dhcps_offer = 0xFF;
|
||||
static dhcps_offer_t dhcps_dns = 0x00;
|
||||
static dhcps_cb_t dhcps_cb;
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : dhcps_option_info
|
||||
|
@ -679,6 +680,10 @@ static void send_ack(struct dhcps_msg *m, u16_t len)
|
|||
DHCPS_LOG("dhcps: send_ack>>udp_sendto result %x\n", SendAck_err_t);
|
||||
#endif
|
||||
|
||||
if (SendAck_err_t == ERR_OK) {
|
||||
dhcps_cb(m->yiaddr);
|
||||
}
|
||||
|
||||
if (p->ref != 0) {
|
||||
#if DHCPS_DEBUG
|
||||
DHCPS_LOG("udhcp: send_ack>>free pbuf\n");
|
||||
|
@ -1105,6 +1110,19 @@ static void dhcps_poll_set(u32_t ip)
|
|||
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : dhcps_set_new_lease_cb
|
||||
* Description : set callback for dhcp server when it assign an IP
|
||||
* to the connected dhcp client
|
||||
* Parameters : cb -- callback for dhcp server
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
void dhcps_set_new_lease_cb(dhcps_cb_t cb)
|
||||
{
|
||||
dhcps_cb = cb;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : dhcps_start
|
||||
* Description : start dhcp server function
|
||||
|
|
|
@ -70,6 +70,8 @@ typedef struct {
|
|||
dhcps_lease_t dhcps_poll;
|
||||
} dhcps_options_t;
|
||||
|
||||
typedef void (*dhcps_cb_t)(u8_t client_ip[4]);
|
||||
|
||||
static inline bool dhcps_router_enabled (dhcps_offer_t offer)
|
||||
{
|
||||
return (offer & OFFER_ROUTER) != 0;
|
||||
|
@ -87,6 +89,7 @@ void dhcps_set_option_info(u8_t op_id, void *opt_info, u32_t opt_len);
|
|||
bool dhcp_search_ip_on_mac(u8_t *mac, ip4_addr_t *ip);
|
||||
void dhcps_dns_setserver(const ip_addr_t *dnsserver);
|
||||
ip4_addr_t dhcps_dns_getserver();
|
||||
void dhcps_set_new_lease_cb(dhcps_cb_t cb);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -85,6 +85,15 @@ static void tcpip_adapter_api_cb(void* api_msg)
|
|||
return;
|
||||
}
|
||||
|
||||
static void tcpip_adapter_dhcps_cb(u8_t client_ip[4])
|
||||
{
|
||||
ESP_LOGI(TAG,"softAP assign IP to station,IP is: %d.%d.%d.%d",
|
||||
client_ip[0],client_ip[1],client_ip[2],client_ip[3]);
|
||||
system_event_t evt;
|
||||
evt.event_id = SYSTEM_EVENT_AP_STAIPASSIGNED;
|
||||
esp_event_send(&evt);
|
||||
}
|
||||
|
||||
void tcpip_adapter_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
@ -181,6 +190,8 @@ esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_a
|
|||
netif_set_up(esp_netif[tcpip_if]);
|
||||
|
||||
if (dhcps_status == TCPIP_ADAPTER_DHCP_INIT) {
|
||||
dhcps_set_new_lease_cb(tcpip_adapter_dhcps_cb);
|
||||
|
||||
dhcps_start(esp_netif[tcpip_if], ip_info->ip);
|
||||
|
||||
ESP_LOGD(TAG, "dhcp server start:(ip: " IPSTR ", mask: " IPSTR ", gw: " IPSTR ")",
|
||||
|
|
Ładowanie…
Reference in New Issue