demomain.c

来自「在VC6.0上编译通过的蓝牙通信演示程序, COM1口控制.」· C语言 代码 · 共 73 行

C
73
字号
/*******************************************************************************
Copyright (C) Excelpoint System (Pte) Ltd. 2006

FILE: demoMain.c

DESCRIPTION: This file the entry function
*******************************************************************************/

#include <stdio.h>
#include <windows.h>
#include <winbase.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <crtdbg.h> 
#include "serialcom.h"
#include "demoBlueCAP.h"
#include "HBCP.h"

#define	BUF_SIZE		2000


static unsigned long	baudRate = 115200;
static unsigned char	theBuf[BUF_SIZE];


/********************************************************************************
 * Function: main
 * Description: Entry function. Receive key and read data into event handler
 *
 ********************************************************************************/

int main(int argc, char* argv[])
{
	int rx_num;

	UartDrv_Configure(baudRate, (argc < 2)?"COM1":argv[1]);

	if (!UartDrv_Start())
	{
		printf("UartDrv_Start() failed! Exiting...\n");
		return 0;
	}

	init_demo();
	Menu();

	while (1)
	{
		// receive a key
		if (kbhit())
		{
			char ch;
			ch = getch();
			HandKey(ch);
		}

		// Read event
		UartDrv_Rx(theBuf, BUF_SIZE, &rx_num);
		if (rx_num>0)
		{
			// rx handler
			HBCP_Receive(rx_num,theBuf);
		}
		else
		{
			Sleep(10);
		}
	}

	return 0;
}

⌨️ 快捷键说明

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