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

📄 btagext.cpp

📁 Windows CE操作系统中适用的蓝牙驱动程序
💻 CPP
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//

#include <windows.h>
#include <btagpub.h>


PFN_SendATCommand g_pfnSendATCommand = NULL;


void DbgPrintATCmd(DWORD dwZone, LPSTR szCommand, int cbCommand)
{
    CHAR szDebug[512];

    for (int i = 0, j = 0; i < cbCommand; i++, j++) {
        if (szCommand[i] == '\r') {
            szDebug[j] = '<'; j++;
            szDebug[j] = 'c'; j++;
            szDebug[j] = 'r'; j++;
            szDebug[j] = '>';
        }
        else if (szCommand[i] == '\n') {
            szDebug[j] = '<'; j++;
            szDebug[j] = 'l'; j++;
            szDebug[j] = 'f'; j++;
            szDebug[j] = '>';
        }
        else {
            szDebug[j] = szCommand[i];
        }
    }

    szDebug[j] = '\0';

    DEBUGMSG(dwZone, (L"%hs", szDebug));
}



void BthAGATSetCallback(PFN_SendATCommand pfn)
{
    g_pfnSendATCommand = pfn;
}

BOOL BthAGATHandler(LPSTR szCommand, DWORD cbCommand)
{
    DEBUGMSG(1, (L"----> BTAGATEXT SAMPLE: Received command: "));
    DbgPrintATCmd(1, szCommand, cbCommand);
    DEBUGMSG(1, (L"\n"));

    if (! _strnicmp(szCommand, "AT+BVRA", 7)) {
		HANDLE h = CreateFile(L"BAG0:",0,0,NULL,OPEN_EXISTING,0,NULL);
		if (INVALID_HANDLE_VALUE == h) {
			DEBUGMSG(1, (L"BTAGATEXT: Error opening handle to AG service.\n"));
			return FALSE;
		}

		DeviceIoControl(h,IOCTL_AG_OPEN_AUDIO,NULL,0,NULL,0,NULL,NULL);
		CloseHandle(h);

		g_pfnSendATCommand("\r\nOK\r\n", 6);
		return TRUE;
    }

    return FALSE;
}


⌨️ 快捷键说明

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