📄 main.cpp
字号:
#include <stdio.h> // 包含所需的C运行库
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <time.h>
#include <dos.h>
#include <dir.h>
#include "etr_ppp.h" // 英创TCP/IP库
#include "gprs.h"
#include "etr232i.h"
#include "WSP.H"
int main( )
{
int i2, FirstFlag;
unsigned char host[11] = "10.0.0.172";
unsigned char url[42] = "wap.monternet.com";
char url1[42] = "http://mmsc.monternet.com/";
unsigned char OwnIPStr[20];
unsigned char buffer[1460];
char buffer1[2000];
int length;
int status = 0;
int ret;
FILE *fp;
PPPGPRSState PPPState;
for(FirstFlag=0,i2=-1;;) // 系统主循环
{
PPPState = PPP_Running( ); //拨号上网
if ( PPPState!=PPPLINKUP ) //判断拨号上网否网成功(GPRS是否连接上)否则等待
{
FirstFlag = 0;
if ( PPPState != i2 )
{
printf( "RIdx=%d ", PPPState );
i2 = PPPState;
}
continue;
}
if ( FirstFlag==0 )
{
GetOWNIP( OwnIPStr );//获取IP地址
printf( "\nIP=%d.%d.%d.%d\n", OwnIPStr[0], OwnIPStr[1], OwnIPStr[2], OwnIPStr[3] );
FirstFlag = 1;
break;
}
}
// wap open
if (!WspInit( TARGET_WAP_BROWSER, host, 9201 ))
{
printf("can not open wap\r\n");
WspClose();
return 0;
}
printf("open wap success\r\n");
// wap Request
if (!WspConnect())
{
printf("wap connect fail\r\n");
WspClose();
return 0;
}
if (!WspIsConnectEstablished())
{
printf("wap connect fail\r\n");
WspClose();
return 0;
}
printf("wap connect success\r\n");
/*if (!WspMethodInvoke(METHOD_GET, url, NULL, 0))
{
printf("wap get invoke fail\r\n");
WspClose();
return 0;
}
printf("wap get invoke success\r\n");
if (!WspReply(&status, buffer, 1460))
{
printf("wap response fail\r\n");
WspClose();
return 0;
}
printf("wap response success\r\n");
printf("status: %d\r\n", status);
if (!WspMethodInvoke(METHOD_GET, url, NULL, 0))
{
printf("wap get invoke fail\r\n");
WspClose();
return 0;
}
printf("wap get invoke success\r\n");
if (!WspReply(&status, buffer, 1460))
{
printf("wap response fail\r\n");
WspClose();
return 0;
}
printf("wap response success\r\n");
printf("status: %d\r\n", status);*/
fp = fopen("TEST.MMS", "r+b");
if (fp == NULL)
{
printf("Can Not Open File\r\n");
WspClose();
return 0;
}
ret = (int)fread(buffer1, 1, 2000, fp);
if (!WspMethodInvoke(METHOD_POST, url1, buffer1, ret))
{
printf("wap post invoke fail\r\n");
fclose(fp);
WspClose();
return 0;
}
printf("wap post invoke success\r\n");
fclose(fp);
if (!WspReply(&status, buffer, 1460))
{
printf("wap response fail\r\n");
WspClose();
return 0;
}
printf("wap response success\r\n");
printf("status: %d\r\n", status);
WspClose();
printf("wap close success\r\n");
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -