Hi ,
I couldnt upload the file so Pasted the code here itself.
Pls help
static u8 snd_buffer[12002];
static u8 snd_bufferr[12002];
unsigned char dev_status = 0;
int atwritecnt=0;
/***********************************************************************************
READ THE DATA FROM UART
***********************************************************************************/
bool fcmdatahandler2(u16 datalen,u8 *data)
{
//adl_atSendResponsePort(ADL_AT_RSP, uart1_port,("Data at the Uart port \n" ));
//adl_atSendResponsePort(ADL_AT_RSP, uart1_port," data at uart\n");
u16 counter;
if((dev_status & 0x01) == 0)
{
for(counter=0;counter<datalen;counter++)
{
// if(data[counter]=='T' &&data[counter+1]=='H')
// adl_atSendResponsePort(ADL_AT_RSP, uart1_port,"Rcvd the End\n");
snd_bufferr[atwritecnt] = (u8)data[counter];
atwritecnt++;
}
if(atwritecnt >= 12000)
{
dev_status |= 0X01;
atwritecnt = 0;
adl_atSendResponsePort(ADL_AT_RSP, uart1_port," 1200byt\n");
//send_sms("Oh thanks god i have received 12784b of data using status");
//strcpy(snd_buffer,snd_bufferr);
wm_memcpy(snd_buffer,snd_bufferr,12000);
wm_memcpy(snd_bufferr,"",12002);
//Call FTP appln to upload the data
adl_tmrSubscribe ( FALSE, 100, ADL_TMR_TYPE_100MS, appli_entry_point());
}
}
return TRUE;
}
/*****************************************************************/
/ Function : evh_data /
/-------------------------------------------------------------------------/
/ Object : Handling events happenning on the TCP client socket. /
/-------------------------------------------------------------------------/
/ Variable Name |IN |OUT|GLB| Utilisation /
/--------------------±–±--±–±---------------------------------------/
/ ev | X | | | WIP event /
/--------------------±–±--±–±---------------------------------------/
/ ctx | X | | | user data (unused) /
/--------------------±–±--±–±---------------------------------------/
/***************************************************************************/
static void evh( wip_event_t *ev, void *ctx) {
switch( ev->kind) {
case WIP_CEV_OPEN: {
wip_debug ("[SAMPLE] Connection established successfully\n");
adl_atSendResponsePort(ADL_AT_RSP, uart1_port,("[SAMPLE] Connection established successfully\n"));
break;
}
case WIP_CEV_READ: {
int nread;
wip_debug ("[SAMPLE] Some data arrived\n");
adl_atSendResponsePort(ADL_AT_RSP, uart1_port,("[SAMPLE] Some data arrived\n"));
nread = wip_read( ev->channel, rcv_buffer + rcv_offset,
sizeof( rcv_buffer) - rcv_offset);
if( nread < 0) { wip_debug( “[SAMPLE] read error %i\n”, nread); return; }
rcv_offset += nread;
if( rcv_offset == sizeof( rcv_buffer)) {
wip_debug( “[SAMPLE] Reception capacity exceeded, won’t read more\n”);
} else {
wip_debug( “[SAMPLE] Wrote %i bytes of data from network to rcv_buffer. "
“%i bytes remain available in rcv_buffer\n”,
nread, sizeof( rcv_buffer) - rcv_offset);
}
break;
}
case WIP_CEV_DONE:
wip_debug (” Your Data Uploaded successfully\n");
adl_atSendResponsePort(ADL_AT_RSP, uart1_port,(" Your Data Uploaded successfully\n"));
break;
case WIP_CEV_WRITE: {
int nwrite;
// wip_debug ("[SAMPLE] Can send more data\n");
// wm_memcpy(snd_buffer+Mkdatalen,"",2000-Mkdatalen);
// adl_atSendResponsePort(ADL_AT_RSP, uart1_port,("[SAMPLE] Can send more data\n"));
nwrite = wip_write( ev->channel, snd_buffer + snd_offset,
sizeof( snd_buffer) - snd_offset);
if( nwrite < 0) { wip_debug( “[SAMPLE] write error %i\n”, nwrite); return; }
snd_offset += nwrite;
if( snd_offset == sizeof( snd_buffer)) {
dev_status &=~0x01;
wm_memcpy(snd_buffer,"",1002);
wip_debug( "[SAMPLE] Everything has been sent, won't send more.\n");
adl_atSendResponsePort(ADL_AT_RSP, uart1_port,("[SAMPLE] Everything has been sent, won't send more.\n"));
print("[SAMPLE] Everything has been sent, won't send more.\n");
//wip_debug("Buffer which has sent %s", snd_buffer);
;
wip_close( ev->channel);
} else {
wip_debug( "[SAMPLE] Wrote %i bytes. "
"%i bytes left to send in snd_buffer\n",
nwrite, sizeof( snd_buffer) - snd_offset);
}
break;
}
case WIP_CEV_ERROR: {
wip_debug( “[SAMPLE] Error %i on socket. Closing.\n”,
ev->content.error.errnum);
adl_atSendResponsePort(ADL_AT_RSP, uart1_port,("[SAMPLE] Error %i on socket. Closing.\n"));
wip_close( ev->channel);
adl_tmrSubscribe ( FALSE, 100, ADL_TMR_TYPE_100MS, FTP_TimerHandler18MS);//call FTP after time out
break;
}
case WIP_CEV_PEER_CLOSE: {
wip_debug( “[SAMPLE] Connection closed by peer\n”);
adl_atSendResponsePort(ADL_AT_RSP, uart1_port,("[SAMPLE] Connection closed by peer\n"));
wip_close( ev->channel);
break;
}
}
}