btutils.h

来自「linux下bluetooth后台服务程序」· C头文件 代码 · 共 56 行

H
56
字号
#ifndef _BTUTILS_H_#define _BTUTILS_H_#include <stdio.h>#include <signal.h>#include <sys/time.h>#define BTU_PROCBASE "/proc"#ifdef ENABLE_DEBUG_LOG#define DEBUG_LOG(fmt)                { struct timeval tv; gettimeofday(&tv, NULL); printf("(%ld.%ld):", tv.tv_sec, tv.tv_usec); printf(__FILE__ "(%d): %s: " fmt "\n", (int)__LINE__,__FUNCTION__); fflush(stdout);}#define DEBUG_LOG1(fmt, p1)           { struct timeval tv; gettimeofday(&tv, NULL); printf("(%ld.%ld):", tv.tv_sec, tv.tv_usec); printf(__FILE__ "(%d): %s: " fmt "\n", (int)__LINE__, __FUNCTION__, p1); fflush(stdout);}#define DEBUG_LOG2(fmt, p1, p2)       { struct timeval tv; gettimeofday(&tv, NULL); printf("(%ld.%ld):", tv.tv_sec, tv.tv_usec); printf(__FILE__ "(%d): %s: " fmt "\n", (int)__LINE__, __FUNCTION__, p1, p2); fflush(stdout);}#define DEBUG_LOG3(fmt, p1, p2, p3)   { struct timeval tv; gettimeofday(&tv, NULL); printf("(%ld.%ld):", tv.tv_sec, tv.tv_usec); printf(__FILE__ "(%d): %s: " fmt "\n", (int)__LINE__, __FUNCTION__, p1, p2, p3); fflush(stdout);}#define DEBUG_LOG4(fmt, p1, p2, p3, p4)   { struct timeval tv; gettimeofday(&tv, NULL); printf("(%ld.%ld):", tv.tv_sec, tv.tv_usec); printf(__FILE__ "(%d): %s: " fmt "\n", (int)__LINE__, __FUNCTION__, p1, p2, p3, p4); fflush(stdout);}#define DEBUG_LOG5(fmt, p1, p2, p3, p4, p5)   { struct timeval tv; gettimeofday(&tv, NULL); printf("(%ld.%ld):", tv.tv_sec, tv.tv_usec); printf(__FILE__ "(%d): %s: " fmt "\n", (int)__LINE__, __FUNCTION__, p1, p2, p3, p4, p5); fflush(stdout);}#define DEBUG_LOG6(fmt, p1, p2, p3, p4, p5, p6)   { struct timeval tv; gettimeofday(&tv, NULL); printf("(%ld.%ld):", tv.tv_sec, tv.tv_usec); printf(__FILE__ "(%d): %s: " fmt "\n", (int)__LINE__, __FUNCTION__, p1, p2, p3, p4, p5, p6); fflush(stdout);}#else //ENABLE_DEBUG_LOG#define DEBUG_LOG(fmt)                { }#define DEBUG_LOG1(fmt, p1)           { }#define DEBUG_LOG2(fmt, p1, p2)       { }#define DEBUG_LOG3(fmt, p1, p2, p3)   { }#define DEBUG_LOG4(fmt, p1, p2, p3, p4)   { }#define DEBUG_LOG5(fmt, p1, p2, p3, p4, p5)   { }#define DEBUG_LOG6(fmt, p1, p2, p3, p4, p5, p6)   { }#endif //ENABLE_DEBUG_LOGstruct sBTTimer {	struct timeval start;	struct timeval stop;	unsigned int timeout;};typedef struct sBTTimer *BTTimer;int BTSendSig(char* procname, int sig);void BTSetTimer(BTTimer timer, unsigned int timeout);int BTTimerExpired(BTTimer timer);void BTEnablePageScan();void BTDisablePageScan();int BTIsAclLinkActive(char *bdaddrstr);void BTDestroyAclLink(char *bdaddrstr);int BTGetFileInt(const char* name);// Debug stuffchar* state2str(int state);char* error2str(int error);#endif //_BTUTILS_H_

⌨️ 快捷键说明

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