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

📄 btttmp.h

📁 linux下bluetooth后台服务程序
💻 H
字号:
#ifndef _BTTTMP_H_#define _BTTTMP_H_#include "btdefines.h"#include "TTMP.h"#include "btutils.h"//server socket#define SERVER_SOCKET_ADDR	"/var/run/btserver"#define BT_TTMP_TIMEOUT		10000000 // us (10 sec should be enough to communicate to the server)//commands TTMP#define CMD_INIT		0#define CMD_CLOSE		1#define CMD_RELEASE		2#define CMD_SEND		3#define CMD_RECEIVE		4#define CMD_GETSTATE		5#define CMD_GETERROR		6#define CMD_STARTUSINGCHANNEL	7#define CMD_STOPUSINGCHANNEL	8#define CMD_GETFLAGS		9#define CMD_SETFLAGS		10#define CMD_ISPROFILEACTIVE	11//parameter name for TTMP#define CMD_PAR_COMMAND		"cmd"#define CMD_PAR_ADDRESS		"add"#define CMD_PAR_CHANNEL		"cha"#define CMD_PAR_PROFILE		"pro"#define CMD_PAR_OPTION		"opt"#define CMD_PAR_PIN		"pin"#define CMD_PAR_HANDLE		"hdl"#define CMD_PAR_DATA		"dat"#define CMD_PAR_STATE		"sta"#define CMD_PAR_RESULT		"res"#define CMD_PAR_SIZE		"siz"#define CMD_ID			"id"//TTMP macro's#define TTMP_SETFIELDINT(msg, param, param_val) \	{ \	int ttmpres; \	if ((ttmpres = TTMPSetFieldInt32(msg, param, param_val)) < TTMP_ERR_NONE) { \		DEBUG_LOG2("Setting %s failed, error = %d", param, ttmpres); \		TTMPMessageDestroy(msg); \		return TTMP_ERROR; \	} \	}#define TTMP_SETFIELDSTR(msg, param, param_val) \	{ \	int ttmpres; \	if ((ttmpres = TTMPSetFieldStr(msg, param, (TChr*)param_val)) < TTMP_ERR_NONE) { \		DEBUG_LOG2("Setting %s failed, error = %d", param, ttmpres); \		TTMPMessageDestroy(msg); \		return TTMP_ERROR; \	} \	}#define TTMP_SETFIELDBIN(msg, param, param_val, size) \	{ \	int ttmpres; \	if ((ttmpres = TTMPSetFieldBinary(msg, param, param_val, size)) < TTMP_ERR_NONE) { \		DEBUG_LOG2("Setting %s failed, error = %d", param, ttmpres); \		TTMPMessageDestroy(msg); \		return TTMP_ERROR; \	} \	}#define TTMP_SEND(conn, msg) \	{ \	int ttmpres; \	if ((ttmpres = TTMPConnectionSendTimeout(conn, msg, BT_TTMP_TIMEOUT)) < TTMP_ERR_NONE) { \		DEBUG_LOG1("Cannot send a message, error = %d", ttmpres); \		TTMPMessageDestroy(msg); \		return TTMP_ERROR; \	} \	}#define TTMP_RECEIVE(conn, msg) \	{ \	int ttmpres; \	if ((ttmpres = TTMPConnectionReceiveTimeout(conn, msg, BT_TTMP_TIMEOUT)) != TTMP_ERR_NONE) { \		DEBUG_LOG1("Cannot receive a message, error = %d", ttmpres); \		TTMPMessageDestroy(*msg); \		return TTMP_ERROR; \	} \	}#define TTMP_GETFIELDINT(msg, param, param_val) \	{ \	int ttmpres; \	if ((ttmpres = TTMPGetFieldInt32(msg, param, param_val)) != TTMP_ERR_NONE) { \		DEBUG_LOG2("Getting %s failed, error = %d", param, ttmpres); \		TTMPMessageDestroy(msg); \		return TTMP_ERROR; \	} \	}#define TTMP_GETFIELDSTR(msg, param, param_val, size) \	{ \	int ttmpres; \	if ((ttmpres = TTMPGetFieldStr(msg, param, (TChr*)param_val, size)) != TTMP_ERR_NONE) { \		DEBUG_LOG2("Getting %s failed, error = %d", param, ttmpres); \		TTMPMessageDestroy(msg); \		return TTMP_ERROR; \	} \	}#define TTMP_DETACHFIELDSTR(msg, param, param_val) \	{ \	int ttmpres; \	if ((ttmpres = TTMPDetachFieldStr(msg, param, (TChr**)param_val)) != TTMP_ERR_NONE) { \		DEBUG_LOG2("Getting %s failed, error = %d", param, ttmpres); \		TTMPMessageDestroy(msg); \		return TTMP_ERROR; \	} \	}#define TTMP_DETACHFIELDBIN(msg, param, param_val) \	{ \	int ttmpres; \	if ((ttmpres = TTMPDetachFieldBinary(msg, param, (void**)param_val)) != TTMP_ERR_NONE) { \		DEBUG_LOG2("Getting %s failed, error = %d", param, ttmpres); \		TTMPMessageDestroy(msg); \		return TTMP_ERROR; \	} \	}#define TTMP_GETFIELDSIZE(msg, param, fieldsize) \	{ \	*fieldsize = TTMPGetFieldSize(msg, param); \	if (*fieldsize < TTMP_ERR_NONE) { \		DEBUG_LOG2("Getting %s size failed, error = %d", param, *fieldsize); \		TTMPMessageDestroy(msg); \		return TTMP_ERROR; \	} \	}#define TTMP_GETFIELDBIN(msg, param, param_val, size) \	{ \	int ttmpres; \	if ((ttmpres = TTMPGetFieldBinary(msg, param, param_val, size)) != TTMP_ERR_NONE) { \		DEBUG_LOG2("Getting %s failed, error = %d", param, ttmpres); \		TTMPMessageDestroy(msg); \	} \	}#define TTMP_CLEAR(msg) \	TTMPMessageClear(msg)#define TTMP_DESTROY(msg) \	TTMPMessageDestroy(msg)	#endif //_BTTTMP_H_

⌨️ 快捷键说明

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