-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSMSEngine.h
103 lines (84 loc) · 2.82 KB
/
SMSEngine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/////////////////////////////////////////////////////////////////////////////
// SMSEngine.h
//
// Copyright (C) 2013 Veria Kalantari
// veria.kalantary@gmail.com
// https://github.com/veriak
//
#ifndef SMS_ENGINE_INCLUDED
#define SMS_ENGINE_INCLUDED
#pragma once
#include <list>
#include "SerialCommPort.h"
#include "StrConversion.h"
using namespace SerialCommPort;
using namespace StrConversion;
namespace SMSEngine
{
#define MAXEXPECTEDRESULTS 5
struct ReadMessage
{
char szMessageBody[161];
char szMobileNumber[15];
char szMessageTime[20];
char szMessageCenter[15];
int nMessageSegmentCount;
int nMessageSegmentNumber;
int nMessageIndex;
int nMessageNestNumber;
int nMessageType;
};
typedef std::list<ReadMessage> ReadMessageList;
class CSMSEngine : public CSerialCommPort
{
private:
HINSTANCE m_hInstance;
HWND m_hWnd;
LPTSTR m_ptcsPortName;
LPVOID m_pReadBuff;
int m_nReadBuffSize;
int m_nTotalReadSize;
int m_nExpectedResultsCount;
LPCSTR m_pExpectedResults[MAXEXPECTEDRESULTS];
LPCSTR m_pszFoundResult;
HANDLE m_hExpectedResultEvent;
bool m_bMessageFormat;
CRITICAL_SECTION m_csLock;
int m_nRefNum;
protected:
void ClearBuffer(LPVOID &lpBuff);
virtual void Clear(void);
void CleanUp(void);
static LRESULT CALLBACK OnCommReadEvent(CSMSEngine *_this, DWORD dwBytesRead);
public:
CSMSEngine(void);
CSMSEngine(LPCTSTR lptcsPortName, DWORD dwBaudRate = 9600);
~CSMSEngine(void);
void Init(void);
void Init(LPCTSTR lptcsPortName, DWORD dwBaudRate = 9600);
void LockThis();
void UnLockThis();
void InitLock();
void DelLock();
char *SwapBuffer(char *lpBuffer, int nBuffSize);
char *SwapMobileNumber(char *lpszBuffer);
int StrToPDU(LPSTR lpszBuffer);
int PDUToStr(LPBYTE lpPDUBuffer, int nPDULen, LPSTR lpszStrBuffer);
bool CheckGSMModemActivity(void);
bool SetCMGF(bool bMessageFormat = false);
bool SetCPMS(LPCSTR lpszMS = "SM");
bool SetSMSC(LPCSTR lpszSMSCNumber);
bool SendTextMessage(LPCSTR lpszMobileNumber, LPCSTR lpszMessageBody, int nWaitTimeInSec = 60);
bool SendPDUMessage(LPCSTR lpszMobileNumber, LPCSTR lpszMessageBody, int nWaitTimeInSec = 60);
bool SendUnicodeMessage(LPCSTR lpszMobileNumber, LPCWSTR lpwcsMessageBody, int nWaitTimeInSec = 60);
bool GetIMEI(LPSTR lpszIMEIBuff);
bool DeleteMessage(LPCSTR lpszMessageIndex);
bool SendVCard(LPCSTR lpszMobileNumber,
LPCSTR lpszVCardName, LPCSTR lpszVCardNumber, int nWaitTimeInSec = 60);
bool GetReadMessageList(ReadMessageList *lpReadMessageList,
int nMessageType = 0, int nWaitTimeInSec = 60);
bool SendLongPDUMessage(LPCSTR lpszMobileNumber, LPCSTR lpszMessageBody, int nWaitTimeInSec = 60);
bool SendLongUnicodeMessage(LPCSTR lpszMobileNumber, LPCWSTR lpwcsMessageBody, int nWaitTimeInSec = 60);
};
}
#endif