Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem in Sending UTF-8 SMS From VFP
Message
De
13/02/2014 05:49:05
Reza Meamar
Homa Programming Group
Shiraz, Iran
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Problem in Sending UTF-8 SMS From VFP
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP3
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01594220
Message ID:
01594220
Vues:
63
Dear expert,
Please see below code.
cPduMobNumber = PduMobNumMaker("+989177176649")

oSMS=Createobject("MSCommLib.MSComm.1")


MainMsg1 = "ارسال پيامك جهت تست اندازه طولشك"        && LEN = 32 character
lcPDUMessage1 ="40062706310633062706440020067E064A0627064506430020062C0647062A0020062A0633062A002006270646062F062706320647002006370648064406340643"

MainMsg2 = "ارسال پيامك جهت تست اندازه طول وا"       && LEN = 33 character
lcPDUMessage2 ="42062706310633062706440020067E064A0627064506430020062C0647062A0020062A0633062A002006270646062F0627063206470020063706480644002006480627"

= SendSMS("001100"+cPduMobNumber+"0008AA"+lcPDUMessage1)
= SendSMS("001100"+cPduMobNumber+"0008AA"+lcPDUMessage2)


RETURN
*******************************************************************************************
Procedure SendSMS
Parameters pMessage
	With oSMS
		If .PortOpen
			.PortOpen = .F.
		Endif
		.CommPort = 5     && variable  (MUST SET AS YOUR MODEM COM PORT)
		.Settings = "460800,N,8,1"
		.Handshaking = 3
		.RTSEnable = .T.
		.DTREnable = .T.
		.RThreshold = 1
		.SThreshold = 1
		.InputLen = 0
		Try
			.PortOpen = .T.
		Catch To oError
		Endtry
		If Vartype(oError)==[O]
			Messagebox("Check your connection/port setting.",16,"Daniela SMS Sender")
			Return .F.
		Endif
	ENDWITH
	
	
	oSMS.Output = "AT" +Chr(13)+Chr(10)
	Delay(Datetime(),5000)
	
	oSMS.Output = "AT+CSCS=" + Chr(34) + "UCS2" + Chr(34) +Chr(13)+Chr(10)
	Delay(Datetime(),5000)
	
	oSMS.Output = "AT+CMGF=0" +Chr(13)+Chr(10)
	Delay(Datetime(),5000)
	
	
	lnMesLen = TRANSFORM(LEN(pMessage)/2-1)
	
	
	oSMS.Output = "AT+CMGS=" + lnMesLen +Chr(13)+Chr(10)
	Delay(Datetime(),5000)
	
	oSMS.Output = pMessage + Chr(26)
	Delay(Datetime(),5000)
	
	oSMS.PortOpen = .F.
	
ENDPROC


********************************************************************************************
*****  Function PduMobNumMaker()  (PDU Mobile Number Maker)                            *****
*****  Parameters :                                                                    *****
*****              pMobNumber : Mobile Number in international format (+989171234567)  *****
********************************************************************************************
FUNCTION PduMobNumMaker()
PARAMETERS pMobNumber

IF AT("+",pMobNumber) = 0
   RETURN ("")
ENDIF

pMobNumber = ALLTRIM(CHRTRAN(pMobNumber, "+", ""))
cLeftPart  = RIGHT(TRANSFORM(LEN(pMobNumber), "@0"),2) + "91"
pMobNumber = IIF(LEN(pMobNumber)-INT(LEN(pMobNumber)/2)*2 = 0, pMobNumber, pMobNumber+"F")

cNewNum = ""
FOR nCounter = 1 TO LEN(pMobNumber) STEP 2
    cNewNum = cNewNum + SUBSTR(pMobNumber, nCounter+1, 1) + SUBSTR(pMobNumber, nCounter, 1)
ENDFOR
pMobNumber = cLeftPart + cNewNum

RETURN (pMobNumber)

**********************************************************************************************************************************************
Procedure Delay
Parameters pStart,pEnd
  Do While Datetime()-pStart=pEnd
     Do Events
  Enddo
Endfunc
It is very nice, but I have a problem. If message length be 32 character( As in MainMsg1) , it is ok and I can send this. But if the length become 33 or more ( As in MainMsg2) an error occurred and sms not sent.

I check it in hyperterminal and all thing is ok, only in last step when I want to type last number (7 in lcPDUMessage2) an ERROR shows.
Here is hyperterminal window activity :
AT
OK
AT+CSCS="UCS2"
OK
AT+CMGF=0
OK
AT+CMGS=80
>0011000C918919777166940008AA42062706310633062706440020067E064A0627064506430020062C0647062A0020062A0633062A002006270646062F062706320647002006370648064400200648062
ERROR

Please help me.
Thanks
Répondre
Fil
Voir

Click here to load this message in the networking platform