43 lines
1.5 KiB
C
43 lines
1.5 KiB
C
#ifndef __BLE_H
|
|
#define __BLE_H
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "stdlib.h"
|
|
#include "stdint.h"
|
|
#include <stdbool.h>
|
|
/* 定义类型 ------------------------------------------------------------------*/
|
|
#define u8 uint8_t
|
|
/* 定义宏 --------------------------------------------------------------------*/
|
|
|
|
|
|
/* ------------------- 时间参数 -------------------*/
|
|
#define BLE_RESET_HOLD_TIME 100U
|
|
#define BLE_RESET_WAIT_TIME 700U // 必须大于500ms
|
|
#define BLE_CMD_TIMEOUT 200U // 指令超时时间
|
|
#define BLE_MIN_GAP 20U // 【关键】指令发送后的最小保护时间,防止误判
|
|
#define BLE_HEARTBEAT_TIME 1000U
|
|
|
|
#define BLE_OK 0
|
|
#define BLE_ERROR 1
|
|
#define BLE_OTHER 2
|
|
#define BLE_WAIT 3
|
|
|
|
|
|
#define BLE_FLAG_ID 0
|
|
#define BLE_FLAG_METER 1
|
|
/* ------------------- 类型定义 -------------------*/
|
|
|
|
|
|
/* ------------------- 函数声明 -------------------*/
|
|
void BLE_Init(void);
|
|
void BLE_HardwareReset(void);
|
|
bool BLE_IsCTS_Low(void);
|
|
static const void* mem_search(const void *haystack, size_t hay_len, const void *needle, size_t needle_len);
|
|
static bool CheckResponseKeyword(const char *keyword);
|
|
void BLE_SendData(uint8_t *pData, uint16_t len);
|
|
void BLE_Application_Init(void);
|
|
void BLE_Application_Poll(void);
|
|
void BLEModBusReturnDevice(void);
|
|
void BLEModBusReturnData(void);
|
|
void BLEModBusReturnparameter(void);
|
|
#endif |