Wireless signal strength

Wireless signal strength

Postby Maurizio » Fri Jul 25, 2008 2:34 pm

Hi All,

Is there a way to retreive the wireless signal strength?

Thanks in Advance

MAurizio
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Postby Antonio Linares » Wed Jul 30, 2008 1:53 pm

Maurizio,

Code: Select all  Expand view  RUN
// from IPAQUTIL.LIB

#pragma BEGINDUMP

#include <hbapi.h>

HB_FUNC( IPAQGETWLANRADIOREVISIONLEVEL )
{
   TCHAR szRevision[ iPAQ_MAX_REVISION ];
   LPSTR pStr;

   if( iPAQGetWLANRadioRevisionLevel( szRevision ) == iPAQSUCCESS )
   {
      pStr = WideToAnsi( szRevision );
      hb_retc( pStr );
      hb_xfree( pStr );
   }
   else
      hb_retc( "" );
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42103
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Maurizio » Wed Jul 30, 2008 2:36 pm

Thank Antonio

I have this error
hptest.prg(143) : error C2065: 'WideToAnsi' : undeclared identifier

The function iPAQGetWLANRadioRevisionLevel works only for the HP .
The iPAQGetWLANRadioRevisionLevel function gets the radio's revision level .
Last edited by Maurizio on Thu Jul 31, 2008 7:07 am, edited 1 time in total.
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Postby Antonio Linares » Wed Jul 30, 2008 5:47 pm

Maurizio,

Please try it this way:
Code: Select all  Expand view  RUN
// from IPAQUTIL.LIB

#pragma BEGINDUMP

#include <hbapi.h>

LPSTR WideToAnsi( TCHAR * );

HB_FUNC( IPAQGETWLANRADIOREVISIONLEVEL )
{
   TCHAR szRevision[ iPAQ_MAX_REVISION ];
   LPSTR pStr;

   if( iPAQGetWLANRadioRevisionLevel( szRevision ) == iPAQSUCCESS )
   {
      pStr = WideToAnsi( szRevision );
      hb_retc( pStr );
      hb_xfree( pStr );
   }
   else
      hb_retc( "" );
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42103
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Maurizio » Thu Jul 31, 2008 7:14 am

Thank Antonio
Now it works , but The iPAQGetWLANRadioRevisionLevel function gets the radio's revision level , not the wireless signal strength .

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

I found a new function to take the wireless signal strength , but I have this error :
wifi.c
wifi.prg(40) : error C2065: 'GetFirstRFEthernetSignalStrength' : undeclared
iden
tifier
wifi.prg(92) : error C2365: 'GetFirstRFEthernetSignalStrength' :
redefinition; p
revious definition was a 'data variable'

cann you help my ?

Regards Maurizio


Code: Select all  Expand view  RUN
// http://rburdick.blogspot.com/2005/03/determining-80211-signal-strength-for.html

#include "FWCE.ch"

function Main()

  MsgInfo("Hello ")
   
return nil   
/*
int nStrength = 0;
int nQuality = 0;
GetFirstRFEthernetSignalStrength(&nStrength, &nQuality);
hb_retnl( ( long ) nStrength );
*/

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

#pragma BEGINDUMP


#ifdef UNICODE
   #define UNDER_CE
#endif

#include <hbapi.h>
#include <windows.h>
#include <aygshell.h>
#include <ntddndis.h>
#include <nuiouser.h>
#include <winioctl.h>
#include <iphlpapi.h>



HB_FUNC( SIGNAL  )
{
int nStrength = 0;
int nQuality = 0;
GetFirstRFEthernetSignalStrength(&nStrength, &nQuality);
hb_retnl( ( long ) nStrength );
}

HRESULT GetSignalStrength(
TCHAR *ptcDeviceName,
int* piSignalStrength,
int* piSignalQuality
)
{ PNDISUIO_QUERY_OID queryOID;
   DWORD  dwBytesReturned = 0;
   UCHAR  QueryBuffer[sizeof(NDISUIO_QUERY_OID) +sizeof(DWORD)];
   HANDLE  ndisAccess = INVALID_HANDLE_VALUE;
   BOOL  retval;
   HRESULT  hr; // Attach to NDISUIO.
   ndisAccess = CreateFile( NDISUIO_DEVICE_NAME,    0, 0, NULL, OPEN_EXISTING,  FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,    INVALID_HANDLE_VALUE );
   if ( ndisAccess == INVALID_HANDLE_VALUE ) 
   return E_FAIL; // ????
   // Get Signal strength
   queryOID = (PNDISUIO_QUERY_OID)&QueryBuffer[0];
   queryOID->ptcDeviceName = ptcDeviceName;
   queryOID->Oid = OID_802_11_RSSI;
   retval = DeviceIoControl( ndisAccess,  IOCTL_NDISUIO_QUERY_OID_VALUE,  (LPVOID) queryOID,  sizeof(NDISUIO_QUERY_OID) + sizeof(DWORD),  (LPVOID) queryOID,  sizeof(NDISUIO_QUERY_OID) + sizeof(DWORD),  &dwBytesReturned,  NULL);
   if( retval && piSignalStrength && piSignalQuality )
      { 
      hr = S_OK; 
      *piSignalStrength = *(DWORD *)&queryOID->Data; 
      //Here's Microsoft's interpretation 
      //of the return value 
      if(*piSignalStrength < -90)   
         *piSignalQuality = 0; // No signal 
      else if(*piSignalStrength < -81)   
         *piSignalQuality  = 1; // Very low 
      else if(*piSignalStrength < -71)   
         *piSignalQuality  = 2; // Low 
      else if(*piSignalStrength < -67)   
         *piSignalQuality  = 3; // Good 
      else if(*piSignalStrength < -57)   
         *piSignalQuality  = 4; // Very good 
      else   *piSignalQuality  = 5; // Excellent
      }
      else
      { 
         hr = E_FAIL;
      }
      CloseHandle( ndisAccess );
      return hr;
   }
   BOOL GetFirstRFEthernetSignalStrength(
      int* pSignalStrength,
      int* pSignalQuality
      )
      { BOOL retval = FALSE;
      // Get the size of the adapters list.
      DWORD size = 0;
      GetAdaptersInfo( NULL, &size );
      // Allocate space for the list.
      IP_ADAPTER_INFO *info =   
        (IP_ADAPTER_INFO*)new char[ size ];
        DWORD err;
        if ((err = GetAdaptersInfo(info, &size ))   
         == NO_ERROR )
         {
         IP_ADAPTER_INFO *cinfo = info; 
         while ( cinfo ) 
            {   
             // Check the interface media type for   
             // Ethernet, which both   
             // standard Ethernet and RF Ethernet will return.   
             if ( cinfo->Type == MIB_IF_TYPE_ETHERNET )   
               {   
               TCHAR wName[ MAX_ADAPTER_NAME_LENGTH + 4 ];   
               MultiByteToWideChar( CP_ACP, 0,    cinfo->AdapterName, -1,     wName,     sizeof( wName ) / sizeof( wName[ 0 ] ) );
               // Try to get the signal strength.   
               // If it works, we   
               // return the information.   
               // If not, we move on.   
               if ( GetSignalStrength( wName,     
                   pSignalStrength, pSignalQuality ) == S_OK )   
                   {   
                    retval = TRUE;     
                    break;   
                    }   
                }   
                // Go to the next adapter in the list.   
                cinfo = cinfo->Next;
                }
               } // Don't forget to delete the allocation.
               delete [] info;
               return retval;
}
#pragma ENDDUMP
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Postby Antonio Linares » Thu Jul 31, 2008 7:29 am

Mauricio,

In C language you have to delare a function prototype before using it, so place this here:

BOOL GetFirstRFEthernetSignalStrength( int*, int* );

HB_FUNC( SIGNAL )
...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42103
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Otto » Fri Aug 22, 2008 4:54 pm

Hello Maurizio,

would you be so kind to post the whole code how to get the wireless signal strength.

Regards,
Otto


OT:
Maurizio,
on Friday, the 12th of September 2008, there will be a ROLLING STONES tribute concert at Sillian.

Our Rolling Stones Coverband will come straight from Palermo by aeroplane and they already promised a great show – as original as can be. It´s six students, who have dedicated also their private lives totally to their heroes, the ROLLING STONES. “We lead a true rock`n´roll lifestyle and dress the same way as the Stones do.” Vincenzo Matassa (alias Mick Jagger), future lawyer confirms.

It would be great to see you and your family here on the second Friday of September too. We all hope for a great party according to the motto: “It´s only rock`n´roll but I like it.”
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 3 guests