⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bluetoothclient.cpp

📁 蓝牙开发例子拉拉拉拉 蓝牙开发例子拉拉拉拉
💻 CPP
字号:
/*
============================================================================
 Name        : BluetoothClient.cpp
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Client for BluetoothServer.
============================================================================
*/

#include <e32cons.h>
#include "BluetoothReqHandler.h"
#include "BluetoothClient.h"

_LIT(KTextConsoleTitle, "Console");
_LIT(KTextClientServerTest, "Client-Server test\n");
_LIT(KTextFailed, " failed, leave code = %d");
_LIT(KTextPressAnyKey, " [press any key]\n");

LOCAL_D CConsoleBase* console;

LOCAL_C void MainL()
	{
	console->Write(KTextClientServerTest);

	CBluetoothReqHandler* async = CBluetoothReqHandler::NewLC();
	async->RequestTime();

	CActiveScheduler::Start();

	TTime time = async->Time();
	TBuf<KMaxShortDateFormatSpec> timebuf;
	time.FormatL(timebuf, TShortDateFormatSpec());
	console->Write(timebuf);

	CleanupStack::PopAndDestroy();
	}

LOCAL_C void DoStartL()
	{
	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler();
	CleanupStack::PushL(scheduler);
	CActiveScheduler::Install(scheduler);

	MainL();

	CleanupStack::PopAndDestroy();
	}

GLDEF_C TInt E32Main()
	{
	__UHEAP_MARK;
	CTrapCleanup* cleanup = CTrapCleanup::New();
	if(!cleanup)
		{
		return KErrNoMemory;
		}

	TRAPD(errno, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen, KConsFullScreen)));
	if(errno)
		{
		return errno;
		}

	// Run application code inside TRAP harness, wait keypress when terminated
	TRAP(errno, DoStartL());
	if(errno)
		{
		console->Printf(KTextFailed, errno);
		}
	console->Printf(KTextPressAnyKey);
	console->Getch();

	delete console;
	delete cleanup;
	__UHEAP_MARKEND;
	return KErrNone;
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -