Hi,
I am working on TCP/IP data transfer by using fastrack supreme 20 modem.
I can create TCP/IP connection with client and server mode. There is no problem with client mode.
But I have a problem with server mode. I can create TCP/IP server connection.
But I can only send just one data package and I can not see sending data on hyper terminal,
How I can solve this problem and if possible please send a code sample which uses the server data transfer.
Thanks,
Following my source code for server data transfer :
/***************************************************************************/
#include “adl_global.h”
#include “wip.h”
/***************************************************************************/
const u16 wm_apmCustomStackSize = 1024;
/***************************************************************************/
ascii GPRS_APN[] = “internet”; //APN
ascii GPRS_LOGIN[] = “”; // User Name
ascii GPRS_PASSWORD[] = “”; // Password
wip_in_addr_t my_address = 0;
ascii MyIPAddress[15];
wip_bearer_t b;
wip_channel_t Handle_Channel;
ascii buffer[1000];
/***************************************************************************/
void EventHandler_Channel(wip_event_t *ev, void *ctx)
{
switch (ev->kind)
{
case WIP_CEV_DONE:
{
adl_atSendResponse( ADL_AT_RSP, “\r\n WIP_CEV_DONE \r\n” );
break;
}
case WIP_CEV_ERROR:
{
adl_atSendResponse( ADL_AT_RSP, "\r\n WIP_CEV_ERROR \r\n" );
break;
}
case WIP_CEV_OPEN:
{
adl_atSendResponse( ADL_AT_RSP, "\r\n WIP_CEV_OPEN \r\n" );
break;
}
case WIP_CEV_PEER_CLOSE:
{
adl_atSendResponse( ADL_AT_RSP, "\r\n WIP_CEV_PEER_CLOSE \r\n" );
break;
}
case WIP_CEV_PING:
{
adl_atSendResponse( ADL_AT_RSP, "\r\n WIP_CEV_PING \r\n" );
break;
}
case WIP_CEV_READ:
{
adl_atSendResponse(ADL_AT_RSP", "\r\n WIP_CEV_READ \r\n");
While ( wip_read(Handle_Channel, buffer, 1000) > 0)
{
adl_atSendResponse(ADL_AT_RSP", "\r\n While loop \r\n");
adl_atSendResponse(ADL_AT_RSP", buffer);
}
break;
}
case WIP_CEV_WRITE:
{
adl_atSendResponse( ADL_AT_RSP, "\r\n WIP_CEV_WRITE \r\n" );
break;
}
}
}
/***************************************************************************/
void OpenTCPServerPort(void)
{
Handle_Channel = wip_TCPServerCreate(3000, EventHandler_Channel, NULL);
if (Handle_Channel == NULL)
{
adl_atSendResponse( ADL_AT_RSP, "\r\n OpenTCPServerPort NULL \r\n" );
}
else
{
adl_atSendResponse( ADL_AT_RSP, "\r\n OpenTCPServerPort \r\n" );
}
}
/***************************************************************************/
void EventHandler_Bearer(wip_bearer_t b, s8 event, void *ctx)
{
wip_in_addr_t appIpAddr;
ascii IpAddr[15];
s8 sRet;
ascii TempString[100];
switch (event)
{
case WIP_BEV_CONN_FAILED:
{
wip_bearerStart(b);
adl_atSendResponse( ADL_AT_RSP, “\r\n WIP_BEV_CONN_FAILED \r\n” );
break;
}
case WIP_BEV_IP_CONNECTED:
{
ascii Buffer[50];
sRet = wip_bearerGetOpts(b,WIP_BOPT_IP_ADDR,&appIpAddr,WIP_BOPT_END); // Get your IP address
wip_inet_ntoa(appIpAddr, IpAddr,15);
wm_sprintf(Buffer, "IP address -> %s\r\n",IpAddr);
adl_atSendResponsePort (ADL_AT_RSP, ADL_PORT_UART1, Buffer); // Display your IP address over UART1
OpenTCPServerPort();
break;
}
case WIP_BEV_IP_DISCONNECTED:
{
adl_atSendResponse( ADL_AT_RSP, "\r\n WIP_BEV_IP_DISCONNECTED \r\n" );
break;
}
case WIP_BEV_STOPPED:
{
adl_atSendResponse( ADL_AT_RSP, "\r\n WIP_BEV_STOPPED \r\n" );
break;
}
}
}
//***************************************************************************
void EventHandler_Sim(u8 event)
{
int r;
switch (event)
{
case ADL_SIM_EVENT_FULL_INIT:
r = wip_bearerOpen(&b, "GPRS", EventHandler_Bearer, NULL);
r = wip_bearerSetOpts(b, WIP_BOPT_GPRS_APN, GPRS_APN, WIP_BOPT_LOGIN,GPRS_LOGIN, WIP_BOPT_PASSWORD, GPRS_PASSWORD, WIP_BOPT_END);
r = wip_bearerStart(b);
adl_atSendResponse( ADL_AT_RSP, "\r\n ADL_SIM_EVENT_FULL_INIT \r\n" );
break;
}
}
//***************************************************************************
void adl_main ( adl_InitType_e InitType )
{
s8 Retval;
Retval = wip_netInit();
adl_simSubscribe(EventHandler_Sim, NULL);
adl_atSendResponse( ADL_AT_RSP, “\r\n Main OK \r\n” );
}
//***************************************************************************