Exemple #1
0
PUMA_FUNC(Bool) PUMA_Init(uint16_t wHeightCode, void* hStorage)
{
	gwHeightRC = wHeightCode;

	if(!InitMem())
		return FALSE;

	InitDebug();

 return ModulesInit((void*)ghStorage);
}
Exemple #2
0
/*
 * @brief	主程序
 */
int main(void)
{
	Request req;
	char weightBUf[32];
	char devCode[32];

  	SystemInit();
	ModulesInit();

	SelectChannel(GPRS_CHANNEL);
	GPRS_GetDevCode(devCode, sizeof(devCode));

	SelectChannel(BLUETOOTH_CHANNEL);
	while(GetRequest() != SYS_START){}	/* 等待接收SYS_START信号以开始工作 */
	SendResponse(SYS_START);

	BT_Println(devCode);

	while(1) {
		myWDGInit(30);	/* 设置定时器,值为30*2=60s=1min。超时会导致系统认为蓝牙已断开,从而进入alarm模式。 */

		req = GetRequest();	/* 获取应用请求,并调用相应功能API */
		if(FALSE == TimeoutFlag) {
			switch(req) {
				case KEEP_ALIVE:
					SendResponse(KEEP_ALIVE);
					ResetWDGCounter();
					break;

				case GET_WEIGHT:
					SendResponse(GET_WEIGHT);
					GetWeight(weightBUf);
					BT_Println(weightBUf);
					ResetWDGCounter();
					break;

				case UNLOCK_DEVICE:
					SendResponse(UNLOCK_DEVICE);
					LOCK_Unlock();	/* 解锁电子锁 */
					ResetWDGCounter();
					break;

				default:
					BT_Println("Request invalid.");
			}
		}else {
			while(1) { ReportLocation(); }
		}

	}

	return 0;
}
Exemple #3
0
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdParam,
				   int nCmdShow)
{
	MSG msg;
	WINDOWPLACEMENT w;
	BOOL bQuit = FALSE;

	InitCommonControls();

	hInst = hInstance;

	// Find location of configuration file
	ConfigInit();

	/* Register our custom classes */
	RegisterWindowClasses();

	hMain = CreateWindow(szAppName,       /* window class name */
		szAppName,               /* window caption */
		WS_OVERLAPPEDWINDOW,     /* window style */
		0, 0, 0, 0,              /* initially zero size; changed below */
		NULL,                    /* parent window handle */
		NULL,                    /* window menu handle */
		hInstance,               /* program instance handle */
		NULL);	   	         /* creation parameters */

	if (!hMain)
	{
		char buf[256];
		DWORD err = GetLastError();
		sprintf(buf, "Error - Couldn't Create Client Window : %d", err);
		MessageBox(NULL, buf, "ERROR!", MB_OK);
		MainQuit(hMain);
		exit(1);
	}

	if (config.debug)
		CreateDebugWindow();

	if (lpszCmdParam && strlen(lpszCmdParam) > 0)
		ConfigOverride(lpszCmdParam);

	w.length = sizeof(WINDOWPLACEMENT);
	WindowSettingsLoad(&w);
	SetWindowPlacement(hMain, &w);

	D3DRenderInit(hMain);

	ModulesInit();   // Set up data structures for modules


/* attempt make a crc16 on the meridian.exe */
	GenerateCRC16();

	MainInitState(STATE_OFFLINE);

	UpdateWindow(hMain);

	while (!bQuit)
	{
		MainIdle();

		while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
		{
			if (!GetMessage(&msg, NULL, 0, 0))
			{
				bQuit = TRUE;
				break;
			}

			// Forward appropriate messages for tooltips
			if (state == STATE_GAME)
				TooltipForwardMessage(&msg);

			/* Handle modeless dialog messages separately */
			if ((hCurrentDlg == NULL || !IsDialogMessage(hCurrentDlg, &msg)))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
	}

	/* Unregister our custom classes--not good to leave them around */
	UnregisterWindowClasses();

	return msg.wParam;  // Return value of PostQuitMessage
}