srithi
asked on
Reading SMS messages (inbox) in pocketpc 2002
hi all,
i am trying to write a program in evc++3.0 to read the SMS messages ,
here is the code,
SMS_HANDLE inbox;
SMS_ADDRESS s;
HANDLE wait;
DWORD size,read;
size=19;
HRESULT hr;
SmsGetPhoneNumber (&s);
CString a;
a=s.ptsAddress;
AfxMessageBox(a);
hr=SmsOpen(_T("Microsoft Text SMS Protocol"),SMS_MODE_RECEIV E,&inbox,N ULL);
if(hr != S_OK)
{
DWORD error;
error=GetLastError();
CString s;
s.Format(_T("%ld"),hr);
AfxMessageBox(_T("Failed With Error : ") + s);
}
else
{
AfxMessageBox(_T("Opened") );
}
char buffer[20];
hr=SmsReadMessage (inbox,NULL,NULL,NULL,(uns igned char *)buffer,size,NULL,0,&read );
if(FAILED(hr))
{
DWORD error;
error=GetLastError();
CString s;
s.Format(_T("%ld"),hr);
AfxMessageBox(_T("Failed With Error : ") + s);
//return;
}
else
{
AfxMessageBox(_T("Read"));
}
CString len;
len.Format(_T("%d"),read);
AfxMessageBox(len);
// AfxMessageBox(_T("3"));
CString testSMS;
TCHAR InBuffer[20];
mbstowcs(InBuffer, buffer, 19);
testSMS=InBuffer;
AfxMessageBox(testSMS);
SmsClose(inbox);
above is the code which i have written but this code is unable to read the
message,i am unable to understand the mistake,can anyone tell me the mistake or can u help with peice of code to read or send SMS messages.
my platform,
OS : WINCE(pocketpc 2002)
CPU : StrongARM
Language : EVC++3.0
Machine : T-Mobile
Regards,
Srinivas
i am trying to write a program in evc++3.0 to read the SMS messages ,
here is the code,
SMS_HANDLE inbox;
SMS_ADDRESS s;
HANDLE wait;
DWORD size,read;
size=19;
HRESULT hr;
SmsGetPhoneNumber (&s);
CString a;
a=s.ptsAddress;
AfxMessageBox(a);
hr=SmsOpen(_T("Microsoft Text SMS Protocol"),SMS_MODE_RECEIV
if(hr != S_OK)
{
DWORD error;
error=GetLastError();
CString s;
s.Format(_T("%ld"),hr);
AfxMessageBox(_T("Failed With Error : ") + s);
}
else
{
AfxMessageBox(_T("Opened")
}
char buffer[20];
hr=SmsReadMessage (inbox,NULL,NULL,NULL,(uns
if(FAILED(hr))
{
DWORD error;
error=GetLastError();
CString s;
s.Format(_T("%ld"),hr);
AfxMessageBox(_T("Failed With Error : ") + s);
//return;
}
else
{
AfxMessageBox(_T("Read"));
}
CString len;
len.Format(_T("%d"),read);
AfxMessageBox(len);
// AfxMessageBox(_T("3"));
CString testSMS;
TCHAR InBuffer[20];
mbstowcs(InBuffer, buffer, 19);
testSMS=InBuffer;
AfxMessageBox(testSMS);
SmsClose(inbox);
above is the code which i have written but this code is unable to read the
message,i am unable to understand the mistake,can anyone tell me the mistake or can u help with peice of code to read or send SMS messages.
my platform,
OS : WINCE(pocketpc 2002)
CPU : StrongARM
Language : EVC++3.0
Machine : T-Mobile
Regards,
Srinivas
What error message do you get? Which phone/modem are you using
ASKER
hi bigrat,
thankx for the quick response ,
after i call
SmsOpen
i am printing the HRESULT value which is giveing some number and dont see that error number in the CE help.
hence unable to obtain the Handle to inbox.
i dont no what modem is built in,
the product which i have is ,please see this URL
http://www.t-mobile.com/products/overview.asp?phoneid=166765
i have a taken a simcard from local carrier called Airtel,which supports GPRS.
if any more input required,please tell me i will give you,i will refer the T-mobile manual try to find out what modem does it use.
thank you very much for your time.
Regards,
Srinivas
thankx for the quick response ,
after i call
SmsOpen
i am printing the HRESULT value which is giveing some number and dont see that error number in the CE help.
hence unable to obtain the Handle to inbox.
i dont no what modem is built in,
the product which i have is ,please see this URL
http://www.t-mobile.com/products/overview.asp?phoneid=166765
i have a taken a simcard from local carrier called Airtel,which supports GPRS.
if any more input required,please tell me i will give you,i will refer the T-mobile manual try to find out what modem does it use.
thank you very much for your time.
Regards,
Srinivas
OK, the one from T-Mobile.
What HResult do you actually get?
I presume that the display of the telephone number works?
What HResult do you actually get?
I presume that the display of the telephone number works?
ASKER
no i am unable to get the telephone number even,so i tried
SmsGetSMSC like,
hr=SmsGetSMSC(&s);
switch(s.smsatAddressType)
{
case SMSAT_UNKNOWN:
AfxMessageBox(_T("SMSAT_UN KNOWN"));
break;
case SMSAT_INTERNATIONAL :
AfxMessageBox(_T("SMSAT_IN TERNATIONA L "));
break;
case SMSAT_NATIONAL :
AfxMessageBox(_T("SMSAT_NA TIONAL "));
break;
case SMSAT_NETWORKSPECIFIC :
AfxMessageBox(_T("SMSAT_NE TWORKSPECI FIC"));
break;
case SMSAT_SUBSCRIBER :
AfxMessageBox(_T("SMSAT_SU BSCRIBER") );
break;
case SMSAT_ALPHANUMERIC :
AfxMessageBox(_T("SMSAT_AL PHANUMERIC "));
break;
case SMSAT_ABBREVIATED :
AfxMessageBox(_T("SMSAT_AB BREVIATED" ));
break;
default :
AfxMessageBox(_T("No Enum Value"));
}
CString a;
a=s.ptsAddress;
AfxMessageBox(a);
i am getting the Adress Type as international and i am able to get the SMS center number,
but still unable to open the inbox,
it is goining into if loop and displays
"Failed With Error :- 2147024809
here is the code.
hr=SmsOpen(_T("Microsoft Text SMS Protocol"),SMS_MODE_RECEIV E,&inbox,N ULL);
if(hr != S_OK)
{
DWORD error;
error=GetLastError();
CString s;
s.Format(_T("%ld"),hr);
AfxMessageBox(_T("Failed With Error : ") + s);
}
else
{
AfxMessageBox(_T("Opened") );
}
Is the protocol Correct? i am missing something ?
kindly help,
thankyou very much for your time.
Regards,
Srinivas
SmsGetSMSC like,
hr=SmsGetSMSC(&s);
switch(s.smsatAddressType)
{
case SMSAT_UNKNOWN:
AfxMessageBox(_T("SMSAT_UN
break;
case SMSAT_INTERNATIONAL :
AfxMessageBox(_T("SMSAT_IN
break;
case SMSAT_NATIONAL :
AfxMessageBox(_T("SMSAT_NA
break;
case SMSAT_NETWORKSPECIFIC :
AfxMessageBox(_T("SMSAT_NE
break;
case SMSAT_SUBSCRIBER :
AfxMessageBox(_T("SMSAT_SU
break;
case SMSAT_ALPHANUMERIC :
AfxMessageBox(_T("SMSAT_AL
break;
case SMSAT_ABBREVIATED :
AfxMessageBox(_T("SMSAT_AB
break;
default :
AfxMessageBox(_T("No Enum Value"));
}
CString a;
a=s.ptsAddress;
AfxMessageBox(a);
i am getting the Adress Type as international and i am able to get the SMS center number,
but still unable to open the inbox,
it is goining into if loop and displays
"Failed With Error :- 2147024809
here is the code.
hr=SmsOpen(_T("Microsoft Text SMS Protocol"),SMS_MODE_RECEIV
if(hr != S_OK)
{
DWORD error;
error=GetLastError();
CString s;
s.Format(_T("%ld"),hr);
AfxMessageBox(_T("Failed With Error : ") + s);
}
else
{
AfxMessageBox(_T("Opened")
}
Is the protocol Correct? i am missing something ?
kindly help,
thankyou very much for your time.
Regards,
Srinivas
The HResult value which you have (2147024809 = hex 7FF8FFA9) is strictly speaking not an error. The definition from MSDN is :-
An HRESULT value is made up of the following fields:
A 1-bit code indicating severity, where zero represents success and 1 represents failure.
A 4-bit reserved value.
An 11-bit code indicating responsibility for the error or warning, also known as a facility code.
A 16-bit code describing the error or warning.
The correct way to test is :-
if(SUCCEEDED(hr)) {
I don't have the defintion of the MS interface (.h file) but I assume that the all return HRESULT.
An HRESULT value is made up of the following fields:
A 1-bit code indicating severity, where zero represents success and 1 represents failure.
A 4-bit reserved value.
An 11-bit code indicating responsibility for the error or warning, also known as a facility code.
A 16-bit code describing the error or warning.
The correct way to test is :-
if(SUCCEEDED(hr)) {
I don't have the defintion of the MS interface (.h file) but I assume that the all return HRESULT.
ASKER
i have tested by changing the code.
hr=SmsOpen(_T("Microsoft Text SMS Protocol"),SMS_MODE_RECEIV
if(SUCCEEDED(hr))
{
AfxMessageBox(_T("Opened")
}
else
{
DWORD error;
error=GetLastError();
CString s;
s.Format(_T("%ld"),hr);
AfxMessageBox(_T("Failed With Error : ") + s);
}
but still control goes into ELSE loop,and prints hr value as 2147024809 ,
i assumed that smsOpen is success and if i try to call smsReadMessage function,it failes again goes into,
if loop with hr value as 2147024890
char buffer[20];
hr=SmsReadMessage (inbox,NULL,NULL,NULL,(uns
if(FAILED(hr))
{
DWORD error;
error=GetLastError();
CString s;
s.Format(_T("%ld"),hr);
AfxMessageBox(_T("Failed With Error : ") + s);
//return;
}
else
{
AfxMessageBox(_T("Read"));
}
CString len;
len.Format(_T("%d"),read);
AfxMessageBox(len);
this message box prints no of bytes read as 0.
what am i missing??
thankx for your time,hope you will continue till i fix this.
once again thank you very much for oyur time.
Regards,
Srinivas.
I don't have the defintion of the MS interface (.h file) for the SMSOpen() call. Could you post it? Isn't the phone on COM6 and if so how is that specified?
ASKER
here is SMS.h
////////////////////////// ////////// ////////// ////////// ////////// ////////
// Copyright (c) Microsoft Corporation. All rights reserved. //
////////////////////////// ////////// ////////// ////////// ////////// ////////
#ifndef _SMS_H_
#define _SMS_H_
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
//
// Errors
//
#define FACILITY_SMS 0x200
// Specific registration errors (for SmsSetMessageNotification, SmsClearMessageNotificatio n)
#define SMS_E_INVALIDPROTOCOL MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0001)
#define SMS_E_REGISTRATIONEXISTS MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0002)
#define SMS_S_NOSUCHREGISTRATION MAKE_HRESULT(SEVERITY_SUCC ESS, FACILITY_SMS, 0x0003)
// Specific messaging errors (for SmsOpen, SmsSendMessage, SmsGetSMSC, etc.)
#define SMS_E_TOOMUCHDATA MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0100)
#define SMS_E_INVALIDDATA MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0101)
#define SMS_E_BUFFERTOOSMALL MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0102)
#define SMS_E_PROVIDERSPECIFICBUFF ERWRONGSIZ E MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0103)
#define SMS_E_TIMEUNAVAILABLE MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0104)
#define SMS_E_RECEIVEHANDLEALREADY OPEN MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0105)
#define SMS_E_DESTINATIONOUTOFSVC MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0106)
#define SMS_E_INVALIDADDRESS MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0107)
#define SMS_E_MSGBARREDBYOPERATOR MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0108)
#define SMS_E_MSGCALLBARRED MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0109)
#define SMS_E_NOSCSUBSCRIPTION MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x010a)
#define SMS_E_SCBUSY MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x010b)
#define SMS_E_SVCNOTSUBSCRIBED MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x010c)
#define SMS_E_UNASSIGNEDNUMBER MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x010d)
#define SMS_E_UNKNOWNSCADDRESS MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x010e)
#define SMS_E_UNIDENTIFIEDSUBCRIBE R MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x010f)
// General SMS messaging errors
#define SMS_E_MISC MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0200)
#define SMS_E_PASSWORD MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0201)
#define SMS_E_SIM MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0202)
#define SMS_E_NETWORKACCESS MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0203)
#define SMS_E_NETWORK MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0204)
#define SMS_E_MOBILE MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0205)
#define SMS_E_NETWORKUNSUPPORTED MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0206)
#define SMS_E_MOBILEUNSUPPORTED MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0207)
#define SMS_E_BADPARAM MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0208)
#define SMS_E_STORAGE MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x0209)
#define SMS_E_SMSC MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x020a)
#define SMS_E_DESTINATION MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x020b)
#define SMS_E_DESTINATIONUNSUPPORT ED MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x020c)
#define SMS_E_RADIOUNAVAILABLE MAKE_HRESULT(SEVERITY_ERRO R, FACILITY_SMS, 0x020d)
//
// Constants
//
#define SMS_DATAGRAM_SIZE (140)
#define SMS_BROADCAST_DATAGRAM_SIZ E (82)
#define SMS_MAX_APPNAME_LENGTH (MAX_PATH)
#define SMS_MAX_PARAMS_LENGTH (MAX_PATH)
#define SMS_MAX_PROTOCOLNAME_LENGT H (MAX_PATH)
#define SMS_MAX_MESSAGEUID_SIZE (1024)
#define SMS_MAX_ADDRESS_LENGTH (256)
#define SMS_MAX_SUBADDRESS_SIZE (256)
// dwMessageModes for SmsOpen
#define SMS_MODE_RECEIVE (0x00000001)
#define SMS_MODE_SEND (0x00000002)
// dwOptions for SmsSendMessage
#define SMS_OPTION_DELIVERY_NONE (0x00000000)
#define SMS_OPTION_DELIVERY_NO_RET RY (0x00000001)
// dwMessageOptions for TEXT_PROVIDER_SPECIFIC_DAT A
#define PS_MESSAGE_OPTION_NONE (0x00000000)
#define PS_MESSAGE_OPTION_REPLYPAT H (0x00000001)
#define PS_MESSAGE_OPTION_STATUSRE PORT (0x00000002)
#define PS_MESSAGE_OPTION_DISCARD (0x00000004)
// dwMessageStatus0 and dwMessageStatus1 for SmsGetMessageStatus and the SMS status-message provider (SMS_MSGTYPE_STATUS)
// Message status is unknown iff dwMessageStatus0 and dwMessageStatus1 are both set to MESSAGE_STATUS_UNKNOWN
#define MESSAGE_STATUS_UNKNOWN (0x00000000)
// Valid bits for dwMessageStatus0
#define MESSAGE_STATUS_0_RECEIVEDB YSME (0x00000001)
#define MESSAGE_STATUS_0_FORWARDED TOSME (0x00000002)
#define MESSAGE_STATUS_0_REPLACEDB YSC (0x00000004)
#define MESSAGE_STATUS_0_CONGESTIO N_TRYING (0x00000008)
#define MESSAGE_STATUS_0_SMEBUSY_T RYING (0x00000010)
#define MESSAGE_STATUS_0_SMENOTRES PONDING_TR YING (0x00000020)
#define MESSAGE_STATUS_0_SVCREJECT ED_TRYING (0x00000040)
#define MESSAGE_STATUS_0_QUALITYUN AVAIL_TRYI NG (0x00000080)
#define MESSAGE_STATUS_0_SMEERROR_ TRYING (0x00000100)
#define MESSAGE_STATUS_0_CONGESTIO N (0x00000200)
#define MESSAGE_STATUS_0_SMEBUSY (0x00000400)
#define MESSAGE_STATUS_0_SMENOTRES PONDING (0x00000800)
#define MESSAGE_STATUS_0_SVCREJECT ED (0x00001000)
#define MESSAGE_STATUS_0_QUALITYUN AVAIL_TEMP (0x00002000)
#define MESSAGE_STATUS_0_SMEERROR (0x00004000)
#define MESSAGE_STATUS_0_REMOTEPRO CERROR (0x00008000)
#define MESSAGE_STATUS_0_INCOMPATI BLEDEST (0x00010000)
#define MESSAGE_STATUS_0_CONNECTIO NREJECTED (0x00020000)
#define MESSAGE_STATUS_0_NOTOBTAIN ABLE (0x00040000)
#define MESSAGE_STATUS_0_NOINTERNE TWORKING (0x00080000)
#define MESSAGE_STATUS_0_VPEXPIRED (0x00100000)
#define MESSAGE_STATUS_0_DELETEDBY ORIGSME (0x00200000)
#define MESSAGE_STATUS_0_DELETEDBY SC (0x00400000)
#define MESSAGE_STATUS_0_NOLONGERE XISTS (0x00800000)
#define MESSAGE_STATUS_0_QUALITYUN AVAIL (0x01000000)
#define MESSAGE_STATUS_0_RESERVED_ COMPLETED (0x02000000)
#define MESSAGE_STATUS_0_RESERVED_ TRYING (0x04000000)
#define MESSAGE_STATUS_0_RESERVED_ ERROR (0x08000000)
#define MESSAGE_STATUS_0_RESERVED_ TMPERROR (0x10000000)
#define MESSAGE_STATUS_0_SCSPECIFI C_COMPLETE D (0x20000000)
#define MESSAGE_STATUS_0_SCSPECIFI C_TRYING (0x40000000)
#define MESSAGE_STATUS_0_SCSPECIFI C_ERROR (0x80000000)
// Valid bits for dwMessageStatus1
#define MESSAGE_STATUS_1_SCSPECIFI C_TMPERROR (0x00000001)
// Language identifiers for SMS_BROADCAST_RANGES.dwBro adcastMsgL angs
#define SMS_DCSLANG_UNKNOWN (0x00000001)
#define SMS_DCSLANG_GERMAN (0x00000002)
#define SMS_DCSLANG_ENGLISH (0x00000004)
#define SMS_DCSLANG_ITALIAN (0x00000008)
#define SMS_DCSLANG_FRENCH (0x00000010)
#define SMS_DCSLANG_SPANISH (0x00000020)
#define SMS_DCSLANG_DUTCH (0x00000040)
#define SMS_DCSLANG_SWEDISH (0x00000080)
#define SMS_DCSLANG_DANISH (0x00000100)
#define SMS_DCSLANG_PORTUGUESE (0x00000200)
#define SMS_DCSLANG_FINNISH (0x00000400)
#define SMS_DCSLANG_NORWEGIAN (0x00000800)
#define SMS_DCSLANG_GREEK (0x00001000)
#define SMS_DCSLANG_TURKISH (0x00002000)
#define SMS_DCSLANG_HUNGARIAN (0x00004000)
#define SMS_DCSLANG_POLISH (0x00008000)
#define SMS_DCSLANG_CZECH (0x00010000)
#define SMS_DCSLANG_ALL (0x0001ffff)
// Valid flags for SMS_BROADCAST_RANGES.dwPar ams
#define SMS_PARAM_SBR_BROADCASTMSG IDS (0x00000001)
#define SMS_PARAM_SBR_BROADCASTMSG LANGS (0x00000002)
#define SMS_PARAM_SBR_ACCEPTIDS (0x00000004)
//
// Enumerations
//
enum SMS_ADDRESS_TYPE {
SMSAT_UNKNOWN=0,
SMSAT_INTERNATIONAL,
SMSAT_NATIONAL,
SMSAT_NETWORKSPECIFIC,
SMSAT_SUBSCRIBER,
SMSAT_ALPHANUMERIC,
SMSAT_ABBREVIATED
};
enum SMS_DATA_ENCODING {
SMSDE_OPTIMAL=0,
SMSDE_GSM,
SMSDE_UCS2,
};
enum PROVIDER_SPECIFIC_MESSAGE_ CLASS {
PS_MESSAGE_CLASS0 = 0,
PS_MESSAGE_CLASS1,
PS_MESSAGE_CLASS2,
PS_MESSAGE_CLASS3,
};
enum PROVIDER_SPECIFIC_REPLACE_ OPTION {
PSRO_NONE = 0,
PSRO_REPLACE_TYPE1,
PSRO_REPLACE_TYPE2,
PSRO_REPLACE_TYPE3,
PSRO_REPLACE_TYPE4,
PSRO_REPLACE_TYPE5,
PSRO_REPLACE_TYPE6,
PSRO_REPLACE_TYPE7,
PSRO_RETURN_CALL,
PSRO_DEPERSONALIZATION,
};
//
// Types
//
typedef DWORD SMS_HANDLE;
typedef DWORD SMS_MESSAGE_ID;
#define INVALID_MESSAGE_ID ((SMS_MESSAGE_ID)0xfffffff f)
// Registration structure used by SmsSetMessageNotification and SmsClearMessageNotificatio n
typedef struct smsregistrationdata_tag {
DWORD cbSize;
TCHAR tszAppName[SMS_MAX_APPNAME _LENGTH];
TCHAR tszParams[SMS_MAX_PARAMS_L ENGTH];
TCHAR tszProtocolName[SMS_MAX_PR OTOCOLNAME _LENGTH];
} SMSREGISTRATIONDATA, *LPSMSREGISTRATIONDATA;
// SMS addressing information
typedef struct sms_address_tag {
SMS_ADDRESS_TYPE smsatAddressType;
TCHAR ptsAddress[SMS_MAX_ADDRESS _LENGTH];
} SMS_ADDRESS, *LPSMS_ADDRESS;
// SMS status message information
typedef struct sms_status_information_tag {
SMS_MESSAGE_ID smsmidMessageID;
DWORD dwMessageStatus0;
DWORD dwMessageStatus1;
SMS_ADDRESS smsaRecipientAddress;
SYSTEMTIME stServiceCenterTimeStamp; // (UTC time)
SYSTEMTIME stDischargeTime; // (UTC time)
} SMS_STATUS_INFORMATION, *LPSMS_STATUS_INFORMATION;
// SMS broadcast message range information
typedef struct sms_range_tag {
DWORD dwMinimum;
DWORD dwMaximum;
} SMS_RANGE, *LPSMS_RANGE;
// SMS broadcast message ranges information
// Use #pragma to avoid "warning C4200: nonstandard extension used : zero-sized array in struct/union
#pragma warning(disable:4200)
typedef struct sms_broadcast_ranges_tag {
DWORD cbSize;
DWORD dwParams;
DWORD dwNumRanges;
DWORD dwBroadcastMsgLangs;
BOOL bAccept;
SMS_RANGE smsrBroadcastRanges[];
} SMS_BROADCAST_RANGES, *LPSMS_BROADCAST_RANGES;
#pragma warning(default:4200)
//
// SMS message types (for use with SmsOpen)
//
// Text message type
#define SMS_MSGTYPE_TEXT TEXT("Microsoft Text SMS Protocol")
// Provider-specific data for use with SmsSendMessage and SmsReadMessage
typedef struct text_provider_specific_dat a_tag {
DWORD dwMessageOptions;
PROVIDER_SPECIFIC_MESSAGE_ CLASS psMessageClass;
PROVIDER_SPECIFIC_REPLACE_ OPTION psReplaceOption;
} TEXT_PROVIDER_SPECIFIC_DAT A;
// Notification message type
#define SMS_MSGTYPE_NOTIFICATION TEXT("Microsoft Notification SMS Protocol (Receive Only)")
// Provider-specific data for use with SmsReadMessage
enum NOTIFICATION_PROVIDER_SPEC IFIC_MSG_W AITING_TYP E {
NOTIFICATIONPSMWT_NONE = 0,
NOTIFICATIONPSMWT_GENERIC,
NOTIFICATIONPSMWT_VOICEMAI L,
NOTIFICATIONPSMWT_FAX,
NOTIFICATIONPSMWT_EMAIL,
NOTIFICATIONPSMWT_OTHER,
};
#define NOTIFICATIONPS_NUM_MSG_WAI TING_UNKNO WN (-1)
#define NOTIFICATIONPS_NUM_MSG_WAI TING_NONZE RO (-2)
enum NOTIFICATION_PROVIDER_SPEC IFIC_INDIC ATOR_TYPE {
NOTIFICATIONPSIT_NONE = 0,
NOTIFICATIONPSIT_LINE1 = 1,
NOTIFICATIONPSIT_LINE2 = 2,
};
typedef struct notification_provider_spec ific_data_ tag {
DWORD dwMessageOptions;
PROVIDER_SPECIFIC_MESSAGE_ CLASS psMessageClass;
PROVIDER_SPECIFIC_REPLACE_ OPTION psReplaceOption;
NOTIFICATION_PROVIDER_SPEC IFIC_MSG_W AITING_TYP E npsMsgWaitingType;
int iNumberOfMessagesWaiting;
NOTIFICATION_PROVIDER_SPEC IFIC_INDIC ATOR_TYPE npsIndicatorType;
} NOTIFICATION_PROVIDER_SPEC IFIC_DATA;
// WDP message type
#define SMS_MSGTYPE_WDP TEXT("Microsoft WDP SMS Protocol")
// Provider-specific data for use with SmsSendMessage and SmsReadMessage
enum WDP_PROVIDER_SPECIFIC_PORT _ADDRESSIN G {
WDPPSPA_8_BIT_PORT_NUMBERS = 0,
WDPPSPA_16_BIT_PORT_NUMBER S,
};
typedef struct wdp_provider_specific_data _tag {
WDP_PROVIDER_SPECIFIC_PORT _ADDRESSIN G wdppsPortAddressing;
WORD wDestinationPort;
WORD wOriginatorPort;
} WDP_PROVIDER_SPECIFIC_DATA ;
// WCMP message type
#define SMS_MSGTYPE_WCMP TEXT("Microsoft WCMP SMS Protocol")
// Provider-specific data for use with SmsSendMessage and SmsReadMessage
enum WCMP_PROVIDER_SPECIFIC_MES SAGE_TYPE {
WCMPPSMT_UNSUPPORTED = 0,
WCMPPSMT_PORT_UNREACHABLE,
WCMPPSMT_MESSAGE_TOO_BIG,
WCMPPSMT_ECHO_REQUEST,
WCMPPSMT_ECHO_REPLY,
};
typedef struct wcmp_provider_specific_dat a_tag {
WCMP_PROVIDER_SPECIFIC_MES SAGE_TYPE wcmppsMessageType;
WORD wParam1;
WORD wParam2;
WORD wParam3;
SMS_ADDRESS smsaAddress;
} WCMP_PROVIDER_SPECIFIC_DAT A;
// Status message type
#define SMS_MSGTYPE_STATUS TEXT("Microsoft Status Message SMS Protocol (Receive Only)")
// Provider-specific data for use with SmsReadMessage
typedef struct status_provider_specific_d ata_tag {
SMS_STATUS_INFORMATION smssiStatusInformation;
} STATUS_PROVIDER_SPECIFIC_D ATA;
// Broadcast message type
#define SMS_MSGTYPE_BROADCAST TEXT("Microsoft Broadcast Message SMS Protocol (Receive Only)")
enum BROADCAST_PROVIDER_SPECIFI C_GEOGRAPH ICAL_SCOPE {
BPSGS_UNKNOWN = 0,
BPSGS_CELL_DISPLAY_IMMEDIA TE,
BPSGS_CELL,
BPSGS_PLMN,
BPSGS_LOCATION_AREA,
};
// Provider-specific data for use with SmsReadMessage
typedef struct broadcast_provider_specifi c_data_tag {
WORD wMessageID;
WORD wMessageCode;
BROADCAST_PROVIDER_SPECIFI C_GEOGRAPH ICAL_SCOPE bpsgsGeographicalScope;
WORD wUpdateNumber;
} BROADCAST_PROVIDER_SPECIFI C_DATA;
// Raw message type
#define SMS_MSGTYPE_RAW TEXT("Microsoft Raw SMS Protocol (Receive Only)")
// Provider-specific data for use with SmsReadMessage
typedef struct raw_provider_specific_data _tag {
DWORD dwHeaderDataSize;
BYTE pbHeaderData[SMS_DATAGRAM_ SIZE];
} RAW_PROVIDER_SPECIFIC_DATA ;
//
// APIs for SMS.dll
//
HRESULT SmsSetMessageNotification (
const SMSREGISTRATIONDATA* psmsrd
);
HRESULT SmsClearMessageNotificatio n (
const LPCTSTR tszProtocolName
);
// Open the SMS Messaging component for read and/or write access
HRESULT SmsOpen (
const LPCTSTR ptsMessageProtocol,
const DWORD dwMessageModes,
SMS_HANDLE* const psmshHandle,
HANDLE* const phMessageAvailableEvent
);
// Close a handle to the SMS messaging component
HRESULT SmsClose (
const SMS_HANDLE smshHandle
);
// Send an SMS message
HRESULT SmsSendMessage (
const SMS_HANDLE smshHandle,
const SMS_ADDRESS* const psmsaSMSCAddress,
const SMS_ADDRESS* const psmsaDestinationAddress,
const SYSTEMTIME* const pstValidityPeriod, // (Values in this structure are expressed relative to the current time)
const BYTE* const pbData,
const DWORD dwDataSize,
const BYTE* const pbProviderSpecificData,
const DWORD dwProviderSpecificDataSize ,
const SMS_DATA_ENCODING smsdeDataEncoding,
const DWORD dwOptions,
SMS_MESSAGE_ID* psmsmidMessageID
);
// Determine an upper-bound for the size of the buffer needed by the next call to SmsReadMessage
HRESULT SmsGetMessageSize (
const SMS_HANDLE smshHandle,
DWORD* const pdwDataSize
);
// Read an SMS message (the appropriate size of the buffer can be found via a call to SmsGetMessageSize)
HRESULT SmsReadMessage (
const SMS_HANDLE smshHandle,
SMS_ADDRESS* const psmsaSMSCAddress,
SMS_ADDRESS* const psmsaSourceAddress,
SYSTEMTIME* const pstReceiveTime, // (UTC time)
BYTE* const pbBuffer,
DWORD dwBufferSize,
BYTE* const pbProviderSpecificBuffer,
DWORD dwProviderSpecificDataBuff er,
DWORD* pdwBytesRead
);
// Waits to receive a status-report for an SMS message
HRESULT SmsGetMessageStatus (
const SMS_HANDLE smshHandle,
SMS_MESSAGE_ID smsmidMessageID,
SMS_STATUS_INFORMATION* const psmssiStatusInformation,
const DWORD dwTimeout
);
// Get the default SMS Service Center address
HRESULT SmsGetSMSC (
SMS_ADDRESS* const psmsaSMSCAddress
);
// Set the default SMS Service Center address
HRESULT SmsSetSMSC (
const SMS_ADDRESS* const psmsaSMSCAddress
);
// Get the range of broadcast messages to listen for
HRESULT SmsGetBroadcastMsgRanges (
SMS_BROADCAST_RANGES* const psmsbrBroadcastRanges
);
// Set the range of broadcast messages to listen for
HRESULT SmsSetBroadcastMsgRanges (
const SMS_BROADCAST_RANGES* const psmsbrBroadcastRanges
);
// Get the device's phone number for SMS
HRESULT SmsGetPhoneNumber (
SMS_ADDRESS* const psmsaAddress
);
// Approximate the system time based on the time indicated by the SMSC in the last status-report message
HRESULT SmsGetTime (
SYSTEMTIME* const ptsCurrentTime, // (UTC time)
DWORD* const pdwErrorMargin
);
#ifdef __cplusplus
}
#endif
#endif // _SMS_H_
//////////////////////////
// Copyright (c) Microsoft Corporation. All rights reserved. //
//////////////////////////
#ifndef _SMS_H_
#define _SMS_H_
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
//
// Errors
//
#define FACILITY_SMS 0x200
// Specific registration errors (for SmsSetMessageNotification,
#define SMS_E_INVALIDPROTOCOL MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_REGISTRATIONEXISTS MAKE_HRESULT(SEVERITY_ERRO
#define SMS_S_NOSUCHREGISTRATION MAKE_HRESULT(SEVERITY_SUCC
// Specific messaging errors (for SmsOpen, SmsSendMessage, SmsGetSMSC, etc.)
#define SMS_E_TOOMUCHDATA MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_INVALIDDATA MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_BUFFERTOOSMALL MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_PROVIDERSPECIFICBUFF
#define SMS_E_TIMEUNAVAILABLE MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_RECEIVEHANDLEALREADY
#define SMS_E_DESTINATIONOUTOFSVC MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_INVALIDADDRESS MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_MSGBARREDBYOPERATOR MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_MSGCALLBARRED MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_NOSCSUBSCRIPTION MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_SCBUSY MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_SVCNOTSUBSCRIBED MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_UNASSIGNEDNUMBER MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_UNKNOWNSCADDRESS MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_UNIDENTIFIEDSUBCRIBE
// General SMS messaging errors
#define SMS_E_MISC MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_PASSWORD MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_SIM MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_NETWORKACCESS MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_NETWORK MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_MOBILE MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_NETWORKUNSUPPORTED MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_MOBILEUNSUPPORTED MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_BADPARAM MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_STORAGE MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_SMSC MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_DESTINATION MAKE_HRESULT(SEVERITY_ERRO
#define SMS_E_DESTINATIONUNSUPPORT
#define SMS_E_RADIOUNAVAILABLE MAKE_HRESULT(SEVERITY_ERRO
//
// Constants
//
#define SMS_DATAGRAM_SIZE (140)
#define SMS_BROADCAST_DATAGRAM_SIZ
#define SMS_MAX_APPNAME_LENGTH (MAX_PATH)
#define SMS_MAX_PARAMS_LENGTH (MAX_PATH)
#define SMS_MAX_PROTOCOLNAME_LENGT
#define SMS_MAX_MESSAGEUID_SIZE (1024)
#define SMS_MAX_ADDRESS_LENGTH (256)
#define SMS_MAX_SUBADDRESS_SIZE (256)
// dwMessageModes for SmsOpen
#define SMS_MODE_RECEIVE (0x00000001)
#define SMS_MODE_SEND (0x00000002)
// dwOptions for SmsSendMessage
#define SMS_OPTION_DELIVERY_NONE (0x00000000)
#define SMS_OPTION_DELIVERY_NO_RET
// dwMessageOptions for TEXT_PROVIDER_SPECIFIC_DAT
#define PS_MESSAGE_OPTION_NONE (0x00000000)
#define PS_MESSAGE_OPTION_REPLYPAT
#define PS_MESSAGE_OPTION_STATUSRE
#define PS_MESSAGE_OPTION_DISCARD (0x00000004)
// dwMessageStatus0 and dwMessageStatus1 for SmsGetMessageStatus and the SMS status-message provider (SMS_MSGTYPE_STATUS)
// Message status is unknown iff dwMessageStatus0 and dwMessageStatus1 are both set to MESSAGE_STATUS_UNKNOWN
#define MESSAGE_STATUS_UNKNOWN (0x00000000)
// Valid bits for dwMessageStatus0
#define MESSAGE_STATUS_0_RECEIVEDB
#define MESSAGE_STATUS_0_FORWARDED
#define MESSAGE_STATUS_0_REPLACEDB
#define MESSAGE_STATUS_0_CONGESTIO
#define MESSAGE_STATUS_0_SMEBUSY_T
#define MESSAGE_STATUS_0_SMENOTRES
#define MESSAGE_STATUS_0_SVCREJECT
#define MESSAGE_STATUS_0_QUALITYUN
#define MESSAGE_STATUS_0_SMEERROR_
#define MESSAGE_STATUS_0_CONGESTIO
#define MESSAGE_STATUS_0_SMEBUSY (0x00000400)
#define MESSAGE_STATUS_0_SMENOTRES
#define MESSAGE_STATUS_0_SVCREJECT
#define MESSAGE_STATUS_0_QUALITYUN
#define MESSAGE_STATUS_0_SMEERROR (0x00004000)
#define MESSAGE_STATUS_0_REMOTEPRO
#define MESSAGE_STATUS_0_INCOMPATI
#define MESSAGE_STATUS_0_CONNECTIO
#define MESSAGE_STATUS_0_NOTOBTAIN
#define MESSAGE_STATUS_0_NOINTERNE
#define MESSAGE_STATUS_0_VPEXPIRED
#define MESSAGE_STATUS_0_DELETEDBY
#define MESSAGE_STATUS_0_DELETEDBY
#define MESSAGE_STATUS_0_NOLONGERE
#define MESSAGE_STATUS_0_QUALITYUN
#define MESSAGE_STATUS_0_RESERVED_
#define MESSAGE_STATUS_0_RESERVED_
#define MESSAGE_STATUS_0_RESERVED_
#define MESSAGE_STATUS_0_RESERVED_
#define MESSAGE_STATUS_0_SCSPECIFI
#define MESSAGE_STATUS_0_SCSPECIFI
#define MESSAGE_STATUS_0_SCSPECIFI
// Valid bits for dwMessageStatus1
#define MESSAGE_STATUS_1_SCSPECIFI
// Language identifiers for SMS_BROADCAST_RANGES.dwBro
#define SMS_DCSLANG_UNKNOWN (0x00000001)
#define SMS_DCSLANG_GERMAN (0x00000002)
#define SMS_DCSLANG_ENGLISH (0x00000004)
#define SMS_DCSLANG_ITALIAN (0x00000008)
#define SMS_DCSLANG_FRENCH (0x00000010)
#define SMS_DCSLANG_SPANISH (0x00000020)
#define SMS_DCSLANG_DUTCH (0x00000040)
#define SMS_DCSLANG_SWEDISH (0x00000080)
#define SMS_DCSLANG_DANISH (0x00000100)
#define SMS_DCSLANG_PORTUGUESE (0x00000200)
#define SMS_DCSLANG_FINNISH (0x00000400)
#define SMS_DCSLANG_NORWEGIAN (0x00000800)
#define SMS_DCSLANG_GREEK (0x00001000)
#define SMS_DCSLANG_TURKISH (0x00002000)
#define SMS_DCSLANG_HUNGARIAN (0x00004000)
#define SMS_DCSLANG_POLISH (0x00008000)
#define SMS_DCSLANG_CZECH (0x00010000)
#define SMS_DCSLANG_ALL (0x0001ffff)
// Valid flags for SMS_BROADCAST_RANGES.dwPar
#define SMS_PARAM_SBR_BROADCASTMSG
#define SMS_PARAM_SBR_BROADCASTMSG
#define SMS_PARAM_SBR_ACCEPTIDS (0x00000004)
//
// Enumerations
//
enum SMS_ADDRESS_TYPE {
SMSAT_UNKNOWN=0,
SMSAT_INTERNATIONAL,
SMSAT_NATIONAL,
SMSAT_NETWORKSPECIFIC,
SMSAT_SUBSCRIBER,
SMSAT_ALPHANUMERIC,
SMSAT_ABBREVIATED
};
enum SMS_DATA_ENCODING {
SMSDE_OPTIMAL=0,
SMSDE_GSM,
SMSDE_UCS2,
};
enum PROVIDER_SPECIFIC_MESSAGE_
PS_MESSAGE_CLASS0 = 0,
PS_MESSAGE_CLASS1,
PS_MESSAGE_CLASS2,
PS_MESSAGE_CLASS3,
};
enum PROVIDER_SPECIFIC_REPLACE_
PSRO_NONE = 0,
PSRO_REPLACE_TYPE1,
PSRO_REPLACE_TYPE2,
PSRO_REPLACE_TYPE3,
PSRO_REPLACE_TYPE4,
PSRO_REPLACE_TYPE5,
PSRO_REPLACE_TYPE6,
PSRO_REPLACE_TYPE7,
PSRO_RETURN_CALL,
PSRO_DEPERSONALIZATION,
};
//
// Types
//
typedef DWORD SMS_HANDLE;
typedef DWORD SMS_MESSAGE_ID;
#define INVALID_MESSAGE_ID ((SMS_MESSAGE_ID)0xfffffff
// Registration structure used by SmsSetMessageNotification and SmsClearMessageNotificatio
typedef struct smsregistrationdata_tag {
DWORD cbSize;
TCHAR tszAppName[SMS_MAX_APPNAME
TCHAR tszParams[SMS_MAX_PARAMS_L
TCHAR tszProtocolName[SMS_MAX_PR
} SMSREGISTRATIONDATA, *LPSMSREGISTRATIONDATA;
// SMS addressing information
typedef struct sms_address_tag {
SMS_ADDRESS_TYPE smsatAddressType;
TCHAR ptsAddress[SMS_MAX_ADDRESS
} SMS_ADDRESS, *LPSMS_ADDRESS;
// SMS status message information
typedef struct sms_status_information_tag
SMS_MESSAGE_ID smsmidMessageID;
DWORD dwMessageStatus0;
DWORD dwMessageStatus1;
SMS_ADDRESS smsaRecipientAddress;
SYSTEMTIME stServiceCenterTimeStamp; // (UTC time)
SYSTEMTIME stDischargeTime; // (UTC time)
} SMS_STATUS_INFORMATION, *LPSMS_STATUS_INFORMATION;
// SMS broadcast message range information
typedef struct sms_range_tag {
DWORD dwMinimum;
DWORD dwMaximum;
} SMS_RANGE, *LPSMS_RANGE;
// SMS broadcast message ranges information
// Use #pragma to avoid "warning C4200: nonstandard extension used : zero-sized array in struct/union
#pragma warning(disable:4200)
typedef struct sms_broadcast_ranges_tag {
DWORD cbSize;
DWORD dwParams;
DWORD dwNumRanges;
DWORD dwBroadcastMsgLangs;
BOOL bAccept;
SMS_RANGE smsrBroadcastRanges[];
} SMS_BROADCAST_RANGES, *LPSMS_BROADCAST_RANGES;
#pragma warning(default:4200)
//
// SMS message types (for use with SmsOpen)
//
// Text message type
#define SMS_MSGTYPE_TEXT TEXT("Microsoft Text SMS Protocol")
// Provider-specific data for use with SmsSendMessage and SmsReadMessage
typedef struct text_provider_specific_dat
DWORD dwMessageOptions;
PROVIDER_SPECIFIC_MESSAGE_
PROVIDER_SPECIFIC_REPLACE_
} TEXT_PROVIDER_SPECIFIC_DAT
// Notification message type
#define SMS_MSGTYPE_NOTIFICATION TEXT("Microsoft Notification SMS Protocol (Receive Only)")
// Provider-specific data for use with SmsReadMessage
enum NOTIFICATION_PROVIDER_SPEC
NOTIFICATIONPSMWT_NONE = 0,
NOTIFICATIONPSMWT_GENERIC,
NOTIFICATIONPSMWT_VOICEMAI
NOTIFICATIONPSMWT_FAX,
NOTIFICATIONPSMWT_EMAIL,
NOTIFICATIONPSMWT_OTHER,
};
#define NOTIFICATIONPS_NUM_MSG_WAI
#define NOTIFICATIONPS_NUM_MSG_WAI
enum NOTIFICATION_PROVIDER_SPEC
NOTIFICATIONPSIT_NONE = 0,
NOTIFICATIONPSIT_LINE1 = 1,
NOTIFICATIONPSIT_LINE2 = 2,
};
typedef struct notification_provider_spec
DWORD dwMessageOptions;
PROVIDER_SPECIFIC_MESSAGE_
PROVIDER_SPECIFIC_REPLACE_
NOTIFICATION_PROVIDER_SPEC
int iNumberOfMessagesWaiting;
NOTIFICATION_PROVIDER_SPEC
} NOTIFICATION_PROVIDER_SPEC
// WDP message type
#define SMS_MSGTYPE_WDP TEXT("Microsoft WDP SMS Protocol")
// Provider-specific data for use with SmsSendMessage and SmsReadMessage
enum WDP_PROVIDER_SPECIFIC_PORT
WDPPSPA_8_BIT_PORT_NUMBERS
WDPPSPA_16_BIT_PORT_NUMBER
};
typedef struct wdp_provider_specific_data
WDP_PROVIDER_SPECIFIC_PORT
WORD wDestinationPort;
WORD wOriginatorPort;
} WDP_PROVIDER_SPECIFIC_DATA
// WCMP message type
#define SMS_MSGTYPE_WCMP TEXT("Microsoft WCMP SMS Protocol")
// Provider-specific data for use with SmsSendMessage and SmsReadMessage
enum WCMP_PROVIDER_SPECIFIC_MES
WCMPPSMT_UNSUPPORTED = 0,
WCMPPSMT_PORT_UNREACHABLE,
WCMPPSMT_MESSAGE_TOO_BIG,
WCMPPSMT_ECHO_REQUEST,
WCMPPSMT_ECHO_REPLY,
};
typedef struct wcmp_provider_specific_dat
WCMP_PROVIDER_SPECIFIC_MES
WORD wParam1;
WORD wParam2;
WORD wParam3;
SMS_ADDRESS smsaAddress;
} WCMP_PROVIDER_SPECIFIC_DAT
// Status message type
#define SMS_MSGTYPE_STATUS TEXT("Microsoft Status Message SMS Protocol (Receive Only)")
// Provider-specific data for use with SmsReadMessage
typedef struct status_provider_specific_d
SMS_STATUS_INFORMATION smssiStatusInformation;
} STATUS_PROVIDER_SPECIFIC_D
// Broadcast message type
#define SMS_MSGTYPE_BROADCAST TEXT("Microsoft Broadcast Message SMS Protocol (Receive Only)")
enum BROADCAST_PROVIDER_SPECIFI
BPSGS_UNKNOWN = 0,
BPSGS_CELL_DISPLAY_IMMEDIA
BPSGS_CELL,
BPSGS_PLMN,
BPSGS_LOCATION_AREA,
};
// Provider-specific data for use with SmsReadMessage
typedef struct broadcast_provider_specifi
WORD wMessageID;
WORD wMessageCode;
BROADCAST_PROVIDER_SPECIFI
WORD wUpdateNumber;
} BROADCAST_PROVIDER_SPECIFI
// Raw message type
#define SMS_MSGTYPE_RAW TEXT("Microsoft Raw SMS Protocol (Receive Only)")
// Provider-specific data for use with SmsReadMessage
typedef struct raw_provider_specific_data
DWORD dwHeaderDataSize;
BYTE pbHeaderData[SMS_DATAGRAM_
} RAW_PROVIDER_SPECIFIC_DATA
//
// APIs for SMS.dll
//
HRESULT SmsSetMessageNotification (
const SMSREGISTRATIONDATA* psmsrd
);
HRESULT SmsClearMessageNotificatio
const LPCTSTR tszProtocolName
);
// Open the SMS Messaging component for read and/or write access
HRESULT SmsOpen (
const LPCTSTR ptsMessageProtocol,
const DWORD dwMessageModes,
SMS_HANDLE* const psmshHandle,
HANDLE* const phMessageAvailableEvent
);
// Close a handle to the SMS messaging component
HRESULT SmsClose (
const SMS_HANDLE smshHandle
);
// Send an SMS message
HRESULT SmsSendMessage (
const SMS_HANDLE smshHandle,
const SMS_ADDRESS* const psmsaSMSCAddress,
const SMS_ADDRESS* const psmsaDestinationAddress,
const SYSTEMTIME* const pstValidityPeriod, // (Values in this structure are expressed relative to the current time)
const BYTE* const pbData,
const DWORD dwDataSize,
const BYTE* const pbProviderSpecificData,
const DWORD dwProviderSpecificDataSize
const SMS_DATA_ENCODING smsdeDataEncoding,
const DWORD dwOptions,
SMS_MESSAGE_ID* psmsmidMessageID
);
// Determine an upper-bound for the size of the buffer needed by the next call to SmsReadMessage
HRESULT SmsGetMessageSize (
const SMS_HANDLE smshHandle,
DWORD* const pdwDataSize
);
// Read an SMS message (the appropriate size of the buffer can be found via a call to SmsGetMessageSize)
HRESULT SmsReadMessage (
const SMS_HANDLE smshHandle,
SMS_ADDRESS* const psmsaSMSCAddress,
SMS_ADDRESS* const psmsaSourceAddress,
SYSTEMTIME* const pstReceiveTime, // (UTC time)
BYTE* const pbBuffer,
DWORD dwBufferSize,
BYTE* const pbProviderSpecificBuffer,
DWORD dwProviderSpecificDataBuff
DWORD* pdwBytesRead
);
// Waits to receive a status-report for an SMS message
HRESULT SmsGetMessageStatus (
const SMS_HANDLE smshHandle,
SMS_MESSAGE_ID smsmidMessageID,
SMS_STATUS_INFORMATION* const psmssiStatusInformation,
const DWORD dwTimeout
);
// Get the default SMS Service Center address
HRESULT SmsGetSMSC (
SMS_ADDRESS* const psmsaSMSCAddress
);
// Set the default SMS Service Center address
HRESULT SmsSetSMSC (
const SMS_ADDRESS* const psmsaSMSCAddress
);
// Get the range of broadcast messages to listen for
HRESULT SmsGetBroadcastMsgRanges (
SMS_BROADCAST_RANGES* const psmsbrBroadcastRanges
);
// Set the range of broadcast messages to listen for
HRESULT SmsSetBroadcastMsgRanges (
const SMS_BROADCAST_RANGES* const psmsbrBroadcastRanges
);
// Get the device's phone number for SMS
HRESULT SmsGetPhoneNumber (
SMS_ADDRESS* const psmsaAddress
);
// Approximate the system time based on the time indicated by the SMSC in the last status-report message
HRESULT SmsGetTime (
SYSTEMTIME* const ptsCurrentTime, // (UTC time)
DWORD* const pdwErrorMargin
);
#ifdef __cplusplus
}
#endif
#endif // _SMS_H_
Thanks I've copied that.
I notice that you open for receive but there is no handle for the available event (null as last parameter). I suggest that you give the procedure a handle parameter, so that the event may be returned, even though you don't use it.
Otherwise I don't see what is wrong. You code is identical to the VB sample at MSDN ;)
I notice that you open for receive but there is no handle for the available event (null as last parameter). I suggest that you give the procedure a handle parameter, so that the event may be returned, even though you don't use it.
Otherwise I don't see what is wrong. You code is identical to the VB sample at MSDN ;)
ASKER
hi bigrat,
i have been trying and last ended up righting functions to send the SMS message and read the SMS message,
sending the messsage is succesful everytime but i was able to read the message only once and after then it is failing all the time...again struck..for your inoformation i am pasting both the functions for sending and reading,if u can try out the code and tell me where am i goining wrong ,it would be great!
//Function Code For sending SMS message
void CTestSMSDlg::OnSend()
{
HRESULT hrSms;
SMS_HANDLE psmshHandle;
SMSREGISTRATIONDATA smsrd;
CEvent hEvtHandle;
TCHAR ptsMessageProtocol[100];
wcscpy(ptsMessageProtocol, SMS_MSGTYP E_TEXT) ;
hrSms = SmsOpen(ptsMessageProtocol ,SMS_MODE_ SEND,&psms hHandle,(H ANDLE*)&hE vtHandle);
if (hrSms)
{
AfxMessageBox(L"SmsOpen failed");
return ;
}
else
{
AfxMessageBox(L"SmsOpen Success");
}
SMS_ADDRESS smsaDestinationAddress;
smsaDestinationAddress.sms atAddressT ype = SMSAT_INTERNATIONAL;
wcscpy(smsaDestinationAddr ess.ptsAdd ress,L"984 9393706") ;
BYTE * pbData;
DWORD dwDataSize;
BYTE * pbProviderSpecificData;
DWORD dwProviderSpecificDataSize ;
TEXT_PROVIDER_SPECIFIC_DAT A providerSD;
providerSD.dwMessageOption s = PS_MESSAGE_OPTION_NONE ;
providerSD.psMessageClass = PS_MESSAGE_CLASS1 ;
providerSD.psReplaceOption = PSRO_NONE;
dwProviderSpecificDataSize = sizeof(TEXT_PROVIDER_SPECI FIC_DATA);
TCHAR szMsg[]=L"Warning: Yahooo you Did it";
pbData = (BYTE *)szMsg;
dwDataSize = wcslen(szMsg)*sizeof(TCHAR );
pbProviderSpecificData = (BYTE *)&providerSD;
hrSms = SmsSendMessage (psmshHandle,NULL,&smsaDes tinationAd dress,NULL ,pbData,dw DataSize,p bProviderS pecificDat a,dwProvid erSpecific DataSize,/ *SMSDE_GSM */SMSDE_OP TIMAL,SMS_ OPTION_DEL IVERY_NONE ,NULL);
if (hrSms)
{
AfxMessageBox(L"Sms sent failed.");
}
else AfxMessageBox(L"Sms sent sucessfull.");
hrSms = SmsClose (psmshHandle);
if (hrSms)
{
AfxMessageBox(L"SmsClose failed.");
}
else AfxMessageBox(L"SmsClose sucessfull.");
return ;
}
// Function Code to Read The SMS Message
void CTestSMSDlg::Onread()
{
HRESULT hrSms;
SMS_HANDLE psmshHandle;
SMSREGISTRATIONDATA smsrd;
CEvent hEvtHandle;
DWORD size,read;
size=399;
SMS_ADDRESS smsaDestinationAddress;
smsaDestinationAddress.sms atAddressT ype = SMSAT_INTERNATIONAL;
//wcscpy(smsaDestinationAd dress.ptsA ddress,L"8 6138666688 88") ;
wcscpy(smsaDestinationAddr ess.ptsAdd ress,L"984 9393706") ;
TCHAR ptsMessageProtocol[100];
wcscpy(ptsMessageProtocol, SMS_MSGTYP E_TEXT) ;
hrSms = SmsOpen(ptsMessageProtocol ,SMS_MODE_ RECEIVE,&p smshHandle ,(HANDLE*) &hEvtHandl e);
if (hrSms)
{
//AlertErrorType(hrSms);
AfxMessageBox(L"SmsOpen failed");
return ;
}
else
{
AfxMessageBox(L"SmsOpen Success");
}
BYTE * pbProviderSpecificData;
DWORD dwProviderSpecificDataSize ;
TEXT_PROVIDER_SPECIFIC_DAT A providerSD;
providerSD.dwMessageOption s = PS_MESSAGE_OPTION_NONE ;
providerSD.psMessageClass = PS_MESSAGE_CLASS1 ;
providerSD.psReplaceOption = PSRO_NONE;
dwProviderSpecificDataSize = sizeof(TEXT_PROVIDER_SPECI FIC_DATA);
TCHAR buffer[160] ;
BYTE *p;
p =(BYTE *) buffer;
hrSms=SmsReadMessage (psmshHandle,NULL,&smsaDes tinationAd dress,NULL ,p,318,pbP roviderSpe cificData, dwProvider SpecificDa taSize,&re ad);
if (hrSms)
{
AfxMessageBox(L"SmsRead Failed");
hrSms = SmsClose (psmshHandle);
return ;
}
else
{
AfxMessageBox(L"SmsRead Success");
CString s;
s=buffer;
AfxMessageBox(s);
}
hrSms = SmsClose (psmshHandle);
if (hrSms)
{
AfxMessageBox(L"SmsClose failed.");
}
else
{
AfxMessageBox(L"SmsClose sucessfull.");
return ;
}
}
the above read function was succesful only for once, i could read the complete message and then afterwards when i hit read the smsread fails..........
FYI: what i have observed is before we open a handle to the inbox we should make sure that no other application has an handle to inbox,so i have stopped tmail.exe which always holds an handle to the inbox.hence i am able to open the inbox for reading...
my badluck is still unable to read the messages....
for sure i am missing something somewhere...
kidly help me out...
thank you very much for your time.
Regards,
Srinivas
i have been trying and last ended up righting functions to send the SMS message and read the SMS message,
sending the messsage is succesful everytime but i was able to read the message only once and after then it is failing all the time...again struck..for your inoformation i am pasting both the functions for sending and reading,if u can try out the code and tell me where am i goining wrong ,it would be great!
//Function Code For sending SMS message
void CTestSMSDlg::OnSend()
{
HRESULT hrSms;
SMS_HANDLE psmshHandle;
SMSREGISTRATIONDATA smsrd;
CEvent hEvtHandle;
TCHAR ptsMessageProtocol[100];
wcscpy(ptsMessageProtocol,
hrSms = SmsOpen(ptsMessageProtocol
if (hrSms)
{
AfxMessageBox(L"SmsOpen failed");
return ;
}
else
{
AfxMessageBox(L"SmsOpen Success");
}
SMS_ADDRESS smsaDestinationAddress;
smsaDestinationAddress.sms
wcscpy(smsaDestinationAddr
BYTE * pbData;
DWORD dwDataSize;
BYTE * pbProviderSpecificData;
DWORD dwProviderSpecificDataSize
TEXT_PROVIDER_SPECIFIC_DAT
providerSD.dwMessageOption
providerSD.psMessageClass = PS_MESSAGE_CLASS1 ;
providerSD.psReplaceOption
dwProviderSpecificDataSize
TCHAR szMsg[]=L"Warning: Yahooo you Did it";
pbData = (BYTE *)szMsg;
dwDataSize = wcslen(szMsg)*sizeof(TCHAR
pbProviderSpecificData = (BYTE *)&providerSD;
hrSms = SmsSendMessage (psmshHandle,NULL,&smsaDes
if (hrSms)
{
AfxMessageBox(L"Sms sent failed.");
}
else AfxMessageBox(L"Sms sent sucessfull.");
hrSms = SmsClose (psmshHandle);
if (hrSms)
{
AfxMessageBox(L"SmsClose failed.");
}
else AfxMessageBox(L"SmsClose sucessfull.");
return ;
}
// Function Code to Read The SMS Message
void CTestSMSDlg::Onread()
{
HRESULT hrSms;
SMS_HANDLE psmshHandle;
SMSREGISTRATIONDATA smsrd;
CEvent hEvtHandle;
DWORD size,read;
size=399;
SMS_ADDRESS smsaDestinationAddress;
smsaDestinationAddress.sms
//wcscpy(smsaDestinationAd
wcscpy(smsaDestinationAddr
TCHAR ptsMessageProtocol[100];
wcscpy(ptsMessageProtocol,
hrSms = SmsOpen(ptsMessageProtocol
if (hrSms)
{
//AlertErrorType(hrSms);
AfxMessageBox(L"SmsOpen failed");
return ;
}
else
{
AfxMessageBox(L"SmsOpen Success");
}
BYTE * pbProviderSpecificData;
DWORD dwProviderSpecificDataSize
TEXT_PROVIDER_SPECIFIC_DAT
providerSD.dwMessageOption
providerSD.psMessageClass = PS_MESSAGE_CLASS1 ;
providerSD.psReplaceOption
dwProviderSpecificDataSize
TCHAR buffer[160] ;
BYTE *p;
p =(BYTE *) buffer;
hrSms=SmsReadMessage (psmshHandle,NULL,&smsaDes
if (hrSms)
{
AfxMessageBox(L"SmsRead Failed");
hrSms = SmsClose (psmshHandle);
return ;
}
else
{
AfxMessageBox(L"SmsRead Success");
CString s;
s=buffer;
AfxMessageBox(s);
}
hrSms = SmsClose (psmshHandle);
if (hrSms)
{
AfxMessageBox(L"SmsClose failed.");
}
else
{
AfxMessageBox(L"SmsClose sucessfull.");
return ;
}
}
the above read function was succesful only for once, i could read the complete message and then afterwards when i hit read the smsread fails..........
FYI: what i have observed is before we open a handle to the inbox we should make sure that no other application has an handle to inbox,so i have stopped tmail.exe which always holds an handle to the inbox.hence i am able to open the inbox for reading...
my badluck is still unable to read the messages....
for sure i am missing something somewhere...
kidly help me out...
thank you very much for your time.
Regards,
Srinivas
tmail.exe: Funny that the HResult did not reflect that?! I would have thought that we'd get a straight-forward "in-use" response.
You say that you can read the message once. I see from the interface that there is no queue which on can index (ie: no getQueueLength(), getQueueItem(i) etc...), so I suspect that the underlying software reads the message out of the memory and then deletes the first element in the memory.
"my badluck ............."
Don't be so negative. This is early days for this sort of technology. The amount of information from MS is appalling! I think you're doing great!
You say that you can read the message once. I see from the interface that there is no queue which on can index (ie: no getQueueLength(), getQueueItem(i) etc...), so I suspect that the underlying software reads the message out of the memory and then deletes the first element in the memory.
"my badluck ............."
Don't be so negative. This is early days for this sort of technology. The amount of information from MS is appalling! I think you're doing great!
ASKER
hi bigrat ,
your words boost my confidence,i am still working on this program if you find anything useful please post it here,it will be of great help.
FYI: i am also working on INTERMEC 760 Device where in intermec guys have provided WWANTOOLKIT.dll which has simple functions which can read/send SMS messsages.once i am done with this i will again move on to T-mobile.
thank you very much for your time,
Regards,
Srinivas Sesham.
your words boost my confidence,i am still working on this program if you find anything useful please post it here,it will be of great help.
FYI: i am also working on INTERMEC 760 Device where in intermec guys have provided WWANTOOLKIT.dll which has simple functions which can read/send SMS messsages.once i am done with this i will again move on to T-mobile.
thank you very much for your time,
Regards,
Srinivas Sesham.
OK. If I find anything I'll post it!
ASKER
hi bigrat,
i am back,even the WWANToolkit.dll provided by intermec does not work for reading the SMS messages propely,so i have decided to work with AT commands.
i have written a sample applicaton in EVC++ to open the COM4: and write AT commands to that,and read back the message from the port.
But when i write some command(for Ex : AT+CMGF=1) to te port it is taking quite some time and when i read from the port what i get is error(AT+CMGF=1 ERROR).
do i need to take any additional steps before i write to the port.
for your info i am pasting my code,
void CTestATCommandsDlg::OnOpen com4()
{
if(port.SerialOpen(_T("COM 4:"),11520 0,_T("N"), TEXT("1")) )
{
AfxMessageBox(_T("COM4: Opened"));
}
else
{
AfxMessageBox(_T("COM4: Open Failed"));
}
}
void CTestATCommandsDlg::OnClos e()
{
port.SerialClose();
}
void CTestATCommandsDlg::OnSend ()
{
CString command;
m_edit.GetWindowText(comma nd);
command.TrimLeft();
command.TrimRight();
if(command=="")
{
AfxMessageBox(_T("Please Enter A Valid AT Command,And Press 'Send'"));
return;
}
port.SerialWrite((unsigned short *)(LPCTSTR)command);
OnRead();
}
void CTestATCommandsDlg::OnRead ()
{
CString command;
TCHAR msg[256];
port.SerialRead(msg,255);
command=msg;
command.TrimLeft();
command.TrimRight();
AfxMessageBox(command);
m_result.AddString(command );
}
thanks in advance,
Srinivas Sesham
i am back,even the WWANToolkit.dll provided by intermec does not work for reading the SMS messages propely,so i have decided to work with AT commands.
i have written a sample applicaton in EVC++ to open the COM4: and write AT commands to that,and read back the message from the port.
But when i write some command(for Ex : AT+CMGF=1) to te port it is taking quite some time and when i read from the port what i get is error(AT+CMGF=1 ERROR).
do i need to take any additional steps before i write to the port.
for your info i am pasting my code,
void CTestATCommandsDlg::OnOpen
{
if(port.SerialOpen(_T("COM
{
AfxMessageBox(_T("COM4: Opened"));
}
else
{
AfxMessageBox(_T("COM4: Open Failed"));
}
}
void CTestATCommandsDlg::OnClos
{
port.SerialClose();
}
void CTestATCommandsDlg::OnSend
{
CString command;
m_edit.GetWindowText(comma
command.TrimLeft();
command.TrimRight();
if(command=="")
{
AfxMessageBox(_T("Please Enter A Valid AT Command,And Press 'Send'"));
return;
}
port.SerialWrite((unsigned
OnRead();
}
void CTestATCommandsDlg::OnRead
{
CString command;
TCHAR msg[256];
port.SerialRead(msg,255);
command=msg;
command.TrimLeft();
command.TrimRight();
AfxMessageBox(command);
m_result.AddString(command
}
thanks in advance,
Srinivas Sesham
ASKER
hi,
i am using,AT Command Set for the Siemens MC45 Cellular Engine.
now i am able to send AT commands and receive the response ,but when i use AT+CMGR=<index> then the response is
+CMGR: <stat>,<oa>,[<alpha>],<sct s> [,<tooa>,<fo>,<pid>,<dcs>,
<sca>,<tosca>,<length>]<CR ><LF><data >
in the above response,i am getting data after <CR><LF> ,how do i know whats the length of the 'data'.if i hardcode the no of characters(say 160) to be read then the Read method waits for ever if the data length is less (say 50)than the harcoded value(160).
how do i solve this?
thanks in advance,
Srinivas Sesham.
i am using,AT Command Set for the Siemens MC45 Cellular Engine.
now i am able to send AT commands and receive the response ,but when i use AT+CMGR=<index> then the response is
+CMGR: <stat>,<oa>,[<alpha>],<sct
<sca>,<tosca>,<length>]<CR
in the above response,i am getting data after <CR><LF> ,how do i know whats the length of the 'data'.if i hardcode the no of characters(say 160) to be read then the Read method waits for ever if the data length is less (say 50)than the harcoded value(160).
how do i solve this?
thanks in advance,
Srinivas Sesham.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi,
no it does not end with ok<CR><LF> ,i am getting data after <CR><LF><data is here.......>
i am pasting the content of the document.
5.5 AT+CMGR Read SMS message
Test command
AT+CMGR=?
Response
OK
Execute command
AT+CMGR=
<index>
Parameter
<index> integer type; value in the range of location numbers supported by the
associated memory
Response
TA returns SMS message with location value <index> from message storage
<mem1> to the TE. If status of the message is ‚received unread™, status in the
storage changes to ‚received read™.
1) If text mode (+CMGF=1) and command successful:
for SMS-DELIVER:
+CMGR: <stat>,<oa>,[<alpha>],<sct s> [,<tooa>,<fo>,<pid>,<dcs>,
<sca>,<tosca>,<length>]<CR ><LF><data >
for SMS-SUBMIT:
+CMGR: <stat>,<da>,[<alpha>] [,<toda>,<fo>,<pid>,<dcs>, [<vp>],
<sca>,<tosca>,<length>]<CR ><LF><data >
for SMS-STATUS-REPORT:
+CMGR: <stat>,<fo>,<mr>,[<ra>],[< tora>],<sc ts>,<dt>,< st>
for SMS- COMMAND:
+CMGR: <stat>,<fo>,<ct> [,<pid>,[<mn>],[<da>],[<to da>],<leng th>
<CR><LF><cdata>]
for CBM storage:
+CMGR: <stat>,<sn>,<mid>,<dcs>,<p age>,<page s><CR><LF> <data>
2) If PDU mode (+CMGF=0) and command successful:
+CMGR: <stat>,[<alpha>],<length>< CR><LF><pd u> OK
for CBM storage:
+CMGR: <length><CR><LF><pdu>
3)If error is related to ME functionality:
+CMS ERROR: <err>
kindly help,thanks.
Srinivas.
no it does not end with ok<CR><LF> ,i am getting data after <CR><LF><data is here.......>
i am pasting the content of the document.
5.5 AT+CMGR Read SMS message
Test command
AT+CMGR=?
Response
OK
Execute command
AT+CMGR=
<index>
Parameter
<index> integer type; value in the range of location numbers supported by the
associated memory
Response
TA returns SMS message with location value <index> from message storage
<mem1> to the TE. If status of the message is ‚received unread™, status in the
storage changes to ‚received read™.
1) If text mode (+CMGF=1) and command successful:
for SMS-DELIVER:
+CMGR: <stat>,<oa>,[<alpha>],<sct
<sca>,<tosca>,<length>]<CR
for SMS-SUBMIT:
+CMGR: <stat>,<da>,[<alpha>] [,<toda>,<fo>,<pid>,<dcs>,
<sca>,<tosca>,<length>]<CR
for SMS-STATUS-REPORT:
+CMGR: <stat>,<fo>,<mr>,[<ra>],[<
for SMS- COMMAND:
+CMGR: <stat>,<fo>,<ct> [,<pid>,[<mn>],[<da>],[<to
<CR><LF><cdata>]
for CBM storage:
+CMGR: <stat>,<sn>,<mid>,<dcs>,<p
2) If PDU mode (+CMGF=0) and command successful:
+CMGR: <stat>,[<alpha>],<length><
for CBM storage:
+CMGR: <length><CR><LF><pdu>
3)If error is related to ME functionality:
+CMS ERROR: <err>
kindly help,thanks.
Srinivas.
No, re-read the specification again and carefully.
Every command ends with an OK, in fact with a CF/LF/OK/CR/LF sequence. Or it ends with ERROR <text>CR/LF
The individual descriptions of the commands OMIT the trailing OK sequence since it occurs on EVERY command.
That is how I have implemented it.
Every command ends with an OK, in fact with a CF/LF/OK/CR/LF sequence. Or it ends with ERROR <text>CR/LF
The individual descriptions of the commands OMIT the trailing OK sequence since it occurs on EVERY command.
That is how I have implemented it.
ASKER
you were right, i got it.thankyou very much for your time.
one last question,
>>"I first turn echo OFF!
how do you do that and why?
one last question,
>>"I first turn echo OFF!
how do you do that and why?
By sending ATE0<CR><LF> at the very beginning and expecting ATE0<CR><LF>OK<CR><LF>. From then on you don't have to ignore the echoed characters.
ASKER
ok thanks,
i have placed a new question regarding the AT commands..please check it out.
i have placed a new question regarding the AT commands..please check it out.
Hi Guys
I know this thread was started ages ago, but I've just started doing somethings of the SPV this morning, and found this thread very usfull so I just thought
I would let you know where srithi was going wrong using SmsOpen and receiving only one SMS notification. When you call smsOpen like this
(from your last code snippit on 16th March)
SmsOpen(ptsMessageProtocol ,SMS_MODE_ RECEIVE,&p smshHandle ,(HANDLE*) &hEvtHandl e);
The problem is you are not waiting for the message to arrive with the hEvtHandle, if you do WaitForEvent(hEvtHandle, INFINITE) when the event
signals a new sms has arrived, so you can read it, using as you have done smsReadMesage, once read and the hEvtHandle is reset (ResetEvent(hEvtHandle))
, call it WaitForEvent again and recieve the next SMS sent and so on.
Check out this for more info hEvtHandle http://msdn.microsoft.com/library/default.asp?url=/library/en-us/win_ce/htm/pwc_smsmessaging.asp
Hope its of some help, and you hacnt completely given up on this.
I know this thread was started ages ago, but I've just started doing somethings of the SPV this morning, and found this thread very usfull so I just thought
I would let you know where srithi was going wrong using SmsOpen and receiving only one SMS notification. When you call smsOpen like this
(from your last code snippit on 16th March)
SmsOpen(ptsMessageProtocol
The problem is you are not waiting for the message to arrive with the hEvtHandle, if you do WaitForEvent(hEvtHandle, INFINITE) when the event
signals a new sms has arrived, so you can read it, using as you have done smsReadMesage, once read and the hEvtHandle is reset (ResetEvent(hEvtHandle))
, call it WaitForEvent again and recieve the next SMS sent and so on.
Check out this for more info hEvtHandle http://msdn.microsoft.com/library/default.asp?url=/library/en-us/win_ce/htm/pwc_smsmessaging.asp
Hope its of some help, and you hacnt completely given up on this.
How can i set Application Port Address in Binary SMS message using SmsSendMessage ?
I have a guess that WDP_PROVIDER_SPECIFIC_DATA should be used in the dwProviderSpecificDataSize ,
parameter for SmsSendMessage, am i right??
How do i register my application to be notified whenever the device receives a SMS with UDH (GSM 3.40) containing a
particular potr number??
Please help.
Regards
I have a guess that WDP_PROVIDER_SPECIFIC_DATA
parameter for SmsSendMessage, am i right??
How do i register my application to be notified whenever the device receives a SMS with UDH (GSM 3.40) containing a
particular potr number??
Please help.
Regards
sorrie... I'm also working on it too... U ppl mind helping me?
I tried to program my project(almost the same as U, using MFC onCommandstuff) after I have read up then I was able to compile and have no error...
but when I execute it occur this error
\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\
LuckySMSDlg.obj : error LNK2019: unresolved external symbol SmsOpen referenced in function "protected: void __cdecl CLuckySMSDlg::OnSubmit(voi d)" (?OnSubmit@CLuckySMSDlg@@I AAXXZ)
ARMRel/LuckySMS.exe : fatal error LNK1120: 1 unresolved externals
\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\
this is my code...................... ..
void CLuckySMSDlg::OnSubmit()
{
SMS_HANDLE smsHandle = NULL;
HANDLE hSmsEvent = NULL;
if (0 != SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smsHandle, &hSmsEvent)){
}
}
no error in compiling.
then I tot is my fault so I took your code and paste it on my program.
and it can compile too. but in the end same problem occur so may I know wat did I miss out?
I tried to program my project(almost the same as U, using MFC onCommandstuff) after I have read up then I was able to compile and have no error...
but when I execute it occur this error
\\\\\\\\\\\\\\\\\\\\\\\\\\
LuckySMSDlg.obj : error LNK2019: unresolved external symbol SmsOpen referenced in function "protected: void __cdecl CLuckySMSDlg::OnSubmit(voi
ARMRel/LuckySMS.exe : fatal error LNK1120: 1 unresolved externals
\\\\\\\\\\\\\\\\\\\\\\\\\\
this is my code......................
void CLuckySMSDlg::OnSubmit()
{
SMS_HANDLE smsHandle = NULL;
HANDLE hSmsEvent = NULL;
if (0 != SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smsHandle, &hSmsEvent)){
}
}
no error in compiling.
then I tot is my fault so I took your code and paste it on my program.
and it can compile too. but in the end same problem occur so may I know wat did I miss out?