Estimados Colegas
Alguien tiene un ejemplo sencillo de como enviar SMS utilizando un modem 3g desde Fivewin
desde ya muchas gracias
Fabian
Estimados Colegas
Alguien tiene un ejemplo sencillo de como enviar SMS utilizando un modem 3g desde Fivewin
desde ya muchas gracias
Fabian
#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