udp listen on the sta+softap mode.

nice72
Posts: 10
Joined: Wed Nov 26, 2014 3:47 pm

udp listen on the sta+softap mode.

Postby nice72 » Fri Apr 17, 2015 11:05 am

Hi !! :)

In order to recevie a udp packet from station side and softAp side, I made simple source code.

SDK version the latest version (esp_iot_sdk_v1.0.1_b2_15_04_10)
wifi mode station and softAp mode

Code: Select all

static void ICACHE_FLASH_ATTR mng_udp_init( void )
{
    g_mng_udp_esp_conn.type = ESPCONN_UDP;
    g_mng_udp_esp_conn.state = ESPCONN_NONE;
    g_mng_udp_esp_conn.proto.udp = &g_mng_udp_espudp;
    g_mng_udp_esp_conn.proto.udp->local_port = MNG_UDP_PORT; 
    espconn_regist_recvcb(&g_mng_udp_esp_conn, mng_udp_recv);
    espconn_create(&g_mng_udp_esp_conn); 
}

static void ICACHE_FLASH_ATTR mng_udp_recv(void *arg, char *rxmsg, unsigned short len)
{
    struct espconn *pesp_conn = arg;

    os_printf("\nmng udp recv  %d.%d.%d.%d %d -> %d.%d.%d.%d %d state(%d)\n",
            pesp_conn->proto.udp->remote_ip[0],
            pesp_conn->proto.udp->remote_ip[1],
            pesp_conn->proto.udp->remote_ip[2],
            pesp_conn->proto.udp->remote_ip[3],
            pesp_conn->proto.udp->remote_port,
            pesp_conn->proto.udp->local_ip[0],
            pesp_conn->proto.udp->local_ip[1],
            pesp_conn->proto.udp->local_ip[2],
            pesp_conn->proto.udp->local_ip[3],
            pesp_conn->proto.udp->local_port, pesp_conn->state
            );
}


ESP8266 can receive the 1st packet from any direction.
Thereafter, ESP8266 can receive the packet is received in only one direction.

[Testing Procedure 1]

SmartPhone1 --(1)--> ESP8266 <--(3)-- CISCO AP <--(3)-- SmartPhone2

1. SmartPhone1 send a udp packet to the ESP8266
2. ESP8266 can receive that one.
3. Using the same destination udp port, SmartPhone2 send a udp packet to the ESP8266
4. ESP8266 can't receive udp packet.

[Testing Procedure 2]

0. Restart the esp8266 (power reset)

SmartPhone1 --(3)--> ESP8266 <--(1)-- CISCO AP <--(1)-- SmartPhone2

1. SmartPhone2 send a udp packet to the ESP8266
2. ESP8266 can receive that one.
3. Using the same destination udp port, SmartPhone1 send a udp packet to the ESP8266
4. ESP8266 can't receive udp packet.

[Testing Procedure 3]

0. Without system restart

SmartPhone1 <--(1)-- ESP8266 --(3)--> CISCO AP --(3)--> SmartPhone2

1. ESP8266 send a udp packet to the SmartPhone1
2. SmartPhone1 can receive the packet.
3. ESP8266 send a udp packet to the SmartPhone2
2. SmartPhone2 can receive the packet.

In order to solve this problem, I need your help. :roll:

Thanks,
Peter

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: udp listen on the sta+softap mode.

Postby ESP_Faye » Fri Apr 17, 2015 6:19 pm

Hi,

Thanks for your interest in ESP8266.

In this case , you need to create two UDP with two port,one for station , one for softAP.

nice72
Posts: 10
Joined: Wed Nov 26, 2014 3:47 pm

Re: udp listen on the sta+softap mode.

Postby nice72 » Mon Apr 20, 2015 8:54 am

Hi,

I have already used the method which you have supposed. But..
If someone performs a portscan, I shall always reset the connection.
It seems too absurd way.
For a more substantial issue, you please distribute me a new sdk.

Thanks,
Peter

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: udp listen on the sta+softap mode.

Postby ESP_Faye » Mon Apr 20, 2015 2:29 pm

Hi,

Thanks for your valuable advice.

We will optimize this issue in next SDK which is going to released at the end of April.

nice72
Posts: 10
Joined: Wed Nov 26, 2014 3:47 pm

Re: udp listen on the sta+softap mode.

Postby nice72 » Mon Apr 20, 2015 2:34 pm

Thanks a lot !!

Who is online

Users browsing this forum: No registered users and 1 guest