locked
How to wake up network in unattended mode? RRS feed

  • Question


  • Hi all,

    I have a problem. I need to wake up device from suspend mode, wake up network, write file on network share and allow to device to sleep again.

    I am using the following code to do it:

     HANDLE l_hEvent = CreateEvent(NULL, FALSE, FALSE, _T("TestWakeUpEvent"
    ));
    
     SYSTEMTIME l_stTime;
     GetLocalTime(&l_stTime);
     FILETIME l_ftPlannedTime;
     SystemTimeToFileTime(&l_stTime, &l_ftPlannedTime);
     ULARGE_INTEGER l_bigInteger;
     l_bigInteger.LowPart = l_ftPlannedTime.dwLowDateTime;
     l_bigInteger.HighPart = l_ftPlannedTime.dwHighDateTime;
     l_bigInteger.QuadPart += 1200000000; // 120 seconds
    
     l_ftPlannedTime.dwLowDateTime = l_bigInteger.LowPart;
     l_ftPlannedTime.dwHighDateTime = l_bigInteger.HighPart;
     FileTimeToSystemTime(&l_ftPlannedTime, &l_stTime);
    
     LogMessage(TEXT("Initiating wake up procedure..."
    ));
     BOOL l_bInitialized = CeRunAppAtTime(_T("\\\\.\\Notifications\\NamedEvents\\TestWakeUpEvent"
    ), &l_stTime);
    
     LogMessage(TEXT("Waiting for the event..."
    ));
     WaitForSingleObject(l_hEvent, INFINITE);
    
     LogMessage(TEXT("Go to unattended mode..."
    ));
     PowerPolicyNotify(PPN_UNATTENDEDMODE,TRUE);
    
     LogMessage(TEXT("Set power requirement..."
    ));
     HANDLE l_hPower1 = MySetPowerRequirement(L"UFN1:"
    , D1);
     HANDLE l_hPower2 = MySetPowerRequirement(L"NDS0:"
    , D0);
    
     LogMessage(TEXT("Initiating network waiting event..."
    ));
     CeRunAppAtEvent(_T("\\\\.\\Notifications\\NamedEvents\\TestWakeUpEvent"
    ), NOTIFICATION_EVENT_NET_CONNECT);
    
     LogMessage(TEXT("Waiting on network..."
    ));
     DWORD dwWait = WaitForSingleObject(l_hEvent, 20000);
    
     LogMessage(TEXT("Testing connection..."
    ));
     BOOL l_bFileCreation = TestConnection();
    
     LogMessage(TEXT("Releasing the power requirements..."
    ));
     ReleasePowerRequirement(l_hPower2);
     ReleasePowerRequirement(l_hPower1);
    
     LogMessage(TEXT("Exiting from unattended mode..."
    ));
     PowerPolicyNotify(PPN_UNATTENDEDMODE,FALSE);
    
     LogMessage(TEXT("Closing the event handle..."
    ));
     CloseHandle(l_hEvent);
    
    
    Device wakes up, but connection is not established. Before device goes to suspend, connection is established using WiFi. What is wrong?


    Aleksey
    Wednesday, May 12, 2010 5:19 AM

All replies

  • >>Device wakes up, but connection is not established. Before device goes to suspend, connection is established using WiFi

    Aren't your sayings contradictory? I see you make some logs. What's the content of the logs? Besides, tell me something about your environment.


    Please mark the post that helps you, and unmark that does not. This benefits our community.
    Friday, May 14, 2010 9:38 AM
  • I meant, that the program was tested in the following way:

    1. WiFi on the device was enabled and connection was established.
    2. Program was launched.
    3. Device suspended.
    4. Program waked up the device in unattended mode.
    5. Expected, that connection will be reestablished, but was not.

    Aleksey
    Saturday, May 15, 2010 1:17 PM