2024-12-13 19:07:17 +08:00
|
|
|
|
/***
|
2024-12-04 10:31:57 +08:00
|
|
|
|
* @Author: mbw
|
|
|
|
|
* @Date: 2024-12-03 10:31:59
|
|
|
|
|
* @LastEditors: mbw && 1600520629@qq.com
|
2024-12-13 19:07:17 +08:00
|
|
|
|
* @LastEditTime: 2024-12-10 14:51:37
|
2024-12-04 18:55:59 +08:00
|
|
|
|
* @FilePath: \ble_bjq_ch303rct6_ml307\bsp\inc\bsp_bt.h
|
2024-12-13 19:07:17 +08:00
|
|
|
|
* @Description:
|
2024-12-04 10:31:57 +08:00
|
|
|
|
* @
|
2024-12-13 19:07:17 +08:00
|
|
|
|
* @Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
2024-12-04 10:31:57 +08:00
|
|
|
|
*/
|
|
|
|
|
#ifndef __BSP_BT_H__
|
|
|
|
|
#define __BSP_BT_H__
|
|
|
|
|
|
|
|
|
|
#include "rtthread.h"
|
|
|
|
|
#include "board.h"
|
|
|
|
|
#include "drv_gpio.h"
|
|
|
|
|
|
2024-12-13 19:07:17 +08:00
|
|
|
|
#define BT_FRAME_HEAD_LEN (2)
|
|
|
|
|
#define BT_FRAME_TAIL_LEN (2)
|
2024-12-07 17:09:57 +08:00
|
|
|
|
#define BT_FRAME_MAX_LEN (32)
|
2024-12-13 19:07:17 +08:00
|
|
|
|
#define BT_FRAME_HEAD_DATA (0xAA)
|
|
|
|
|
#define BT_FRAME_TAIL_DATA (0x55)
|
2024-12-04 10:31:57 +08:00
|
|
|
|
|
2024-12-07 17:09:57 +08:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2024-12-13 19:07:17 +08:00
|
|
|
|
WirelessValveClose = 0x01,
|
|
|
|
|
WirelessValveOpen,
|
2024-12-07 17:09:57 +08:00
|
|
|
|
} WireLessState;
|
2024-12-04 10:31:57 +08:00
|
|
|
|
|
2024-12-13 19:07:17 +08:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2024-12-07 17:09:57 +08:00
|
|
|
|
kValveCmdCtr = 0X01,
|
|
|
|
|
kValveCmdReg,
|
|
|
|
|
kValveCmdRem,
|
|
|
|
|
kValveCmdRep,
|
2025-01-02 15:12:34 +08:00
|
|
|
|
kValveCmdRemAll,
|
2024-12-07 17:09:57 +08:00
|
|
|
|
kValveCmdMax
|
|
|
|
|
} ValveCmdType;
|
2024-12-04 10:31:57 +08:00
|
|
|
|
|
2024-12-13 19:07:17 +08:00
|
|
|
|
/*事件类型: 1: 阀门控制响应
|
|
|
|
|
2: 阀门注册响应
|
|
|
|
|
3:阀门移除响应
|
|
|
|
|
4: 阀门更换响应
|
|
|
|
|
5:阀门状态上报
|
|
|
|
|
*/
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
kValveEventCtr = 0x01,
|
2025-04-09 14:25:24 +08:00
|
|
|
|
kValveEventReg,//阀门注册
|
|
|
|
|
kValveEventRem,//阀门移除
|
|
|
|
|
kValveEventRep,//阀门更换
|
|
|
|
|
kValveEventRemAll,//移除所有,此时不看阀门是否对应,直接删除全部
|
2025-04-25 08:49:49 +08:00
|
|
|
|
kValveEventStatus,//阀门主动上报信息
|
|
|
|
|
kValveEventConnect,//阀门连接状态上报,未实现
|
2024-12-13 19:07:17 +08:00
|
|
|
|
kValveEventMax
|
|
|
|
|
}ValveEventType;
|
2024-12-04 10:31:57 +08:00
|
|
|
|
|
2024-12-07 17:09:57 +08:00
|
|
|
|
typedef struct __attribute__((packed))
|
|
|
|
|
{
|
|
|
|
|
rt_uint8_t cmd;
|
|
|
|
|
uint8_t buf[];
|
2024-12-13 19:07:17 +08:00
|
|
|
|
} BtData_t;
|
2024-12-04 10:31:57 +08:00
|
|
|
|
|
2024-12-07 17:09:57 +08:00
|
|
|
|
typedef struct __attribute__((packed))
|
|
|
|
|
{
|
|
|
|
|
rt_uint8_t len;
|
|
|
|
|
rt_uint8_t buf[256];
|
|
|
|
|
} BTFrameData;
|
2024-12-04 10:31:57 +08:00
|
|
|
|
|
2024-12-13 19:07:17 +08:00
|
|
|
|
extern struct rt_semaphore bt_ctr_sem; //控制阀门信号量
|
|
|
|
|
extern struct rt_semaphore bt_reg_sem; //注册阀门信号量
|
|
|
|
|
extern struct rt_semaphore bt_rem_sem; //移除阀门信号量
|
|
|
|
|
extern struct rt_semaphore bt_rep_sem; //更换阀门信号量
|
2024-12-04 10:31:57 +08:00
|
|
|
|
|
2025-01-04 17:19:34 +08:00
|
|
|
|
int BSP_Bt_Init(void);
|
2024-12-13 19:07:17 +08:00
|
|
|
|
int Bt_Valve_Handler(ValveCmdType type, rt_uint8_t id, rt_uint8_t *data);
|
|
|
|
|
#endif // BSP_BT_H__
|