Ayuda envio de Sms modem 3G

Ayuda envio de Sms modem 3G

Postby devwin2010 » Wed Nov 07, 2012 2:43 am

Estimados Colegas

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

Fabian
devwin2010
 
Posts: 60
Joined: Tue Jul 17, 2007 12:37 pm

Re: Ayuda envio de Sms modem 3G

Postby FiveWiDi » 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: Select all  Expand view
#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 24.02 + Harbour 3.2.0dev (r2403071241), BCC 7.7 Windows 10
FiveWiDi
 
Posts: 1060
Joined: Mon Oct 10, 2005 2:38 pm

Re: Ayuda envio de Sms modem 3G

Postby devwin2010 » Thu Nov 08, 2012 12:26 am

Fivewidi

Por favor Enviamelo a windev2@yahoo.com.ar

Gracias
Fabian
devwin2010
 
Posts: 60
Joined: Tue Jul 17, 2007 12:37 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 99 guests