ESP8266 Developer Zone The Official ESP8266 Forum 2015-09-24T23:38:57+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=1152 2015-09-24T23:38:57+08:00 2015-09-24T23:38:57+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1152&p=3848#p3848 <![CDATA[Re: Outgoing TCP connection in STATIONAP_MODE]]>
Anyway thanks for help.

James

Statistics: Posted by geo.espressif — Thu Sep 24, 2015 11:38 pm


]]>
2015-09-24T23:13:50+08:00 2015-09-24T23:13:50+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1152&p=3847#p3847 <![CDATA[Re: Outgoing TCP connection in STATIONAP_MODE]]>
The key to this particular issue was that it appears I can't create the connection from within the callback. When I use a system task & create the connection within the callback it seems to work ok.

Statistics: Posted by geo.espressif — Thu Sep 24, 2015 11:13 pm


]]>
2015-09-24T21:10:34+08:00 2015-09-24T21:10:34+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1152&p=3845#p3845 <![CDATA[Re: Outgoing TCP connection in STATIONAP_MODE]]>
Sounds great in theory ... but where I now get confused is that in Station+AP mode, the ESP is "multi homed" ... i.e. it has TWO network interfaces. One to the network of stations that are connected to it as an access point and one to the network it joined to the external access point. And THAT then leads me to the need for a routing table ... which I have not seen any mention of in any of the docs.

Statistics: Posted by kolban — Thu Sep 24, 2015 9:10 pm


]]>
2015-09-24T17:18:55+08:00 2015-09-24T17:18:55+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1152&p=3839#p3839 <![CDATA[Outgoing TCP connection in STATIONAP_MODE]]>

Code:

wifi_set_opmode_current( STATIONAP_MODE );


My connection code is made from the

Code:

case EVENT_STAMODE_GOT_IP
of the wifi event callback, and my connection code is as follows:

Code:

os_memset( &connector, 0, sizeof(connector));
       connector.type = ESPCONN_TCP;
       connector.state = ESPCONN_NONE;
       connector.proto.tcp = &tcp_con;
   
       os_memset( &tcp_con, 0, sizeof(tcp_con));
       tcp_con.local_port = espconn_port();
       tcp_con.remote_port = tcp_port;
       os_memcpy ( tcp_con.remote_ip, serverIp, 4 );

       espconn_regist_connectcb( &connector, tcpConnected );
       espconn_regist_disconcb( &connector, tcpDisconnected );
      
       if ( err = espconn_connect ( &connector ) != 0 )
       {
      os_printf ( "Error connecting: %d", err );
       }


Basically in STATION_MODE, it connects immediately, in STATIONAP_MODE, it doesn't do anything. I was sure to set the local_ip in the tcp structure, and the esp_connect function seems to return '1', which is indicated as an error in the documentation but it doesn't list which one (i.e. anything non 0 is apparently an error, but 1 is not one of the listed types).

Any ideas? Making an outbound connection when an AP is being hosted should work right? I'm using version 1.3 of the SDK.

Statistics: Posted by geo.espressif — Thu Sep 24, 2015 5:18 pm


]]>