wifi

Post Reply
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

wifi

Post by Silvio »

it is possible check the level of the wireless ?
I use win ce 50/6.1 HTc TYNT II
Best Regards, Saludos

Falconi Silvio
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: wifi

Post by Otto »

Hello Silvio,
have you found a way to check the level of wireless lan?
Best regads,

Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: wifi

Post by Silvio »

Otto,
I need it because a man use the htc from beach and the server is on the chalet and use it to see the situation of umbrellas on beach.
I wanted see a progress bar with the level of wifi and battery
have you an idea ?
Best Regards, Saludos

Falconi Silvio
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: wifi

Post by Otto »

Hello Silvio,

only an idea - I would use ftp via Internet in your case. WLAN is very limited (50-100m???).
I have a ftp up – and download for such purpose for my mobile ECR on HTC.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: wifi

Post by Silvio »

I wish create also ftp link
but I not Know How I can make it have uou an sample ?
the wifi is too slow and danger beacuse we can found on beach smarthphone and phones with wifi system and How you sad we can use it on 50-100 metres.
Best Regards, Saludos

Falconi Silvio
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: wifi

Post by Otto »

Hello Silvio,
here is my code.


1) FWppc for the handy 2 ) FW for the PC

Best regards,
Otto


// FTP sample developed by Enrico Maria Giordano
#include "Fwce.ch"
#define FILE_ATTRIBUTE_READONLY 1
#define FILE_ATTRIBUTE_HIDDEN 2
#define FILE_ATTRIBUTE_SYSTEM 4
#define FILE_ATTRIBUTE_DIRECTORY 16
#define FILE_ATTRIBUTE_ARCHIVE 32
#define FILE_ATTRIBUTE_NORMAL 128
#define FILE_ATTRIBUTE_TEMPORARY 256

//
// access types for InternetOpen()
//
#define INTERNET_OPEN_TYPE_PRECONFIG 0 // use registry configuration
#define INTERNET_OPEN_TYPE_DIRECT 1 // direct to net
#define INTERNET_OPEN_TYPE_PROXY 3 // via named proxy
#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 4 // prevent using java/script/INS
//
// manifests
//

#define INTERNET_INVALID_PORT_NUMBER 0 // use the protocol-specific default

#define INTERNET_DEFAULT_FTP_PORT 21 // default for FTP servers
#define INTERNET_DEFAULT_GOPHER_PORT 70 // " " gopher "
#define INTERNET_DEFAULT_HTTP_PORT 80 // " " HTTP "
#define INTERNET_DEFAULT_HTTPS_PORT 443 // " " HTTPS "
#define INTERNET_DEFAULT_SOCKS_PORT 1080 // default for SOCKS firewall servers.

//
// service types for InternetConnect()
//

#define INTERNET_SERVICE_FTP 1
#define INTERNET_SERVICE_GOPHER 2
#define INTERNET_SERVICE_HTTP 3

//
// flags for FTP
//

#define INTERNET_FLAG_TRANSFER_ASCII 1
#define INTERNET_FLAG_TRANSFER_BINARY 2

//----------------------------------------------------------------------------//

function Main()
local oWnd, oTmr

DEFINE WINDOW oWnd TITLE "Timers" ;

DEFINE TIMER oTmr INTERVAL 500 ACTION (oTmr:DeActivate(),oWnd:Say( 10, 17, Time() ), upload(),oTmr:Activate() )
ACTIVATE TIMER oTmr

ACTIVATE WINDOW oWnd ON INIT (oWnd:SetSize( 200, 200, .T. ));
ON CLICK MsgInfo( "Click!" )

oTmr:End()

return nil

//----------------------------------------------------------------------------//

FUNC upload()

LOCAL hInternet, hConnect
local aInfo := {}
LOCAL I := 0

aInfo := Directory( CurDir() + "\*.TXT" )
if Len( aInfo ) > 0


hGprs:=GprsConnect()

hInternet = INTERNETOPEN( "216.117.77.7", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 )

IF hINTERNET = 0
MSGINFO("ERREUR CONNEXION INTERNET envoi sortant")
RETURN .F.
ENDIF
// hConnect = INTERNETCONNECT( hInternet, "216.117.77.7", INTERNET_INVALID_PORT_NUMBER, "testinfo", "test", INTERNET_SERVICE_FTP, 0, 0 )

hConnect = INTERNETCONNECT( hInternet, "ftp.test.info", INTERNET_INVALID_PORT_NUMBER, "testinfo", "test", INTERNET_SERVICE_FTP, 0, 0 )
//msginfo( " hInternet " + str(hInternet) +" hConnect " + str( hConnect))

IF hConnect = 0
MSGINFO("ERREUR Création CONNEXION FTP envoi sortant ... Abandon transmission ")
RETURN .F.
ENDIF

//? FTPGETFILE( hConnect, "Your remote file", "Your local file", 0, FILE_ATTRIBUTE_ARCHIVE, 0, 0 )
//? FTPPUTFILE( hConnect, "Your local file", "Your remote file", 0, 0 )

// IF file(CurDir() + "\test.txt")=.t.
// msginfo("Datei vorhanden")
// ENDIF

aInfo := Directory( CurDir() + "\*.TXT" )

FOR I := 1 TO Len( aInfo )
msginfo( aInfo[I,1])
//msginfo( FTPPUTFILE( hConnect, CurDir() +"\"+ aInfo[I,1], "/testinfo/STB1/"+aInfo[I,1], 0, 0 ))


if FTPPUTFILE( hConnect, CurDir() +"\"+ aInfo[I,1], "/testinfo/STB1/"+aInfo[I,1], 0, 0 )=.t.
/*
DLL32 FUNCTION FtpPutFile( hFTP AS LONG,
cFileName AS LPSTR,
cDestFile AS LPSTR,;
n1 AS LONG,
n2 AS LONG )
*/

ferase ( CurDir() +"\"+aInfo[I,1])
else
msginfo("konnte nicht gesendet werden: " + aInfo[I,1])
endif

NEXT

INTERNETCLOSEHANDLE( hConnect )

INTERNETCLOSEHANDLE( hInternet )

//msginfo("OK")

endif
RETURN NIL


#pragma BEGINDUMP

#include "windows.h"
#include "wininet.h"
#include "hbapi.h"
#include "initguid.h"
#include "connmgr.h"


LPWSTR AnsiToWide( LPSTR );

HB_FUNC (GPRSCONNECT)
{
// By Pawel
HANDLE phWebConnection = NULL;
DWORD pdwStatus = 0;
//Comprobamos si ya estamos conectados.
ConnMgrConnectionStatus (phWebConnection, &pdwStatus);
if (pdwStatus == CONNMGR_STATUS_CONNECTED)
{
hb_retnl( (long) 0 );
}
else
{
//No estamos conectados.
//CONNECTIONINFO es la estructura que
//le indica al Connection manager como nos queremos conectar.
CONNMGR_CONNECTIONINFO sConInfo;
memset (&sConInfo,0, sizeof (CONNMGR_CONNECTIONINFO));
sConInfo.cbSize = sizeof (CONNMGR_CONNECTIONINFO);
sConInfo.dwParams = CONNMGR_PARAM_GUIDDESTNET; //Queremos usar parametros "GuisDesNet"
sConInfo.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE; //Esta es la prioridad mas alta.
sConInfo.dwFlags = CONNMGR_FLAG_PROXY_HTTP;
sConInfo.bExclusive = TRUE ; //Permitimos compartir la conexion con otras aplicaciones.
sConInfo.bDisabled = FALSE;
sConInfo.guidDestNet = IID_DestNetInternet;

if (ConnMgrEstablishConnection (&sConInfo, &phWebConnection) == S_OK)
{
unsigned int k;

for( k = 0; k < 8; k ++)
{
ConnMgrConnectionStatus(phWebConnection,&pdwStatus);
if (pdwStatus == CONNMGR_STATUS_CONNECTED)
{
hb_retnl( (long) phWebConnection );
}
if (pdwStatus == CONNMGR_STATUS_CONNECTIONCANCELED || pdwStatus == CONNMGR_STATUS_WAITINGCONNECTIONABORT)
{
hb_retnl( (long) -1 );
}
Sleep (2500);
}
hb_retnl( (long) phWebConnection );
}
else
{
hb_retnl( (long) -1 );
}
}
}


HB_FUNC (GPRSRELEASE)
{
HANDLE hCon= NULL;
ConnMgrReleaseConnection( ( HANDLE ) hb_parnl( 1 ),2 );
}


HB_FUNC( INTERNETOPEN )
{
LPWSTR cAgent = AnsiToWide( hb_parc( 1 ) );
LPWSTR cProxyName = AnsiToWide( hb_parc( 3 ) );
LPWSTR cProxyBypass = AnsiToWide( hb_parc( 4 ) );

HINTERNET hInternet = InternetOpen( cAgent, hb_parnl( 2 ), cProxyName, cProxyBypass, hb_parnl( 5 ) );

hb_xfree( cAgent );
hb_xfree( cProxyName );
hb_xfree( cProxyBypass );

hb_retnl( ( LONG ) hInternet );
}


HB_FUNC( INTERNETCLOSEHANDLE )
{
hb_retl( InternetCloseHandle( ( HINTERNET ) hb_parnl( 1 ) ) );
}


HB_FUNC( INTERNETCONNECT )
{
LPWSTR cServerName = AnsiToWide( hb_parc( 2 ) );
LPWSTR cUserName = AnsiToWide( hb_parc( 4 ) );
LPWSTR cPassword = AnsiToWide( hb_parc( 5 ) );

HINTERNET hInternet = InternetConnect( ( HINTERNET ) hb_parnl( 1 ), cServerName, ( INTERNET_PORT ) hb_parnl( 3 ), cUserName, cPassword, hb_parnl( 6 ), hb_parnl( 7 ), hb_parnl( 8 ) );

hb_xfree( cServerName );
hb_xfree( cUserName );
hb_xfree( cPassword );

hb_retnl( ( LONG ) hInternet );
}


HB_FUNC( FTPGETFILE )
{
LPWSTR cRemoteFile = AnsiToWide( hb_parc( 2 ) );
LPWSTR cNewFile = AnsiToWide( hb_parc( 3 ) );

hb_retl( FtpGetFile( ( HINTERNET ) hb_parnl( 1 ), cRemoteFile, cNewFile, hb_parl( 4 ), hb_parnl( 5 ), hb_parnl( 6 ), hb_parnl( 7 ) ) );

hb_xfree( cRemoteFile );
hb_xfree( cNewFile );
}


HB_FUNC( FTPPUTFILE )
{
LPWSTR cLocalFile = AnsiToWide( hb_parc( 2 ) );
LPWSTR cNewRemoteFile = AnsiToWide( hb_parc( 3 ) );

hb_retl( FtpPutFile( ( HINTERNET ) hb_parnl( 1 ), cLocalFile, cNewRemoteFile, hb_parnl( 4 ), hb_parnl( 5 ) ) );

hb_xfree( cLocalFile );
hb_xfree( cNewRemoteFile );
}
#pragma ENDDUMP
And here the code for download:

// Testing the FiveWin new Internet Classes

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()
local oWnd, oTmr

DEFINE WINDOW oWnd TITLE "Timers"

DEFINE TIMER oTmr INTERVAL 10000 ACTION (oTmr:DeActivate(),oWnd:Say( 10, 17, Time() ), upload(),oTmr:Activate() ) of oWnd
ACTIVATE TIMER oTmr

ACTIVATE WINDOW oWnd ;
ON CLICK MsgInfo( "Click!" )

oTmr:End()

return nil

//----------------------------------------------------------------------------//

FUNC upload()
local oInternet := TInternet():New()
local oFTP := TFTP():New( "ftp.test.info", oInternet,"testinfo", "test" )
local aFiles
LOCAL handle
local cFile := ""

if ! Empty( oFTP:hFTP )

/*
DLL32 FUNCTION FtpSetCurrentDirectory(
hFTP AS LONG,
cDirName AS LPSTR ) ;
AS BOOL PASCAL ;
*/
FtpSetCurrentDirectory(oFTP:hFTP, "/testinfo/STB1/")
aFiles = oFTP:Directory("*.*" )

IF len(aFiles) > 0

AEval( aFiles, { | aFile | msginfo( aFile[ 1 ] ),cFile := ALLTRIM( aFile[ 1 ] ),;
cFile := STRTRAN(UPPER(cFile),".TXT",".LTX"),;
memowrit( "c:\dbf\" + cFile, ("STBWEB "+DTOC(date())+" / "+time()) ) ,;
FtpGetFile (oFTP:hFTP,aFile[ 1 ], "c:\dbf\" + aFile[ 1 ] ,.t.,0,0,0 ) ,;
oFTP:DeleteFile( aFile[ 1 ]),;
ferase ("c:\dbf\" + cFile) } )

ENDIF


/*
DLL32 FUNCTION FtpGetFile(
hFTP AS LONG, = INTERNETCONNECT
cRemoteFile AS LPSTR
cLocalFile AS LPSTR
lOverWrite AS LONG
n1 AS LONG
n2 AS LONG
n3 AS LONG
*/

else
MsgAlert( "oFTP:hFTP is null" )
endif

oInternet:End()

//MsgInfo( "Done!" )

return nil

//----------------------------------------------------------------------------//


********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: wifi

Post by Silvio »

thanks a lot.

Now I have a doubt ...
If I use the HTC and I use a dbf I must save only on the dbf of pc or smartphone
How I can use a ftp link to pc from smarthphone if it can download or upload a dbf file and not save into file dbf .
I not understand How we must use ftp instead Wifi ( \\nomepc\folder)
Best Regards, Saludos

Falconi Silvio
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: wifi

Post by Otto »

Hello Silvio,

Here a little example:
Handy sends a file to the ftp-server:
sendmetheUmbrellatablefrom15.8.2009.txt
The PC sees a file sendmetheUmbrellatable ... and uploads a umbrella.dbf which the handy downloads.
Now you have the actual data on your handy.
If you make a change in umbrella.dbf you send for example a file “changeumbrellatable.dbf” which the PC processes.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: wifi

Post by Otto »

Hello Antonio,
do you think this class can be adapted to FWPPC?
Thanks in advance
Otto

The CWifiPeek class does all the Wifi query stuff. It can be used in non-MFC applications, too. You have to add CWifiPeek.h and CWifiPeek.cpp to your project.

http://www.codeproject.com/KB/mobile/PeekPocket.aspx
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: wifi

Post by Antonio Linares »

Otto,

yes, we can use it from FWPPC :-)

Next week I will adapt it. This week I am busy with some other code.

Please send me a reminder by email next week, thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply