FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Ayuda envio de Sms modem 3G
Posts: 69
Joined: Tue Jul 17, 2007 12:37 PM
Ayuda envio de Sms modem 3G
Posted: Wed Nov 07, 2012 02:43 AM

Estimados Colegas

Alguien tiene un ejemplo sencillo de como enviar SMS utilizando un modem 3g desde Fivewin
desde ya muchas gracias

Fabian

Posts: 1446
Joined: Mon Oct 10, 2005 02:38 PM
Re: Ayuda envio de Sms modem 3G
Posted: Thu Nov 08, 2012 12:09 AM
A ver si esto te sirve.

Te faltar谩 el InfoCOM.exe, 驴Donde te lo opuedo enviar?

M铆rate este c贸digo con paciencia, enseguida pillar谩s como funciona.

Code (fw): Select all Collapse
#include "fivewin.ch"

/* Funci贸n para usar la utilidad InfoCOM.exe para gestionar puertos COM.
聽 聽------------------------------------------------------------------ */

STATIC nPORTCOMSIM := 0
STATIC nPINSIM 聽 聽 := -1

//------------------------------------------------------------------
//------------------------------------------------------------------
FUNCTION nGetCOMofSIM( lmensaje )

Local nContador 聽:= 0
Local nRespuesta := 0

For nContador := 0 To 35

聽 聽 //nRespuesta := ShellExecute( 0, "open", "c:\temp\infocom.exe", "COM" + AllTrim(Str(nContador, 3, 0 )) + " ICC", "", 1)聽聽 聽 
聽 聽 //nRespuesta := Waitrun( "c:\temp\infocom.exe COM" + AllTrim(Str(nContador, 3, 0 )) + " ICC", 2 )

聽 聽 nRespuesta := Waitrun( cPathINFOCOM( .T. ) + "Infocom.exe" + " COM" + AllTrim(Str(nContador, 3, 0 )) + " AT+CPIN?", 1 ) 聽 // If(nContador = 0, 1, 2) )
聽 聽 
聽 聽 Traza( 1, "nContador/nRespuesta:", nContador, "/", nRespuesta )

聽 聽 If nRespuesta = 0
聽 聽 聽 聽 If lmensaje
聽 聽 聽 聽 聽 聽 MsgInfo( GetTrad( "SIM localitzat al port:") + " COM" + AllTrim(Str(nContador, 3, 0 )), Gettrad( "Atenci贸" ) )
聽 聽 聽 聽 EndIf
聽 聽 聽 聽 nPORTCOMSIM := nContador
聽 聽 聽 聽 Exit
聽 聽 EndIf

EndFor

If nContador > 35 .and. lmensaje
聽 聽 MsgInfo( GetTrad( "SIM NO localitzat.") , Gettrad( "ERROR !" ) )
EndIf

Return If( nContador > 35, 0, nContador )
//------------------------------------------------------------------
//------------------------------------------------------------------
FUNCTION uSetPINSIM( nCom, lMensaje )
Local nPIN 聽 聽 聽 := 0
Local nRespuesta := 0

If nCom = 0
聽 聽 nCom := If( nPORTCOMSIM = 0, nGetCOMofSIM( lMensaje ), nPORTCOMSIM )
EndIf

If nCom = 0
聽 聽 Return .F.
EndIf

MsgGet( GetTrad("Atenci贸!"), GetTrad("Indiqui el COM del SIM:"), @ncOM )
MsgGet( GetTrad("Atenci贸!"), GetTrad("Indiqui el PIN del SIM:"), @nPIN )

If nPIN = 0
聽 聽 /* Si torna a entrar al programa i ja ha desblocat el SIM si indicar una altra vegada el PIN dona error, per
聽 聽 聽 聽tan permeto que indiqui un PIN '0000' i s'intentar脿 llegir el IMEI del SIM, si s'aconsegueix permetr脿
聽 聽 聽 聽continuar, si no vol dir que no t茅 acc茅s al SIM.
聽 聽 聽 聽------------------------------------------------------------------------------------------------------ */
聽 聽 nRespuesta := Waitrun( cPathINFOCOM( .T. ) + "Infocom.exe" + " COM" + AllTrim(Str(nCOM, 3, 0 )) + " ICC", 2 )
聽 
聽 Else

聽 聽 nRespuesta := Waitrun( cPathINFOCOM( .T. ) + "Infocom.exe" + " COM" + AllTrim(Str(nCOM, 3, 0 )) + " AT+CPIN=" + Right( Str( 10000 + nPIN, 10, 0), 4), 2 )

EndIf

If nRespuesta = 0
聽 聽 If lMensaje
聽 聽 聽 聽 MsgInfo( GetTrad( "SIM desblocat."), Gettrad( "Atenci贸" ) )
聽 聽 EndIf
聽 聽 nPORTCOMSIM := nCOM
聽 聽 nPINSIM 聽 聽 := Val( Right( Str( 10000 + nPIN, 10, 0), 4) )
ElseIf lmensaje
聽 聽 MsgInfo( GetTrad( "PIN erroni." ), Gettrad( "ERROR !" ) )
EndIf

Traza( 1, "nRespuesta:", nRespuesta )

Return ( nRespuesta == 0 )
//------------------------------------------------------------------
//------------------------------------------------------------------
FUNCTION lEnviaSMS( nCom, cTelefono, cMensaje, nVisual, lmensaje )

Local nRespuesta := -1

If nCom = 0
聽 聽 nCom := If( nPORTCOMSIM = 0, nGetCOMofSIM( lMensaje ), nPORTCOMSIM )
EndIf
If nCom = 0
聽 聽 Return .F.
EndIf

If nPINSIM = -1
聽 聽 uSetPINSIM( nCom, lMensaje )
EndIf
If nPINSIM = -1
聽 聽 Return .F.
EndIf

cMensaje := cMensaje := Strtran( cMensaje, '"', "'", nil, Nil )

//nRespuesta := Waitrun( cPathINFOCOM( .T. ) + "Infocom.exe" + " COM" + AllTrim(Str(nCOM, 3, 0 )) + " SMS " + cTelefono + ' "' + cMensaje + "-" + AllTrim(Str(nCOM, 3, 0 ))+ '"', nVisual )

nRespuesta := Waitrun( cPathINFOCOM( .T. ) + "Infocom.exe" + " COM" + AllTrim(Str(nCOM, 3, 0 )) + " SMS " + cTelefono + ' "' + cMensaje + '"', nVisual )
Traza( 1, "Env铆o SMS a: ", cTelefono )
//nRespuesta = 0

Traza( 1, "nRespuesta:", nRespuesta, ( nRespuesta == 0 ) )

If lMensaje .and. ( nRespuesta <> 0 )
聽 聽 MsgInfo( GetTrad( "Missatge no enviat a " + cTelefono), Gettrad( "ERROR !" ) )
EndIf

Return ( nRespuesta == 0 )
//------------------------------------------------------------------
//------------------------------------------------------------------
FUNCTION Traza( )
return Nil
FUNCTION GetTrad(c)
Return c
FUNCTION cPathINFOCOM( )
Return "C:\Temp\"

Un Saludo

Carlos G.



FiveWin 25.12 + Harbour 3.2.0dev (r2502110321), BCC 7.7 Windows 11 Home

Posts: 69
Joined: Tue Jul 17, 2007 12:37 PM
Re: Ayuda envio de Sms modem 3G
Posted: Thu Nov 08, 2012 12:26 AM

Fivewidi

Por favor Enviamelo a windev2@yahoo.com.ar

Gracias
Fabian

Continue the discussion