RCM6600W wont connect to a device after DHCP

After successful DHCP the RCM6600W will not connect further via TCP to a device on the
same network nor will it allow TCP connections to itself and produces a connection
refused on the client end". We have proven that the unit can be Pinged so we know
the DHCP was correct.

Here is the code we think should work-

#define TCPCONFIG 5

#define WIFI_USE_WPA // Bring in WPA_PSK support
#define WIFI_AES_ENABLED // Enable AES specific code
#define IFC_WIFI_ROAM_ENABLE 1
#define IFC_WIFI_ROAM_BEACON_MISS 20
#define IFC_WIFI_MODE IFPARAM_WIFI_INFRASTRUCTURE
#define IFC_WIFI_REGION IFPARAM_WIFI_REGION_AMERICAS
#define IFC_WIFI_ENCRYPTION IFPARAM_WIFI_ENCR_CCMP // Define cypher suite
//#define WIFI_VERBOSE_PASSPHRASE

#define IFC_WIFI_SSID “Verizon-MiFi6620L-070F”
#define IFC_WIFI_WPA_PSK_PASSPHRASE “9c3d8e78”

#define VERBOSE
#define BOOTP_VERBOSE

#memmap xmem

#use “dcrtcp.lib”
#use “tcp_config.lib”
#use “rcm66xxw.lib”
//-------------------------------------------------------------

#define DEST_IP “192.168.1.4”
#define PORT 500

tcp_Socket socket;

int DESTstatus, Ctrys;
longword DESTip;

void delayMs(unsigned long delay)
{
auto unsigned long time0;

for (time0 = MS_TIMER; MS_TIMER - time0 < delay; )
	tcp_tick(NULL);

}

void main(void)
{
unsigned char buffer[100];
int TcpOpenStat;
unsigned long ip;
unsigned long Dip;

char ipbuf[20];


printf( "Initializing network...

");

ifconfig( IF_WIFI0, IFG_IPADDR, &ip, IFS_END);

printf("
Sock Init
");
sock_init();

printf("
Starting DHCP:
");
dhcp_acquire();

for(;:wink:
{
delayMs(1000);
ifconfig( IF_WIFI0, IFG_IPADDR, &Dip, IFS_END);
if(Dip != ip)
break;
dhcp_acquire(); // this helps for sleeping network
printf(“.”);
}
printf( "My IP Address is now %s.
", inet_ntoa( ipbuf, Dip));
// DHCP now has an address for us

printf("Connecting host
");
Ctrys = 30;

ReTryConnect:

			DESTip = resolve(DEST_IP);
			TcpOpenStat = tcp_open(&socket, 0, DESTip, PORT, NULL);


		   sock_wait_established(&socket, 0, NULL, &DESTstatus);
			sock_mode(&socket, TCP_MODE_ASCII);
        printf("Established

");
if (DESTstatus == -1)
{
printf("Timout
");
exit(1);
}

			if (DESTstatus != 0)
			{
           printf("Unknown error

");
exit(1);
}
printf("Connected
");

		sprintf(buffer,"Connection to SERVER Established

");
sock_write(&socket,buffer,35);
printf("Response Sent…Should see on SERVER
");
exit(0);

sock_err:
printf("sock error = %x Stat=%x Tries=%d
", TcpOpenStat, DESTstatus, Ctrys);

  		tcp_close(&socket);
	  	sock_close(&socket);

		Ctrys --;
		if(Ctrys > 0)
     {
     	delayMs(500);
			goto ReTryConnect;
     }
     printf("retry error error

");
exit(1);

}

I believe dhcp_acquire() is a deprecated API. You should be calling tcp_tick() repeatedly in your loop while waiting for the connection to come up. You can use set_timeout() and chk_timeout() to do things every 1000ms inside the loop calling tcp_tick(). You can use ifpending() to determine if the interface is up.

If that doesn’t resolve the problems:

What is the result of TcpOpenStat? If you aren’t using Ethernet, try defining DISABLE_ETHERNET in your Project Options and running the code again.

There was a recent bug fix related to the default route when using both Ethernet and Wi-Fi interfaces: https://github.com/digidotcom/DCRabbit_10/commit/89cf78849625243511e77fd42c16edf56ec2e7f9

Make sure you’re running Dynamic C 10.72C (installer on www.digi.com) in case there are other routing bugs that have already been fixed.

1 Like