Home > Archive > Smartphone Developer Forum > October 2005 > Sending SMS text
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| hansw77041 2005-10-07, 7:04 pm |
| There seems to be very few real working examples for Sending / Receiving SMS
text messages using eVC++ 4.2 or for PocketPC.
I found Douglas Boling's SMSTalk in his book, but unfortunately the code
compiles but does not work.
Here is my abreviated SMS code that I'm using.
// try to open an SMS Handle
HREULST hr = HSmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smshHandle,
&hSmsEvent);
if (hr != ERROR_SUCCESS)
{
return hr; // never fails
}
// wait for SMS Event to become signaled
DWORD dwReturn = 0;
dwReturn = WaitForSingleObject( hSmsEvent, INFINITE ); // never fails
if(dwReturn == WAIT_ABANDONED || dwReturn == WAIT_TIMEOUT)
{
SmsClose(smshHandle);
return -1; // never fails
}
// Set up provider specific data
DWORD sof = sizeof(TEXT_PROVIDER_SPECIFIC_DATA);
memset(&tpsd, 0, sof);
tpsd.dwMessageOptions = PS_MESSAGE_OPTION_NONE;
tpsd.psMessageClass = PS_MESSAGE_CLASS0; // I also tried PS_MESSAGE_CLASS1
tpsd.psReplaceOption = PSRO_NONE;
// send the message
hr = SmsSendMessage (smshHandle,
NULL,
&smsDest,
NULL,
(PBYTE)pMsg, // the message
Len, // the message l;ength
(PBYTE) &tpsd,
sof, // Boling sets this to 12 tired it each way
does not change anything
SMSDE_OPTIMAL,
SMS_OPTION_DELIVERY_NONE,
&smsmidMessageID );
// at this point hr is always 0 which is S_OK which means success and never
fails
// Just to be sure, retrieve the status from the Service Center
memset(&smsStatusInfo, NULL, sizeof(SMS_STATUS_INFORMATION));
memset(tmpStr, NULL, sizeof(wchar_t) * STD_STR_LEN);
HRESULT sendResult = SmsGetMessageStatus(smshHandle, smsmidMessageID,
&smsStatusInfo, 5000); // always fails !
SmsClose (smshHandle);
-------------------------end
code-----------------------------------------------------------
SmsGetMessageStatus() always fails with this message "Unable to get Service
Center info: 0X80004005"
Sending the same message 10 times, SmsSendMessage() always returns S_OK the
message gets delivered ONCE (out of 10) but the NO text, just that a text
message came form my phone.!
My Questions:
Is there a real SMS example for PocketPC or SmartPhone using eVC++ ?
Any suggestions about problems with my version of this code are welcome.
Has anyone used .NET to SmartPhone 2003 Second Edition with the eVC++ 4.2
IDE ?
Is there a better way to do SMS on eVC++ 4.2 ?
Thanks
Hans W
PS the 1 in 10 partial success rate is the same if I do or don't use
SmsGetMessageStatus() to check the status... it's as if SmsGetMessageStatus()
is not needed !
| |
| hansw77041 2005-10-08, 7:00 pm |
| After a god nights sleep and checking my messages I found 20+ SMS text
messages waiting to be read !
Turns out (may be provider specific) sending text message to myself can take
a LONG time to before message arrives !
Testing my code with by sending SMS messages to another cell phone the
messages arrive in seconds to 1-2 minutes max.
However SmsGetMessageStatus() still fails everytime ! I sure would like to
get a ststus reoprt form the server.
Has anyone ever made SmsGetMessageStatus() work, if so what is the trick ?
Also Note! The problem I'm having with Douglas Boling's SMSTalk example is
the text input fields to not accept data, and the menus is hosed ! I feel
sure there is a simple solution for this also.
"hansw77041" wrote:
> HRESULT sendResult = SmsGetMessageStatus(smshHandle, smsmidMessageID,
> &smsStatusInfo, 5000); // always fails !
| |
|
| hansw77041 wrote:
> There seems to be very few real working examples for Sending / Receiving SMS
> text messages using eVC++ 4.2 or for PocketPC.
> I found Douglas Boling's SMSTalk in his book, but unfortunately the code
> compiles but does not work.
>
> Here is my abreviated SMS code that I'm using.
>
> // try to open an SMS Handle
> HREULST hr = HSmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smshHandle,
> &hSmsEvent);
>
> if (hr != ERROR_SUCCESS)
> {
> return hr; // never fails
> }
>
> // wait for SMS Event to become signaled
> DWORD dwReturn = 0;
> dwReturn = WaitForSingleObject( hSmsEvent, INFINITE ); // never fails
>
> if(dwReturn == WAIT_ABANDONED || dwReturn == WAIT_TIMEOUT)
> {
> SmsClose(smshHandle);
> return -1; // never fails
> }
>
> // Set up provider specific data
> DWORD sof = sizeof(TEXT_PROVIDER_SPECIFIC_DATA);
> memset(&tpsd, 0, sof);
> tpsd.dwMessageOptions = PS_MESSAGE_OPTION_NONE;
> tpsd.psMessageClass = PS_MESSAGE_CLASS0; // I also tried PS_MESSAGE_CLASS1
> tpsd.psReplaceOption = PSRO_NONE;
>
> // send the message
> hr = SmsSendMessage (smshHandle,
> NULL,
> &smsDest,
> NULL,
> (PBYTE)pMsg, // the message
> Len, // the message l;ength
> (PBYTE) &tpsd,
> sof, // Boling sets this to 12 tired it each way
> does not change anything
> SMSDE_OPTIMAL,
> SMS_OPTION_DELIVERY_NONE,
> &smsmidMessageID );
>
> // at this point hr is always 0 which is S_OK which means success and never
> fails
>
> // Just to be sure, retrieve the status from the Service Center
>
> memset(&smsStatusInfo, NULL, sizeof(SMS_STATUS_INFORMATION));
> memset(tmpStr, NULL, sizeof(wchar_t) * STD_STR_LEN);
>
> HRESULT sendResult = SmsGetMessageStatus(smshHandle, smsmidMessageID,
> &smsStatusInfo, 5000); // always fails !
>
> SmsClose (smshHandle);
>
> -------------------------end
> code-----------------------------------------------------------
>
> SmsGetMessageStatus() always fails with this message "Unable to get Service
> Center info: 0X80004005"
>
> Sending the same message 10 times, SmsSendMessage() always returns S_OK the
> message gets delivered ONCE (out of 10) but the NO text, just that a text
> message came form my phone.!
>
> My Questions:
>
> Is there a real SMS example for PocketPC or SmartPhone using eVC++ ?
>
> Any suggestions about problems with my version of this code are welcome.
>
> Has anyone used .NET to SmartPhone 2003 Second Edition with the eVC++ 4.2
> IDE ?
>
> Is there a better way to do SMS on eVC++ 4.2 ?
>
> Thanks
> Hans W
> PS the 1 in 10 partial success rate is the same if I do or don't use
> SmsGetMessageStatus() to check the status... it's as if SmsGetMessageStatus()
> is not needed !
>
>
i use PS_MESSAGE_CLASS1, but other than that, it looks ok - how is 'Len'
calculated?
how is smsDest filled out? (can you include the first few digits of the
number you are using?
riki
Who is this General Failure and why is he reading my hard drive?
By Night:
ThemeChanger for Smartphone : http://homepages.inspire.net.nz/~gambit/
AbstractStart for Smartphone :
http://homepages.inspire.net.nz/~gambit/AbstractStart/
By Day: http://www.EmbeddedFusion.com
|
|
|
|
|