2026-03-20 21:16:58 +08:00
|
|
|
|
#ifndef __BLE_H
|
|
|
|
|
|
#define __BLE_H
|
|
|
|
|
|
|
|
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
|
|
|
|
#include "stdlib.h"
|
|
|
|
|
|
#include "stdint.h"
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ------------------------------------------------------------------*/
|
|
|
|
|
|
#define u8 uint8_t
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> --------------------------------------------------------------------*/
|
2026-03-20 21:19:53 +08:00
|
|
|
|
|
2026-03-20 21:16:58 +08:00
|
|
|
|
|
|
|
|
|
|
/* ------------------- ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -------------------*/
|
|
|
|
|
|
#define BLE_RESET_HOLD_TIME 100U
|
|
|
|
|
|
#define BLE_RESET_WAIT_TIME 700U // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>500ms
|
|
|
|
|
|
#define BLE_CMD_TIMEOUT 200U // ָ<>ʱʱ<CAB1><CAB1>
|
|
|
|
|
|
#define BLE_MIN_GAP 20U // <20><><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>ָ<EFBFBD><EFBFBD>ͺ<EFBFBD><CDBA><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>ʱ<EFBFBD>䣬<EFBFBD><E4A3AC>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
|
|
|
|
|
|
#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
|
|
|
|
|
|
/* ------------------- <20><><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD> -------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -------------------*/
|
|
|
|
|
|
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
|