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

📄 gsmport.h

📁 GSM通讯串口类,通过RS232串口与GSM MODEM连接,发送短信.
💻 H
字号:
// GSMPort.h: interface for the CGSMPort class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_GSMPORT_H__7EE22FA1_9A43_4E2E_86AB_491C2FAE24DE__INCLUDED_)
#define AFX_GSMPORT_H__7EE22FA1_9A43_4E2E_86AB_491C2FAE24DE__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "SerialPort.h"
#include <afxcoll.h>

class CGSMDataFrame : public CObject
{

#define COMMAND_LENGTH 2

public:
	CGSMDataFrame();
	virtual ~CGSMDataFrame();

	operator BYTE*(void) const { return m_lpMsgData; }

	BOOL CopyMsg(const BYTE* lpMsgData, const UINT& nMsgDataLength);
	void Detach(void);

	UINT GetNumOfMsg(void) const { return m_arrNumOfMsg.GetSize(); }
	UINT GetDataFrameLength(void) const { return m_nMsgDataLength; }

	BOOL NewEmptyFrame(const UINT& nLength = 140);
	
	BOOL	SetCommand(const USHORT& Command);
	USHORT	GetCommand(const UINT& nIndex) const;
	BOOL	SetDataFrame(const CString& strData);
	BYTE*	GetDataFrame(const UINT& nIndex, UINT& pMsgLength);

	friend class CGSMPort;

private:
	void AnalyseMsg(void);

private:
	BYTE*	m_lpMsgData;
	UINT	m_nMsgDataLength;

	CUIntArray m_arrNumOfMsg;

	DECLARE_DYNAMIC(CGSMDataFrame)
};

class CGSMPort : public CSerialPort  
{
	
#define _00H	0x00AA
#	define _00H_MODEMINFO		_T("HRH GSM MODEM")
#	define _00H_MODEMINITIAL	_T("GSM MODEM INITIAL OK")
#	define _00H_MODEMENGINE		_T("GSM ENGINE FAILURE !")
#	define _00H_MODEMSIMERROR	_T("SIM CARD ERROR !")
#	define _00H_MODEMNOTSIM		_T("NOT FIND SIM CARD !")
#	define _00H_MODEMANTENNA	_T("ANTENNA ERROR !")
#	define _00H_MODEMOTHER		_T("DATA ERROR !")
#define _01H	0x01AA
#	define _01H_ERROR		_T("ERROR")
#	define _01H_OK			_T("OK")
#	define _01H_SENDOK		_T("SEND OK")
#	define _01H_SUCCESS		_T("SUCCESS")
#	define _01H_FAILURE		_T("FAILURE")
#define _02H	0x02AA
#define _03H	0x03AA
#define _07H	0x07AA
#define _09H	0x09AA
#define _10H	0x10AA
#define _11H	0x11AA
#define _12H	0x12AA
#define _13H	0x13AA
#define _14H	0x14AA
#define _15H	0x15AA
#define _16H	0x16AA
#define _20H	0x20AA
#define _21H	0x21AA

public:
	CGSMPort();
	virtual ~CGSMPort();

	void SendGsmMsg(const USHORT& Command, const CString& strData);

	CString Process_00H(const BYTE* lpMsgData, const UINT& nMsgLength);
	CString Process_01H(const BYTE* lpMsgData, const UINT& nMsgLength);
	BYTE Process_14H(const BYTE* lpMsgData, const UINT& nMsgLength);

protected:
	virtual BOOL HandleReadedEvent(LPVOID pParam, const DWORD& dwReadCount);
	virtual BOOL HandleWriteEvent(void);

private:
	CGSMDataFrame m_DataFrame;

	DECLARE_DYNAMIC(CGSMPort)
};

#endif // !defined(AFX_GSMPORT_H__7EE22FA1_9A43_4E2E_86AB_491C2FAE24DE__INCLUDED_)

⌨️ 快捷键说明

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