Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Telenor modem i C++

[es] :: C/C++ programiranje :: Telenor modem i C++

[ Pregleda: 1362 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Lukic111
Marko Lukic
Beograd,Srbija

Član broj: 259787
Poruke: 51
*.dynamic.isp.telekom.rs.



+8 Profil

icon Telenor modem i C++22.12.2012. u 16:57 - pre 137 meseci
Ja sam postavio temu http://www.elitesecurity.org/t...ekranu-sa-zadatim-koordinatama ali sam se prilicno udaljio od zadate teme.

Skinuo sam http://www.saeautom.sk/services/oursmsservices.htm biblioteku, podesio parameter koji odgovaraju nasoj mrezi, uspesno kompajlirao ali mi pri pokusaju slanja poruke program stampa izvestaj Error<5> GSM modem answer : ERRORCRLF.
Modem je K1550 Huawei.
Mreza je Telenor.
A kod izgleda:


#include "stdafx.h"
#include "Sample1.h"

#include "GSMModem.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;

// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
_tprintf( _T("****************************************\n") );
_tprintf( _T("* SAEAUT SMS Library (MFC) 1.01.00 *\n") );
_tprintf( _T("* sample of using *\n") );
_tprintf( _T("****************************************\n\n") );

CGSMModem GSMModem; // GSM modem instance

// TODO: change all folowing parameters to suit your needs
CString strComPort = _T("COM2"); // Com Port
DWORD dwReadTimeout = 15000; // 15 seconds

GSMModem.SetComPort(strComPort, 9600, 8, 0, 0);
GSMModem.SetReadTimeout(dwReadTimeout);

_tprintf( _T("COM Port: %s\n"), GSMModem.GetComPortName() );

_tprintf( _T("\n\n* Connection to modem in progress, please wait ...") );

// make a modem connection
if (GSMModem.Connect())
{
_tprintf( _T(" OK\n\n") );
_tprintf( _T("Modem: %s %s\n\n"), GSMModem.GetModemModel(), GSMModem.GetModemManufacturer() );

// TODO: change the PIN code to suit your needs
CString strPIN = _T("1111"); // PIN code e.g. 0000
GSMModem.SetPIN(strPIN);
_tprintf( _T("PIN: %s\n"), strPIN );


// TODO: change the service center address to suit your needs
// according to your card provider
CString strSCA = _T("+38163100100"); // Service Center Address e.g. ORANGE SVK (+421905303303)
GSMModem.SetServiceCenterAddress(strSCA);
_tprintf( _T("SCA: %s\n"), strSCA );


// TODO: change the phone number to suit your needs
CString strPhoneNumber = _T("0642959963"); // Phone number e.g 0123456789
_tprintf( _T("Phone Number: %s\n"), strPhoneNumber );

// TODO: change the SMS text to suit your needs
CString strSMSText = _T("Hello world!"); // SMT text
_tprintf( _T("SMS text: %s\n"), strSMSText );

if ( strPhoneNumber == _T("XXXX") )
{
_tprintf( _T("\n\n* Error: Bad destination Phone Number. Please change the Phone Number in the sample source code.\n") );

::Sleep(10000);
return nRetCode;
}

_tprintf( _T("\n\n* Sending SMS in progress, please wait ...\n") );

// send the SMS
int nRefNumber = GSMModem.DoSendSMS( strPhoneNumber,
strSMSText,
true,
3);

if ( nRefNumber != SMS_ERROR )
{
_tprintf( _T("SMS was sent sucessfully (Ref Nr. %d).\n\n"), nRefNumber);
}
else
{
int nLastError = GSMModem.GetLastError();

_tprintf( _T("Error(%d): %s\n\n"), nLastError, CGSMModem::GetErrorMessage(nLastError) );
}


_tprintf( _T("* Reading SMS in progress, please wait ...\n") );
Sleep(1000);

// read SMS
switch (GSMModem.DoReadSMS())
{
case SMS_RECV_NOSMS:
{
_tprintf( _T("No SMS available for reading.\n") );
}
break;

case SMS_RECV_DELIVER:
{
_tprintf( _T("Received SMS: %s %s %s\n"), GSMModem.GetRecvSMSSenderPhoneNumber(),
GSMModem.GetRecvSMSTimestamp(),
GSMModem.GetRecvSMSText());
}
break;

case SMS_RECV_STATUS:
{
int nDeliveryStatus = GSMModem.GetRecvSMSStatusReport();

_tprintf( _T("Delivered SMS (Ref Nr. %d): %s %s %s (%d) %s\n"), GSMModem.GetRecvSMSReferenceNumber(),
GSMModem.GetRecvSMSSenderPhoneNumber(),
GSMModem.GetRecvSMSTimestamp(),
GSMModem.GetRecvSMSServiceCentreTimestamp(),
nDeliveryStatus,
CGSMModem::GetDeliveryStatusText( nDeliveryStatus ) );
}
break;

case SMS_ERROR:
{
int nLastError = GSMModem.GetLastError();

_tprintf( _T("Error(%d): %s\n"), nLastError, CGSMModem::GetErrorMessage(nLastError) );
}
}
}
else
{
_tprintf( _T(" ERROR\n") );

_tprintf( _T("Error(%d): %s\n"), GSMModem.GetLastError(), CGSMModem::GetErrorMessage(GSMModem.GetLastError()) );
}

// close a modem connection
GSMModem.Disconnect();
}

_tprintf( _T("\n\n* Please wait (10 s) for application terminating ...\n") );

::Sleep(10000);

return nRetCode;
}

Nadam se da neko ima resennje :) ?
 
Odgovor na temu

Boyka
BPS

Član broj: 287185
Poruke: 338
*.dynamic.isp.telekom.rs.



+33 Profil

icon Re: Telenor modem i C++23.12.2012. u 17:55 - pre 137 meseci
jao covece koriisti code tag

Code (c):

#include "stdafx.h"
#include "Sample1.h"

#include "GSMModem.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;

// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
_tprintf( _T("****************************************\n") );
_tprintf( _T("* SAEAUT SMS Library (MFC) 1.01.00 *\n") );
_tprintf( _T("* sample of using *\n") );
_tprintf( _T("****************************************\n\n") );

CGSMModem GSMModem;  // GSM modem instance

// TODO: change all folowing parameters to suit your needs
CString strComPort = _T("COM2");    // Com Port
DWORD dwReadTimeout = 15000;   // 15 seconds

GSMModem.SetComPort(strComPort, 9600, 8, 0, 0);
GSMModem.SetReadTimeout(dwReadTimeout);

_tprintf( _T("COM Port: %s\n"),    GSMModem.GetComPortName() );

_tprintf( _T("\n\n* Connection to modem in progress, please wait ...") );

// make a modem connection
if (GSMModem.Connect())
{    
_tprintf( _T(" OK\n\n") );
_tprintf( _T("Modem: %s %s\n\n"), GSMModem.GetModemModel(), GSMModem.GetModemManufacturer() );

// TODO: change the PIN code to suit your needs
CString strPIN = _T("1111");   // PIN code e.g. 0000
GSMModem.SetPIN(strPIN);
_tprintf( _T("PIN: %s\n"), strPIN );


// TODO: change the service center address to suit your needs
// according to your card provider
CString strSCA = _T("+38163100100");     // Service Center Address e.g. ORANGE SVK (+421905303303)
GSMModem.SetServiceCenterAddress(strSCA);
_tprintf( _T("SCA: %s\n"), strSCA );


// TODO: change the phone number to suit your needs
CString strPhoneNumber = _T("0642959963");    // Phone number e.g 0123456789
_tprintf( _T("Phone Number: %s\n"),     strPhoneNumber );

// TODO: change the SMS text to suit your needs
CString strSMSText = _T("Hello world!");      // SMT text
_tprintf( _T("SMS text: %s\n"), strSMSText );

if ( strPhoneNumber == _T("XXXX") )
{
_tprintf( _T("\n\n* Error: Bad destination Phone Number. Please change the Phone Number in the sample source code.\n") );

::Sleep(10000);    
return nRetCode;
}

_tprintf( _T("\n\n* Sending SMS in progress, please wait ...\n") );

// send the SMS
int nRefNumber = GSMModem.DoSendSMS( strPhoneNumber,
strSMSText,
true,
3);

if ( nRefNumber != SMS_ERROR )
{
_tprintf( _T("SMS was sent sucessfully (Ref Nr. %d).\n\n"), nRefNumber);
}
else
{
int nLastError = GSMModem.GetLastError();

_tprintf( _T("Error(%d): %s\n\n"), nLastError, CGSMModem::GetErrorMessage(nLastError) ); 
}


_tprintf( _T("* Reading SMS in progress, please wait ...\n") );
Sleep(1000);

// read SMS
switch (GSMModem.DoReadSMS())
{
case SMS_RECV_NOSMS:
{    
_tprintf( _T("No SMS available for reading.\n") );
}
break;

case SMS_RECV_DELIVER:
{
_tprintf( _T("Received SMS: %s %s %s\n"), GSMModem.GetRecvSMSSenderPhoneNumber(),
GSMModem.GetRecvSMSTimestamp(),
GSMModem.GetRecvSMSText());
}
break;

case SMS_RECV_STATUS:
{
int nDeliveryStatus = GSMModem.GetRecvSMSStatusReport();

_tprintf( _T("Delivered SMS (Ref Nr. %d): %s %s %s (%d) %s\n"), GSMModem.GetRecvSMSReferenceNumber(),
GSMModem.GetRecvSMSSenderPhoneNumber(),
GSMModem.GetRecvSMSTimestamp(),
GSMModem.GetRecvSMSServiceCentreTimestamp(),
nDeliveryStatus,
CGSMModem::GetDeliveryStatusText( nDeliveryStatus ) );
}
break;

case SMS_ERROR:
{
int nLastError = GSMModem.GetLastError();

_tprintf( _T("Error(%d): %s\n"), nLastError, CGSMModem::GetErrorMessage(nLastError) );   
}
}
}
else
{
_tprintf( _T(" ERROR\n") );

_tprintf( _T("Error(%d): %s\n"), GSMModem.GetLastError(), CGSMModem::GetErrorMessage(GSMModem.GetLastError()) );
}

// close a modem connection
GSMModem.Disconnect();
}

_tprintf( _T("\n\n* Please wait (10 s) for application terminating ...\n") );

::Sleep(10000);

return nRetCode;
}
 
 
Odgovor na temu

[es] :: C/C++ programiranje :: Telenor modem i C++

[ Pregleda: 1362 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.