Ejemplo n.º 1
0
uint16_t MODEM_CheckGPRSDataOut(uint8_t socket)
{
	COMPARE_TYPE cmp1,cmp2;
	Timeout_Type tOut;
	uint8_t buf[32],c;
	DelayMs(100);
	MODEM_FlushBuffer();
	MODEM_Info("\r\nGSM->CHECK OUTCOMING UNACK SOCKET:%d\r\n",socket);
	sprintf((char *)buf, "AT+USOCTL=%d,11\r",socketMask[socket]);
	COMM_Puts(buf);
	InitFindData(&cmp1,"OK");
	InitFindData(&cmp2,"ERROR");
	InitTimeout(&tOut,TIME_MS(1000));
	while(CheckTimeout(&tOut))
	{
		if(RINGBUF_Get(&commBuf,&c) == 0)
		{
			if(FindData(&cmp1,c) == 0)
			{
				MODEM_Info("\r\nGPRS->UNACK:%dBytes\r\n",GPRS_dataUnackLength[socket]);
				return GPRS_dataUnackLength[socket];
			}
			if(FindData(&cmp2,c) == 0)
			{
				MODEM_Info("\r\nGPRS->ERROR\r\n");
				//tcpSocketStatus[socket] = SOCKET_CLOSE;
				break;
			}
		}
	}
	//num of data will check in at_command_parser.c 
	// return GPRS_dataUnackLength
	MODEM_Info("\r\nGPRS->UNACK:%dBytes\r\n",GPRS_dataUnackLength[socket]);
	return 0xffff;
}
Ejemplo n.º 2
0
uint8_t MODEM_CloseSocket(uint8_t socket)
{
	COMPARE_TYPE cmp1,cmp2;
	Timeout_Type tOut;
	uint8_t c;
	uint8_t buf[32];
	DelayMs(100);
	MODEM_FlushBuffer();
	MODEM_Info("\r\nGSM->CLOSE SOCKET:%d\r\n",socket);
	sprintf((char *)buf, "AT+USOCL=%d\r",socket);
	COMM_Puts(buf);
	InitFindData(&cmp1,"OK");
	InitFindData(&cmp2,"ERROR");
	InitTimeout(&tOut,TIME_MS(3000));
	while(CheckTimeout(&tOut))
	{
		if(RINGBUF_Get(&commBuf,&c) == 0)
		{
			if(FindData(&cmp1,c) == 0)
			{
				//MODEM_Info("\r\nGSM->CLOSE SOCKET OK\r\n");
				return 0;
			}
			if(FindData(&cmp2,c) == 0)
			{
				break;
			}
		}
	}
	//MODEM_Info("\r\nGSM->CLOSE SOCKET FAILS\r\n");
	return 0xff;
}
Ejemplo n.º 3
0
/*
+UULOC: 27/09/2012,18:26:13.363,21.0213870,105.8091050,0,127,0,0�
nmea_scanf((char *)buff,128,"%d/%d/%d,%d:%d:%d.%d,%f,%f,%f,%f,%f,%f",&t1,&t2,&t3,&t4,&t5,&t6,&t7,
						cellLocateType.lat,cellLocateType.lon,cellLocateType.alt,cellLocateType.uncertainty,
						cellLocateType.speed,cellLocateType.dir;
					);
*/
uint8_t GetCellLocate(uint8_t *buff)
{
	COMPARE_TYPE cmp1;
	Timeout_Type tOut;
	uint8_t c,i;
	uint32_t t1,t2,t3,t4,t5,t6,t7;
	DelayMs(100);
	MODEM_FlushBuffer();
	MODEM_Info("\r\nGSM->GET CELL LOCATE\r\n");
	sprintf((char *)buff, "AT+ULOC=2,2,1,500,1\r");
	COMM_Puts(buff);
	InitFindData(&cmp1,"+UULOC: ");
	InitTimeout(&tOut,TIME_SEC(3));
	i = 0;
	while(CheckTimeout(&tOut))
	{
		if(RINGBUF_Get(&commBuf,&c) == 0)
		{
			if(FindData(&cmp1,c) == 0)
			{
				i = 1;
				break;
			}
		}
	}
	if(i)
	{	
		InitFindData(&cmp1,"\r\n");
		InitTimeout(&tOut,TIME_SEC(3));
		i = 0;
		while(CheckTimeout(&tOut))
		{
			if(RINGBUF_Get(&commBuf,&c) == 0)
			{
				buff[i++] = c;
				if(FindData(&cmp1,c) == 0)
				{
					nmea_scanf((char *)buff,128,"%d/%d/%d,%d:%d:%d.%d,%f,%f,%f,%f,%f,%f",&t1,&t2,&t3,&t4,&t5,&t6,&t7,
						&cellLocate.lat,&cellLocate.lon,&cellLocate.alt,&cellLocate.uncertainty,
						&cellLocate.speed,&cellLocate.dir);
					cellLocate.ew = 'E';
					cellLocate.ns = 'N';
					if(cellLocate.lat < 0) cellLocate.ns = 'S';
					if(cellLocate.lon < 0) cellLocate.ew = 'W';
					cellLocate.lon = neamFormatLatLng(cellLocate.lon);
					cellLocate.lat = neamFormatLatLng(cellLocate.lat);
					cellLocate.time.mday = t1;
					cellLocate.time.month = t2;
					cellLocate.time.year = t3;
					cellLocate.time.hour = t4;
					cellLocate.time.min = t5;
					cellLocate.time.sec = t6;
					return 0;
				}
			}
		}
	}
	return 0xff;
}
Ejemplo n.º 4
0
wxDirData::wxDirData(
  const wxString&                   rsDirname
)
: m_sDirname(rsDirname)
{
    m_vFinddata = InitFindData();
} // end of wxDirData::wxDirData
Ejemplo n.º 5
0
void wxDirData::Close()
{
    if ( IsFindDataOk(m_vFinddata) )
    {
        FreeFindData(m_vFinddata);
        m_vFinddata = InitFindData();
    }
} // end of wxDirData::Close
Ejemplo n.º 6
0
uint8_t MODEM_CreateSocket(uint8_t socket)
{
	COMPARE_TYPE cmp1,cmp2;
	Timeout_Type tOut;
	uint8_t c;
	DelayMs(100);
	MODEM_FlushBuffer();
	socketMask[socket] = 0xff;
	createSocketNow = socket;
	MODEM_Info("\r\nGSM->CREATE SOCKET\r\n");
	COMM_Puts("AT+USOCR=6\r");
	InitFindData(&cmp1,"OK");
	InitFindData(&cmp2,"ERROR");
	InitTimeout(&tOut,TIME_MS(3000));
	while(CheckTimeout(&tOut))
	{
		if(RINGBUF_Get(&commBuf,&c) == 0)
		{
			if(FindData(&cmp1,c) == 0)
			{
				if((socketMask[socket] == 0xff)) 
				{
					break;
				}	
				MODEM_Info("\r\nGSM->CREATE SOCKET OK\r\n");
				return 0;
			}
			if(FindData(&cmp2,c) == 0)
			{
				break;
			}
		}
	}
	MODEM_Info("\r\nGSM->CREATE SOCKET FAILS\r\n");
	return 0xff;
}
Ejemplo n.º 7
0
uint8_t MODEM_CheckResponse(uint8_t *str,uint32_t t)
{
	COMPARE_TYPE cmp;
	uint8_t c;
	InitFindData(&cmp,str);
	while(t--)
	{
		DelayMs(1);
		if(RINGBUF_Get(&commBuf,&c) == 0)
		{
			if(FindData(&cmp,c) == 0)
			{
				return 0;
			}
		}
	}
	return 0xff;
}
Ejemplo n.º 8
0
static inline FIND_DATA FindFirst(
  const wxString&               rsSpec
, FIND_STRUCT*                  pFinddata
)
{
    ULONG                       ulFindCount = 1;
    FIND_DATA                   hDir = HDIR_CREATE;
    FIND_ATTR                   rc;

    rc = ::DosFindFirst( rsSpec.c_str()
                        ,&hDir
                        ,0x37 // was: FILE_NORMAL
                        ,pFinddata
                        ,sizeof(FILEFINDBUF3)
                        ,&ulFindCount
                        ,FIL_STANDARD
                       );
    if (rc != 0)
        return InitFindData();
    return hDir;
}
Ejemplo n.º 9
0
wxDirData::wxDirData(const wxString& dirname)
         : m_dirname(dirname)
{
    m_finddata = InitFindData();
}
Ejemplo n.º 10
0
uint8_t MODEM_ConnectSocket(uint8_t socket,uint8_t *ip,uint16_t port,uint8_t useIp)
{
	COMPARE_TYPE cmp1,cmp2;
	Timeout_Type tOut;
	uint8_t c,i;
	uint8_t buf[32];
	DelayMs(100);
	MODEM_FlushBuffer();
	socketMask[socket] = 0;
	for(i = 0; i < SOCKET_NUM;)
	{
		if(tcpSocketStatus[i] == SOCKET_OPEN)
		{
			if((socketMask[i] == socketMask[socket]) && (i != socket))
			{
				socketMask[socket]++;
				i = 0;
				continue;
			}
		}
		i++;
	}
	MODEM_CloseSocket(socketMask[socket]);
	if(MODEM_CreateSocket(socket)) return 0xff;
	DelayMs(500);
	if(useIp == 0)
	{
		MODEM_Info("\r\nGSM->GET DOMAIN\r\n");
		sprintf((char *)buf, "AT+UDNSRN=0,\"%s\"\r",ip);
		COMM_Puts(buf);
		if(MODEM_CheckResponse("OK", 5000))
		{
			MODEM_Info("\r\nGSM->GET DOMAIN FAILS\r\n");
			return 0xff;
		}
		ip = DNS_serverIp;
	}
	MODEM_Info("\r\nGSM->IP:%s\r\n",ip);
	MODEM_Info("\r\nGSM->CONNECT SOCKET:%d:%s:%d\r\n",socketMask[socket],ip,port);
	sprintf((char *)buf, "AT+USOCO=%d,\"%s\",%d\r",socketMask[socket],ip,port);
	COMM_Puts(buf);
	InitFindData(&cmp1,"OK");
	InitFindData(&cmp2,"ERROR");
	InitTimeout(&tOut,TIME_SEC(10));
	while(CheckTimeout(&tOut))
	{
		if(RINGBUF_Get(&commBuf,&c) == 0)
		{
			if(FindData(&cmp1,c) == 0)
			{
				MODEM_Info("\r\nGSM->CONNECT SOCKET OK\r\n");
				return 0;
			}
			if(FindData(&cmp2,c) == 0)
			{
				break;
			}
		}
	}
	MODEM_Info("\r\nGSM->CONNECT SOCKET FAILS\r\n");
	return 0xff;
}
Ejemplo n.º 11
0
uint8_t MODEM_GprsSendData(uint8_t socket,uint8_t *data,uint32_t length)
{
	COMPARE_TYPE cmp1;
	Timeout_Type tOut;
	uint8_t buf[32],c;
	uint32_t i;
	uint32_t tryNum = 5;
	MODEM_FlushBuffer();
	sprintf((char *)buf, "AT+USOWR=%d,%d\r",socketMask[socket],length);
	
	for(;;)
	{	
		DelayMs(100);
		COMM_Puts(buf);
		InitTimeout(&tOut,TIME_MS(5000));
		InitFindData(&cmp1,"@");
		while(CheckTimeout(&tOut))
		{
			if(RINGBUF_Get(&commBuf,&c) == 0)
			{
				if(FindData(&cmp1,c) == 0)
				{
					break;
				}
			}
		}
		if(CheckTimeout(&tOut) == TIMEOUT)
		{
			tryNum --;
			if(tryNum == 0) 
			{
				tcpSocketStatus[socket] = SOCKET_CLOSE;
				return 0xff;
			}
			continue;
		}
		i = length;
		for(i = 0; i < length ;i++)
		{
			COMM_Putc(data[i]);
		}
		InitTimeout(&tOut,TIME_MS(5000));
		InitFindData(&cmp1,"OK");
		while(CheckTimeout(&tOut))
		{
			if(RINGBUF_Get(&commBuf,&c) == 0)
			{
				if(FindData(&cmp1,c) == 0)
				{
					MODEM_Info("\r\nGSM->%s OK\r\n",buf);
					DelayMs(100);
					return 0;
				}
			}
		}
		MODEM_Info("\r\nGSM->%s FAILS\r\n",buf);
		tryNum --;
		if(tryNum == 0) 
		{
			tcpSocketStatus[socket] = SOCKET_CLOSE;
			return 0xff;
		}
	}
}