locked
Wifi programing on Windows Mobile RRS feed

  • Question

  • Hello all,

    I would like to create an application on windows mobile 6.0.
    The app is connecting to the given AccessPoint but in 5-10 second it disconnects and I don't know why.

    The program is using

    OID_802_11_INFRASTRUCTURE_MODE
    OID_802_11_AUTHENTICATION_MODE
    OID_802_11_ENCRYPTION_STATUS

    and

    OID_802_11_SSID <- after this command the connection is established for 5-10 seconds.

    Can someone help to me or has anyone any C++ sample code for the Wifi connection building?

    Thanks,
    Buxi 

     

    Monday, August 4, 2008 6:50 AM

Answers

  • Hi Buxi,

    I know your idea. In fact, you can enuerate all available connections. Then check if it is wifi, connect it, like the code below:  

    Code Snippet

          while (hr ==S_OK)

            {

            hr = ConnMgrEnumDestinations(index, &pDestInfo);// enumerate all available connections

            if(pDestInfo.szDescription==L"wifi related information"

                    break;

            index++;

     

            }

            HRESULT lResult;

            GUID guidNetwork;

            lResult = ConnMgrMapConRef(ConRefType_NAP, pDestInfo.szDescription, &guidNetwork);

     

     

    I don't try the code, you can try it.

     

    Another approach, OpennetCF wrapped connection manager.It provide the function(OpenNETCF.Net.Adapter ) to connect the wi-fi network, a sample in below link:

    http://community.opennetcf.com/search/SearchResults.aspx?q=accesspoint

     

    Best regards,

    Guang-Ming Bian - MSFT

    Friday, August 8, 2008 3:03 AM

All replies

  • Hi Buxi,

    Windows mobile platform use connection manager(CM) to manage all connection, CM computes the “best” path for each of the Connection Requests (CRs), connects all connections on it to satisfy the requests, and provides a continuous feed of status notifications to the owner application informing them when status of their CR changes.

     

    Beginning with WM 5.0, an application can specify precisely the connection that CM will use to satisfy its CR.  This is done by selecting the connection by name using ConnMgrMapConRef() and passing the returned GUID as guidDestNet field of the CONNMGR_CONNECTIONINFO structure when calling ConnMgrEstablishConnection[Sync]().  The disadvantage of this is that the resultant connection path will contain only one connection (ex. no proxies), and the choice of connection may not be optimal (ex. there may be a faster connection available).

     

     For more information:

    http://blogs.msdn.com/cenet/archive/2006/06/06/620360.aspx

     

    From above explanation, we can code like below:

    Code Snippet

    void CConnMgrConnectMobile6TestDlg::OnBnClickedButton1()

    {

            // TODO: Add your control notification handler code here

            // TODO: Add your control notification handler code here

            int index = 0;

            CONNMGR_DESTINATION_INFO   pDestInfo;

            HRESULT hr = S_OK;

     

            while (hr ==S_OK)

            {

            hr = ConnMgrEnumDestinations(index, &pDestInfo);  // enumerate all available connections

            index++;

     

            }

            HRESULT lResult;

            GUID guidNetwork;

            lResult = ConnMgrMapConRef(ConRefType_NAP, L"My Connection", &guidNetwork); //connect a special connect

     

     

     

            HANDLE phConnection;

            DWORD dwStatus = 0;

     

                    CONNMGR_CONNECTIONINFO ConnInfo;

            ZeroMemory(&ConnInfo, sizeof(ConnInfo));

            ConnInfo.cbSize = sizeof(ConnInfo);

            ConnInfo.dwParams = CONNMGR_PARAM_GUIDDESTNET;

            ConnInfo.dwFlags = CONNMGR_FLAG_PROXY_HTTP | CONNMGR_FLAG_PROXY_WAP | CONNMGR_FLAG_PROXY_SOCKS4 | CONNMGR_FLAG_PROXY_SOCKS5;

            ConnInfo.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;

            ConnInfo.guidDestNet = guidNetwork;

            ConnInfo.bExclusive    = FALSE;

            ConnInfo.bDisabled = FALSE;

            HRESULT hResult = ConnMgrEstablishConnectionSync(&ConnInfo, &phConnection, 10*1000, &dwStatus );

    } 

     

    Best regards,

    Guang-Ming Bian - MSFT

    Wednesday, August 6, 2008 3:03 AM
  • Hi Guang-Ming,

     

    Thanks for you reply

    Maybe I wrote wrong way my question, but as I know the connection manager can work just on the established line. I'm using the connection manager on the Atctive Sync and GPRS connection as well.

    My main problem is that I need to prepare a "line" between my PPC and a given access point and this is that what I couldn't prepare. After if this "line" prepared I can use the connection manager on this connection or m'I wrong?

     

    Best regards,

    Buxi

     

     

     

    Wednesday, August 6, 2008 8:10 AM
  • Hi Buxi,

    I know your idea. In fact, you can enuerate all available connections. Then check if it is wifi, connect it, like the code below:  

    Code Snippet

          while (hr ==S_OK)

            {

            hr = ConnMgrEnumDestinations(index, &pDestInfo);// enumerate all available connections

            if(pDestInfo.szDescription==L"wifi related information"

                    break;

            index++;

     

            }

            HRESULT lResult;

            GUID guidNetwork;

            lResult = ConnMgrMapConRef(ConRefType_NAP, pDestInfo.szDescription, &guidNetwork);

     

     

    I don't try the code, you can try it.

     

    Another approach, OpennetCF wrapped connection manager.It provide the function(OpenNETCF.Net.Adapter ) to connect the wi-fi network, a sample in below link:

    http://community.opennetcf.com/search/SearchResults.aspx?q=accesspoint

     

    Best regards,

    Guang-Ming Bian - MSFT

    Friday, August 8, 2008 3:03 AM
  • Hello Guang-Ming,

     

    Thanks for your answers. It helped to me.

    I just have only one question yet.

    How can I manage the WIFI card power from my program? I mean how can I switch wifi radio on/off?

     

    Best Regards,

    Buxi

     

    Sunday, August 10, 2008 9:42 AM
  • Hi Buxi,

    Please refer to following thread:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=998656&SiteID=1

     

    Best regards,

    Guang-Ming Bian - MSFT

    Tuesday, August 12, 2008 7:32 AM