Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inform new client ip4 address during SYSTEM_EVENT_AP_STAIPASSIGNED (IDFGH-563) #2949

Closed
123swk123 opened this issue Jan 15, 2019 · 5 comments

Comments

@123swk123
Copy link

in the soft AP mode, when a new client connects SYSTEM_EVENT_AP_STAIPASSIGNED is raised and it would be good if it also has additional information about which IP address it has assigned to its new client in the event information.

some thing like below.

    89	static void tcpip_adapter_dhcps_cb(u8_t client_ip[4])
    90	{
    91	    ESP_LOGI(TAG,"softAP assign IP to station,IP is: %d.%d.%d.%d",
    92	                client_ip[0],client_ip[1],client_ip[2],client_ip[3]);
    93	    system_event_t evt;
    94	    evt.event_id = SYSTEM_EVENT_AP_STAIPASSIGNED;
    95	    memcpy((char *) &evt.event_info.got_ip.ip_info.ip.addr, (char *) client_ip, sizeof(evt.event_info.got_ip.ip_info.ip.addr));
    96	    esp_event_send(&evt);
    97	}
@Alvin1Zhang Alvin1Zhang changed the title inform new client ip4 address during SYSTEM_EVENT_AP_STAIPASSIGNED [TW#28414] inform new client ip4 address during SYSTEM_EVENT_AP_STAIPASSIGNED Jan 15, 2019
@TimXia
Copy link
Contributor

TimXia commented Jan 15, 2019

Sorry, I can't catch you. Isn't IP address in the event information?

@123swk123
Copy link
Author

123swk123 commented Jan 15, 2019 via email

@TimXia
Copy link
Contributor

TimXia commented Jan 15, 2019

@123swk123 OK, we will add it. Thanks for your suggestion.

@zhangyanjiaoesp
Copy link
Collaborator

@123swk123 Thanks, it's a good idea. We can add it in v4.0

@ic3man5
Copy link

ic3man5 commented Jan 22, 2019

Should have searched here before, I basically came up with the same changes. I'll be patching my v3.1 branch for this change.

Its kind of scary we initialize the event with random values and pass over the event to the user without an explanation on what is expected to be populated, talk about potential debugging headaches... A quick search through the code base shows at least 5 spots in components/tcpip_adapter/include/tcpip_adapter.h alone where the structure isn't initialized.

+1 to @123swk123's code, here is a follow up with the event zero'd out.

static void tcpip_adapter_dhcps_cb(u8_t client_ip[4])
{
    ESP_LOGI(TAG,"DHCP client assigned an IP of %d.%d.%d.%d",
                client_ip[0],client_ip[1],client_ip[2],client_ip[3]);
    system_event_t evt;
    memset(&evt, 0, sizeof(evt));
    evt.event_id = SYSTEM_EVENT_AP_STAIPASSIGNED;
    memcpy((char *) &evt.event_info.got_ip.ip_info.ip.addr, (char *) client_ip, sizeof(evt.event_info.got_ip.ip_info.ip.addr));
    esp_event_send(&evt);
}

I'd also like to add there is no documentation for the event.

@projectgus projectgus changed the title [TW#28414] inform new client ip4 address during SYSTEM_EVENT_AP_STAIPASSIGNED inform new client ip4 address during SYSTEM_EVENT_AP_STAIPASSIGNED (IDFGH-563) Mar 12, 2019
@igrr igrr closed this as completed in 27cc0d1 Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants