This repository has been archived on 2025-02-28. You can view files and clone it, but cannot push or open issues or pull requests.
controller-hd/User/application/inc/at_bluetooth.h

58 lines
1.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __ATBLUETOOTH_H__
#define __ATBLUETOOTH_H__
#include "stdio.h"
#include "string.h"
#include "data_type_def.h"
#include "osel_arch.h"
#define BLE_TYPE_HC42 0 ///< HC42蓝牙模块
#define BLE_TYPE_MX02 1 ///< MX02蓝牙模块
#define BLE_TYPE BLE_TYPE_MX02 // 蓝牙模块类型
#define AT_SUCCESS (0) /* 指令正常 */
#define AT_ERR (1) /* 指令异常 */
#define AT_ERR_UNINVAIL (2) /* 没有对应指令 */
#define AT_ERR_FUN_UNUSED (3) /* 没有可执行函数 */
#define ROBOT_DEBUG
#ifdef ROBOT_DEBUG
#define AT_DEBUG_INFO(format, ...) printf(format, ##__VA_ARGS__)
#else
#define AT_DEBUG_INFO(format, ...)
#endif
typedef unsigned char (*pFunc)(unsigned char *ptr, unsigned char len);
typedef enum
{
AT_CMD_TEST = 0, /* 测试指令 */
AT_CMD_NAME_REQ, /* 查询名称 */
AT_CMD_NAME, /* 设置名称 */
AT_CMD_DISA, /* 断开当前连接 */
AT_CMD_TX_POWER, /* 设置发送功率 */
AT_CMD_ADV_INTERVAL, /* 设置广播间隔 */
AT_CMD_CON_INTERVAL, /* 设置连接间隔 */
AT_CMD_ADV_ONOFF, /* 设置打开、关闭广播 */
AT_GET_VER, /* 获取版本号 */
AT_GET_CON_STATE, /* 获取连接状态 */
AT_CMD_UART_CFG, /* 配置UART参数 */
AT_CMD_READY, /* 模块准备就绪 */
AT_END
} at_cmd_e;
typedef struct
{
at_cmd_e cmd; /* 指令序号 */
char *str; /* 指令内容 */
pFunc cb; /* 指令执行 */
} at_cmd_func_t;
/* 返回值参数内容如上, p-指向解析的指令len-解析指令长度 */
unsigned char at_cmd_parse(unsigned char *p, unsigned char len);
void at_set_memcmp_cache(unsigned char *p, unsigned char len);
extern unsigned char bluetooth_state;
#endif // __ATBLUETOOTH_H__