Google
 
Web ppczone.net

View Full Version : "Receive SMS" eVB3.0 Smartphone


markus.haefner@gmail.com
08-28-2006, 04:03 AM
Dear People,

I would like using a HP/Ipaq-Smartphone and eVB3.0 for sending and
receiving SMS via the GSM-Modul

for sending I am using the following motified listing from MSDN:

'************************************************* ***********************************
Public Const SMS_MSGTYPE_TEXT = "Microsoft Text SMS Protocol"
Public Const SMS_MODE_SEND = 2 ' Open in send mode
Public Const SMSDE_GSM = 1 ' Use standard GSM encoding
Public Const SMSAT_INTERNATIONAL = 1 ' International number Format
Public Const PS_MESSAGE_OPTION_NONE = 0 ' No message options
Public Const PS_MESSAGE_CLASS0 = 0 ' Send immediately
Public Const PSRO_NONE = 0 ' No replacements
Public Const SMS_OPTION_DELIVERY_NONE = 0 ' No delivery options


Public Declare Function SmsOpen Lib "SMS" (ByVal ptsMessageProtocol As
String, ByVal dwMessageModes As Long, ByRef psmshHandle As Long, ByRef
phMessageAvailableEvent As Long) As Long

Public Declare Function SmsOpen Lib "SMS" (ByVal ptsMessageProtocol As
String, ByVal dwMessageModes As Long, ByRef psmshHandle As Long, ByRef
phMessageAvailableEvent As Long) As Long

Public Declare Function SmsSendMessage Lib "SMS" (ByVal smshHandle As
Long, ByVal psmsaSMSCAddress As Long, ByVal psmsaDestinationAddress As
String, ByVal pstValidityPeriod As Long, ByVal pbData As String, ByVal
dwDataSize As Long, ByVal pbProviderSpecificData As String, ByVal
dwProviderSpecificDataSize As Long, ByVal smsdeDataEncoding As Long,
ByVal dwOptions As Long, ByRef psmsmidMessageID As Long) As Long

Public Declare Function SmsClose Lib "SMS" (ByVal smshHandle As Long)
As Long


Private Sub Command1_Click()
Dim number As String
Dim msg As String
number = text2.Text
msg = Text1.Text
SendSMS number, msg
End Sub


Private Sub SendSMS(ByVal number As String, ByVal Message As String)
Dim SMSHandle As Long
Dim SMSEvent As Long
Dim SMSAddress As String
Dim SMSProvider As String
' Open SMS Messaging Component
Call SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, SMSHandle, SMSEvent)
' Set Address structure (UDT as string)
SMSAddress = LongToBytes(SMSAT_INTERNATIONAL) & number
' Set Provider structure (UDT as string)
SMSProvider = LongToBytes(PS_MESSAGE_OPTION_NONE) &
LongToBytes(PS_MESSAGE_CLASS0) & LongToBytes(PSRO_NONE)
' Send message
If 0 = SmsSendMessage(SMSHandle, 0, SMSAddress, 0, Message,
LenB(Message), SMSProvider, 12, SMSDE_GSM, SMS_OPTION_DELIVERY_NONE, 0)
Then
MsgBox "Message sent!", vbInformation, App.Title
Else
MsgBox "Could not send message!", vbCritical, App.Title
End If
' Close SMS Messaging Component
Call SmsClose(SMSHandle)
End Sub


Private Function LongToBytes(ByVal Value As Long) As String
Dim lsHex As String, i As Integer
lsHex = Right("00000000" & Hex(Value), 8)
For i = 1 To 7 Step 2
LongToBytes = ChrB(CInt("&H" & Mid(lsHex, i, 2))) & LongToBytes
Next
End Function

'************************************************* ************************************************** ****


I also did found a "SmsReadMessage-function" on msdn.
Probably it has to be called as an event in eVB 3.0 - but I have no
idea how to do it.

Can you please help me ?

I would like to complete the above listing with an event or sub for
receiving SMS.

thanks,
mark