#ifndef __BLE_H #define __BLE_H #include "ble_core.h" #include #ifdef __cplusplus extern "C" { #endif #ifdef __BLE_H_GLOBAL #define __BLE_H_EXTERN #else #define __BLE_H_EXTERN extern #endif /************************************************************************************************ * Version * ************************************************************************************************/ /************************************************************************************************ * How to use * ************************************************************************************************/ /************************************************************************************************ * Enable config * ************************************************************************************************/ /************************************************************************************************ * Includes * ************************************************************************************************/ /************************************************************************************************ * Defines * ************************************************************************************************/ #define BT_BUSY_IND_PORT GPIOB #define BT_BUSY_IND_PIN GPIO_Pin_12 #define BT_CONN_IND_PORT GPIOB #define BT_CONN_IND_PIN GPIO_Pin_13 #define BT_RST_PORT GPIOC #define BT_RST_PIN GPIO_Pin_2 #define BLE_NAME "ALIENTEK" #define BLE_CODE 0 #define BLE_CFG_DELAY_MS 1020 #define BLE_START_DELAY_MS 500 #define BLE_QRY_DELAY_MS 500 #define BLE_RESTORE_DELAY_MS 1000 #define MAC_LEN 6 #define SN_LEN 10 #define MODEL_LEN 6 /************************************************************************************************ * Typedefs * ************************************************************************************************/ #pragma pack(1) typedef enum { BLE_INIT_CMD_NAME_QRY = 0, BLE_INIT_CMD_NAME_CFG, BLE_INIT_CMD_CODE_CFG, BLE_INIT_CMD_TXWPR_CFG, BLE_INIT_CMD_MAX, } EN_BLE_INIT_CMD; typedef enum { BLE_QRY_CMD_ADV_QRY = 0, BLE_QRY_CMD_MAC_QRY, BLE_QRY_CMD_ADV_CFG, BLE_QRY_CMD_MAX, } EN_BLE_QRY_CMD; #define BLE_MTU 100 typedef struct { uint8_t is_used; uint8_t cmd; uint8_t len; uint8_t data[BLE_MTU]; int32_t (*p_func)(uint8_t cmd, uint8_t status, uint8_t *data, uint8_t len); uint32_t tick; } BLE_CMD_CACHE; #pragma pack(0) /************************************************************************************************ * Interfaces * ************************************************************************************************/ void ble_init(void); int32_t ble_loop(void); int32_t ble_send_data(uint8_t data[], int32_t length); int32_t ble_data_recv(uint8_t data[], uint8_t length, int32_t ms); #ifdef __cplusplus }; #endif #endif // __BLE_H