/* * Copyright 2016, yichip Semiconductor(shenzhen office) * All Rights Reserved. * * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Yichip Semiconductor; * the contents of this file may not be disclosed to third parties, copied * or duplicated in any form, in whole or in part, without the prior * written permission of Yichip Semiconductor. */ /** *@file yc11xx_bt_interface *@brief bt support for application. */ #ifndef _YC_BT_INTERFACE_H #define _YC_BT_INTERFACE_H #include "yc11xx.h" #include "ipc.h" #include "ycdef.h" #include #include #define MAX_MTU_SIZE 200 #define MIN_MTU_SIZE 23 #define LE_ADV_DATA_MAX_LENGTH 31 #define LE_SCAN_RSP_MAX_LENGTH 31 #define LE_MAX_PATCKET_LENGTH HREAD(mem_mtu_size) #define Adv_Type_Flags 0x01 #define Adv_Type_CompleteLocalName 0x09 typedef struct { uint8_t topState; uint8_t secondState; uint8_t thirdlyState; }BR_STATE; //ble state enumration typedef enum { BLE_STATE_INVALID, BLE_IDLE, BLE_ADV, BLE_CONNECTING, BLE_CONNECTED, BLE_PAIRED, BLE_FAST_PAIRED, BLE_DIRECT_ADV, }BLE_STATE_TYPE; typedef struct { uint8_t topState; uint8_t secondState; }BLE_STATE; //adv type enumration typedef enum { ADV_TYPE_NOMAL, ADV_TYPE_DIRECT, ADV_TYPE_NOCONNECT, SCAN_REQ, SCAN_RSP, CONNECT_REQ, ADV_TYPE_SCAN, }advType; //scan type enumration typedef enum { SCAN_TYPE_PASSIVE, SCAN_TYPE_ACTIVE, }scanType; //adv state enumration typedef enum { ADV_DISABLE=0x00, ADV_ENABLE=0x01, }ADV_STATE; typedef struct { uint16_t min_interval; /*Defines minimum value for the conntection event interval in the following manner. *min_interval range: 6 to 800. *Time = min_interval * 1.25ms; *min_interval shall be less than or equal to max_interval. */ uint16_t max_interval; /* maximum value for the conntection event interval. *max_interval range: 6 to 800. *Time = max_interval * 1.25ms; *max_interval shall be greater than or equal to min_interval. */ uint16_t latency; /* slave latency for the conntection in number of connection events. *range: 0 to 499. */ uint16_t timeout; /* Supervision timeout for the LE link. *range: 10 to 3200. *Time = timeout * 10 ms. *timeout >( (1+latency) * max_interval ). */ }BLE_Conn_param; void Bt_SndCmdSppStartDiscovery(void); void Bt_SndCmdSppStopDiscovery(void); void Bt_GetSppMac(uint8_t *adr); void Bt_SetSppAddr(uint8_t *adr); bool Bt_SetSppName(uint8_t *name,int len); bool Bt_SndSppData(uint8_t *data,uint8_t len); void Bt_SndCmdLeStartAdv(void); void Bt_SndCmdLeStopAdv(void); void Bt_SndCmdLeStartDirectAdv(void); void Bt_SndCmdLeStopDirectAdv(void); void Bt_SndCmdLeStartScanAdv(void); void Bt_SndCmdLeDisconnect(void); void Bt_SndCmdLeUpdateConn(BLE_Conn_param* param); void Bt_SetLocalMtuSize(uint16_t size); void Bt_SndCmdLeUpdateAttMTU(void); void Bt_GetLeMac(uint8_t *adr); void Bt_SetLeMac(uint8_t *adr); uint8_t Bt_Re_LeAdvName(uint8_t *name,uint8_t len); void Bt_Re_LeDeivcename(uint8_t *name,uint8_t len); bool Bt_Renew_Le_AdvData(uint8_t *data,uint8_t len); bool Bt_Renew_Le_ScanRsp(uint8_t *data,uint8_t len); void Bt_SetLeAdvType(advType Type); void Bt_SetLeScanRspType(scanType Type); void Bt_SetLeAdvInterval(uint16_t gap); bool Bt_SndBleData(uint16_t BLE_WRITE_HANDLE, uint8_t *data, uint8_t len); void Bt_SndCmdStartScan(void); void Bt_SndCmdStopScan(void); void Bt_SndCmdPwroff(void); #endif