gmodem.h

来自「GmsModemDll Gms ModemDll 关于GPRS MODEM的」· C头文件 代码 · 共 129 行

H
129
字号
/*
* Copyright (c) 2003,Shenzhen TaiJi SoftWare
* All rights reserved.
* 
* Name of the File:			GModem.h
* symbol of the File:		Descript in DVS UML
* Summary:					Send and Receive SM by GSM Modem class
* 
* Current Version:			1.1
* Author:					DengYangjun
* Created Date:				17:09 01-10-2004
* Finished Date:			??
*
* Substitutional Version:	
* Original Author:
* Finished Date:
*/

// GModem.h: interface for the CGModem class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_GMODEM_H__5F479E3F_DA8D_4A70_B70C_E261BD420755__INCLUDED_)
#define AFX_GMODEM_H__5F479E3F_DA8D_4A70_B70C_E261BD420755__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
 
#include "ComPort.h"	//for use class CCommPort
#include "TJMdmApi.h"	//for STRU_SMS

class CGModem  
{

public:
	CGModem();
	virtual ~CGModem();

	//Mothord
	BOOL LinkModem(UINT nPort);
	BOOL SendSm(LPCTSTR destAddr, LPCTSTR userData, UINT nSmsFormat=UDP);
	INT  ReadSm(STRU_SMS* pSm, UINT nIndex ,INT iProperty=-1);
	BOOL DelSm(UINT nIndex);
	UINT GetError(LPSTR error);
	BOOL SaveLog(LPCTSTR logFileName, BOOL add=TRUE);
	void SetNewSmEvent(UINT nMessage, HWND hWnd);
	void GetLog(LPSTR log, UINT nMaxLength);
	void Close();

	static BOOL ExecCmd(CString sCommand);

public:
	//attribute

	enum SM_SEND_MODE					//Send Mode
	{
		TEXT,
		UDP
	};

	//error description
	enum GMODEM_API_ERROR_DESP
	{
		GMODEM_OPEN_COMM_FAIL=1,		//1:open comm port fail or 
										//comm port is not exsit
		GMODEM_LINK_MODEM_FAIL,			//2:Modem is not exsit can't 
										//execute AT command
		GMODEM_EXECUTE_TIME_OUT,		//3:can not execute comamnd in Timeout
		
		GMODEM_NOT_LINKED,				//4:Not linked modem

	};

	static LsComm::CComPort m_ComPort;	//Comm Tools class
	static STRU_SMS m_readSm;			//the temp of readsm
	static CString m_sErrorDesp;		//desription of error
	static UINT m_nMessageID;			//when receive new SM, send the message
	static HWND m_hMessageWnd;			//handle of window who receive the message 

protected:

//--------------------------------------------------------------------
	 static void OnReceiveData(LPVOID pSender,void* pBuf,DWORD InBufferCount);
	CString CreatePduSms(CString sDestADdr,CString userData, UINT *nDataLength);
	
//--------------------------------------------------------------------

private:
	//constant define 
	enum GMODEM_CONST
	{
		MAX_COUNT_SM_STORAGE=100,	//Max count of sim storage
	};

	enum COMM_RESPONSE				//Comm Response
	{
		RESPONSE_OK,
		RESPONSE_ERROR,
		RESPONSE_TIMEOUT,
		RESPONSE_FAIL,
		
		//About SM
		RESPONSE_SEND_SM,
		RESPONSE_READ_SM,
		RESPONSE_DELETE_SM,
		RESPONSE_INPUT,
		RESPONSE_LIST_SM,
	};

	//Mothords
	static void HandleResponse(CString sResponse);
	static STRU_SMS  ResolvePduSm(CString sReceiveData, int iLength, int iProperty, int iIndex);
	COMM_RESPONSE  WaitAnswer(DWORD dwMiliseconds);
	COMM_RESPONSE  WaitSingleAnswer(COMM_RESPONSE response, DWORD dwMiliseconds);
	static void OnReceiveSm(CString sNewSm);
	
	//Attribute
	UINT m_nError;				//Index of error
	UINT  m_smsFormat;			//Mode of send SM		
	static int m_iCurrentIndex;	//the index of current operate SM
	static BOOL m_fIsLinked;	//is Linked Modem
	static CStringArray m_commandSet;  //sCommand string set	
	SM_SEND_MODE m_currentMode;	//Current modem's Mode
	static	HANDLE m_responseEvent[RESPONSE_LIST_SM+1];  //singal object
};

#endif // !defined(AFX_GMODEM_H__5F479E3F_DA8D_4A70_B70C_E261BD420755__INCLUDED_)

⌨️ 快捷键说明

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