2023年7月31日发(作者:)
短信开发包接口文档 杭州爱赛德软件技术有限公司
短信开发包接口文档
版 本 号:V 2.0
杭州爱赛德软件技术有限公司
2001-6-8
第 1 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
目录
1.开发包说明..........................................................................................................3
2.接口函数一览表:..............................................................................................4
3.动态库接口函数说明..........................................................................................5
3.1模块控制函数...............................................................................................5
3.1.1打开模块(OpenComm).................................................................5
3.1.2关闭模块(CloseComm).................................................................5
3.1.3强制关闭模块(ForceCloseComm)................................................6
3.1.4读取模块序列号(GetSerialNo).....................................................7
3.2短信息处理函数...........................................................................................7
3.2.1发送短信息(SendMsg)..................................................................7
3.2.2接收短信(GetNewMsg)................................................................8
3.2.3取得发送队列中短信息数目(GetUnSendCount)........................9
3.2.4取得下一条发送的短信息(GetNextSendMsg)............................9
3.2.5获取发送失败短信(GetFailedMsg)............................................10
3.3短信中心设置函数.....................................................................................11
3.3.1取得短信中心号码(GetSCA).....................................................11
3.3.2设置短信中心号码(SetSCA)......................................................12
4.在DELPHI中使用..............................................................................................13
4.1各接口函数说明.........................................................................................13
4.2函数申明.....................................................................................................13
4.3示例程序.....................................................................................................13
5.在VC中使用....................................................................................................14
5.1各接口函数说明.........................................................................................14
5.2在头文件里做函数申明:.........................................................................14
5.3调用函数.....................................................................................................14
6.在VB中使用....................................................................................................15
6.1各接口函数说明.........................................................................................15
6.2函数申明.....................................................................................................15
6.3示例程序.....................................................................................................15
7.在C++BUILDER中使用........................................................................................16
7.1各接口函数说明.........................................................................................16
7.2在头文件里做函数申明:.........................................................................16
7.3调用函数.....................................................................................................16
第 2 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
1.开发包说明
文件及目录列表:
文件名称
GSM MODEM操作手册.pdf
Dll/
Dll/
Dll/
Dll/短信开发包接口文档.pdf
Example目录
Tools目录
说明
如何正确使用GSM MODEM
通讯处理动态连接库
短信处理动态连接库
LIB库文件(VC中使用)
接口说明文档
例子程序源代码目录,包括VC ,VB,Delphi,C++Builder,PB,Lotus Notes等
包括串口测试工具和模块测试工具
第 3 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
2.接口函数一览表:
第 4 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
3.动态库接口函数说明
3.1模块控制函数
3.1.1打开模块(OpenComm)
打开模块,以便进行短信息的收发操作。
函数申明:
调用语言 函数申明
Visual C++ int __stdcall OpenComm(int ComIndex);
Visual Basic Public Declare Function OpenComm Lib “”
(ByVal CommIndex As Long) As Long
Delphi function OpenComm(CommIndex: LongInt): LongInt;
C++Builder extern "C" long __stdcall OpenComm(long CommIndex);
参数:
参数名称 说明
ComIndex
模块所连接的COM口编号
函数返回:
返回值 说明
0
成功
-5
模块注册失败
-6
打开COM口失败
-9
未检测到GSM模块
-10
设置模块参数失败
-11
保存模块参数失败
注意:
OpenComm ()函数要在调用其他接口函数前调用。
3.1.2关闭模块(CloseComm)
关闭模块,结束对模块的操作。
函数申明:
调用语言
Visual C++
Visual Basic
Delphi
C++Builder
函数申明
int __stdcall CloseComm(int ComIndex);
Public Declare Function CloseComm Lib ""
(ByVal CommIndex As Long) As Long
function CloseComm(CommIndex: LongInt): LongInt;
extern "C" long __stdcall CloseComm(long CommIndex);
第 5 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
参数:
参数名称
ComIndex
说明
模块所连接的COM口编号
函数返回:
返回值
0
-1
-7
-8
说明
成功
发送队列中还有未发消息待发
关闭COM口失败
模块未打开
3.1.3强制关闭模块(ForceCloseComm)
强制关闭模块。
函数申明:
调用语言
Visual C++
Visual Basic
Delphi
C++Builder
参数:
参数名称
ComIndex
函数返回:
返回值
0
-7
-8
注意:
1) 若队列中还有未处理消息,调用该函数将会丢失所以未处理短信
2) 建议调用该函数前先循环调用GetNextSendMsg将所有未发的短信依次取出,以便保存所有未发短信的信息,提高系统的可靠性,具体调用方法详见下文
说明
成功
关闭COM口失败
模块未打开
函数申明
int __stdcall ForceCloseComm(int ComIndex);
Public Declare Function ForceCloseComm Lib ""
(ByVal CommIndex As Long) As Long
function ForceCloseComm(CommIndex: LongInt): LongInt;
extern "C" long __stdcall ForceCloseComm(long CommIndex);
说明
模块所连接的COM口编号
第 6 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
3.1.4读取模块序列号(GetSerialNo)
读取模块的序列号(IMEI)
函数申明:
调用语言 函数申明
Visual C++
bool __stdcall GetSerialNo(int ComIndex,char *SN);
Visual Basic Public Declare Function GetSerialNo Lib "" (ByVal
CommIndex As Long,ByVal SN As String) As Boolean
Delphi function GetSerialNo(CommIndex: LongInt;SN:Pchar): Boolean;
C++Builder extern "C" bool __stdcall GetSerialNo(long CommIndex,char *SN);
参数:
参数名称 说明
ComIndex
模块所连接的COM口编号
SN
取得的序列号的指针
函数返回:
返回值 说明
True
成功
False
失败
3.2短信息处理函数
3.2.1发送短信息(SendMsg)
发送消息,将要发送短信插入发送消息队列。
函数申明:
调用语言 函数申明
Visual C++
int __stdcall SendMsg(int ComIndex,char * Msg,char* Mobile,int
Msg_Index,bool Chinese);
Visual Basic Public Declare Function SendMsg Lib "" (ByVal
CommIndex As Long, ByVal Msg As String, ByVal MobileNo
As String, ByVal MsgIndex As Long, ByVal Chinese As
Boolean) As Long
function SendMsg(CommIndex: LongInt; Msg: Pchar;
MobileNo:Pchar;Msg_Index:LongInt;Chinese:Boolean): LongInt;extern "C" long __stdcall SendMsg(long CommIndex,
char * Msg,char * MobileNo,long Msg_Index,bool Chinese);
Delphi
C++Builder
参数:
第 7 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
参数名称
ComIndex
Msg
MobileNo
说明
模块所连接的COM口编号
短消息内容
接收端手机号码 ,包括普通手机号码和特殊号码,如168
Msg_Index
消息序号,开发商自己定义,方便检索
Chinese
是否为中文信息(中文为True,否则为False)
函数返回:
返回值
0
-2
-3
-4
-8
注意:
本系统采用异步方式发送短信,调用SendMsg函数发送成功的短信插入发送队列,由发送线程负责实际的发送,如果实际发送失败,系统将发送失败的短信转移到另一队列中,可以通过GetFailedMsg取得发送失败的短信,对于发送队列中尚未发送出去的短信,可以通过GetUnSendCount和GetNextSendMsg获取相关的信息,以便搭建可靠性高的应用系统,GetFailedMsg,GetUnSendCount,GetNextSendMsg的具体使用详见下文。
返回参数为-8表示模块未打开,出现模块未打开有几种可能:
• 模块确实没有打开
用户在调用之前先打开模块即可。
• 模块出现异常
在调用之前模块已经正常打开,但出现例如断电或串口连接出问题等等情况,系统会将串口关闭。在恢复正常后,用户必须重新打开模块才能继续使用。
3.2.2接收短信(GetNewMsg)
接收新的短信息。
函数申明:
调用语言
Visual C++
Visual Basic
Delphi
C++Builder
说明
成功,消息已插入发送队列
消息长度超过最大长度
手机号码不正确
发送队列已满
模块未打开
函数申明
bool __stdcall GetNewMsg(int ComIndex,char* NewMsg);
Public Declare Function GetNewMsg Lib “” (ByVal
CommIndex As Long, ByVal NewMsg As String) As Boolean
function GetNewMsg(CommIndex: LongInt; NewMsg:
Pchar):Boolean;
extern "C" bool __stdcall GetNewMsg(long CommIndex,
char * Msg);
第 8 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
参数:
参数名称
ComIndex
NewMsg
函数返回:
返回值
True
False
注意:
1) 返回值为True时,NewMsg为接收到的短信;返回值为False且NewMsg为:“Module Error”时,表示模块当前无响应,可能是断电或模块出故障;返回值为False且NewMsg为空时表示模块在正常工作但没有收到短信
2) 短信息格式:发送端号码+“|”+接收时间+“|”+短信内容短信息格式:发送端号码+“|”+接收时间+“|”+短信内容。此处接收时间指的是短信中心接收到该短信的时间,例如向168发送“GP 0001”,接收到的信息为:168|01-09-28 12:33:39|<0001>深发展A买12.66卖12.68现12.68高12.75低12.55昨12.49量488.87K12:32
说明
成功接收到新的短信
未接收到新的短信
说明
模块所连接的COM口编号
取得的短信息的指针
3.2.3取得发送队列中短信息数目(GetUnSendCount)
取得发送队列中未发短消息的数目。
函数申明:
调用语言 函数申明
Visual C++
int __stdcall GetUnSendCount(int ComIndex);
Visual Basic Public Declare Function GetUnSendCount Lib “”
(ByVal CommIndex As Long) As Long
Delphi function GetUnSendCount(CommIndex: Longint): LongInt;
C++Builder extern "C" long __stdcall GetUnSendCount(long CommIndex);
参数:
参数名称 说明
ComIndex
模块所连接的COM口编号
函数返回:
发送队列中未发短消息的数目。
3.2.4取得下一条发送的短信息(GetNextSendMsg)
读取发送队列中下一条要发送的短信息,通常用于监控实际的发送情况。
第 9 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
函数申明:
调用语言
Visual C++
Visual Basic
Delphi
C++Builder
参数:
函数申明
bool __stdcall GetNextSendMsg(int ComIndex,char* Msg,bool
DeleteAfterRead);
Public Declare Function GetNextSendMsg Lib “”
(ByVal CommIndex As Long, ByVal Msg As String,ByVal
DeleteAfterRead As Boolean ) As Boolean
function GetNextSendMsg(CommIndex: LongInt;Msg:Pchar;
DeleteAfterRead:Boolean):Boolean;
extern "C" bool __stdcall GetNextSendMsg(long CommIndex,
char * Msg,bool DeleteAfterRead);
参数名称
ComIndex
Msg
DeleteAfterRead
说明
模块所连接的COM口编号
取得的短信息的指针
读取该短信后是否将它从队列中删除,True表示读取后删除该短信,False表示读取后保留该短信
函数返回:
返回值
True
False
注意:
1) 该函数只返回发送队列中的第1条未发短信
2) 如果要读取后面的第2条未发短信,可以等到第1条短信发送完毕,或调用本函数时设置参数DeleteAfterRead为True,即读取第1条未发短信后将其删除,这样当前的第2条未发短信将成为第1条未发短信,如此循环可取出所有未发的短信
说明
成功读取到下一条要发送短信
未读到下一条要发送的短信
3.2.5获取发送失败短信(GetFailedMsg)
读取发送失败的短信息。
函数申明:
调用语言 函数申明
Visual C++
bool __stdcall GetFailedMsg(int ComIndex,char* Msg);
Visual Basic
Delphi
C++Builder
Public Declare Function GetFailedMsg Lib “”
(ByVal CommIndex As Long, ByVal Msg As String) As Boolean
function GetFailedMsg(CommIndex: LongInt;Msg:
Pchar):Boolean;
extern "C" bool __stdcall GetFailedMsg(long CommIndex,
char * Msg);
第 10 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
参数:
参数名称
ComIndex
Msg
函数返回:
返回值
True
False
注意:
短信息格式:发送序列号+“|”发送端号码+“|”+短信内容
例如向168发送“GP 0001”,假设序列号为1,若该短信发送失败,则本函数读到的信息为:1|168|GP 0001
1) 若有发送失败的短信,本函数返回最先发送失败的短信
2) 成功读取发送失败的短信后,该短信就从队列中删除
说明
成功读取发送失败的短信
未读到发送失败的短信
说明
模块所连接的COM口编号
取得的短信息的指针
3.3短信中心设置函数
3.3.1取得短信中心号码(GetSCA)
读取模块的短信中心号码。
函数申明:
调用语言 函数申明
Visual C++
bool __stdcall GetSCA(int ComIndex,char * SCA);
Visual Basic Public Declare Function GetSCA Lib “” (ByVal
CommIndex As Long,ByVal SCA As String) As Boolean
Delphi function GetSCA(CommIndex:LongInt;SCA:Pchar):Boolean;
C++Builder extern "C" bool __stdcall GetSCA(long CommIndex,char * SCA);
参数:
参数名称 说明
ComIndex
模块所连接的COM口编号
SCA
取得的短信中心号码的指针
函数返回:
返回值 说明
True
成功取得短信中心的号码
False
取短信中心号码失败
注意:
此函数只能在模块已打开且模块空闲时调用,否则将返回False,模块正在收发短信或开机后的初始化过程中,调用该函数都将返回False
第 11 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
3.3.2设置短信中心号码(SetSCA)
设置模块的短信中心号码。
函数申明:
调用语言 函数申明
Visual C++
bool __stdcall SetSCA(int ComIndex,char * SCA);
Visual Basic Public Declare Function SetSCA Lib “” (ByVal
CommIndex As Long,ByVal SCA As String) As Boolean
Delphi function SetSCA(CommIndex:LongInt;SCA:Pchar):Boolean;
C++Builder extern "C" bool __stdcall SetSCA(long CommIndex,char * SCA);
参数:
参数名称 说明
ComIndex
模块所连接的COM口编号
SCA
短信中心的号码
函数返回:
返回值 说明
True
成功设置了短信中心号码
False
设置短信中心号码失败
注意:
此函数只能在模块已打开且模块空闲时调用,否则将返回False模块正在收发短信或开机后的初始化过程中,调用该函数都将返回False
第 12 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
4.在Delphi中使用
4.1各接口函数说明
各接口函数地说明请参考第三章。
4.2函数申明
function OpenComm(CommIndex: LongInt): LongInt; stdcall;
function CloseComm(CommIndex: LongInt): LongInt; stdcall;
function SendMsg(CommIndex: LongInt; msg,mobileNo:
Pchar;Msg_Index:LongInt;chinese:boolean): LongInt; stdcall;
function GetNewMsg(CommIndex: LongInt; NewMsg:Pchar): boolean; stdcall;
function GetUnSendCount(CommIndex:LongInt):LongInt;stdcall;
function GetSCA(CommIndex:LongInt;SCA:Pchar):Boolean;stdcall;
function SetSCA(CommIndex:LongInt;SCA:Pchar):Boolean;stdcall;
function ForceCloseComm(CommIndex:LongInt):LongInt;stdcall;
function GetFailedMsg(CommIndex:LongInt;Msg:Pchar):Boolean;stdcall;
function GetNextSendMsg(CommIndex:LongInt;Msg:Pchar;
DeleteAfterRead:Boolean):Boolean;stdcall;
implementation
function OpenComm; external '';
function CloseComm; external '';
function SendMsg; external '';
function GetNewMsg;external '';
function GetUnSendCount;external '';
function GetSCA;external '';
function SetSCA;external '';
function ForceCloseComm;external '';
function GetFailedMsg;external '';
function GetNextSendMsg;external '';
4.3示例程序
示例程序详见
第 13 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
5.在VC中使用
5.1各接口函数说明
各接口函数地说明请参考第三章。
5.2在头文件里做函数申明:
int __stdcall OpenComm(int ComIndex);
int __stdcall CloseComm(int ComIndex);
int __stdcall SendMsg(int ComIndex,char * Msg,char* Mobile,int Msg_Index,bool
Chinese);
bool __stdcall GetNewMsg(int ComIndex,char* NewMsg);
int __stdcall GetUnSendCount(int ComIndex);
bool __stdcall GetSCA(int ComIndex,char * SCA);
bool __stdcall SetSCA(int ComIndex,char * SCA);
bool __stdcall GetFailedMsg(int ComIndex,char* Msg);
bool __stdcall GetNextSendMsg(int ComIndex,char* Msg,bool DeleteAfterRead);
int __stdcall ForceCloseComm(int ComIndex);
5.3调用函数
将提供的Ascend_包含在工程中
示例程序详见 ExampleVcDemo Ascend_
第 14 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
6.在VB中使用
6.1各接口函数说明
各接口函数地说明请参考第三章。
6.2函数申明
Public Declare Function OpenComm Lib "" (ByVal CommIndex As Long)
As Long
Public Declare Function CloseComm Lib "" (ByVal CommIndex As
Long) As Long
Public Declare Function SendMsg Lib "" (ByVal CommIndex As Long,
ByVal Msg As String, ByVal MobileNo As String, ByVal MsgIndex As Long, ByVal
Chinese As Boolean) As Long
Public Declare Function GetNewMsg Lib "" (ByVal CommIndex As
Long, ByVal NewMsg As String) As Boolean
Public Declare Function GetUnSendCount Lib "" (ByVal CommIndex As
Long) As Long
Public Declare Function GetSCA Lib "" (ByVal CommIndex As
Long,ByVal SCA As String) As Boolean
Public Declare Function SetSCA Lib "" (ByVal CommIndex As
Long,ByVal SCA As String) As Boolean
Public Declare Function GetFailedMsg Lib "" (ByVal CommIndex As
Long, ByVal Msg As String) As Boolean
Public Declare Function GetNextSendMsg Lib "" (ByVal CommIndex As
Long, ByVal Msg As String,ByVal DeleteAfterRead As Boolean ) As Boolean
Public Declare Function ForceCloseComm Lib "" (ByVal CommIndex As
Long) As Long
6.3示例程序
示例程序详见
第 15 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
7.在C++Builder中使用
7.1各接口函数说明
各接口函数地说明请参考第三章。
7.2在头文件里做函数申明:
extern "C" long __stdcall OpenComm(long CommIndex);
extern "C" long __stdcall CloseComm(long CommIndex);
extern "C" long __stdcall SendMsg(long CommIndex,char * Msg,char * MobileNo,
long Msg_Index,bool Chinese);
extern "C" bool __stdcall GetNewMsg(long CommIndex,char * Msg);
extern "C" long __stdcall GetUnSendCount(long CommIndex);
extern "C" bool __stdcall GetSCA(long CommIndex,char * SCA);
extern "C" bool __stdcall SetSCA(long CommIndex,char * SCA);
extern "C" long __stdcall ForceCloseComm(long CommIndex);
extern "C" bool __stdcall GetFailedMsg(long CommIndex,char * Msg);
extern "C" bool __stdcall GetNextSendMsg(long CommIndex,char * Msg,
bool DeleteAfterRead);
7.3调用函数
用C++Builder自带的工具生成lib文件[例程中已带有],命令格式: implib
将提供的包含在工程中。
示例程序详见 ExampleCb5Demo ,
第 16 页
2023年7月31日发(作者:)
短信开发包接口文档 杭州爱赛德软件技术有限公司
短信开发包接口文档
版 本 号:V 2.0
杭州爱赛德软件技术有限公司
2001-6-8
第 1 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
目录
1.开发包说明..........................................................................................................3
2.接口函数一览表:..............................................................................................4
3.动态库接口函数说明..........................................................................................5
3.1模块控制函数...............................................................................................5
3.1.1打开模块(OpenComm).................................................................5
3.1.2关闭模块(CloseComm).................................................................5
3.1.3强制关闭模块(ForceCloseComm)................................................6
3.1.4读取模块序列号(GetSerialNo).....................................................7
3.2短信息处理函数...........................................................................................7
3.2.1发送短信息(SendMsg)..................................................................7
3.2.2接收短信(GetNewMsg)................................................................8
3.2.3取得发送队列中短信息数目(GetUnSendCount)........................9
3.2.4取得下一条发送的短信息(GetNextSendMsg)............................9
3.2.5获取发送失败短信(GetFailedMsg)............................................10
3.3短信中心设置函数.....................................................................................11
3.3.1取得短信中心号码(GetSCA).....................................................11
3.3.2设置短信中心号码(SetSCA)......................................................12
4.在DELPHI中使用..............................................................................................13
4.1各接口函数说明.........................................................................................13
4.2函数申明.....................................................................................................13
4.3示例程序.....................................................................................................13
5.在VC中使用....................................................................................................14
5.1各接口函数说明.........................................................................................14
5.2在头文件里做函数申明:.........................................................................14
5.3调用函数.....................................................................................................14
6.在VB中使用....................................................................................................15
6.1各接口函数说明.........................................................................................15
6.2函数申明.....................................................................................................15
6.3示例程序.....................................................................................................15
7.在C++BUILDER中使用........................................................................................16
7.1各接口函数说明.........................................................................................16
7.2在头文件里做函数申明:.........................................................................16
7.3调用函数.....................................................................................................16
第 2 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
1.开发包说明
文件及目录列表:
文件名称
GSM MODEM操作手册.pdf
Dll/
Dll/
Dll/
Dll/短信开发包接口文档.pdf
Example目录
Tools目录
说明
如何正确使用GSM MODEM
通讯处理动态连接库
短信处理动态连接库
LIB库文件(VC中使用)
接口说明文档
例子程序源代码目录,包括VC ,VB,Delphi,C++Builder,PB,Lotus Notes等
包括串口测试工具和模块测试工具
第 3 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
2.接口函数一览表:
第 4 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
3.动态库接口函数说明
3.1模块控制函数
3.1.1打开模块(OpenComm)
打开模块,以便进行短信息的收发操作。
函数申明:
调用语言 函数申明
Visual C++ int __stdcall OpenComm(int ComIndex);
Visual Basic Public Declare Function OpenComm Lib “”
(ByVal CommIndex As Long) As Long
Delphi function OpenComm(CommIndex: LongInt): LongInt;
C++Builder extern "C" long __stdcall OpenComm(long CommIndex);
参数:
参数名称 说明
ComIndex
模块所连接的COM口编号
函数返回:
返回值 说明
0
成功
-5
模块注册失败
-6
打开COM口失败
-9
未检测到GSM模块
-10
设置模块参数失败
-11
保存模块参数失败
注意:
OpenComm ()函数要在调用其他接口函数前调用。
3.1.2关闭模块(CloseComm)
关闭模块,结束对模块的操作。
函数申明:
调用语言
Visual C++
Visual Basic
Delphi
C++Builder
函数申明
int __stdcall CloseComm(int ComIndex);
Public Declare Function CloseComm Lib ""
(ByVal CommIndex As Long) As Long
function CloseComm(CommIndex: LongInt): LongInt;
extern "C" long __stdcall CloseComm(long CommIndex);
第 5 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
参数:
参数名称
ComIndex
说明
模块所连接的COM口编号
函数返回:
返回值
0
-1
-7
-8
说明
成功
发送队列中还有未发消息待发
关闭COM口失败
模块未打开
3.1.3强制关闭模块(ForceCloseComm)
强制关闭模块。
函数申明:
调用语言
Visual C++
Visual Basic
Delphi
C++Builder
参数:
参数名称
ComIndex
函数返回:
返回值
0
-7
-8
注意:
1) 若队列中还有未处理消息,调用该函数将会丢失所以未处理短信
2) 建议调用该函数前先循环调用GetNextSendMsg将所有未发的短信依次取出,以便保存所有未发短信的信息,提高系统的可靠性,具体调用方法详见下文
说明
成功
关闭COM口失败
模块未打开
函数申明
int __stdcall ForceCloseComm(int ComIndex);
Public Declare Function ForceCloseComm Lib ""
(ByVal CommIndex As Long) As Long
function ForceCloseComm(CommIndex: LongInt): LongInt;
extern "C" long __stdcall ForceCloseComm(long CommIndex);
说明
模块所连接的COM口编号
第 6 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
3.1.4读取模块序列号(GetSerialNo)
读取模块的序列号(IMEI)
函数申明:
调用语言 函数申明
Visual C++
bool __stdcall GetSerialNo(int ComIndex,char *SN);
Visual Basic Public Declare Function GetSerialNo Lib "" (ByVal
CommIndex As Long,ByVal SN As String) As Boolean
Delphi function GetSerialNo(CommIndex: LongInt;SN:Pchar): Boolean;
C++Builder extern "C" bool __stdcall GetSerialNo(long CommIndex,char *SN);
参数:
参数名称 说明
ComIndex
模块所连接的COM口编号
SN
取得的序列号的指针
函数返回:
返回值 说明
True
成功
False
失败
3.2短信息处理函数
3.2.1发送短信息(SendMsg)
发送消息,将要发送短信插入发送消息队列。
函数申明:
调用语言 函数申明
Visual C++
int __stdcall SendMsg(int ComIndex,char * Msg,char* Mobile,int
Msg_Index,bool Chinese);
Visual Basic Public Declare Function SendMsg Lib "" (ByVal
CommIndex As Long, ByVal Msg As String, ByVal MobileNo
As String, ByVal MsgIndex As Long, ByVal Chinese As
Boolean) As Long
function SendMsg(CommIndex: LongInt; Msg: Pchar;
MobileNo:Pchar;Msg_Index:LongInt;Chinese:Boolean): LongInt;extern "C" long __stdcall SendMsg(long CommIndex,
char * Msg,char * MobileNo,long Msg_Index,bool Chinese);
Delphi
C++Builder
参数:
第 7 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
参数名称
ComIndex
Msg
MobileNo
说明
模块所连接的COM口编号
短消息内容
接收端手机号码 ,包括普通手机号码和特殊号码,如168
Msg_Index
消息序号,开发商自己定义,方便检索
Chinese
是否为中文信息(中文为True,否则为False)
函数返回:
返回值
0
-2
-3
-4
-8
注意:
本系统采用异步方式发送短信,调用SendMsg函数发送成功的短信插入发送队列,由发送线程负责实际的发送,如果实际发送失败,系统将发送失败的短信转移到另一队列中,可以通过GetFailedMsg取得发送失败的短信,对于发送队列中尚未发送出去的短信,可以通过GetUnSendCount和GetNextSendMsg获取相关的信息,以便搭建可靠性高的应用系统,GetFailedMsg,GetUnSendCount,GetNextSendMsg的具体使用详见下文。
返回参数为-8表示模块未打开,出现模块未打开有几种可能:
• 模块确实没有打开
用户在调用之前先打开模块即可。
• 模块出现异常
在调用之前模块已经正常打开,但出现例如断电或串口连接出问题等等情况,系统会将串口关闭。在恢复正常后,用户必须重新打开模块才能继续使用。
3.2.2接收短信(GetNewMsg)
接收新的短信息。
函数申明:
调用语言
Visual C++
Visual Basic
Delphi
C++Builder
说明
成功,消息已插入发送队列
消息长度超过最大长度
手机号码不正确
发送队列已满
模块未打开
函数申明
bool __stdcall GetNewMsg(int ComIndex,char* NewMsg);
Public Declare Function GetNewMsg Lib “” (ByVal
CommIndex As Long, ByVal NewMsg As String) As Boolean
function GetNewMsg(CommIndex: LongInt; NewMsg:
Pchar):Boolean;
extern "C" bool __stdcall GetNewMsg(long CommIndex,
char * Msg);
第 8 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
参数:
参数名称
ComIndex
NewMsg
函数返回:
返回值
True
False
注意:
1) 返回值为True时,NewMsg为接收到的短信;返回值为False且NewMsg为:“Module Error”时,表示模块当前无响应,可能是断电或模块出故障;返回值为False且NewMsg为空时表示模块在正常工作但没有收到短信
2) 短信息格式:发送端号码+“|”+接收时间+“|”+短信内容短信息格式:发送端号码+“|”+接收时间+“|”+短信内容。此处接收时间指的是短信中心接收到该短信的时间,例如向168发送“GP 0001”,接收到的信息为:168|01-09-28 12:33:39|<0001>深发展A买12.66卖12.68现12.68高12.75低12.55昨12.49量488.87K12:32
说明
成功接收到新的短信
未接收到新的短信
说明
模块所连接的COM口编号
取得的短信息的指针
3.2.3取得发送队列中短信息数目(GetUnSendCount)
取得发送队列中未发短消息的数目。
函数申明:
调用语言 函数申明
Visual C++
int __stdcall GetUnSendCount(int ComIndex);
Visual Basic Public Declare Function GetUnSendCount Lib “”
(ByVal CommIndex As Long) As Long
Delphi function GetUnSendCount(CommIndex: Longint): LongInt;
C++Builder extern "C" long __stdcall GetUnSendCount(long CommIndex);
参数:
参数名称 说明
ComIndex
模块所连接的COM口编号
函数返回:
发送队列中未发短消息的数目。
3.2.4取得下一条发送的短信息(GetNextSendMsg)
读取发送队列中下一条要发送的短信息,通常用于监控实际的发送情况。
第 9 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
函数申明:
调用语言
Visual C++
Visual Basic
Delphi
C++Builder
参数:
函数申明
bool __stdcall GetNextSendMsg(int ComIndex,char* Msg,bool
DeleteAfterRead);
Public Declare Function GetNextSendMsg Lib “”
(ByVal CommIndex As Long, ByVal Msg As String,ByVal
DeleteAfterRead As Boolean ) As Boolean
function GetNextSendMsg(CommIndex: LongInt;Msg:Pchar;
DeleteAfterRead:Boolean):Boolean;
extern "C" bool __stdcall GetNextSendMsg(long CommIndex,
char * Msg,bool DeleteAfterRead);
参数名称
ComIndex
Msg
DeleteAfterRead
说明
模块所连接的COM口编号
取得的短信息的指针
读取该短信后是否将它从队列中删除,True表示读取后删除该短信,False表示读取后保留该短信
函数返回:
返回值
True
False
注意:
1) 该函数只返回发送队列中的第1条未发短信
2) 如果要读取后面的第2条未发短信,可以等到第1条短信发送完毕,或调用本函数时设置参数DeleteAfterRead为True,即读取第1条未发短信后将其删除,这样当前的第2条未发短信将成为第1条未发短信,如此循环可取出所有未发的短信
说明
成功读取到下一条要发送短信
未读到下一条要发送的短信
3.2.5获取发送失败短信(GetFailedMsg)
读取发送失败的短信息。
函数申明:
调用语言 函数申明
Visual C++
bool __stdcall GetFailedMsg(int ComIndex,char* Msg);
Visual Basic
Delphi
C++Builder
Public Declare Function GetFailedMsg Lib “”
(ByVal CommIndex As Long, ByVal Msg As String) As Boolean
function GetFailedMsg(CommIndex: LongInt;Msg:
Pchar):Boolean;
extern "C" bool __stdcall GetFailedMsg(long CommIndex,
char * Msg);
第 10 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
参数:
参数名称
ComIndex
Msg
函数返回:
返回值
True
False
注意:
短信息格式:发送序列号+“|”发送端号码+“|”+短信内容
例如向168发送“GP 0001”,假设序列号为1,若该短信发送失败,则本函数读到的信息为:1|168|GP 0001
1) 若有发送失败的短信,本函数返回最先发送失败的短信
2) 成功读取发送失败的短信后,该短信就从队列中删除
说明
成功读取发送失败的短信
未读到发送失败的短信
说明
模块所连接的COM口编号
取得的短信息的指针
3.3短信中心设置函数
3.3.1取得短信中心号码(GetSCA)
读取模块的短信中心号码。
函数申明:
调用语言 函数申明
Visual C++
bool __stdcall GetSCA(int ComIndex,char * SCA);
Visual Basic Public Declare Function GetSCA Lib “” (ByVal
CommIndex As Long,ByVal SCA As String) As Boolean
Delphi function GetSCA(CommIndex:LongInt;SCA:Pchar):Boolean;
C++Builder extern "C" bool __stdcall GetSCA(long CommIndex,char * SCA);
参数:
参数名称 说明
ComIndex
模块所连接的COM口编号
SCA
取得的短信中心号码的指针
函数返回:
返回值 说明
True
成功取得短信中心的号码
False
取短信中心号码失败
注意:
此函数只能在模块已打开且模块空闲时调用,否则将返回False,模块正在收发短信或开机后的初始化过程中,调用该函数都将返回False
第 11 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
3.3.2设置短信中心号码(SetSCA)
设置模块的短信中心号码。
函数申明:
调用语言 函数申明
Visual C++
bool __stdcall SetSCA(int ComIndex,char * SCA);
Visual Basic Public Declare Function SetSCA Lib “” (ByVal
CommIndex As Long,ByVal SCA As String) As Boolean
Delphi function SetSCA(CommIndex:LongInt;SCA:Pchar):Boolean;
C++Builder extern "C" bool __stdcall SetSCA(long CommIndex,char * SCA);
参数:
参数名称 说明
ComIndex
模块所连接的COM口编号
SCA
短信中心的号码
函数返回:
返回值 说明
True
成功设置了短信中心号码
False
设置短信中心号码失败
注意:
此函数只能在模块已打开且模块空闲时调用,否则将返回False模块正在收发短信或开机后的初始化过程中,调用该函数都将返回False
第 12 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
4.在Delphi中使用
4.1各接口函数说明
各接口函数地说明请参考第三章。
4.2函数申明
function OpenComm(CommIndex: LongInt): LongInt; stdcall;
function CloseComm(CommIndex: LongInt): LongInt; stdcall;
function SendMsg(CommIndex: LongInt; msg,mobileNo:
Pchar;Msg_Index:LongInt;chinese:boolean): LongInt; stdcall;
function GetNewMsg(CommIndex: LongInt; NewMsg:Pchar): boolean; stdcall;
function GetUnSendCount(CommIndex:LongInt):LongInt;stdcall;
function GetSCA(CommIndex:LongInt;SCA:Pchar):Boolean;stdcall;
function SetSCA(CommIndex:LongInt;SCA:Pchar):Boolean;stdcall;
function ForceCloseComm(CommIndex:LongInt):LongInt;stdcall;
function GetFailedMsg(CommIndex:LongInt;Msg:Pchar):Boolean;stdcall;
function GetNextSendMsg(CommIndex:LongInt;Msg:Pchar;
DeleteAfterRead:Boolean):Boolean;stdcall;
implementation
function OpenComm; external '';
function CloseComm; external '';
function SendMsg; external '';
function GetNewMsg;external '';
function GetUnSendCount;external '';
function GetSCA;external '';
function SetSCA;external '';
function ForceCloseComm;external '';
function GetFailedMsg;external '';
function GetNextSendMsg;external '';
4.3示例程序
示例程序详见
第 13 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
5.在VC中使用
5.1各接口函数说明
各接口函数地说明请参考第三章。
5.2在头文件里做函数申明:
int __stdcall OpenComm(int ComIndex);
int __stdcall CloseComm(int ComIndex);
int __stdcall SendMsg(int ComIndex,char * Msg,char* Mobile,int Msg_Index,bool
Chinese);
bool __stdcall GetNewMsg(int ComIndex,char* NewMsg);
int __stdcall GetUnSendCount(int ComIndex);
bool __stdcall GetSCA(int ComIndex,char * SCA);
bool __stdcall SetSCA(int ComIndex,char * SCA);
bool __stdcall GetFailedMsg(int ComIndex,char* Msg);
bool __stdcall GetNextSendMsg(int ComIndex,char* Msg,bool DeleteAfterRead);
int __stdcall ForceCloseComm(int ComIndex);
5.3调用函数
将提供的Ascend_包含在工程中
示例程序详见 ExampleVcDemo Ascend_
第 14 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
6.在VB中使用
6.1各接口函数说明
各接口函数地说明请参考第三章。
6.2函数申明
Public Declare Function OpenComm Lib "" (ByVal CommIndex As Long)
As Long
Public Declare Function CloseComm Lib "" (ByVal CommIndex As
Long) As Long
Public Declare Function SendMsg Lib "" (ByVal CommIndex As Long,
ByVal Msg As String, ByVal MobileNo As String, ByVal MsgIndex As Long, ByVal
Chinese As Boolean) As Long
Public Declare Function GetNewMsg Lib "" (ByVal CommIndex As
Long, ByVal NewMsg As String) As Boolean
Public Declare Function GetUnSendCount Lib "" (ByVal CommIndex As
Long) As Long
Public Declare Function GetSCA Lib "" (ByVal CommIndex As
Long,ByVal SCA As String) As Boolean
Public Declare Function SetSCA Lib "" (ByVal CommIndex As
Long,ByVal SCA As String) As Boolean
Public Declare Function GetFailedMsg Lib "" (ByVal CommIndex As
Long, ByVal Msg As String) As Boolean
Public Declare Function GetNextSendMsg Lib "" (ByVal CommIndex As
Long, ByVal Msg As String,ByVal DeleteAfterRead As Boolean ) As Boolean
Public Declare Function ForceCloseComm Lib "" (ByVal CommIndex As
Long) As Long
6.3示例程序
示例程序详见
第 15 页
短信开发包接口文档 杭州爱赛德软件技术有限公司
7.在C++Builder中使用
7.1各接口函数说明
各接口函数地说明请参考第三章。
7.2在头文件里做函数申明:
extern "C" long __stdcall OpenComm(long CommIndex);
extern "C" long __stdcall CloseComm(long CommIndex);
extern "C" long __stdcall SendMsg(long CommIndex,char * Msg,char * MobileNo,
long Msg_Index,bool Chinese);
extern "C" bool __stdcall GetNewMsg(long CommIndex,char * Msg);
extern "C" long __stdcall GetUnSendCount(long CommIndex);
extern "C" bool __stdcall GetSCA(long CommIndex,char * SCA);
extern "C" bool __stdcall SetSCA(long CommIndex,char * SCA);
extern "C" long __stdcall ForceCloseComm(long CommIndex);
extern "C" bool __stdcall GetFailedMsg(long CommIndex,char * Msg);
extern "C" bool __stdcall GetNextSendMsg(long CommIndex,char * Msg,
bool DeleteAfterRead);
7.3调用函数
用C++Builder自带的工具生成lib文件[例程中已带有],命令格式: implib
将提供的包含在工程中。
示例程序详见 ExampleCb5Demo ,
第 16 页
发布评论