122 lines
3.3 KiB
C
122 lines
3.3 KiB
C
#ifndef _USER_MANAGEMENT_SERVER_H_
|
||
#define _USER_MANAGEMENT_SERVER_H_
|
||
|
||
|
||
#include "sys_config.h"
|
||
#include "ble_protocol.h"
|
||
|
||
|
||
typedef struct
|
||
{
|
||
uint16_t max_frame_size; //链路层最大帧长度
|
||
uint16_t max_trans_unit; //MTU大小
|
||
uint16_t max_trans_timeout; //连接间隔
|
||
} conn_param_t;
|
||
|
||
/*******************************************
|
||
* 连接参数能力协商
|
||
*********************************************/
|
||
typedef enum
|
||
{
|
||
max_frame_size_type = 1,
|
||
max_transimission_unit_type,
|
||
max_transimission_timeout_type,
|
||
phone_operating_system_type,
|
||
} conn_param_type;
|
||
|
||
/********************************
|
||
* 握手连接--4.1 命令ID
|
||
**********************************/
|
||
typedef enum
|
||
{
|
||
CONNECTION_PARA_NEGOTIATE_ID = 1, //4.1.1
|
||
QURY_BOND_STATUS_ID = 2, // 4.1.2
|
||
BLE_BOND_REQ_ID = 3, //4.1.3
|
||
mamagement_server_max_ID,
|
||
} mamagement_server_id_type;
|
||
|
||
/*******************************************
|
||
* 查询蓝牙绑定状态
|
||
*********************************************/
|
||
typedef enum
|
||
{
|
||
get_bt_bond_status_type = 1,
|
||
// get_bt_bond_status_info_type,
|
||
get_bt_bond_id_type,
|
||
// get_bt_bond_version_type,
|
||
// get_bt_service_mtu_type,
|
||
// get_bt_mac_addr_type=7,
|
||
get_bt_device_mac_addr_type,
|
||
// get_bt_cmd_cnt_type,
|
||
// get_bt_key_version_type,
|
||
// get_bt_bond_appid_type,
|
||
} bt_bond_status_type;
|
||
|
||
/*******************************************
|
||
* 蓝牙绑定请求
|
||
*********************************************/
|
||
typedef enum
|
||
{
|
||
require_bt_bond_type = 1,
|
||
bt_bond_os_type,
|
||
bt_bond_id_type,
|
||
bt_bond_key_type,
|
||
bt_bond_IV_type,
|
||
} bt_bond_type;
|
||
|
||
/*******************************************
|
||
* 绑定状态
|
||
*********************************************/
|
||
typedef enum
|
||
{
|
||
NOT_BAND = 0,
|
||
BAND_SUCC,
|
||
BAND_TIMEOUT,
|
||
BAND_ERR,
|
||
BAND_REQ_AGAIN,
|
||
BAND_REQUEST,
|
||
BAND_REJECT,
|
||
} bt_bond_status;
|
||
|
||
#define PROTOCOL_BAND_REJECT 0 // 根据协议,为0 代表未绑定
|
||
|
||
#define ANDROID_PHONE 0 // 安卓手机
|
||
#define IOS_PHONE 1 // ios 手机
|
||
|
||
|
||
/********************************
|
||
* 绑定信息结构体
|
||
**********************************/
|
||
typedef struct
|
||
{
|
||
char validMark[32]; //需要与宏做对比,如果不匹配,则填入默认参数
|
||
uint32_t cfgSize; //如果结构体大小和cfgSize不相同,则填入默认参数
|
||
uint8_t status; //蓝牙绑定状态
|
||
uint8_t phone_mac_addr[17]; //手机mac地址
|
||
uint8_t device_mac_addr[6]; //手环mac地址,使用6字节,带:
|
||
uint8_t os; // 绑定的手机的操作系统:0:Android; 1:ios
|
||
uint8_t id[6]; //5.1.14&5.1.15 手机标识码
|
||
uint8_t ios_req_again;
|
||
uint8_t key[32]; //5.1.14 经过key2加密后的key1
|
||
uint8_t iv[16]; //5.1.14 使用key2对key1进行加密用到的iv
|
||
} bond_info_t;
|
||
|
||
|
||
uint8_t GetBandStatus(void);
|
||
void SetBandstatus(uint8_t status);
|
||
uint8_t GetBandPhoneOS(void);
|
||
bool IsTheDeviceBuand(void);
|
||
void UserPairOperate(uint8_t pair_opcode);
|
||
void BleConifgInit(void);
|
||
void SaveBleConfig(void);
|
||
void SavePairingFileWithoutDir(void);
|
||
void BleBondReqRespond(uint8_t BondStatus);
|
||
|
||
|
||
|
||
|
||
extern const p_func_t user_manamagement_server_func[mamagement_server_max_ID];
|
||
|
||
|
||
#endif
|