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(;
{
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);
}