MSP 3.3.1: Check in on AC power?

// Expert user has replied.
H Hunter Bradshaw 3 years 7 months ago
1 5 0

Team,
 

Other MDM’s (eg Avalanche) have the option that as soon as the device gets onto AC power, it will force a check in.  I was looking for a similar setting in Agent.30.setting.xml but didn’t find anything.

 

Please advise if I’m missing something, or there’s a work-around/package/registry key/etc that can do the trick. cheers, Daniel

Please Register or Login to post a reply

5 Replies

A Allan Herrod

Daniel; That is a device question that you would have to direct to the device team through the appropriate forum for that device. Allan

K Kjell Lloyd

Possible work arounds if this is a show stopper vs Avalanche (maybe someone knows better solutions). Symscript: ... OnPower AC GOSUB OnACPower SLEEP INFINITE :END :OnACPower     RUN "\windows\30agent.exe" "-R1" RETURN Optional in C (not fully tested): myapp1.exe could contain: CeRunAppAtEvent("myapp2.exe", NOTIFICATION_EVENT_ON_AC_POWER); myapp2.exe then launches the 30agent.exe with a parameter to do a force check-in (probably need to full-fill the conditions also). PROCESS_INFORMATION pinfo; DWORD dwExitCode = 0; if (CreateProcess(_T("\\windows\\30agent.exe"), _T("-R1"), NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pinfo)) { //uncomment below line to wait for the process to exit //WaitForSingleObject(pinfo.hProcess, INFINITE);   Sleep(10); //wait for the process to initilize CloseHandle(pinfo.hProcess); CloseHandle(pinfo.hThread); } else { //something went wrong.... } the above could merged into one exe... and consider using the RequestPowerNotifications(..) for power notification but requires more code. For more info of the parameters for the MSP client can be found in the MSP documentation. The -R1 parameter will do a full regDoc. Hope this helps.

A Allan Herrod

Running the MSP Agent with the command line "-R1" will, as stated, send a Discovery Document, but it will NOT do ANYTHING else.  So, it is NOT the equivalent of what would happen on a normal check-in or a check-in "forced" via the UI.  To do a FULL check-in, you would need to use the command line "-R1 -C -J".

H Hunter Bradshaw

Thanks for the responses.
I tried the C code... with the CeRunAppAtEvent but it appears Motorola don’t actually pass on the AC event – I get other events, for instance I can register for “NOTIFICATION_EVENT_WAKEUP” and the notification comes up properly when the device wakes up, but if I register for “NOTIFICATION_EVENT_ON_AC_POWER” I never actually receive the event.

 

Test code below...

 

#include "stdafx.h"

#include "notify.h"

 

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)

{

      if(!*lpCmdLine)

      {

            // if no command line, register AC power event

            TCHAR exepath[MAX_PATH];

            if(!GetModuleFileName(0, exepath, MAX_PATH) != ERROR_SUCCESS)

                  return E_FAIL; // can't determine EXE name :(

 

            if(CeRunAppAtEvent(exepath, NOTIFICATION_EVENT_ON_AC_POWER) == TRUE)

                  MessageBox(NULL, L"ac registered", L"foo", MB_OK);

            else

                  MessageBox(NULL, L"couldn't register ac", L"foo", MB_OK);

 

            if(CeRunAppAtEvent(exepath, NOTIFICATION_EVENT_WAKEUP) == TRUE)

                  MessageBox(NULL, L"wakeup registered", L"foo", MB_OK);

            else

                  MessageBox(NULL, L"couldn't register wakeup", L"foo", MB_OK);

 

            return ERROR_SUCCESS;

      }

      else

      {

            // if command line, means it was launched by the notifications system and the event is passed as the parameter...

            MessageBox(NULL, lpCmdLine, L"got event", 0);

 

            PROCESS_INFORMATION pi;

            ZeroMemory( &pi, sizeof( pi ) );

 

            return CreateProcess( L"\\windows\\30agent.exe", L"-R1 -C -J", NULL, NULL, false, 0, NULL, NULL, NULL, &pi );

      }

}

 

 

Do you have an example for using RequestPowerNotifications() instead?  Won’t that be less efficient, since the .exe will have to stay running all the time? cheers, Daniel

A Allan Herrod

No, there is no option to configure the MSP Agent to check in "as soon as the device gets onto AC power".  You can apply a Check-in Condition to indicate that thethe device should only check-in "when it is on AC power".  Combined with a short check-in interval (e.g. one minute), it will check-in within one minute of being placed onto AC power.

CONTACT
Can’t find what you’re looking for?