⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 replysmsdlg.cpp

📁 代码为windows下的无线猫的应用程序(对AT指令的操作)。
💻 CPP
字号:
// ReplySMSDlg.cpp : implementation file
//

#include "stdafx.h"
#include "SIMTOOL.h"
#include "ReplySMSDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CReplySMSDlg dialog
extern CSIMTOOLApp theApp;

CReplySMSDlg::CReplySMSDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CReplySMSDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CReplySMSDlg)
	m_Center = _T("");
	m_SMS = _T("");
	m_Tonum = _T("");
	//}}AFX_DATA_INIT
}


void CReplySMSDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CReplySMSDlg)
	DDX_Control(pDX, IDC_INFO, m_Info);
	DDX_Text(pDX, IDC_CENTER, m_Center);
	DDX_Text(pDX, IDC_SMS, m_SMS);
	DDV_MaxChars(pDX, m_SMS, 140);
	DDX_Text(pDX, IDC_TONUM, m_Tonum);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CReplySMSDlg, CDialog)
	//{{AFX_MSG_MAP(CReplySMSDlg)
	ON_BN_CLICKED(IDC_BTNSEND, OnBtnsend)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CReplySMSDlg message handlers

BOOL CReplySMSDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CReplySMSDlg::ShowWindow(TRUE);
	m_Center = "+8613800100500";
	m_Tonum = m_Num;

	UpdateData(FALSE);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CReplySMSDlg::InfoCreate(CString sName, CString sNum, UINT nIDTemplate)
{
	m_Name = sName;
	m_Num = sNum;

	CReplySMSDlg::Create(nIDTemplate);
}

void CReplySMSDlg::OnOK() 
{
	// TODO: Add extra validation here
	
	CDialog::OnOK();
	CReplySMSDlg::DestroyWindow();
}

void CReplySMSDlg::OnBtnsend() 
{
	// TODO: Add your control notification handler code here
	CString RetInfo, toadr, centernum, sms, sDevComm, sStatus, sAppComm;
	unsigned char cUsc2[500];
	char buf[250], cText[100], comm[20];
	int iLen;

	memset(comm, 0, 20);
	memset(cText, 0, 100);
	memset(buf, 0, 250);
	memset(cUsc2, 0, 500);
	
	sAppComm = theApp.GetAppComm();
	sprintf(comm, "%s", sAppComm);
	theApp.SetStatusText("正在寻找GPRS无线网络设备,请稍后...");
	m_Info.SetWindowText("正在寻找GPRS无线网络设备,请稍后...");
	theApp.SetDevText("");
	sDevComm = theApp.OpenDev(comm, 9600);
	if (sDevComm.GetLength() == 0)
	{
		theApp.SetStatusText("设备未被找到或端口未被初始化,正在尝试初始化...");
		m_Info.SetWindowText("设备未被找到或端口未被初始化,正在尝试初始化...");
		sDevComm = theApp.MultiBautOpenDev(comm);
		if (sDevComm.GetLength() == 0)
		{
			theApp.mobile.CloseComm();
			theApp.SetStatusText("没有找到设备或端口波特率不匹配,请确定设备是否连接...");
			m_Info.SetWindowText("没有找到设备或端口波特率不匹配,请确定设备是否连接...");
			MessageBox("没有找到设备或端口波特率不匹配!", "AWS");
			return;
		}
		else
		{
			theApp.SetStatusText("端口初始化完成,正在打开端口...");
			m_Info.SetWindowText("端口初始化完成,正在打开端口...");
			sDevComm = theApp.OpenDev(comm, 9600);
		}
	}

	UpdateData(TRUE);
	GetDlgItem(IDC_TONUM)->GetWindowText(toadr);
	GetDlgItem(IDC_CENTER)->GetWindowText(centernum);
	sms = m_SMS;

	if (theApp.GetDevType() == "WAVECOM")
	{
		theApp.SetStatusText("");
		sprintf(cText, "ADBON GPRS MODEM : %s/%d", sDevComm, 9600);
		theApp.SetDevText(cText);

		if (toadr.GetLength()==0 || centernum.GetLength()==0 || sms.GetLength()==0)
		{
			theApp.mobile.CloseComm();
			MessageBox("请将信息填写完整!", "AWS");
			return;
		}
		m_Info.SetWindowText("发送短信息到");
		
		theApp.mobile.CSCA(centernum);
		Sleep(10);
		RetInfo = theApp.mobile.ReceiveInfo();
		theApp.mobile.CMGS(toadr, sms);
		Sleep(10);
		RetInfo = theApp.mobile.ReceiveInfo();
	}

	if (theApp.GetDevType() == "BENQ")
	{
		theApp.SetStatusText("");
		sprintf(cText, "ADBON GPRS MODEM : %s/%d", sDevComm, 9600);
		theApp.SetDevText(cText);

		if (toadr.GetLength()==0 || centernum.GetLength()==0 || sms.GetLength()==0)
		{
			theApp.mobile.CloseComm();
			MessageBox("请将信息填写完整!", "AWS");
			return;
		}
		m_Info.SetWindowText("发送短信息到("+m_Name+")"+m_Tonum);

		sprintf(buf, "%s", sms);
		
		theApp.mobile.CSCA(centernum);
		Sleep(10);
		RetInfo = theApp.mobile.ReceiveInfo();
		
		iLen = strlen(buf);
		theApp.mobile.gsmEncodeUcs2(buf, cUsc2, iLen);
		theApp.mobile.gsmBytes2String(cUsc2, buf, iLen*2);
		sms = buf;

		theApp.mobile.CFUN();
		Sleep(10);
		RetInfo = theApp.mobile.ReceiveInfo();
	
		theApp.mobile.COPS();
		Sleep(10);
		theApp.mobile.ReceiveInfo();
	
		theApp.mobile.QCOPS();
		Sleep(10);
		theApp.mobile.ReceiveInfo();
	
		theApp.mobile.CMGF("1");		// 短信格式: 0: PDU; 1: TEXT
		Sleep(10);
		RetInfo = theApp.mobile.ReceiveInfo();

		theApp.mobile.CSCS("\"UCS2\"");
		Sleep(10);
		RetInfo = theApp.mobile.ReceiveInfo();

		theApp.mobile.CSMP(17,168,0,8);
		Sleep(10);
		RetInfo = theApp.mobile.ReceiveInfo();

		theApp.mobile.CMGS("\""+toadr+"\"", "00000000"+sms);
		Sleep(10);
		RetInfo = theApp.mobile.ReceiveInfo();
	}
	if (theApp.GetDevType() == "SAGEM MO1xx")
	{
		theApp.mobile.SetModuleType("SAGEM MO1xx");
		MessageBox("SAGEM MO1xx", "AWS");
	}

	m_SMS = "";
	UpdateData(FALSE);
	theApp.mobile.CloseComm();
	m_Info.SetWindowText("信息发送成功!");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -