修改了Web后台的部分界面,增加了HAmqtt中的总电量传感器,后台新增mqtt上报频率设置

This commit is contained in:
OOP
2025-03-03 21:49:41 +08:00
parent e1e00b60ce
commit 9f9d4c7a56
4468 changed files with 1473046 additions and 10728 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,673 @@
/**
* UNPUBLISHED PROPRIETARY SOURCE CODE
* Copyright (c) 2016 MXCHIP Inc.
*
* 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 MXCHIP Corporation.
*
*/
#ifndef BT_TYPES_H
#define BT_TYPES_H
#include "data_types.h"
#ifdef _WIN32
#ifdef BLUESTACK_TESTER
#include "bte_stack_entry.h"
#endif
#endif
/* READ WELL !!
**
** This section defines global events. These are events that cross layers.
** Any event that passes between layers MUST be one of these events. Tasks
** can use their own events internally, but a FUNDAMENTAL design issue is
** that global events MUST be one of these events defined below.
**
** The convention used is the the event name contains the layer that the
** event is going to.
*/
#define BT_EVT_MASK 0xFF00
#define BT_SUB_EVT_MASK 0x00FF
/* To Bluetooth Upper Layers */
/************************************/
#define BT_EVT_TO_BTU_L2C_EVT 0x0900 /* L2CAP event */
#define BT_EVT_TO_BTU_HCI_EVT 0x1000 /* HCI Event */
#define BT_EVT_TO_BTU_HCI_BR_EDR_EVT (0x0000 | BT_EVT_TO_BTU_HCI_EVT) /* event from BR/EDR controller */
#define BT_EVT_TO_BTU_HCI_ACL 0x1100 /* ACL Data from HCI */
#define BT_EVT_TO_BTU_HCI_SCO 0x1200 /* SCO Data from HCI */
#define BT_EVT_TO_BTU_HCIT_ERR 0x1300 /* HCI Transport Error */
#define BT_EVT_TO_BTU_SP_EVT 0x1400 /* Serial Port Event */
#define BT_EVT_TO_BTU_SP_DATA 0x1500 /* Serial Port Data */
#define BT_EVT_TO_BTU_HCI_CMD 0x1600 /* HCI command from upper layer */
#define BT_EVT_TO_BTU_L2C_SEG_XMIT 0x1900 /* L2CAP segment(s) transmitted */
#define BT_EVT_PROXY_INCOMING_MSG 0x1A00 /* BlueStackTester event: incoming message from target */
#define BT_EVT_BTSIM 0x1B00 /* Insight BTSIM event */
#define BT_EVT_BTISE 0x1C00 /* Insight Script Engine event */
/* To LM */
/************************************/
#define BT_EVT_TO_LM_HCI_CMD 0x2000 /* HCI Command */
#define BT_EVT_TO_LM_HCI_ACL 0x2100 /* HCI ACL Data */
#define BT_EVT_TO_LM_HCI_SCO 0x2200 /* HCI SCO Data */
#define BT_EVT_TO_LM_HCIT_ERR 0x2300 /* HCI Transport Error */
#define BT_EVT_TO_LM_LC_EVT 0x2400 /* LC event */
#define BT_EVT_TO_LM_LC_LMP 0x2500 /* LC Received LMP command frame */
#define BT_EVT_TO_LM_LC_ACL 0x2600 /* LC Received ACL data */
#define BT_EVT_TO_LM_LC_SCO 0x2700 /* LC Received SCO data (not used) */
#define BT_EVT_TO_LM_LC_ACL_TX 0x2800 /* LMP data transmit complete */
#define BT_EVT_TO_LM_LC_LMPC_TX 0x2900 /* LMP Command transmit complete */
#define BT_EVT_TO_LM_LOCAL_ACL_LB 0x2a00 /* Data to be locally loopbacked */
#define BT_EVT_TO_LM_HCI_ACL_ACK 0x2b00 /* HCI ACL Data ack (not used) */
#define BT_EVT_TO_LM_DIAG 0x2c00 /* LM Diagnostics commands */
#define BT_EVT_TO_BTM_CMDS 0x2f00
#define BT_EVT_TO_BTM_PM_MDCHG_EVT (0x0001 | BT_EVT_TO_BTM_CMDS)
#define BT_EVT_TO_OBX_CL_MSG 0x3100
#define BT_EVT_TO_OBX_SR_MSG 0x3200
/* Obex Over L2CAP */
#define BT_EVT_TO_OBX_CL_L2C_MSG 0x3400
#define BT_EVT_TO_OBX_SR_L2C_MSG 0x3500
/* ftp events */
#define BT_EVT_TO_FTP_SRVR_CMDS 0x3600
#define BT_EVT_TO_FTP_CLNT_CMDS 0x3700
#define BT_EVT_TO_BTU_SAP 0x3800 /* SIM Access Profile events */
/* opp events */
#define BT_EVT_TO_OPP_SRVR_CMDS 0x3900
#define BT_EVT_TO_OPP_CLNT_CMDS 0x3a00
/* gap events */
#define BT_EVT_TO_GAP_MSG 0x3b00
/* start timer */
#define BT_EVT_TO_START_TIMER 0x3c00
/* stop timer */
#define BT_EVT_TO_STOP_TIMER 0x3d00
/* start quick timer */
#define BT_EVT_TO_START_QUICK_TIMER 0x3e00
/* for NFC */
/************************************/
#define BT_EVT_TO_NFC_NCI 0x4000 /* NCI Command, Notification or Data*/
#define BT_EVT_TO_NFC_NCI_VS 0x4200 /* Vendor specific message */
#define BT_EVT_TO_NFC_MSGS 0x4300 /* messages between NFC and NCI task */
#define BT_EVT_TO_LLCP_MSGS 0x4400 /* messages for LLCP */
#define BT_EVT_TO_NFCCSIM_NCI 0x4a00 /* events to NFCC simulation (NCI packets) */
/* HCISU Events */
#define BT_EVT_HCISU 0x5000
#define BT_EVT_TO_HCISU_LP_APP_SLEEPING_EVT (0x0005 | BT_EVT_HCISU)
#define BT_EVT_TO_HCISU_LP_ALLOW_BT_SLEEP_EVT (0x0006 | BT_EVT_HCISU)
#define BT_EVT_TO_HCISU_LP_WAKEUP_HOST_EVT (0x0007 | BT_EVT_HCISU)
#define BT_EVT_TO_HCISU_LP_RCV_H4IBSS_EVT (0x0008 | BT_EVT_HCISU)
#define BT_EVT_TO_HCISU_H5_RESET_EVT (0x0009 | BT_EVT_HCISU)
#define BT_EVT_HCISU_START_QUICK_TIMER (0x000a | BT_EVT_HCISU)
/* HSP Events */
#define BT_EVT_BTU_HSP2 0x6000
#define BT_EVT_TO_BTU_HSP2_EVT (0x0001 | BT_EVT_BTU_HSP2)
/* BPP Events */
#define BT_EVT_TO_BPP_PR_CMDS 0x6100 /* Printer Events */
#define BT_EVT_TO_BPP_SND_CMDS 0x6200 /* BPP Sender Events */
/* BIP Events */
#define BT_EVT_TO_BIP_CMDS 0x6300
#define BT_EVT_BTU_HFP 0x8000
#define BT_EVT_TO_BTU_HFP_EVT (0x0001 | BT_EVT_BTU_HFP)
#define BT_EVT_BTU_IPC_EVT 0x9000
#define BT_EVT_BTU_IPC_LOGMSG_EVT (0x0000 | BT_EVT_BTU_IPC_EVT)
#define BT_EVT_BTU_IPC_ACL_EVT (0x0001 | BT_EVT_BTU_IPC_EVT)
#define BT_EVT_BTU_IPC_BTU_EVT (0x0002 | BT_EVT_BTU_IPC_EVT)
#define BT_EVT_BTU_IPC_L2C_EVT (0x0003 | BT_EVT_BTU_IPC_EVT)
#define BT_EVT_BTU_IPC_L2C_MSG_EVT (0x0004 | BT_EVT_BTU_IPC_EVT)
#define BT_EVT_BTU_IPC_BTM_EVT (0x0005 | BT_EVT_BTU_IPC_EVT)
#define BT_EVT_BTU_IPC_AVDT_EVT (0x0006 | BT_EVT_BTU_IPC_EVT)
#define BT_EVT_BTU_IPC_SLIP_EVT (0x0007 | BT_EVT_BTU_IPC_EVT)
#define BT_EVT_BTU_IPC_MGMT_EVT (0x0008 | BT_EVT_BTU_IPC_EVT)
#define BT_EVT_BTU_IPC_BTTRC_EVT (0x0009 | BT_EVT_BTU_IPC_EVT)
#define BT_EVT_BTU_IPC_BURST_EVT (0x000A | BT_EVT_BTU_IPC_EVT)
/* Define the header of each buffer used in the Bluetooth stack.
*/
typedef struct
{
UINT16 event;
UINT16 len;
UINT16 offset;
UINT16 layer_specific;
} BT_HDR;
#define BT_HDR_SIZE (sizeof (BT_HDR))
#define BT_PSM_SDP 0x0001 /* Service Discovery Protocol) */
#define BT_PSM_RFCOMM 0x0003 /* RFCOMM with TS 07.10 */
#define BT_PSM_TCS 0x0005 /* (deprecated) */
#define BT_PSM_CTP 0x0007 /* (deprecated) */
#define BT_PSM_BNEP 0x000F /* Bluetooth Network Encapsulation Protocol */
#define BT_PSM_HIDC 0x0011 /* Human Interface Device (Control) */
#define BT_PSM_HIDI 0x0013 /* Human Interface Device (Interrupt) */
#define BT_PSM_UPNP 0x0015 /* Universal PlugNPlay */
#define BT_PSM_AVCTP 0x0017 /* Audio/Video Control Transport Protocol */
#define BT_PSM_AVDTP 0x0019 /* Audio/Video Distribution Transport Protocol */
#define BT_PSM_AVCTP_13 0x001B /* Advanced Control - Browsing */
#define BT_PSM_UDI_CP 0x001D /* Unrestricted Digital Information C-Plane */
#define BT_PSM_ATT 0x001F /* Attribute Protocol */
#define BT_PSM_3DS 0x0021 /* 3D sync */
#define BT_LE_PSM_IPSP 0x0023 /* Internet Protocol Support (IPv6/6LoWPAN) */
/* These macros extract the HCI opcodes from a buffer
*/
#define HCI_GET_CMD_HDR_OPCODE(p) (UINT16)((*((UINT8 *)((p) + 1) + p->offset) + \
(*((UINT8 *)((p) + 1) + p->offset + 1) << 8)))
#define HCI_GET_CMD_HDR_PARAM_LEN(p) (UINT8) (*((UINT8 *)((p) + 1) + p->offset + 2))
#define HCI_GET_EVT_HDR_OPCODE(p) (UINT8)(*((UINT8 *)((p) + 1) + p->offset))
#define HCI_GET_EVT_HDR_PARAM_LEN(p) (UINT8) (*((UINT8 *)((p) + 1) + p->offset + 1))
/********************************************************************************
** Macros to get and put bytes to and from a stream (Little Endian format).
*/
#define UINT128_TO_STREAM(p, u128) {*(p)++ = (UINT8)(u128); *(p)++ = (UINT8)((u128) >> 8);*(p)++ = (UINT8)((u128) >> 16); *(p)++ = (UINT8)((u128) >> 24); \
*(p)++ = (UINT8)((u128) >> 32); *(p)++ = (UINT8)((u128) >> 40);*(p)++ = (UINT8)((u128) >> 48); *(p)++ = (UINT8)((u128) >> 56); \
*(p)++ = (UINT8)((u128) >> 64); *(p)++ = (UINT8)((u128) >> 72);*(p)++ = (UINT8)((u128) >> 80); *(p)++ = (UINT8)((u128) >> 88); \
*(p)++ = (UINT8)((u128) >> 96); *(p)++ = (UINT8)((u128) >> 104);*(p)++ = (UINT8)((u128) >> 112); *(p)++ = (UINT8)((u128) >> 120); }
#define UINT64_TO_STREAM(p, u64) {*(p)++ = (UINT8)(u64); *(p)++ = (UINT8)((u64) >> 8);*(p)++ = (UINT8)((u64) >> 16); *(p)++ = (UINT8)((u64) >> 24); \
*(p)++ = (UINT8)((u64) >> 32); *(p)++ = (UINT8)((u64) >> 40);*(p)++ = (UINT8)((u64) >> 48); *(p)++ = (UINT8)((u64) >> 56);}
#define UINT32_TO_STREAM(p, u32) {*(p)++ = (UINT8)(u32); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 24);}
#define UINT24_TO_STREAM(p, u24) {*(p)++ = (UINT8)(u24); *(p)++ = (UINT8)((u24) >> 8); *(p)++ = (UINT8)((u24) >> 16);}
#define UINT16_TO_STREAM(p, u16) {*(p)++ = (UINT8)(u16); *(p)++ = (UINT8)((u16) >> 8);}
#define UINT8_TO_STREAM(p, u8) {*(p)++ = (UINT8)(u8);}
#define INT8_TO_STREAM(p, u8) {*(p)++ = (INT8)(u8);}
#define ARRAY32_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < 32; ijk++) *(p)++ = (UINT8) a[31 - ijk];}
#define ARRAY16_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < 16; ijk++) *(p)++ = (UINT8) a[15 - ijk];}
#define ARRAY8_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < 8; ijk++) *(p)++ = (UINT8) a[7 - ijk];}
#define BDADDR_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) *(p)++ = (UINT8) a[BD_ADDR_LEN - 1 - ijk];}
#define LAP_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < LAP_LEN; ijk++) *(p)++ = (UINT8) a[LAP_LEN - 1 - ijk];}
#define DEVCLASS_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < DEV_CLASS_LEN;ijk++) *(p)++ = (UINT8) a[DEV_CLASS_LEN - 1 - ijk];}
#define ARRAY_TO_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[ijk];}
#define REVERSE_ARRAY_TO_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[len - 1 - ijk];}
#define STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;}
#define STREAM_TO_UINT16(u16, p) {u16 = ((UINT16)(*(p)) + (((UINT16)(*((p) + 1))) << 8)); (p) += 2;}
#define STREAM_TO_UINT24(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) ); (p) += 3;}
#define STREAM_TO_UINT32(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) + ((((UINT32)(*((p) + 3)))) << 24)); (p) += 4;}
#define STREAM_TO_BDADDR(a, p) {register int ijk; register UINT8 *pbda = (UINT8 *)a + BD_ADDR_LEN - 1; for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) *pbda-- = *p++;}
#define STREAM_TO_ARRAY32(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + 31; for (ijk = 0; ijk < 32; ijk++) *_pa-- = *p++;}
#define STREAM_TO_ARRAY16(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + 15; for (ijk = 0; ijk < 16; ijk++) *_pa-- = *p++;}
#define STREAM_TO_ARRAY8(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + 7; for (ijk = 0; ijk < 8; ijk++) *_pa-- = *p++;}
#define STREAM_TO_DEVCLASS(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + DEV_CLASS_LEN - 1; for (ijk = 0; ijk < DEV_CLASS_LEN; ijk++) *_pa-- = *p++;}
#define STREAM_TO_LAP(a, p) {register int ijk; register UINT8 *plap = (UINT8 *)a + LAP_LEN - 1; for (ijk = 0; ijk < LAP_LEN; ijk++) *plap-- = *p++;}
#define STREAM_TO_ARRAY(a, p, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) ((UINT8 *) a)[ijk] = *p++;}
#define REVERSE_STREAM_TO_ARRAY(a, p, len) {register int ijk; register UINT8 *_pa = (UINT8 *)a + len - 1; for (ijk = 0; ijk < len; ijk++) *_pa-- = *p++;}
/********************************************************************************
** Macros to get and put bytes to and from a field (Little Endian format).
** These are the same as to stream, except the pointer is not incremented.
*/
#define UINT32_TO_FIELD(p, u32) {*(UINT8 *)(p) = (UINT8)(u32); *((UINT8 *)(p)+1) = (UINT8)((u32) >> 8); *((UINT8 *)(p)+2) = (UINT8)((u32) >> 16); *((UINT8 *)(p)+3) = (UINT8)((u32) >> 24);}
#define UINT24_TO_FIELD(p, u24) {*(UINT8 *)(p) = (UINT8)(u24); *((UINT8 *)(p)+1) = (UINT8)((u24) >> 8); *((UINT8 *)(p)+2) = (UINT8)((u24) >> 16);}
#define UINT16_TO_FIELD(p, u16) {*(UINT8 *)(p) = (UINT8)(u16); *((UINT8 *)(p)+1) = (UINT8)((u16) >> 8);}
#define UINT8_TO_FIELD(p, u8) {*(UINT8 *)(p) = (UINT8)(u8);}
/********************************************************************************
** Macros to get and put bytes to and from a stream (Big Endian format)
*/
#define UINT128_TO_BE_STREAM(p, u128) {*(p)++ = (UINT8)(u128)>> 120; *(p)++ = (UINT8)((u128) >> 112);*(p)++ = (UINT8)((u128) >> 104); *(p)++ = (UINT8)((u128) >> 96); \
*(p)++ = (UINT8)((u128) >> 88); *(p)++ = (UINT8)((u128) >> 80);*(p)++ = (UINT8)((u128) >> 72); *(p)++ = (UINT8)((u128) >> 64); \
*(p)++ = (UINT8)((u128) >> 56); *(p)++ = (UINT8)((u128) >> 48);*(p)++ = (UINT8)((u128) >> 40); *(p)++ = (UINT8)((u128) >> 32); \
*(p)++ = (UINT8)((u128) >> 24); *(p)++ = (UINT8)((u128) >> 16);*(p)++ = (UINT8)((u128) >> 8); *(p)++ = (UINT8)(u128); }
#define UINT64_TO_BE_STREAM(p, u64) {*(p)++ = (UINT8)((u64) >> 56); *(p)++ = (UINT8)((u64) >> 48);*(p)++ = (UINT8)((u64) >> 40); *(p)++ = (UINT8)((u64) >> 32); \
*(p)++ = (UINT8)((u64) >> 24); *(p)++ = (UINT8)((u64) >> 16);*(p)++ = (UINT8)((u64) >> 8); *(p)++ = (UINT8)(u64); }
#define UINT32_TO_BE_STREAM(p, u32) {*(p)++ = (UINT8)((u32) >> 24); *(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)(u32); }
#define UINT24_TO_BE_STREAM(p, u24) {*(p)++ = (UINT8)((u24) >> 16); *(p)++ = (UINT8)((u24) >> 8); *(p)++ = (UINT8)(u24);}
#define UINT16_TO_BE_STREAM(p, u16) {*(p)++ = (UINT8)((u16) >> 8); *(p)++ = (UINT8)(u16);}
#define UINT8_TO_BE_STREAM(p, u8) {*(p)++ = (UINT8)(u8);}
#define ARRAY_TO_BE_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[ijk];}
#define BE_STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;}
#define BE_STREAM_TO_UINT16(u16, p) {u16 = (UINT16)(((UINT16)(*(p)) << 8) + (UINT16)(*((p) + 1))); (p) += 2;}
#define BE_STREAM_TO_UINT24(u32, p) {u32 = (((UINT32)(*((p) + 2))) + ((UINT32)(*((p) + 1)) << 8) + ((UINT32)(*(p)) << 16)); (p) += 3;}
#define BE_STREAM_TO_UINT32(u32, p) {u32 = ((UINT32)(*((p) + 3)) + ((UINT32)(*((p) + 2)) << 8) + ((UINT32)(*((p) + 1)) << 16) + ((UINT32)(*(p)) << 24)); (p) += 4;}
#define BE_STREAM_TO_UINT64(u64, p) {u64 = ((UINT64)(*((p) + 7)) + ((UINT64)(*((p) + 6)) << 8) + ((UINT64)(*((p) + 5)) << 16) + ((UINT64)(*((p) + 4)) << 24) + \
((UINT64)(*((p) + 3)) << 32) + ((UINT64)(*((p) + 2)) << 40) + ((UINT64)(*((p) + 1)) << 48) + ((UINT64)(*(p)) << 56)); (p) += 8;}
#define BE_STREAM_TO_ARRAY(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) ((UINT8 *) a)[ijk] = *p++;}
/********************************************************************************
** Macros to get and put bytes to and from a field (Big Endian format).
** These are the same as to stream, except the pointer is not incremented.
*/
#define UINT32_TO_BE_FIELD(p, u32) {*(UINT8 *)(p) = (UINT8)((u32) >> 24); *((UINT8 *)(p)+1) = (UINT8)((u32) >> 16); *((UINT8 *)(p)+2) = (UINT8)((u32) >> 8); *((UINT8 *)(p)+3) = (UINT8)(u32); }
#define UINT24_TO_BE_FIELD(p, u24) {*(UINT8 *)(p) = (UINT8)((u24) >> 16); *((UINT8 *)(p)+1) = (UINT8)((u24) >> 8); *((UINT8 *)(p)+2) = (UINT8)(u24);}
#define UINT16_TO_BE_FIELD(p, u16) {*(UINT8 *)(p) = (UINT8)((u16) >> 8); *((UINT8 *)(p)+1) = (UINT8)(u16);}
#define UINT8_TO_BE_FIELD(p, u8) {*(UINT8 *)(p) = (UINT8)(u8);}
/* Common Bluetooth field definitions */
#define BD_ADDR_LEN 6 /* Device address length */
typedef UINT8 BD_ADDR[BD_ADDR_LEN]; /* Device address */
typedef UINT8 *BD_ADDR_PTR; /* Pointer to Device Address */
#define BT_OCTET8_LEN 8
typedef UINT8 BT_OCTET8[BT_OCTET8_LEN]; /* octet array: size 8 */
#define LINK_KEY_LEN 16
typedef UINT8 LINK_KEY[LINK_KEY_LEN]; /* Link Key */
#define BT_OCTET16_LEN 16
typedef UINT8 BT_OCTET16[BT_OCTET16_LEN]; /* octet array: size 16 */
#define BT_OCTET32_LEN 32
typedef UINT8 BT_OCTET32[BT_OCTET32_LEN]; /* octet array: size 32 */
#define PIN_CODE_LEN 16
typedef UINT8 PIN_CODE[PIN_CODE_LEN]; /* Pin Code (upto 128 bits) MSB is 0 */
typedef UINT8 *PIN_CODE_PTR; /* Pointer to Pin Code */
#define DEV_CLASS_LEN 3
typedef UINT8 DEV_CLASS[DEV_CLASS_LEN]; /* Device class */
typedef UINT8 *DEV_CLASS_PTR; /* Pointer to Device class */
#define EXT_INQ_RESP_LEN 3
typedef UINT8 EXT_INQ_RESP[EXT_INQ_RESP_LEN];/* Extended Inquiry Response */
typedef UINT8 *EXT_INQ_RESP_PTR; /* Pointer to Extended Inquiry Response */
#define BD_NAME_LEN 248
typedef UINT8 BD_NAME[BD_NAME_LEN + 1]; /* Device name */
typedef UINT8 *BD_NAME_PTR; /* Pointer to Device name */
#define BD_FEATURES_LEN 8
typedef UINT8 BD_FEATURES[BD_FEATURES_LEN]; /* LMP features supported by device */
#define BT_EVENT_MASK_LEN 8
typedef UINT8 BT_EVENT_MASK[BT_EVENT_MASK_LEN]; /* Event Mask */
#define LAP_LEN 3
typedef UINT8 LAP[LAP_LEN]; /* IAC as passed to Inquiry (LAP) */
typedef UINT8 INQ_LAP[LAP_LEN]; /* IAC as passed to Inquiry (LAP) */
#define RAND_NUM_LEN 16
typedef UINT8 RAND_NUM[RAND_NUM_LEN];
#define ACO_LEN 12
typedef UINT8 ACO[ACO_LEN]; /* Authenticated ciphering offset */
#define COF_LEN 12
typedef UINT8 COF[COF_LEN]; /* ciphering offset number */
typedef struct {
UINT8 qos_flags; /* TBD */
UINT8 service_type; /* see below */
UINT32 token_rate; /* bytes/second */
UINT32 token_bucket_size; /* bytes */
UINT32 peak_bandwidth; /* bytes/second */
UINT32 latency; /* microseconds */
UINT32 delay_variation; /* microseconds */
} FLOW_SPEC;
/* Values for service_type */
#define NO_TRAFFIC 0
#define BEST_EFFORT 1
#define GUARANTEED 2
/* Service class of the CoD */
#define SERV_CLASS_NETWORKING (1 << 1)
#define SERV_CLASS_RENDERING (1 << 2)
#define SERV_CLASS_CAPTURING (1 << 3)
#define SERV_CLASS_OBJECT_TRANSFER (1 << 4)
#define SERV_CLASS_OBJECT_AUDIO (1 << 5)
#define SERV_CLASS_OBJECT_TELEPHONY (1 << 6)
#define SERV_CLASS_OBJECT_INFORMATION (1 << 7)
/* Second byte */
#define SERV_CLASS_LIMITED_DISC_MODE (0x20)
/* Field size definitions. Note that byte lengths are rounded up. */
#define ACCESS_CODE_BIT_LEN 72
#define ACCESS_CODE_BYTE_LEN 9
#define SHORTENED_ACCESS_CODE_BIT_LEN 68
typedef UINT8 ACCESS_CODE[ACCESS_CODE_BYTE_LEN];
#define SYNTH_TX 1 /* want synth code to TRANSMIT at this freq */
#define SYNTH_RX 2 /* want synth code to RECEIVE at this freq */
#define SYNC_REPS 1 /* repeats of sync word transmitted to start of burst */
/* Bluetooth CLK27 */
#define BT_CLK27 (2 << 26)
/* Bluetooth CLK12 is 1.28 sec */
#define BT_CLK12_TO_MS(x) ((x) * 1280)
#define BT_MS_TO_CLK12(x) ((x) / 1280)
#define BT_CLK12_TO_SLOTS(x) ((x) << 11)
/* Bluetooth CLK is 0.625 msec */
#define BT_CLK_TO_MS(x) (((x) * 5 + 3) / 8)
#define BT_MS_TO_CLK(x) (((x) * 8 + 2) / 5)
#define BT_CLK_TO_MICROSECS(x) (((x) * 5000 + 3) / 8)
#define BT_MICROSECS_TO_CLK(x) (((x) * 8 + 2499) / 5000)
/* Maximum UUID size - 16 bytes, and structure to hold any type of UUID. */
#define MAX_UUID_SIZE 16
typedef struct
{
#define LEN_UUID_16 2
#define LEN_UUID_32 4
#define LEN_UUID_128 16
UINT16 len;
union
{
UINT16 uuid16;
UINT32 uuid32;
UINT8 uuid128[MAX_UUID_SIZE];
} uu;
} tBT_UUID;
#define BT_EIR_FLAGS_TYPE 0x01
#define BT_EIR_MORE_16BITS_UUID_TYPE 0x02
#define BT_EIR_COMPLETE_16BITS_UUID_TYPE 0x03
#define BT_EIR_MORE_32BITS_UUID_TYPE 0x04
#define BT_EIR_COMPLETE_32BITS_UUID_TYPE 0x05
#define BT_EIR_MORE_128BITS_UUID_TYPE 0x06
#define BT_EIR_COMPLETE_128BITS_UUID_TYPE 0x07
#define BT_EIR_SHORTENED_LOCAL_NAME_TYPE 0x08
#define BT_EIR_COMPLETE_LOCAL_NAME_TYPE 0x09
#define BT_EIR_TX_POWER_LEVEL_TYPE 0x0A
#define BT_EIR_OOB_BD_ADDR_TYPE 0x0C
#define BT_EIR_OOB_COD_TYPE 0x0D
#define BT_EIR_OOB_SSP_HASH_C_TYPE 0x0E
#define BT_EIR_OOB_SSP_RAND_R_TYPE 0x0F
#define BT_EIR_OOB_SSP_HASH_C_256_TYPE 0x1D
#define BT_EIR_OOB_SSP_RAND_R_256_TYPE 0x1E
#define BT_EIR_3D_SYNC_TYPE 0x3D
#define BT_EIR_MANUFACTURER_SPECIFIC_TYPE 0xFF
#define BT_OOB_COD_SIZE 3
#define BT_OOB_HASH_C_SIZE 16
#define BT_OOB_RAND_R_SIZE 16
#define BT_OOB_HASH_C_256_SIZE 16
#define BT_OOB_RAND_R_256_SIZE 16
/* Broadcom proprietary UUIDs and reserved PSMs
**
** The lowest 4 bytes byte of the UUID or GUID depends on the feature. Typically,
** the value of those bytes will be the PSM or SCN, but it is up to the features.
*/
#define BRCM_PROPRIETARY_UUID_BASE 0xDA, 0x23, 0x41, 0x02, 0xA3, 0xBB, 0xC1, 0x71, 0xBA, 0x09, 0x6f, 0x21
#define BRCM_PROPRIETARY_GUID_BASE 0xda23, 0x4102, 0xa3, 0xbb, 0xc1, 0x71, 0xba, 0x09, 0x6f, 0x21
#define BRCM_RESERVED_PSM_START 0x5AE1
#define BRCM_RESERVED_PSM_END 0x5AFF
#define BRCM_UTILITY_SERVICE_PSM 0x5AE1
#define BRCM_MATCHER_PSM 0x5AE3
/* Connection statistics
*/
/* Structure to hold connection stats */
#ifndef BT_CONN_STATS_DEFINED
#define BT_CONN_STATS_DEFINED
/* These bits are used in the bIsConnected field */
#define BT_CONNECTED_USING_BREDR 1
typedef struct
{
UINT32 is_connected;
INT32 rssi;
UINT32 bytes_sent;
UINT32 bytes_rcvd;
UINT32 duration;
} tBT_CONN_STATS;
#endif
/*****************************************************************************
** Low Energy definitions
**
** Address types
*/
#define BLE_ADDR_PUBLIC 0x00
#define BLE_ADDR_RANDOM 0x01
#define BLE_ADDR_PUBLIC_ID 0x02
#define BLE_ADDR_RANDOM_ID 0x03
typedef UINT8 tBLE_ADDR_TYPE;
#define BLE_ADDR_TYPE_MASK (BLE_ADDR_RANDOM | BLE_ADDR_PUBLIC)
#define BT_TRANSPORT_BR_EDR 1
#define BT_TRANSPORT_LE 2
typedef UINT8 tBT_TRANSPORT;
#define BLE_ADDR_IS_STATIC(x) ((x[0] & 0xC0) == 0xC0)
typedef struct
{
tBLE_ADDR_TYPE type;
BD_ADDR bda;
} tBLE_BD_ADDR;
/* Device Types
*/
#define BT_DEVICE_TYPE_BREDR 0x01
#define BT_DEVICE_TYPE_BLE 0x02
#define BT_DEVICE_TYPE_DUMO 0x03
typedef UINT8 tBT_DEVICE_TYPE;
/*****************************************************************************/
/* Define trace levels */
#define BT_TRACE_LEVEL_NONE 0 /* No trace messages to be generated */
#define BT_TRACE_LEVEL_ERROR 1 /* Error condition trace messages */
#define BT_TRACE_LEVEL_WARNING 2 /* Warning condition trace messages */
#define BT_TRACE_LEVEL_API 3 /* API traces */
#define BT_TRACE_LEVEL_EVENT 4 /* Debug messages for events */
#define BT_TRACE_LEVEL_DEBUG 5 /* Full debug messages */
#define MAX_TRACE_LEVEL 5
/* Define New Trace Type Definition */
/* TRACE_CTRL_TYPE 0x^^000000*/
#define TRACE_CTRL_MASK 0xff000000
#define TRACE_GET_CTRL(x) ((((UINT32)(x)) & TRACE_CTRL_MASK) >> 24)
#define TRACE_CTRL_GENERAL 0x00000000
#define TRACE_CTRL_STR_RESOURCE 0x01000000
#define TRACE_CTRL_SEQ_FLOW 0x02000000
#define TRACE_CTRL_MAX_NUM 3
/* LAYER SPECIFIC 0x00^^0000*/
#define TRACE_LAYER_MASK 0x00ff0000
#define TRACE_GET_LAYER(x) ((((UINT32)(x)) & TRACE_LAYER_MASK) >> 16)
#define TRACE_LAYER_NONE 0x00000000
#define TRACE_LAYER_USB 0x00010000
#define TRACE_LAYER_SERIAL 0x00020000
#define TRACE_LAYER_SOCKET 0x00030000
#define TRACE_LAYER_RS232 0x00040000
#define TRACE_LAYER_TRANS_MAX_NUM 5
#define TRACE_LAYER_TRANS_ALL 0x007f0000
#define TRACE_LAYER_LC 0x00050000
#define TRACE_LAYER_LM 0x00060000
#define TRACE_LAYER_HCI 0x00070000
#define TRACE_LAYER_L2CAP 0x00080000
#define TRACE_LAYER_RFCOMM 0x00090000
#define TRACE_LAYER_SDP 0x000a0000
#define TRACE_LAYER_OBEX 0x000b0000
#define TRACE_LAYER_BTM 0x000c0000
#define TRACE_LAYER_GAP 0x000d0000
#define TRACE_LAYER_DUN 0x000e0000
#define TRACE_LAYER_GOEP 0x000f0000
#define TRACE_LAYER_HSP2 0x00100000
#define TRACE_LAYER_SPP 0x00110000
#define TRACE_LAYER_BPP 0x00120000
#define TRACE_LAYER_FTP 0x00130000
#define TRACE_LAYER_OPP 0x00140000
#define TRACE_LAYER_BTU 0x00150000
#define TRACE_LAYER_GKI 0x00160000 /*it's overwritten in nfc_types.h*/
#define TRACE_LAYER_BNEP 0x00170000
#define TRACE_LAYER_PAN 0x00180000
#define TRACE_LAYER_HFP 0x00190000
#define TRACE_LAYER_HID 0x001a0000
#define TRACE_LAYER_BIP 0x001b0000
#define TRACE_LAYER_AVP 0x001c0000
#define TRACE_LAYER_A2D 0x001d0000
#define TRACE_LAYER_SAP 0x001e0000
#define TRACE_LAYER_MCA 0x001f0000
#define TRACE_LAYER_ATT 0x00200000
#define TRACE_LAYER_SMP 0x00210000
#define TRACE_LAYER_NFC 0x00220000
#define TRACE_LAYER_NCI 0x00230000 /*it's overwritten in nfc_types.h*/
#define TRACE_LAYER_LLCP 0x00240000
#define TRACE_LAYER_NDEF 0x00250000
#define TRACE_LAYER_RW 0x00260000
#define TRACE_LAYER_CE 0x00270000
#define TRACE_LAYER_P2P 0x00280000
#define TRACE_LAYER_SNEP 0x00290000
#define TRACE_LAYER_CHO 0x002a0000
#define TRACE_LAYER_NFA 0x002b0000
#define TRACE_LAYER_HAL 0x002c0000 /*it's overwritten in nfc_types.h*/
#define TRACE_LAYER_MAX_NUM 0x002d
/* TRACE_ORIGINATOR 0x0000^^00*/
#define TRACE_ORG_MASK 0x0000ff00
#define TRACE_GET_ORG(x) ((((UINT32)(x)) & TRACE_ORG_MASK) >> 8)
#define TRACE_ORG_STACK 0x00000000
#define TRACE_ORG_HCI_TRANS 0x00000100
#define TRACE_ORG_PROTO_DISP 0x00000200
#define TRACE_ORG_RPC 0x00000300
#define TRACE_ORG_GKI 0x00000400
#define TRACE_ORG_APPL 0x00000500
#define TRACE_ORG_SCR_WRAPPER 0x00000600
#define TRACE_ORG_SCR_ENGINE 0x00000700
#define TRACE_ORG_USER_SCR 0x00000800
#define TRACE_ORG_TESTER 0x00000900
#define TRACE_ORG_MAX_NUM 10 /* 32-bit mask; must be < 32 */
#define TRACE_LITE_ORG_MAX_NUM 6
#define TRACE_ORG_ALL 0x03ff
#define TRACE_ORG_RPC_TRANS 0x04
#define TRACE_ORG_REG 0x00000909
#define TRACE_ORG_REG_SUCCESS 0x0000090a
/* TRACE_TYPE 0x000000^^*/
#define TRACE_TYPE_MASK 0x000000ff
#define TRACE_GET_TYPE(x) (((UINT32)(x)) & TRACE_TYPE_MASK)
#define TRACE_TYPE_ERROR 0x00000000
#define TRACE_TYPE_WARNING 0x00000001
#define TRACE_TYPE_API 0x00000002
#define TRACE_TYPE_EVENT 0x00000003
#define TRACE_TYPE_DEBUG 0x00000004
#define TRACE_TYPE_STACK_ONLY_MAX TRACE_TYPE_DEBUG
#define TRACE_TYPE_TX 0x00000005
#define TRACE_TYPE_RX 0x00000006
#define TRACE_TYPE_DEBUG_ASSERT 0x00000007
#define TRACE_TYPE_GENERIC 0x00000008
#define TRACE_TYPE_REG 0x00000009
#define TRACE_TYPE_REG_SUCCESS 0x0000000a
#define TRACE_TYPE_CMD_TX 0x0000000b
#define TRACE_TYPE_EVT_TX 0x0000000c
#define TRACE_TYPE_ACL_TX 0x0000000d
#define TRACE_TYPE_CMD_RX 0x0000000e
#define TRACE_TYPE_EVT_RX 0x0000000f
#define TRACE_TYPE_ACL_RX 0x00000010
#define TRACE_TYPE_TARGET_TRACE 0x00000011
#define TRACE_TYPE_SCO_TX 0x00000012
#define TRACE_TYPE_SCO_RX 0x00000013
#define TRACE_TYPE_MAX_NUM 20
#define TRACE_TYPE_ALL 0xffff
/* Define color for script type */
#define SCR_COLOR_DEFAULT 0
#define SCR_COLOR_TYPE_COMMENT 1
#define SCR_COLOR_TYPE_COMMAND 2
#define SCR_COLOR_TYPE_EVENT 3
#define SCR_COLOR_TYPE_SELECT 4
/* Define protocol trace flag values */
#define SCR_PROTO_TRACE_HCI_SUMMARY 0x00000001
#define SCR_PROTO_TRACE_HCI_DATA 0x00000002
#define SCR_PROTO_TRACE_L2CAP 0x00000004
#define SCR_PROTO_TRACE_RFCOMM 0x00000008
#define SCR_PROTO_TRACE_SDP 0x00000010
#define SCR_PROTO_TRACE_OBEX 0x00000040
#define SCR_PROTO_TRACE_OAPP 0x00000080 /* OBEX Application Profile */
#define SCR_PROTO_TRACE_BNEP 0x00000200
#define SCR_PROTO_TRACE_AVP 0x00000400
#define SCR_PROTO_TRACE_MCA 0x00000800
#define SCR_PROTO_TRACE_ATT 0x00001000
#define SCR_PROTO_TRACE_SMP 0x00002000
#define SCR_PROTO_TRACE_NCI 0x00004000
#define SCR_PROTO_TRACE_LLCP 0x00008000
#define SCR_PROTO_TRACE_NDEF 0x00010000
#define SCR_PROTO_TRACE_RW 0x00020000
#define SCR_PROTO_TRACE_CE 0x00040000
#define SCR_PROTO_TRACE_SNEP 0x00080000
#define SCR_PROTO_TRACE_CHO 0x00100000
#define SCR_PROTO_TRACE_ALL 0x001fffff
#define SCR_PROTO_TRACE_HCI_LOGGING_VSE 0x0800 /* Brcm vs event for logmsg and protocol traces */
#define MAX_SCRIPT_TYPE 5
/* Define PSMs HID uses */
#define HID_PSM_CONTROL BT_PSM_HIDC
#define HID_PSM_INTERRUPT BT_PSM_HIDI
#if defined(UCD_HID_INCLUDED) && (UCD_HID_INCLUDED == TRUE)
#define UCD_PSM_MIN 0x8001
#define UCD_PSM_MAX 0x8003
#define UCD_PSM_HID_CTRL 0x8001
#define UCD_PSM_HID_INTR 0x8003
#endif
#if defined(HIDH_UCD_INCLUDED) && (HIDH_UCD_INCLUDED == TRUE)
#define HID_UCD_PSM_CONTROL 0x8001
#define HID_UCD_PSM_INTERRUPT 0x8003
#endif
/* Define a function for logging */
typedef void (BT_LOG_FUNC) (int trace_type, const char *fmt_str, ...);
#endif

View File

@@ -0,0 +1,77 @@
/**
* UNPUBLISHED PROPRIETARY SOURCE CODE
* Copyright (c) 2016 MXCHIP Inc.
*
* 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 MXCHIP Corporation.
*
*/
#ifndef DATA_TYPES_H
#define DATA_TYPES_H
#ifndef NULL
#define NULL 0
#endif
#ifndef FALSE
#define FALSE 0
#endif
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned long UINT32;
typedef unsigned long long int UINT64;
typedef signed long INT32;
typedef signed char INT8;
typedef signed short INT16;
typedef unsigned char BOOLEAN;
typedef UINT32 UINTPTR;
typedef UINT32 TIME_STAMP;
#ifndef TRUE
#define TRUE (!FALSE)
#endif
typedef unsigned char UBYTE;
#ifdef __arm
#define PACKED __packed
#define INLINE __inline
#else
#define PACKED
#define INLINE
#endif
#ifndef BIG_ENDIAN
#define BIG_ENDIAN FALSE
#endif
#define UINT16_LOW_BYTE(x) ((x) & 0xff)
#define UINT16_HI_BYTE(x) ((x) >> 8)
/* MACRO definitions for safe string functions */
/* Replace standard string functions with safe functions if available */
#define BCM_STRCAT_S(x1,x2,x3) strcat((x1),(x3))
#define BCM_STRNCAT_S(x1,x2,x3,x4) strncat((x1),(x3),(x4))
#define BCM_STRCPY_S(x1,x2,x3) strcpy((x1),(x3))
#define BCM_STRNCPY_S(x1,x2,x3,x4) strncpy((x1),(x3),(x4))
#define BCM_SPRINTF_S(x1,x2,x3,x4) sprintf((x1),(x3),(x4))
#define BCM_VSPRINTF_S(x1,x2,x3,x4) vsprintf((x1),(x3),(x4))
#define BT_MEMCPY(a,b,c) memcpy( (a), (b), (c) )
#define BT_MEMSET(a,b,c) memset( (a), (b), (c) )
#define BT_STRLEN(a) strlen( (a) )
#define BT_MEMCMP(a,b,c) memcmp( (a), (b), (c) )
#define BT_MEMCMP_OK 0 // memcmp success
/* Timer list entry callback type
*/
typedef void (TIMER_CBACK)(void *p_tle);
#ifndef TIMER_PARAM_TYPE
#define TIMER_PARAM_TYPE UINT32
#endif
#endif

View File

@@ -0,0 +1,173 @@
/****************************************************************************/
/* */
/* Name: gattdefs.h */
/* */
/* Function this file contains internally used ATT definitions */
/*****************************************************************************/
#ifndef _GATTDEFS_H
#define _GATTDEFS_H
#define GATT_ILLEGAL_UUID 0
/* GATT attribute types
*/
#define GATT_UUID_PRI_SERVICE 0x2800
#define GATT_UUID_SEC_SERVICE 0x2801
#define GATT_UUID_INCLUDE_SERVICE 0x2802
#define GATT_UUID_CHAR_DECLARE 0x2803 /* Characteristic Declaration*/
#define GATT_UUID_CHAR_EXT_PROP 0x2900 /* Characteristic Extended Properties */
#define GATT_UUID_CHAR_DESCRIPTION 0x2901 /* Characteristic User Description*/
#define GATT_UUID_CHAR_CLIENT_CONFIG 0x2902 /* Client Characteristic Configuration */
#define GATT_UUID_CHAR_SRVR_CONFIG 0x2903 /* Server Characteristic Configuration */
#define GATT_UUID_CHAR_PRESENT_FORMAT 0x2904 /* Characteristic Presentation Format*/
#define GATT_UUID_CHAR_AGG_FORMAT 0x2905 /* Characteristic Aggregate Format*/
#define GATT_UUID_CHAR_VALID_RANGE 0x2906 /* Characteristic Valid Range */
#define GATT_UUID_EXT_RPT_REF_DESCR 0x2907
#define GATT_UUID_RPT_REF_DESCR 0x2908
/* GAP Profile Attributes
*/
#define GATT_UUID_GAP_DEVICE_NAME 0x2A00
#define GATT_UUID_GAP_ICON 0x2A01
#define GATT_UUID_GAP_PREF_CONN_PARAM 0x2A04
#define GATT_UUID_GAP_CENTRAL_ADDR_RESOL 0x2AA6
/* Attribute Profile Attribute UUID */
#define GATT_UUID_GATT_SRV_CHGD 0x2A05
/* Attribute Protocol Test */
/* Link Loss Service */
#define GATT_UUID_ALERT_LEVEL 0x2A06 /* Alert Level */
#define GATT_UUID_TX_POWER_LEVEL 0x2A07 /* TX power level */
/* Time Profile */
/* Current Time Service */
#define GATT_UUID_CURRENT_TIME 0x2A2B /* Current Time */
#define GATT_UUID_LOCAL_TIME_INFO 0x2A0F /* Local time info */
#define GATT_UUID_REF_TIME_INFO 0x2A14 /* reference time information */
/* NwA Profile */
#define GATT_UUID_NW_STATUS 0x2A18 /* network availability status */
#define GATT_UUID_NW_TRIGGER 0x2A1A /* Network availability trigger */
/* phone alert */
#define GATT_UUID_ALERT_STATUS 0x2A3F /* alert status */
#define GATT_UUID_RINGER_CP 0x2A40 /* ringer control point */
#define GATT_UUID_RINGER_SETTING 0x2A41 /* ringer setting */
/* Glucose Service */
#define GATT_UUID_GM_MEASUREMENT 0x2A18
#define GATT_UUID_GM_CONTEXT 0x2A34
#define GATT_UUID_GM_CONTROL_POINT 0x2A52
#define GATT_UUID_GM_FEATURE 0x2A51
/* device infor characteristic */
#define GATT_UUID_SYSTEM_ID 0x2A23
#define GATT_UUID_MODEL_NUMBER_STR 0x2A24
#define GATT_UUID_SERIAL_NUMBER_STR 0x2A25
#define GATT_UUID_FW_VERSION_STR 0x2A26
#define GATT_UUID_HW_VERSION_STR 0x2A27
#define GATT_UUID_SW_VERSION_STR 0x2A28
#define GATT_UUID_MANU_NAME 0x2A29
#define GATT_UUID_IEEE_DATA 0x2A2A
#define GATT_UUID_PNP_ID 0x2A50
/* HID characteristics */
#define GATT_UUID_HID_INFORMATION 0x2A4A
#define GATT_UUID_HID_REPORT_MAP 0x2A4B
#define GATT_UUID_HID_CONTROL_POINT 0x2A4C
#define GATT_UUID_HID_REPORT 0x2A4D
#define GATT_UUID_HID_PROTO_MODE 0x2A4E
#define GATT_UUID_HID_BT_KB_INPUT 0x2A22
#define GATT_UUID_HID_BT_KB_OUTPUT 0x2A32
#define GATT_UUID_HID_BT_MOUSE_INPUT 0x2A33
/* Battery Service char */
#define GATT_UUID_BATTERY_LEVEL 0x2A19
#define GATT_UUID_SC_CONTROL_POINT 0x2A55
#define GATT_UUID_SENSOR_LOCATION 0x2A5D
/* RUNNERS SPEED AND CADENCE SERVICE */
#define GATT_UUID_RSC_MEASUREMENT 0x2A53
#define GATT_UUID_RSC_FEATURE 0x2A54
/* CYCLING SPEED AND CADENCE SERVICE */
#define GATT_UUID_CSC_MEASUREMENT 0x2A5B
#define GATT_UUID_CSC_FEATURE 0x2A5C
/* CYCLING POWER SERVICE (Temp for IOP) */
#define GATT_UUID_CP_MEASUREMENT 0x2A63
#define GATT_UUID_CP_VECTOR 0x2A64
#define GATT_UUID_CP_FEATURE 0x2A65
#define GATT_UUID_CP_CONTROL_POINT 0x2A66
/* LOCATION AND NAVIGATION SERVICE (Temp for IOP) */
#define GATT_UUID_LN_LOC_AND_SPEED 0x2A67
#define GATT_UUID_LN_NAVIGATION 0x2A68
#define GATT_UUID_LN_POSITION_QUALITY 0x2A69
#define GATT_UUID_LN_FEATURE 0x2A6A
#define GATT_UUID_LN_CONTROL_POINT 0x2A6B
/* HTTP Proxy Service */
#define GATT_UUID_HPS_URI 0x7F11
#define GATT_UUID_HPS_HEADERS 0x7F12
#define GATT_UUID_HPS_STATUS_CODE 0x7F13
#define GATT_UUID_HPS_ENTITY_BODY 0x7F14
#define GATT_UUID_HPS_CONTROL_POINT 0x7F15
#define GATT_UUID_HPS_SERCURITY 0x7F16
/* Scan Parameter charatceristics */
#define GATT_UUID_SCAN_INT_WINDOW 0x2A4F
#define GATT_UUID_SCAN_REFRESH 0x2A31
/* GATT appearance definitions */
enum gatt_appearance_e
{
APPEARANCE_GENERIC_PHONE = 64,
APPEARANCE_GENERIC_COMPUTER = 128,
APPEARANCE_GENERIC_WATCH = 192,
APPEARANCE_WATCH_SPORTS = 193,
APPEARANCE_GENERIC_CLOCK = 256,
APPEARANCE_GENERIC_DISPLAY = 320,
APPEARANCE_GENERIC_REMOTE_CONTROL = 384,
APPEARANCE_GENERIC_EYE_GLASSES = 448,
APPEARANCE_GENERIC_TAG = 512,
APPEARANCE_GENERIC_KEYRING = 576,
APPEARANCE_GENERIC_MEDIA_PLAYER = 640,
APPEARANCE_GENERIC_BARCODE_SCANNER = 704,
APPEARANCE_GENERIC_THERMOMETER = 768,
APPEARANCE_THERMOMETER_EAR = 769,
APPEARANCE_GENERIC_HEART_RATE_SENSOR = 832,
APPEARANCE_HEART_RATE_BELT = 833,
APPEARANCE_GENERIC_BLOOD_PRESSURE = 896,
APPEARANCE_BLOOD_PRESSURE_ARM = 897,
APPEARANCE_BLOOD_PRESSURE_WRIST = 898,
APPEARANCE_GENERIC_HID_DEVICE = 960,
APPEARANCE_HID_KEYBOARD = 961,
APPEARANCE_HID_MOUSE = 962,
APPEARANCE_HID_JOYSTICK = 963,
APPEARANCE_HID_GAMEPAD = 964,
APPEARANCE_HID_DIGITIZER_TABLET = 965,
APPEARANCE_HID_CARD_READER = 966,
APPEARANCE_HID_DIGITAL_PEN = 967,
APPEARANCE_HID_BARCODE_SCANNER = 968,
APPEARANCE_GENERIC_GLUCOSE_METER = 1024,
APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR = 1088,
APPEARANCE_RUNNING_WALKING_SENSOR_IN_SHOE = 1089,
APPEARANCE_RUNNING_WALKING_SENSOR_ON_SHOE = 1090,
APPEARANCE_RUNNING_WALKING_SENSOR_ON_HIP = 1091,
APPEARANCE_GENERIC_CYCLING = 1152,
APPEARANCE_CYCLING_COMPUTER = 1153,
APPEARANCE_CYCLING_SPEED_SENSOR = 1154,
APPEARANCE_CYCLING_CADENCE_SENSOR = 1155,
APPEARANCE_CYCLING_POWER_SENSOR = 1156,
APPEARANCE_CYCLING_SPEED_AND_CADENCE_SENSOR = 1157,
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,321 @@
/****************************************************************************
**
** Name: l2cdefs.h
**
** Function: This file contains L2CAP protocol definitions
**
**
*****************************************************************************/
#ifndef L2CDEFS_H
#define L2CDEFS_H
/* L2CAP command codes
*/
#define L2CAP_CMD_REJECT 0x01
#define L2CAP_CMD_CONN_REQ 0x02
#define L2CAP_CMD_CONN_RSP 0x03
#define L2CAP_CMD_CONFIG_REQ 0x04
#define L2CAP_CMD_CONFIG_RSP 0x05
#define L2CAP_CMD_DISC_REQ 0x06
#define L2CAP_CMD_DISC_RSP 0x07
#define L2CAP_CMD_ECHO_REQ 0x08
#define L2CAP_CMD_ECHO_RSP 0x09
#define L2CAP_CMD_INFO_REQ 0x0A
#define L2CAP_CMD_INFO_RSP 0x0B
#define L2CAP_CMD_AMP_CONN_REQ 0x0C
#define L2CAP_CMD_AMP_CONN_RSP 0x0D
#define L2CAP_CMD_AMP_MOVE_REQ 0x0E
#define L2CAP_CMD_AMP_MOVE_RSP 0x0F
#define L2CAP_CMD_AMP_MOVE_CFM 0x10
#define L2CAP_CMD_AMP_MOVE_CFM_RSP 0x11
#define L2CAP_CMD_BLE_UPDATE_REQ 0x12
#define L2CAP_CMD_BLE_UPDATE_RSP 0x13
#define L2CAP_CMD_BLE_CONN_REQ 0x14
#define L2CAP_CMD_BLE_CONN_RSP 0x15
#define L2CAP_CMD_BLE_CREDIT 0x16
/* Define some packet and header lengths
*/
#define L2CAP_PKT_OVERHEAD 4 /* Length and CID */
#define L2CAP_CMD_OVERHEAD 4 /* Cmd code, Id and length */
#define L2CAP_CMD_REJECT_LEN 2 /* Reason (data is optional) */
#define L2CAP_CONN_REQ_LEN 4 /* PSM and source CID */
#define L2CAP_CONN_RSP_LEN 8 /* Dest CID, source CID, reason, status */
#define L2CAP_CONFIG_REQ_LEN 4 /* Dest CID, flags (data is optional) */
#define L2CAP_CONFIG_RSP_LEN 6 /* Dest CID, flags, result,data optional*/
#define L2CAP_DISC_REQ_LEN 4 /* Dest CID, source CID */
#define L2CAP_DISC_RSP_LEN 4 /* Dest CID, source CID */
#define L2CAP_ECHO_REQ_LEN 0 /* Data is optional */
#define L2CAP_ECHO_RSP_LEN 0 /* Data is optional */
#define L2CAP_INFO_REQ_LEN 2 /* Info type */
#define L2CAP_INFO_RSP_LEN 4 /* Info type, result (data is optional) */
#define L2CAP_BCST_OVERHEAD 2 /* Additional broadcast packet overhead */
#define L2CAP_UCD_OVERHEAD 2 /* Additional connectionless packet overhead */
#define L2CAP_AMP_CONN_REQ_LEN 5 /* PSM, CID, and remote controller ID */
#define L2CAP_AMP_MOVE_REQ_LEN 3 /* CID and remote controller ID */
#define L2CAP_AMP_MOVE_RSP_LEN 4 /* CID and result */
#define L2CAP_AMP_MOVE_CFM_LEN 4 /* CID and result */
#define L2CAP_AMP_MOVE_CFM_RSP_LEN 2 /* CID */
#define L2CAP_CMD_BLE_UPD_REQ_LEN 8 /* Min and max interval, latency, tout */
#define L2CAP_CMD_BLE_UPD_RSP_LEN 2 /* Result */
#define L2CAP_BLE_CONN_REQ_LEN 10 /* LE_PSM, src CID, MTU, MPS, init credits */
#define L2CAP_BLE_CONN_RSP_LEN 10 /* Dest CID, MTU, MPS, init credits, result */
#define L2CAP_BLE_CONN_CRED_LEN 4 /* Local CID, connection credits to add */
/* Define the packet boundary flags
*/
#if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
#define L2CAP_PKT_START_FLUSHABLE 2
#define L2CAP_PKT_START_NON_FLUSHABLE 0
#endif
#define L2CAP_COMPLETE_AMP_PKT 3 /* complete L2CAP packet on AMP HCI */
#define L2CAP_PKT_START 2
#define L2CAP_PKT_CONTINUE 1
#define L2CAP_MASK_FLAG 0x0FFF
#define L2CAP_PKT_TYPE_SHIFT 12
#define L2CAP_PKT_TYPE_MASK 3
#define L2CAP_BLE_CONN_MIN_MPS_SIZE 23
#define L2CAP_BLE_CONN_MAX_MPS_SIZE 65533
#define L2CAP_BLE_CONN_MIN_MTU_SIZE 23
#define L2CAP_BLE_CONN_SDU_LEN_FIELD_SIZE 2
/* Define the L2CAP connection result codes
*/
#define L2CAP_CONN_OK 0
#define L2CAP_CONN_PENDING 1
#define L2CAP_CONN_NO_PSM 2
#define L2CAP_CONN_SECURITY_BLOCK 3
#define L2CAP_CONN_NO_RESOURCES 4
#define L2CAP_CONN_BAD_CTLR_ID 5 /* AMP related */
#define L2CAP_BLE_CONN_BAD_AUTHENT 5 /* BLE L2CAP connections related */
#define L2CAP_BLE_CONN_BAD_AUTHORIZ 6
#define L2CAP_BLE_CONN_BAD_KEY_SIZE 7
#define L2CAP_BLE_CONN_BAD_ENCRYPT 8
/* Add a couple of our own for internal use */
#define L2CAP_CONN_TIMEOUT 0xEEEE
#define L2CAP_BLE_CMD_REJ 253
#define L2CAP_CONN_AMP_FAILED 254
#define L2CAP_CONN_NO_LINK 255
#define L2CAP_CONN_CANCEL 256 /* L2CAP connection cancelled */
/* Define L2CAP Move Channel Response result codes
*/
#define L2CAP_MOVE_OK 0
#define L2CAP_MOVE_PENDING 1
#define L2CAP_MOVE_CTRL_ID_NOT_SUPPORT 2
#define L2CAP_MOVE_SAME_CTRLR_ID 3
#define L2CAP_MOVE_CONFIG_NOT_SUPPORTED 4
#define L2CAP_MOVE_CHAN_COLLISION 5
#define L2CAP_MOVE_NOT_ALLOWED 6
/* Define L2CAP Move Channel Confirmation result codes
*/
#define L2CAP_MOVE_CFM_OK 0
#define L2CAP_MOVE_CFM_REFUSED 1
/* Define the L2CAP command reject reason codes
*/
#define L2CAP_CMD_REJ_NOT_UNDERSTOOD 0
#define L2CAP_CMD_REJ_MTU_EXCEEDED 1
#define L2CAP_CMD_REJ_INVALID_CID 2
/* L2CAP Predefined CIDs
*/
#define L2CAP_SIGNALLING_CID 1
#define L2CAP_CONNECTIONLESS_CID 2
#define L2CAP_AMP_CID 3
#define L2CAP_ATT_CID 4
#define L2CAP_BLE_SIGNALLING_CID 5
#define L2CAP_SMP_CID 6
#define L2CAP_SMP_BR_CID 7
#define L2CAP_AMP_TEST_CID 0x003F
#define L2CAP_BASE_APPL_CID 0x0040
#define L2CAP_BLE_CONN_MAX_CID 0x007F
/* Fixed Channels mask bits
*/
#define L2CAP_FIXED_CHNL_SIG_BIT (1 << L2CAP_SIGNALLING_CID) /* Signal Channel Supported (Mandatory) */
#define L2CAP_FIXED_CHNL_CNCTLESS_BIT (1 << L2CAP_CONNECTIONLESS_CID) /* Connectionless Reception */
#define L2CAP_FIXED_CHNL_AMP_BIT (1 << L2CAP_AMP_CID) /* AMP Manager Supported */
#define L2CAP_FIXED_CHNL_ATT_BIT (1 << L2CAP_ATT_CID) /* Attribute protocol Supported */
#define L2CAP_FIXED_CHNL_BLE_SIG_BIT (1 << L2CAP_BLE_SIGNALLING_CID) /* BLE Signalling Supported */
#define L2CAP_FIXED_CHNL_SMP_BIT (1 << L2CAP_SMP_CID) /* BLE Security Manager Supported */
#define L2CAP_FIXED_CHNL_SMP_BR_BIT (1 << L2CAP_SMP_BR_CID) /* Security Manager over BR Supported */
/* Define the L2CAP configuration result codes
*/
#define L2CAP_CFG_OK 0
#define L2CAP_CFG_UNACCEPTABLE_PARAMS 1
#define L2CAP_CFG_FAILED_NO_REASON 2
#define L2CAP_CFG_UNKNOWN_OPTIONS 3
#define L2CAP_CFG_PENDING 4
#define L2CAP_CFG_FLOW_SPEC_REJECTED 5
/* Define the L2CAP configuration option types
*/
#define L2CAP_CFG_TYPE_MTU 0x01
#define L2CAP_CFG_TYPE_FLUSH_TOUT 0x02
#define L2CAP_CFG_TYPE_QOS 0x03
#define L2CAP_CFG_TYPE_FCR 0x04
#define L2CAP_CFG_TYPE_FCS 0x05
#define L2CAP_CFG_TYPE_EXT_FLOW 0x06
#define L2CAP_CFG_TYPE_EXT_WIN_SIZE 0x07
#define L2CAP_CFG_MTU_OPTION_LEN 2 /* MTU option length */
#define L2CAP_CFG_FLUSH_OPTION_LEN 2 /* Flush option len */
#define L2CAP_CFG_QOS_OPTION_LEN 22 /* QOS option length */
#define L2CAP_CFG_FCR_OPTION_LEN 9 /* FCR option length */
#define L2CAP_CFG_FCS_OPTION_LEN 1 /* FCR option length */
#define L2CAP_CFG_EXT_FLOW_OPTION_LEN 16 /* Extended Flow Spec */
#define L2CAP_CFG_EXT_WIN_SIZE_LEN 2 /* Ext window size length */
#define L2CAP_CFG_OPTION_OVERHEAD 2 /* Type and length */
/* Configuration Cmd/Rsp Flags mask
*/
#define L2CAP_CFG_FLAGS_MASK_CONT 0x0001 /* Flags mask: Continuation */
/* FCS Check Option values
*/
#define L2CAP_CFG_FCS_BYPASS 0 /* Bypass the FCS in streaming or ERTM modes */
#define L2CAP_CFG_FCS_USE 1 /* Use the FCS in streaming or ERTM modes [default] */
/* Default values for configuration
*/
#define L2CAP_NO_AUTOMATIC_FLUSH 0xFFFF
#define L2CAP_NO_RETRANSMISSION 0x0001
#define L2CAP_DEFAULT_MTU (672)
#define L2CAP_DEFAULT_FLUSH_TO L2CAP_NO_AUTOMATIC_FLUSH
#define L2CAP_DEFAULT_SERV_TYPE 1
#define L2CAP_DEFAULT_TOKEN_RATE 0
#define L2CAP_DEFAULT_BUCKET_SIZE 0
#define L2CAP_DEFAULT_PEAK_BANDWIDTH 0
#define L2CAP_DEFAULT_LATENCY 0xFFFFFFFF
#define L2CAP_DEFAULT_DELAY 0xFFFFFFFF
#define L2CAP_DEFAULT_FCS L2CAP_CFG_FCS_USE
/* Define the L2CAP disconnect result codes
*/
#define L2CAP_DISC_OK 0
#define L2CAP_DISC_TIMEOUT 0xEEEE
/* Define the L2CAP info resp result codes
*/
#define L2CAP_INFO_RESP_RESULT_SUCCESS 0
#define L2CAP_INFO_RESP_RESULT_NOT_SUPPORTED 1
/* Define the info-type fields of information request & response
*/
#define L2CAP_CONNLESS_MTU_INFO_TYPE 0x0001
#define L2CAP_EXTENDED_FEATURES_INFO_TYPE 0x0002 /* Used in Information Req/Response */
#define L2CAP_FIXED_CHANNELS_INFO_TYPE 0x0003 /* Used in AMP */
#define L2CAP_CONNLESS_MTU_INFO_SIZE 2 /* Connectionless MTU size */
#define L2CAP_EXTENDED_FEATURES_ARRAY_SIZE 4 /* Extended features array size */
#define L2CAP_FIXED_CHNL_ARRAY_SIZE 8 /* Fixed channel array size */
/* Extended features mask bits
*/
#define L2CAP_EXTFEA_RTRANS 0x00000001 /* Retransmission Mode (Not Supported) */
#define L2CAP_EXTFEA_FC 0x00000002 /* Flow Control Mode (Not Supported) */
#define L2CAP_EXTFEA_QOS 0x00000004
#define L2CAP_EXTFEA_ENH_RETRANS 0x00000008 /* Enhanced retransmission mode */
#define L2CAP_EXTFEA_STREAM_MODE 0x00000010 /* Streaming Mode */
#define L2CAP_EXTFEA_NO_CRC 0x00000020 /* Optional FCS (if set No FCS desired) */
#define L2CAP_EXTFEA_EXT_FLOW_SPEC 0x00000040 /* Extended flow spec */
#define L2CAP_EXTFEA_FIXED_CHNLS 0x00000080 /* Fixed channels */
#define L2CAP_EXTFEA_EXT_WINDOW 0x00000100 /* Extended Window Size */
#define L2CAP_EXTFEA_UCD_RECEPTION 0x00000200 /* Unicast Connectionless Data Reception */
/* Mask for locally supported features used in Information Response (default to none) */
#ifndef L2CAP_EXTFEA_SUPPORTED_MASK
#define L2CAP_EXTFEA_SUPPORTED_MASK 0
#endif
/* Mask for LE supported features used in Information Response (default to none) */
#ifndef L2CAP_BLE_EXTFEA_MASK
#define L2CAP_BLE_EXTFEA_MASK 0
#endif
/* Define a value that tells L2CAP to use the default HCI ACL buffer pool */
#define L2CAP_DEFAULT_ERM_POOL_ID 0xFF
/* Define a value that tells L2CAP to use the default MPS */
#define L2CAP_DEFAULT_ERM_MPS 0x0000
#define L2CAP_FCR_OVERHEAD 2 /* Control word */
#define L2CAP_FCS_LEN 2 /* FCS takes 2 bytes */
#define L2CAP_SDU_LEN_OVERHEAD 2 /* SDU length field is 2 bytes */
#define L2CAP_SDU_LEN_OFFSET 2 /* SDU length offset is 2 bytes */
#define L2CAP_EXT_CONTROL_OVERHEAD 4 /* Extended Control Field */
#define L2CAP_MAX_HEADER_FCS (L2CAP_PKT_OVERHEAD + L2CAP_EXT_CONTROL_OVERHEAD + L2CAP_SDU_LEN_OVERHEAD + L2CAP_FCS_LEN)
/* length(2), channel(2), control(4), SDU length(2) FCS(2) */
/* Part of L2CAP_MIN_OFFSET that is not part of L2CAP
*/
#define L2CAP_OFFSET_WO_L2HDR (L2CAP_MIN_OFFSET-(L2CAP_PKT_OVERHEAD+L2CAP_FCR_OVERHEAD))
/* SAR bits in the control word
*/
#define L2CAP_FCR_UNSEG_SDU 0x0000 /* Control word to begin with for unsegmented PDU*/
#define L2CAP_FCR_START_SDU 0x4000 /* ...for Starting PDU of a semented SDU */
#define L2CAP_FCR_END_SDU 0x8000 /* ...for ending PDU of a segmented SDU */
#define L2CAP_FCR_CONT_SDU 0xc000 /* ...for continuation PDU of a segmented SDU */
/* Supervisory frame types
*/
#define L2CAP_FCR_SUP_RR 0x0000 /* Supervisory frame - RR */
#define L2CAP_FCR_SUP_REJ 0x0001 /* Supervisory frame - REJ */
#define L2CAP_FCR_SUP_RNR 0x0002 /* Supervisory frame - RNR */
#define L2CAP_FCR_SUP_SREJ 0x0003 /* Supervisory frame - SREJ */
#define L2CAP_FCR_SAR_BITS 0xC000 /* Mask to get the SAR bits from control word */
#define L2CAP_FCR_SAR_BITS_SHIFT 14 /* Bits to shift right to get the SAR bits from ctrl-word */
#define L2CAP_FCR_S_FRAME_BIT 0x0001 /* Mask to check if a PDU is S-frame */
#define L2CAP_FCR_REQ_SEQ_BITS 0x3F00 /* Mask to get the req-seq from control word */
#define L2CAP_FCR_REQ_SEQ_BITS_SHIFT 8 /* Bits to shift right to get the req-seq from ctrl-word */
#define L2CAP_FCR_TX_SEQ_BITS 0x007E /* Mask on get the tx-seq from control word */
#define L2CAP_FCR_TX_SEQ_BITS_SHIFT 1 /* Bits to shift right to get the tx-seq from ctrl-word */
#define L2CAP_FCR_F_BIT 0x0080 /* F-bit in the control word (Sup and I frames) */
#define L2CAP_FCR_P_BIT 0x0010 /* P-bit in the control word (Sup frames only) */
#define L2CAP_FCR_F_BIT_SHIFT 7
#define L2CAP_FCR_P_BIT_SHIFT 4
#define L2CAP_FCR_SEG_BITS 0xC000 /* Mask to get the segmentation bits from ctrl-word */
#define L2CAP_FCR_SUP_SHIFT 2 /* Bits to shift right to get the S-bits from ctrl-word */
#define L2CAP_FCR_SUP_BITS 0x000C /* Mask to get the supervisory bits from ctrl-word */
#define L2CAP_FCR_INIT_CRC 0 /* Initial state of the CRC register */
#define L2CAP_FCR_SEQ_MODULO 0x3F /* Mask for sequence numbers (range 0 - 63) */
/*************************************************************************************************
** The following definitions are only used for internal testing of ERTM at the application level
*************************************************************************************************/
/* L2CA_SetupErtmTest() corruption test types */
#define L2CAP_FCR_TTYPE_CORR_IFRAME 0 /* Corrupt one or more I-frames, based on count */
#define L2CAP_FCR_TTYPE_CORR_SFRAME 1 /* Corrupt an S-frame, (acknowledgement) */
#define L2CAP_FCR_TTYPE_STOP_TEST 2 /* Used when turning off a test */
#define L2CAP_FCR_TTYPE_GET_CID 3 /* Returns RFCOMM cid when '0' is passed in cid argument */
/* L2CA_SetupErtmTest() Freq */
#define L2CAP_FCR_FREQ_NORMAL 0 /* A single test is run */
#define L2CAP_FCR_FREQ_RANDOM 1 /* Randomly loses or corrupts a packet */
#endif

View File

@@ -0,0 +1,675 @@
/**
* UNPUBLISHED PROPRIETARY SOURCE CODE
* Copyright (c) 2016 MXCHIP Inc.
*
* 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 MXCHIP Corporation.
*
*/
/** @file
*
* MiCO Bluetooth Low Energy (BLE) Functions
*
*/
#pragma once
#include "mico_bt_dev.h"
#define CHNL_MAP_LEN 5
typedef uint8_t mico_bt_ble_chnl_map_t[CHNL_MAP_LEN];
/** Scan modes */
enum mico_bt_ble_scan_mode_e
{
BTM_BLE_SCAN_MODE_PASSIVE = 0, /**< Passive scan mode */
BTM_BLE_SCAN_MODE_ACTIVE = 1, /**< Active scan mode */
BTM_BLE_SCAN_MODE_NONE = 0xff /**< None */
};
typedef uint8_t mico_bt_ble_scan_mode_t; /**< scan mode (see #mico_bt_ble_scan_mode_e) */
/** Scan filter policy */
enum mico_bt_ble_scan_filter_policy_e
{
BTM_BLE_SCAN_FILTER_POLICY_NONE = 0, /**< Not use White List for Scanning Procedure. */
BTM_BLE_SCAN_FILTER_POLICY_WHITE_LIST = 1, /**< Use White List for Scanning Procedure. */
};
typedef uint8_t mico_bt_ble_scan_filter_policy_t; /**< scan filter policy (see #mico_bt_ble_scan_filter_policy_e) */
/** advertising channel map */
enum mico_bt_ble_advert_chnl_map_e
{
BTM_BLE_ADVERT_CHNL_37 = (0x01 << 0), /**< ADV channel */
BTM_BLE_ADVERT_CHNL_38 = (0x01 << 1), /**< ADV channel */
BTM_BLE_ADVERT_CHNL_39 = (0x01 << 2) /**< ADV channel */
};
typedef uint8_t mico_bt_ble_advert_chnl_map_t; /**< BLE advertisement channel map (see #mico_bt_ble_advert_chnl_map_e) */
/* default advertising channel map */
#ifndef BTM_BLE_DEFAULT_ADVERT_CHNL_MAP
#define BTM_BLE_DEFAULT_ADVERT_CHNL_MAP (BTM_BLE_ADVERT_CHNL_37| BTM_BLE_ADVERT_CHNL_38| BTM_BLE_ADVERT_CHNL_39)
#endif
/** Advertising filter policy */
enum mico_bt_ble_advert_filter_policy_e {
BTM_BLE_ADVERT_FILTER_ALL_CONNECTION_REQ_ALL_SCAN_REQ = 0x00, /**< Process scan and connection requests from all devices (i.e., the White List is not in use) (default) */
BTM_BLE_ADVERT_FILTER_ALL_CONNECTION_REQ_WHITELIST_SCAN_REQ = 0x01, /**< Process connection requests from all devices and only scan requests from devices that are in the White List. */
BTM_BLE_ADVERT_FILTER_WHITELIST_CONNECTION_REQ_ALL_SCAN_REQ = 0x02, /**< Process scan requests from all devices and only connection requests from devices that are in the White List */
BTM_BLE_ADVERT_FILTER_WHITELIST_CONNECTION_REQ_WHITELIST_SCAN_REQ = 0x03, /**< Process scan and connection requests only from devices in the White List. */
BTM_BLE_ADVERT_FILTER_MAX
};
typedef uint8_t mico_bt_ble_advert_filter_policy_t; /**< Advertising filter policy (see #mico_bt_ble_advert_filter_policy_e) */
/* default advertising filter policy */
#define BTM_BLE_ADVERT_FILTER_DEFAULT BTM_BLE_ADVERT_FILTER_ALL_CONNECTION_REQ_ALL_SCAN_REQ
/* adv parameter boundary values */
#define BTM_BLE_ADVERT_INTERVAL_MIN 0x0020
#define BTM_BLE_ADVERT_INTERVAL_MAX 0x4000
/* connection parameter boundary values */
#define BTM_BLE_SCAN_INTERVAL_MIN 0x0004
#define BTM_BLE_SCAN_INTERVAL_MAX 0x4000
#define BTM_BLE_SCAN_WINDOW_MIN 0x0004
#define BTM_BLE_SCAN_WINDOW_MAX 0x4000
#define BTM_BLE_CONN_INTERVAL_MIN 0x0006
#define BTM_BLE_CONN_INTERVAL_MAX 0x0C80
#define BTM_BLE_CONN_LATENCY_MAX 500
#define BTM_BLE_CONN_SUP_TOUT_MIN 0x000A
#define BTM_BLE_CONN_SUP_TOUT_MAX 0x0C80
#define BTM_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */
#define BTM_BLE_CONN_SUP_TOUT_DEF 700
/* default connection parameters if not configured, use GAP recommend value for auto/selective connection */
/* default scan interval */
#define BTM_BLE_SCAN_FAST_INTERVAL 96 /* 30 ~ 60 ms (use 60) = 96 *0.625 */
/* default scan window for background connection, applicable for auto connection or selective conenction */
#define BTM_BLE_SCAN_FAST_WINDOW 48 /* 30 ms = 48 *0.625 */
/* default scan paramter used in reduced power cycle (background scanning) */
#define BTM_BLE_SCAN_SLOW_INTERVAL_1 2048 /* 1.28 s = 2048 *0.625 */
#define BTM_BLE_SCAN_SLOW_WINDOW_1 18 /* 11.25 ms = 18 *0.625 */
/* default scan paramter used in reduced power cycle (background scanning) */
#define BTM_BLE_SCAN_SLOW_INTERVAL_2 4096 /* 2.56 s = 4096 *0.625 */
#define BTM_BLE_SCAN_SLOW_WINDOW_2 36 /* 22.5 ms = 36 *0.625 */
/* default connection interval min */
#define BTM_BLE_CONN_INTERVAL_MIN_DEF 24 /* recommended min: 30ms = 24 * 1.25 */
/* default connectino interval max */
#define BTM_BLE_CONN_INTERVAL_MAX_DEF 40 /* recommended max: 50 ms = 56 * 1.25 */
/* default slave latency */
#define BTM_BLE_CONN_SLAVE_LATENCY_DEF 0 /* 0 */
/* default supervision timeout */
#define BTM_BLE_CONN_TIMEOUT_DEF 2000
#define BTM_BLE_DIR_CONN_FALLBACK_UNDIR 1
#define BTM_BLE_DIR_CONN_FALLBACK_NO_ADV 2
#define BTM_BLE_DIR_CONN_FALLBACK BTM_BLE_DIR_CONN_FALLBACK_UNDIR
/** BLE Signature */
#define BTM_BLE_AUTH_SIGNATURE_SIZE 12 /**< BLE data signature length 8 Bytes + 4 bytes counter*/
typedef uint8_t mico_dev_ble_signature_t[BTM_BLE_AUTH_SIGNATURE_SIZE]; /**< Device address (see #BTM_BLE_AUTH_SIGNATURE_SIZE) */
#define BTM_BLE_POLICY_BLACK_ALL 0x00 /* relevant to both */
#define BTM_BLE_POLICY_ALLOW_SCAN 0x01 /* relevant to advertiser */
#define BTM_BLE_POLICY_ALLOW_CONN 0x02 /* relevant to advertiser */
#define BTM_BLE_POLICY_WHITE_ALL 0x03 /* relevant to both */
/* ADV data flag bit definition used for BTM_BLE_ADVERT_TYPE_FLAG */
#define BTM_BLE_LIMITED_DISCOVERABLE_FLAG (0x01 << 0)
#define BTM_BLE_GENERAL_DISCOVERABLE_FLAG (0x01 << 1)
#define BTM_BLE_BREDR_NOT_SUPPORTED (0x01 << 2)
/* 4.1 spec adv flag for simultaneous BR/EDR+LE connection support (see) */
#define BTM_BLE_SIMULTANEOUS_DUAL_MODE_TO_SAME_DEVICE_CONTROLLER_SUPPORTED (0x01 << 3) /**< Simultaneous LE and BR/EDR to Same Device Capable (Controller). */
#define BTM_BLE_SIMULTANEOUS_DUAL_MODE_TO_SAME_DEVICE_HOST_SUPPORTED (0x01 << 4) /**< Simultaneous LE and BR/EDR to Same Device Capable (Host). */
#define BTM_BLE_NON_LIMITED_DISCOVERABLE_FLAG (0x00 ) /* lowest bit unset */
#define BTM_BLE_ADVERT_FLAG_MASK (BTM_BLE_LIMITED_DISCOVERABLE_FLAG | BTM_BLE_BREDR_NOT_SUPPORTED | BTM_BLE_GENERAL_DISCOVERABLE_FLAG)
#define BTM_BLE_LIMITED_DISCOVERABLE_MASK (BTM_BLE_LIMITED_DISCOVERABLE_FLAG )
/** Advertisement Data bit masks */
enum mico_bt_ble_advert_mask_e {
BTM_BLE_ADVERT_BIT_DEV_NAME = (0x00000001 << 0), /**< Device Name */
BTM_BLE_ADVERT_BIT_FLAGS = (0x00000001 << 1), /**< Flags */
BTM_BLE_ADVERT_BIT_MANUFACTURER = (0x00000001 << 2), /**< Manufacturer Specific Data */
BTM_BLE_ADVERT_BIT_TX_POWER = (0x00000001 << 3), /**< Transmit Power Level */
BTM_BLE_ADVERT_BIT_INTERVAL_RANGE = (0x00000001 << 5), /**< Slave preferred connection interval range */
BTM_BLE_ADVERT_BIT_SERVICE = (0x00000001 << 6), /**< Service UUID (16-bit) */
BTM_BLE_ADVERT_BIT_SERVICE_SOLICITATION = (0x00000001 << 7), /**< Service Solicitation (16-bit) */
BTM_BLE_ADVERT_BIT_SERVICE_DATA = (0x00000001 << 8), /**< Service Data */
BTM_BLE_ADVERT_BIT_SIGN_DATA = (0x00000001 << 9), /**< Signed data */
BTM_BLE_ADVERT_BIT_SERVICE_128SOLICITATION = (0x00000001 << 10), /**< Service Solicitation (128-bit) */
BTM_BLE_ADVERT_BIT_APPEARANCE = (0x00000001 << 11), /**< Appearance */
BTM_BLE_ADVERT_BIT_PUBLIC_ADDR = (0x00000001 << 12), /**< Public Target Address */
BTM_BLE_ADVERT_BIT_RANDOM_ADDR = (0x00000001 << 13), /**< Random Target Address */
BTM_BLE_ADVERT_BIT_SERVICE_32 = (0x00000001 << 4), /**< Service UUIDs (32-bit) */
BTM_BLE_ADVERT_BIT_SERVICE_32SOLICITATION = (0x00000001 << 14), /**< Service Solicitation (32-bit) */
BTM_BLE_ADVERT_BIT_PROPRIETARY = (0x00000001 << 15), /**< Priorpietary */
BTM_BLE_ADVERT_BIT_SERVICE_128 = (0x00000001 << 16) /**< Service UUIDs (128-bit) */
};
typedef uint32_t mico_bt_ble_advert_mask_t; /**< BLE advertisement mask (see #mico_bt_ble_advert_mask_e) */
/** Advertisement data types */
enum mico_bt_ble_advert_type_e {
BTM_BLE_ADVERT_TYPE_FLAG = 0x01, /**< Advertisement flags */
BTM_BLE_ADVERT_TYPE_16SRV_PARTIAL = 0x02, /**< List of supported services - 16 bit UUIDs (partial) */
BTM_BLE_ADVERT_TYPE_16SRV_COMPLETE = 0x03, /**< List of supported services - 16 bit UUIDs (complete) */
BTM_BLE_ADVERT_TYPE_32SRV_PARTIAL = 0x04, /**< List of supported services - 32 bit UUIDs (partial) */
BTM_BLE_ADVERT_TYPE_32SRV_COMPLETE = 0x05, /**< List of supported services - 32 bit UUIDs (complete) */
BTM_BLE_ADVERT_TYPE_128SRV_PARTIAL = 0x06, /**< List of supported services - 128 bit UUIDs (partial) */
BTM_BLE_ADVERT_TYPE_128SRV_COMPLETE = 0x07, /**< List of supported services - 128 bit UUIDs (complete) */
BTM_BLE_ADVERT_TYPE_NAME_SHORT = 0x08, /**< Short name */
BTM_BLE_ADVERT_TYPE_NAME_COMPLETE = 0x09, /**< Complete name */
BTM_BLE_ADVERT_TYPE_TX_POWER = 0x0A, /**< TX Power level */
BTM_BLE_ADVERT_TYPE_DEV_CLASS = 0x0D, /**< Device Class */
BTM_BLE_ADVERT_TYPE_SM_TK = 0x10, /**< Security manager TK value */
BTM_BLE_ADVERT_TYPE_SM_OOB_FLAG = 0x11, /**< Security manager Out-of-Band data */
BTM_BLE_ADVERT_TYPE_INTERVAL_RANGE = 0x12, /**< Slave connection interval range */
BTM_BLE_ADVERT_TYPE_SOLICITATION_SRV_UUID = 0x14, /**< List of solicitated services - 16 bit UUIDs */
BTM_BLE_ADVERT_TYPE_128SOLICITATION_SRV_UUID = 0x15, /**< List of solicitated services - 128 bit UUIDs */
BTM_BLE_ADVERT_TYPE_SERVICE_DATA = 0x16, /**< Service data - 16 bit UUID */
BTM_BLE_ADVERT_TYPE_PUBLIC_TARGET = 0x17, /**< Public target address */
BTM_BLE_ADVERT_TYPE_RANDOM_TARGET = 0x18, /**< Random target address */
BTM_BLE_ADVERT_TYPE_APPEARANCE = 0x19, /**< Appearance */
BTM_BLE_ADVERT_TYPE_ADVERT_INTERVAL = 0x1a, /**< Advertising interval */
BTM_BLE_ADVERT_TYPE_32SOLICITATION_SRV_UUID = 0x1b, /**< List of solicitated services - 32 bit UUIDs */
BTM_BLE_ADVERT_TYPE_32SERVICE_DATA = 0x1c, /**< Service data - 32 bit UUID */
BTM_BLE_ADVERT_TYPE_128SERVICE_DATA = 0x1d, /**< Service data - 128 bit UUID */
BTM_BLE_ADVERT_TYPE_MANUFACTURER = 0xFF /**< Manufacturer data */
};
typedef uint8_t mico_bt_ble_advert_type_t; /**< BLE advertisement data type (see #mico_bt_ble_advert_type_e) */
/** security settings used with L2CAP LE COC */
enum mico_bt_ble_sec_flags_e
{
BTM_SEC_LE_LINK_ENCRYPTED = 0x01, /**< Link encrypted */
BTM_SEC_LE_LINK_PAIRED_WITHOUT_MITM = 0x02, /**< Paired without man-in-the-middle protection */
BTM_SEC_LE_LINK_PAIRED_WITH_MITM = 0x04 /**< Link with man-in-the-middle protection */
};
/** Slave preferred connection interval range */
typedef struct
{
uint16_t low; /**< Preferred low connection interval */
uint16_t hi; /**< Preferred high connection interval */
}mico_bt_ble_int_range_t;
/** Service tag supported in the device */
typedef struct
{
uint8_t num_service; /**< Number of services */
mico_bool_t list_cmpl; /**< Complete list or not */
uint16_t *p_uuid; /**< 16-bit UUID data */
}mico_bt_ble_service_t;
/** 32 bits Service supported in the device */
typedef struct
{
uint8_t num_service; /**< Number of services */
mico_bool_t list_cmpl; /**< Complete list or not */
uint32_t *p_uuid; /**< 32-bit UUID data */
}mico_bt_ble_32service_t;
/** 128 bits Service supported in the device */
typedef struct
{
mico_bool_t list_cmpl; /**< Complete list or not */
uint8_t uuid128[MAX_UUID_SIZE]; /**< 128-bit UUID data */
}mico_bt_ble_128service_t;
/** Manufacturer data supported in the device */
typedef struct
{
uint8_t len; /**< Length of manufacturer data */
uint8_t *p_val; /**< Manufacturer data */
}mico_bt_ble_manu_t;
/** Service data supported in the device */
typedef struct
{
mico_bt_uuid_t service_uuid; /**< Service UUID data */
uint8_t len; /**< Service UUID length */
uint8_t *p_val; /**< Service data value */
}mico_bt_ble_service_data_t;
/** Proprietary data element supported in the device */
typedef struct
{
uint8_t advert_type; /**< Advertisement type */
uint8_t len; /**< Advertisement length */
uint8_t *p_val; /**< Element data */
}mico_bt_ble_prop_elem_t;
/** Proprietary data elements structure supported in the device */
typedef struct
{
uint8_t num_elem; /**< Number of elements */
mico_bt_ble_prop_elem_t *p_elem; /**< Proprietary elements */
}mico_bt_ble_proprietary_t;
/** Advertising data */
typedef struct
{
mico_bt_ble_int_range_t int_range; /**< slave preferred connection interval range (BTM_BLE_ADVERT_BIT_INTERVAL_RANGE) */
mico_bt_ble_manu_t *p_manu; /**< manufacturer data (BTM_BLE_ADVERT_BIT_MANUFACTURER) */
mico_bt_ble_service_t *p_services; /**< list of supported services - 16 bit UUIDs (BTM_BLE_ADVERT_BIT_SERVICE) */
mico_bt_ble_128service_t *p_services_128b; /**< list of supported services - 128 bit UUIDs (BTM_BLE_ADVERT_BIT_SERVICE_128) */
mico_bt_ble_32service_t *p_service_32b; /**< list of supported services - 32 bit UUIDs (BTM_BLE_ADVERT_BIT_SERVICE_32) */
mico_bt_ble_service_t *p_sol_services; /**< list of solicited services - 16 bit UUIDs (BTM_BLE_ADVERT_BIT_SERVICE_SOLICITATION) */
mico_bt_ble_32service_t *p_sol_service_32b; /**< list of solicited services - 32 bit UUIDs (BTM_BLE_ADVERT_BIT_SERVICE_32SOLICITATION) */
mico_bt_ble_128service_t *p_sol_service_128b; /**< list of solicited services - 128 bit UUIDs (BTM_BLE_ADVERT_BIT_SERVICE_128SOLICITATION) */
mico_bt_ble_proprietary_t *p_proprietary; /**< list of proprietary data elements (BTM_BLE_ADVERT_BIT_PROPRIETARY) */
mico_bt_ble_service_data_t *p_service_data; /**< service data (BTM_BLE_ADVERT_BIT_SERVICE_DATA) */
uint16_t appearance; /**< appearance (BTM_BLE_ADVERT_BIT_APPEARANCE) */
uint8_t flag; /**< flag (BTM_BLE_ADVERT_BIT_FLAGS) */
uint8_t tx_power; /**< transmit power (BTM_BLE_ADVERT_BIT_TX_POWER) */
}mico_bt_ble_advert_data_t;
/** Scan result event type */
enum mico_bt_dev_ble_evt_type_e {
BTM_BLE_EVT_CONNECTABLE_ADVERTISEMENT = 0x00, /**< Connectable advertisement */
BTM_BLE_EVT_CONNECTABLE_DIRECTED_ADVERTISEMENT = 0x01, /**< Connectable Directed advertisement */
BTM_BLE_EVT_SCANNABLE_ADVERTISEMENT = 0x02, /**< Scannable advertisement */
BTM_BLE_EVT_NON_CONNECTABLE_ADVERTISEMENT = 0x03, /**< Non connectable advertisement */
BTM_BLE_EVT_SCAN_RSP = 0x04 /**< Scan response */
};
typedef uint8_t mico_bt_dev_ble_evt_type_t; /**< Scan result event value (see #mico_bt_dev_ble_evt_type_e) */
/** Background connection type */
enum mico_bt_ble_conn_type_e
{
BTM_BLE_CONN_NONE, /**< No background connection */
BTM_BLE_CONN_AUTO, /**< Auto connection */
BTM_BLE_CONN_SELECTIVE /**< Selective connection */
};
typedef uint8_t mico_bt_ble_conn_type_t; /**< Connection type (see #mico_bt_ble_conn_type_e) */
/** LE inquiry result type */
typedef struct
{
mico_bt_device_address_t remote_bd_addr; /**< Device address */
uint8_t ble_addr_type; /**< LE Address type */
mico_bt_dev_ble_evt_type_t ble_evt_type; /**< Scan result event type */
int8_t rssi; /**< Set to #BTM_INQ_RES_IGNORE_RSSI, if not valid */
uint8_t flag;
uint8_t length;
} mico_bt_ble_scan_results_t;
/**
* Callback mico_bt_ble_selective_conn_cback_t
*
* Selective connection callback (registered with #mico_bt_ble_set_background_connection_type)
*
* @param remote_bda : remote device
* @param p_remote_name : remote device name
*
* @return
*/
typedef bool (mico_bt_ble_selective_conn_cback_t)(mico_bt_device_address_t remote_bda, uint8_t *p_remote_name, const uint8_t *p_data, uint8_t length);
/**
* Callback mico_bt_ble_scan_result_cback_t
*
* Scan result callback (from calling #mico_bt_ble_scan)
*
* @param p_scan_result : scan result data (NULL indicates end of scanning)
* @param p_adv_data : Advertisement data (parse using #mico_bt_ble_check_advertising_data)
*
* @return Nothing
*/
typedef void (mico_bt_ble_scan_result_cback_t) (mico_bt_ble_scan_results_t *p_scan_result, uint8_t *p_adv_data);
/******************************************************
* Function Declarations
*
******************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @addtogroup btm_ble_api_functions BLE (Bluetooth Low Energy)
* @ingroup micobt_DeviceManagement
*
* BLE (Bluetooth Low Energy) Functions.
*
* @{
*/
/**
*
* Function mico_bt_start_advertisements
*
* Start advertising.
*
* Use #mico_bt_ble_set_advertisement_data to configure advertising data
* prior to starting avertisements.
*
* The <b>advert_mode</b> parameter determines what advertising parameters and durations
* to use (as specified by the application configuration).
*
* @param[in] advert_mode : advertisement mode
* @param[in] directed_advertisement_bdaddr_type : BLE_ADDR_PUBLIC or BLE_ADDR_RANDOM (if using directed advertisement mode)
* @param[in] directed_advertisement_bdaddr_ptr : Directed advertisement address (NULL if not using directed advertisement)
*
* @return status
*
*/
mico_bt_result_t mico_bt_start_advertisements(mico_bt_ble_advert_mode_t advert_mode, mico_bt_ble_address_type_t directed_advertisement_bdaddr_type, mico_bt_device_address_ptr_t directed_advertisement_bdaddr_ptr);
/**
*
* Function mico_bt_ble_get_current_advert_mode
*
* Get current advertising mode
*
* @return Current advertising mode
*
*/
mico_bt_ble_advert_mode_t mico_bt_ble_get_current_advert_mode(void);
/**
*
* Function mico_bt_ble_set_advertisement_data
*
* Set advertisement data.
*
* @param[in] data_mask : mask of data types to include in the advertisement data
* @param[in] p_data : advertisement data
*
* @return void
*
*/
mico_bt_result_t mico_bt_ble_set_advertisement_data(mico_bt_ble_advert_mask_t data_mask,
mico_bt_ble_advert_data_t *p_data);
/**
*
* Function mico_bt_ble_set_scan_response_data
*
* Set scan response data
*
* @param[in] data_mask : mask of data types to include in the scan response data
* @param[in] p_data : scan response data
*
* @return status of the operation
*
*/
mico_bt_dev_status_t mico_bt_ble_set_scan_response_data(mico_bt_ble_advert_mask_t data_mask,
mico_bt_ble_advert_data_t *p_data);
/**
* Function mico_bt_ble_scan
*
* Start LE scanning
*
* The <b>scan_type</b> parameter determines what scanning parameters and durations
* to use (as specified by the application configuration).
*
* Scan results are notified using <b>p_scan_result_cback</b>
*
* @param[in] scan_type : BTM_BLE_SCAN_TYPE_NONE, BTM_BLE_SCAN_TYPE_HIGH_DUTY, BTM_BLE_SCAN_TYPE_LOW_DUTY
* @param[in] duplicate_filter_enable : TRUE or FALSE to enable or disable duplicate filtering
*
* @param[in] p_scan_result_cback : scan result callback
*
* @return mico_bt_result_t
*
* MICO_BT_PENDING if successfully initiated
* MICO_BT_BUSY if already in progress
* MICO_BT_ILLEGAL_VALUE if parameter(s) are out of range
* MICO_BT_NO_RESOURCES if could not allocate resources to start the command
* MICO_BT_WRONG_MODE if the device is not up.
*/
mico_bt_result_t mico_bt_ble_scan (mico_bt_ble_scan_type_t scan_type, mico_bool_t duplicate_filter_enable, mico_bt_ble_scan_result_cback_t *p_scan_result_cback);
/**
*
* Function mico_bt_ble_get_current_scan_state
*
* Get current scan state
*
* @return mico_bt_ble_scan_type_t
*
* BTM_BLE_SCAN_TYPE_NONE Not scanning
* BTM_BLE_SCAN_TYPE_HIGH_DUTY High duty cycle scan
* BTM_BLE_SCAN_TYPE_LOW_DUTY Low duty cycle scan
*/
mico_bt_ble_scan_type_t mico_bt_ble_get_current_scan_state(void);
/**
*
* Function mico_bt_ble_security_grant
*
* Grant or deny access. Used in response to an BTM_SECURITY_REQUEST_EVT event.
*
* @param[in] bd_addr : peer device bd address.
* @param[in] res : BTM_SUCCESS to grant access; BTM_REPEATED_ATTEMPTS otherwise
*
* @return <b> None </b>
*
*/
void mico_bt_ble_security_grant(mico_bt_device_address_t bd_addr, uint8_t res);
/**
*
* Function mico_bt_ble_data_signature
*
* Sign the data using AES128 CMAC algorith.
*
* @param[in] bd_addr: target device the data to be signed for.
* @param[in] p_text: signing data
* @param[in] len: length of the signing data
* @param[in] signature: output parameter where data signature is going to be stored
*
* @return TRUE if signing successful, otherwise FALSE.
*
*/
mico_bool_t mico_bt_ble_data_signature (mico_bt_device_address_t bd_addr, uint8_t *p_text, uint16_t len,
mico_dev_ble_signature_t signature);
/**
*
* Function mico_bt_ble_verify_signature
*
* Verify the data signature
*
* @param[in] bd_addr: target device the data to be signed for.
* @param[in] p_orig: original data before signature.
* @param[in] len: length of the signing data
* @param[in] counter: counter used when doing data signing
* @param[in] p_comp: signature to be compared against.
*
* @return TRUE if signature verified correctly; otherwise FALSE.
*
*/
mico_bool_t mico_bt_ble_verify_signature (mico_bt_device_address_t bd_addr, uint8_t *p_orig,
uint16_t len, uint32_t counter,
uint8_t *p_comp);
/**
*
* Function mico_bt_ble_set_background_connection_type
*
* Set BLE background connection procedure type.
*
* @param[in] conn_type: BTM_BLE_CONN_NONE, BTM_BLE_CONN_AUTO, or BTM_BLE_CONN_SELECTIVE
* @param[in] p_select_cback: callback for BTM_BLE_CONN_SELECTIVE
*
* @return TRUE if background connection set
*
*/
mico_bool_t mico_bt_ble_set_background_connection_type (mico_bt_ble_conn_type_t conn_type, mico_bt_ble_selective_conn_cback_t *p_select_cback);
/**
*
* Function mico_bt_ble_update_background_connection_device
*
* This function is called to add or remove a device into/from
* background connection procedure. The background connection
* procedure is decided by the background connection type, it can be
* auto connection, or selective connection.
*
* @param[in] add_remove: TRUE to add; FALSE to remove.
* @param[in] remote_bda: device address to add/remove.
*
* @return TRUE if successful
*
*/
mico_bool_t mico_bt_ble_update_background_connection_device(mico_bool_t add_remove, mico_bt_device_address_t remote_bda);
/**
*
* Function mico_bt_ble_get_background_connection_device_size
*
* Get a size of white list for the AUTO or SELECTIVE Connection Procedure.
*
* @param[out] size: white list size
*
* @return MICO_TRUE or MICO_FALSE
*/
mico_bool_t mico_bt_ble_get_background_connection_device_size(uint8_t *size);
/**
*
* Function mico_bt_ble_check_advertising_data
*
* Parse advertising data (returned from scan results callback #mico_bt_ble_scan_result_cback_t).
* Look for specified advertisement data type.
*
* @param[in] p_adv : pointer to advertisement data
* @param[in] type : advertisement data type to look for
* @param[out] p_length : length of advertisement data (if found)
*
* @return pointer to start of requested advertisement data (if found). NULL if requested data type not found.
*
*/
uint8_t *mico_bt_ble_check_advertising_data( uint8_t *p_adv, mico_bt_ble_advert_type_t type, uint8_t *p_length);
/**
*
* Function mico_bt_ble_enable_privacy
*
* This function is called to enable or disable the privacy in
* the local device.
*
* @param[in] enable: TRUE to enable it; FALSE to disable it.
*
* @return void
*
*/
void mico_bt_ble_enable_privacy (mico_bool_t enable);
/**
*
* Function mico_bt_ble_enable_mixed_privacy_mode
*
* This function is called to enabled Mixed mode if privacy 1.2
* is applicable in controller.
*
* @param[in] mixed_on: mixed mode to be used or not.
*
* @return void
*
*/
void mico_bt_ble_enable_mixed_privacy_mode(mico_bool_t mixed_on);
/**
*
* Function mico_bt_ble_get_security_state
*
* Get security mode 1 flags and encryption key size for LE peer.
*
* @param[in] bd_addr : peer address
* @param[out] p_le_sec_flags : security flags (see #mico_bt_ble_sec_flags_e)
* @param[out] p_le_key_size : encryption key size
*
* @return TRUE if successful
*
*/
mico_bool_t mico_bt_ble_get_security_state (mico_bt_device_address_t bd_addr, uint8_t *p_le_sec_flags, uint8_t *p_le_key_size);
/**
*
* Function mico_bt_ble_update_advertising_white_list
*
* Add or remove device from advertising white list
*
* @param[in] add: TRUE to add; FALSE to remove
* @param[in] remote_bda: remote device address.
*
* @return void
*
*/
mico_bool_t mico_bt_ble_update_advertising_white_list(mico_bool_t add, const mico_bt_device_address_t remote_bda);
/**
*
* Function mico_bt_ble_update_advertisement_filter_policy
*
* Update the filter policy of advertiser.
*
* @param[in] advertising_policy: advertising filter policy
*
* @return void
*/
mico_bool_t mico_bt_ble_update_advertisement_filter_policy(mico_bt_ble_advert_filter_policy_t advertising_policy);
/**
*
* Function mico_bt_ble_get_advertisement_white_list_size
*
* Get advertisement white list size.
*
* @param[out] size: white list size
*
* @return MICO_TRUE or MICO_FALSE
*/
mico_bool_t mico_bt_ble_get_advertisement_white_list_size(uint8_t *size);
/**
*
* Function mico_bt_ble_get_white_list_capability
*
* Get All white list size.
*
* @param[out] size: white list size
*
* @return MICO_TRUE or MICO_FALSE
*/
mico_bool_t mico_bt_ble_get_white_list_capability(uint8_t *size);
/**
*
* Function mico_bt_ble_clear_white_list
*
* Clear white list (Advertisement & background connection).
*
* @param none
*
* @return MICO_TRUE or MICO_FALSE
*/
mico_bool_t mico_bt_ble_clear_white_list(void);
/**@} btm_ble_api_functions */
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,258 @@
/**
* UNPUBLISHED PROPRIETARY SOURCE CODE
* Copyright (c) 2016 MXCHIP Inc.
*
* 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 MXCHIP Corporation.
*
*/
/** @file
*
* Runtime Bluetooth configuration parameters
*
*/
#pragma once
#include "data_types.h"
#include "mico_bt_types.h"
#include "mico_bt_dev.h"
#include "mico_bt_ble.h"
#include "mico_bt_gatt.h"
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
* Default configuration values
****************************************************************************/
#define MICO_BT_CFG_DEFAULT_INQUIRY_SCAN_INTERVAL 0x0800 /**< Inquiry scan interval */
#define MICO_BT_CFG_DEFAULT_INQUIRY_SCAN_WINDOW 0x0012 /**< Inquiry scan window */
#define MICO_BT_CFG_DEFAULT_PAGE_SCAN_INTERVAL 0x0800 /**< Page scan interval */
#define MICO_BT_CFG_DEFAULT_PAGE_SCAN_WINDOW 0x0012 /**< Page scan window */
#define MICO_BT_CFG_DEFAULT_HIGH_DUTY_SCAN_INTERVAL 96 /**< High duty scan interval */
#define MICO_BT_CFG_DEFAULT_HIGH_DUTY_SCAN_WINDOW 48 /**< High duty scan window */
#define MICO_BT_CFG_DEFAULT_LOW_DUTY_SCAN_INTERVAL 2048 /**< Low duty scan interval */
#define MICO_BT_CFG_DEFAULT_LOW_DUTY_SCAN_WINDOW 18 /**< Low duty scan window */
#define MICO_BT_CFG_DEFAULT_HIGH_DUTY_CONN_SCAN_INTERVAL 96 /**< High duty cycle connection scan interval BTM_BLE_SCAN_FAST_INT*/
#define MICO_BT_CFG_DEFAULT_HIGH_DUTY_CONN_SCAN_WINDOW 48 /**< High duty cycle connection scan window BTM_BLE_SCAN_FAST_WIN */
#define MICO_BT_CFG_DEFAULT_LOW_DUTY_CONN_SCAN_INTERVAL 2048 /**< Low duty cycle connection scan interval BTM_BLE_SCAN_SLOW_INT_1 */
#define MICO_BT_CFG_DEFAULT_LOW_DUTY_CONN_SCAN_WINDOW 18 /**< Low duty cycle connection scan window BTM_BLE_SCAN_SLOW_WIN_1 */
#define MICO_BT_CFG_DEFAULT_CONN_MIN_INTERVAL 24 /**< Minimum connection event interval */
#define MICO_BT_CFG_DEFAULT_CONN_MAX_INTERVAL 40 /**< Maximum connection event interval */
#define MICO_BT_CFG_DEFAULT_CONN_LATENCY 0 /**< Connection latency */
#define MICO_BT_CFG_DEFAULT_CONN_SUPERVISION_TIMEOUT 700 /**< Connection link supervsion timeout */
/* undirected connectable advertisement high/low duty cycle interval default */
#define MICO_BT_CFG_DEFAULT_HIGH_DUTY_ADV_MIN_INTERVAL 48 /**< Tgap(adv_fast_interval1) = 30(used) ~ 60 ms = 48 *0.625 */
#define MICO_BT_CFG_DEFAULT_HIGH_DUTY_ADV_MAX_INTERVAL 48 /**< Tgap(adv_fast_interval1) = 30(used) ~ 60 ms = 48 *0.625 */
#define MICO_BT_CFG_DEFAULT_LOW_DUTY_ADV_MIN_INTERVAL 2048 /**< Tgap(adv_slow_interval) = 1.28 s= 512 * 0.625 ms */
#define MICO_BT_CFG_DEFAULT_LOW_DUTY_ADV_MAX_INTERVAL 2048 /**< Tgap(adv_slow_interval) = 1.28 s= 512 * 0.625 ms */
/* non-connectable advertisement high/low duty cycle advertisement interval default */
#define MICO_BT_CFG_DEFAULT_HIGH_DUTY_NONCONN_ADV_MIN_INTERVAL 160 /**< Tgap(adv_fast_interval2) = 100(used) ~ 150 ms = 160 * 0.625 ms */
#define MICO_BT_CFG_DEFAULT_HIGH_DUTY_NONCONN_ADV_MAX_INTERVAL 160 /**< Tgap(adv_fast_interval2) = 100(used) ~ 150 ms = 160 * 0.625 ms */
#define MICO_BT_CFG_DEFAULT_LOW_DUTY_NONCONN_ADV_MIN_INTERVAL 2048 /**< Tgap(adv_slow_interval) = 1.28 s= 512 * 0.625 ms */
#define MICO_BT_CFG_DEFAULT_LOW_DUTY_NONCONN_ADV_MAX_INTERVAL 2048 /**< Tgap(adv_slow_interval) = 1.28 s= 512 * 0.625 ms */
/* directed connectable advertisement high/low duty cycle interval default */
#define MICO_BT_CFG_DEFAULT_HIGH_DUTY_DIRECTED_ADV_MIN_INTERVAL 400 /**< Tgap(dir_conn_adv_int_max) = 250 ms = 400 * 0.625 ms */
#define MICO_BT_CFG_DEFAULT_HIGH_DUTY_DIRECTED_ADV_MAX_INTERVAL 800 /**< Tgap(dir_conn_adv_int_min) = 500 ms = 800 * 0.625 ms */
#define MICO_BT_CFG_DEFAULT_LOW_DUTY_DIRECTED_ADV_MIN_INTERVAL 48 /**< Tgap(adv_fast_interval1) = 30(used) ~ 60 ms = 48 *0.625 */
#define MICO_BT_CFG_DEFAULT_LOW_DUTY_DIRECTED_ADV_MAX_INTERVAL 48 /**< Tgap(adv_fast_interval1) = 30(used) ~ 60 ms = 48 *0.625 */
/*****************************************************************************
* mico_bt core stack configuration
****************************************************************************/
/** BR/EDR scan settings */
typedef struct
{
uint16_t inquiry_scan_type; /**< Inquiry scan type (BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED) */
uint16_t inquiry_scan_interval; /**< Inquiry scan interval (default: MICO_BT_CFG_DEFAULT_INQUIRY_SCAN_INTERVAL) */
uint16_t inquiry_scan_window; /**< Inquiry scan window (default: MICO_BT_CFG_DEFAULT_INQUIRY_SCAN_WINDOW) */
uint16_t page_scan_type; /**< Page scan type (BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED) */
uint16_t page_scan_interval; /**< Page scan interval (default: MICO_BT_CFG_DEFAULT_PAGE_SCAN_INTERVAL) */
uint16_t page_scan_window; /**< Page scan window (default: MICO_BT_CFG_DEFAULT_PAGE_SCAN_WINDOW) */
} mico_bt_cfg_br_edr_scan_settings_t;
extern const mico_bt_cfg_br_edr_scan_settings_t *mico_bt_cfg_br_edr_scan_settings; /**< BR/EDR Scan settings (NULL to use defaults) */
/** LE Scan settings */
typedef struct
{
mico_bt_ble_scan_mode_t scan_mode; /**< BLE scan mode (BTM_BLE_SCAN_MODE_PASSIVE, BTM_BLE_SCAN_MODE_ACTIVE) */
mico_bt_ble_scan_filter_policy_t scan_filter_policy; /**< BLE scan filter policy (FILTER_POLICY_NONE or FILTER_POLICY_WHITE_LIST) */
/* Advertisement scan configuration */
uint16_t high_duty_scan_interval; /**< High duty scan interval (default: MICO_BT_CFG_DEFAULT_HIGH_DUTY_SCAN_INTERVAL) */
uint16_t high_duty_scan_window; /**< High duty scan window (default: MICO_BT_CFG_DEFAULT_HIGH_DUTY_SCAN_WINDOW) */
uint16_t high_duty_scan_duration; /**< High duty scan duration in seconds (0 for infinite) */
uint16_t low_duty_scan_interval; /**< Low duty scan interval (default: MICO_BT_CFG_DEFAULT_LOW_DUTY_SCAN_INTERVAL) */
uint16_t low_duty_scan_window; /**< Low duty scan window (default: MICO_BT_CFG_DEFAULT_LOW_DUTY_SCAN_WINDOW) */
uint16_t low_duty_scan_duration; /**< Low duty scan duration in seconds (0 for infinite) */
/* Connection scan configuration */
uint16_t high_duty_conn_scan_interval; /**< High duty cycle connection scan interval (default: MICO_BT_CFG_DEFAULT_HIGH_DUTY_CONN_SCAN_INTERVAL) */
uint16_t high_duty_conn_scan_window; /**< High duty cycle connection scan window (default: MICO_BT_CFG_DEFAULT_HIGH_DUTY_CONN_SCAN_WINDOW) */
uint16_t high_duty_conn_duration; /**< High duty cycle connection duration in seconds (0 for infinite) */
uint16_t low_duty_conn_scan_interval; /**< Low duty cycle connection scan interval (default: MICO_BT_CFG_DEFAULT_LOW_DUTY_CONN_SCAN_INTERVAL) */
uint16_t low_duty_conn_scan_window; /**< Low duty cycle connection scan window (default: MICO_BT_CFG_DEFAULT_LOW_DUTY_CONN_SCAN_WINDOW) */
uint16_t low_duty_conn_duration; /**< Low duty cycle connection duration in seconds (0 for infinite) */
/* Connection configuration */
uint16_t conn_min_interval; /**< Minimum connection interval (default: MICO_BT_CFG_DEFAULT_CONN_MIN_INTERVAL) */
uint16_t conn_max_interval; /**< Maximum connection interval (default: MICO_BT_CFG_DEFAULT_CONN_MAX_INTERVAL) */
uint16_t conn_latency; /**< Connection latency (default: MICO_BT_CFG_DEFAULT_CONN_LATENCY) */
uint16_t conn_supervision_timeout; /**< Connection link supervision timeout (default: MICO_BT_CFG_DEFAULT_ CONN_SUPERVISION_TIMEOUT) */
} mico_bt_cfg_ble_scan_settings_t;
/** Advertising settings */
typedef struct
{
mico_bt_ble_advert_chnl_map_t channel_map; /**< Advertising channel map (mask of BTM_BLE_ADVERT_CHNL_37, BTM_BLE_ADVERT_CHNL_38, BTM_BLE_ADVERT_CHNL_39) */
uint16_t high_duty_min_interval; /**< High duty undirected connectable advert minimum advertising interval (default: MICO_BT_CFG_DEFAULT_HIGH_DUTY_ADV_MIN_INTERVAL) */
uint16_t high_duty_max_interval; /**< High duty undirected connectable advert maximum advertising interval (default: MICO_BT_CFG_DEFAULT_HIGH_DUTY_ADV_MAX_INTERVAL) */
uint16_t high_duty_duration; /**< High duty advertising duration in seconds (0 for infinite) */
uint16_t low_duty_min_interval; /**< Low duty undirected connectable advert minimum advertising interval (default: MICO_BT_CFG_DEFAULT_LOW_DUTY_ADV_MIN_INTERVAL) */
uint16_t low_duty_max_interval; /**< Low duty undirected connectable advert maximum advertising interval (default: MICO_BT_CFG_DEFAULT_LOW_DUTY_ADV_MAX_INTERVAL) */
uint16_t low_duty_duration; /**< Low duty advertising duration in seconds (0 for infinite) */
uint16_t high_duty_directed_min_interval; /**< high duty directed adv minimum advertising interval (default: MICO_BT_CFG_DEFAULT_HIGH_DUTY_DIRECTED_ADV_MIN_INTERVAL) */
uint16_t high_duty_directed_max_interval; /**< high duty directed adv maximum advertising interval (default: MICO_BT_CFG_DEFAULT_HIGH_DUTY_DIRECTED_ADV_MAX_INTERVAL) */
uint16_t low_duty_directed_min_interval; /**< Low duty directed adv minimum advertising interval (default: MICO_BT_CFG_DEFAULT_LOW_DUTY_DIRECTED_ADV_MIN_INTERVAL) */
uint16_t low_duty_directed_max_interval; /**< Low duty directed adv maximum advertising interval (default: MICO_BT_CFG_DEFAULT_LOW_DUTY_DIRECTED_ADV_MAX_INTERVAL) */
uint16_t low_duty_directed_duration; /**< Low duty directed advertising duration in seconds (0 for infinite) */
uint16_t high_duty_nonconn_min_interval; /**< High duty non-connectable adv minimum advertising interval (default: MICO_BT_CFG_DEFAULT_HIGH_DUTY_NONCONN_ADV_MIN_INTERVAL) */
uint16_t high_duty_nonconn_max_interval; /**< High duty non-connectable adv maximum advertising interval (default: MICO_BT_CFG_DEFAULT_HIGH_DUTY_NONCONN_ADV_MAX_INTERVAL) */
uint16_t high_duty_nonconn_duration; /**< High duty non-connectable advertising duration in seconds (0 for infinite) */
uint16_t low_duty_nonconn_min_interval; /**< Low duty non-connectable adv minimum advertising interval (default: MICO_BT_CFG_DEFAULT_LOW_DUTY_NONCONN_ADV_MIN_INTERVAL) */
uint16_t low_duty_nonconn_max_interval; /**< Low duty non-connectable adv maximum advertising interval (default: MICO_BT_CFG_DEFAULT_LOW_DUTY_NONCONN_ADV_MAX_INTERVAL) */
uint16_t low_duty_nonconn_duration; /**< Low duty non-connectable advertising duration in seconds (0 for infinite) */
} mico_bt_cfg_ble_advert_settings_t;
/** GATT settings */
typedef struct
{
mico_bt_gatt_appearance_t appearance; /**< GATT appearance (see #gatt_appearance_e) */
uint8_t client_max_links; /**< Client config: maximum number of servers that local client can connect to */
uint8_t server_max_links; /**< Server config: maximum number of remote clients connections allowed by the local */
uint16_t max_attr_len; /**< Maximum attribute length; gki_cfg must have a corresponding buffer pool that can hold this length */
} mico_bt_cfg_gatt_settings_t;
/** Settings for application managed L2CAP protocols (optional) */
typedef struct
{
uint8_t max_links; /**< Maximum number of application-managed l2cap links (BR/EDR and LE) */
/* BR EDR l2cap configuration */
uint8_t max_psm; /**< Maximum number of application-managed BR/EDR PSMs */
uint8_t max_channels; /**< Maximum number of application-managed BR/EDR channels */
/* LE L2cap connection-oriented channels configuration */
uint8_t max_le_psm; /**< Maximum number of application-managed LE PSMs */
uint8_t max_le_channels; /**< Maximum number of application-managed LE channels */
} mico_bt_cfg_l2cap_application_t;
/** Audio/Video Distribution configuration */
typedef struct
{
uint8_t max_links; /**< Maximum simultaneous audio/video links */
} mico_bt_cfg_avdt_t;
/** Audio/Video Remote Control configuration */
typedef struct
{
uint8_t roles; /**< Mask of local roles supported (AVRC_CONN_INITIATOR|AVRC_CONN_ACCEPTOR) */
uint8_t max_links; /**< Maximum simultaneous remote control links */
} mico_bt_cfg_avrc_t;
/* RFCOMM configuration */
typedef struct
{
uint8_t max_links; /**< Maximum number of simultaneous connected remote devices*/
uint8_t max_ports; /**< Maximum number of simultaneous RFCOMM ports */
} mico_bt_cfg_rfcomm_t;
/** Bluetooth stack configuration */
typedef struct
{
uint8_t *device_name; /**< Local device name (NULL terminated) */
mico_bt_dev_class_t device_class; /**< Local device class */
uint8_t security_requirement_mask; /**< Security requirements mask (BTM_SEC_NONE, or combination of BTM_SEC_IN_AUTHENTICATE, BTM_SEC_OUT_AUTHENTICATE, BTM_SEC_ENCRYPT (see #mico_bt_sec_level_e)) */
uint8_t max_simultaneous_links; /**< Maximum number simultaneous links to different devices */
/* Scan and advertisement configuration */
mico_bt_cfg_br_edr_scan_settings_t br_edr_scan_cfg; /**< BR/EDR scan settings */
mico_bt_cfg_ble_scan_settings_t ble_scan_cfg; /**< BLE scan settings */
mico_bt_cfg_ble_advert_settings_t ble_advert_cfg; /**< BLE advertisement settings */
/* GATT configuration */
mico_bt_cfg_gatt_settings_t gatt_cfg; /**< GATT settings */
/* RFCOMM configuration */
mico_bt_cfg_rfcomm_t rfcomm_cfg; /**< RFCOMM settings */
/* Application managed l2cap protocol configuration */
mico_bt_cfg_l2cap_application_t l2cap_application; /**< Application managed l2cap protocol configuration */
/* Audio/Video Distribution configuration */
mico_bt_cfg_avdt_t avdt_cfg; /**< Audio/Video Distribution configuration */
/* Audio/Video Remote Control configuration */
mico_bt_cfg_avrc_t avrc_cfg; /**< Audio/Video Remote Control configuration */
/* LE Address Resolution DB size */
uint8_t addr_resolution_db_size; /**< LE Address Resolution DB settings - effective only for pre 4.2 controller*/
} mico_bt_cfg_settings_t;
/*****************************************************************************
* Buffer pool configuration
*
* Pools must be ordered in increasing buf_size.
* If a pool runs out of buffers, the next pool will be used
*
* Pool usage (4 pools):
* Pool 0: Small Buffer Pool - miscellaneous use (small HCI messages)
* Pool 1: Medium Buffer Pool - HCI & RFCOMM control messages, min recommended buf_size is 360
* Pool 2: Large Buffer Pool - HCI ACL data messages
* Pool 3: Extra Large Buffer Pool - Used for avdt media packets and miscellaneous (if not needed, set buf_count to 0)
*
****************************************************************************/
#define MICO_BT_CFG_NUM_BUF_POOLS (4) /**< mico_bt stack uses 4 pools */
typedef struct {
uint16_t buf_size; /**< size of buffers in the pool */
uint16_t buf_count; /**< number of buffers in the pool */
} mico_bt_cfg_buf_pool_t;
#ifdef __cplusplus
} /* extern "C" */
#endif
#define DEMO_APP_BLE_REPORTER 1
#define DEMO_APP_BLE_MONITOR 2
#define DEMO_APP_RFCOMM_CLT 3
#define DEMO_APP_RFCOMM_SVR 4
#define DEMO_APP_SCAN 5
#define DEMO_APP_FLOOD_BRIDGE 6
//#define DEMO_APP_TYPE DEMO_APP_BLE_REPORTER
//#define DEMO_APP_TYPE DEMO_APP_RFCOMM_SVR
//#define DEMO_APP_TYPE DEMO_APP_RFCOMM_CLT
//#define DEMO_APP_TYPE DEMO_APP_BLE_MONITOR
//#define DEMO_APP_TYPE DEMO_APP_SCAN
#define DEMO_APP_TYPE DEMO_APP_FLOOD_BRIDGE

View File

@@ -0,0 +1,112 @@
/** @file
* Defines common constants and types for the MBLE Bluetooth Framework
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************
* Macros
******************************************************/
#ifndef RESULT_ENUM
#define RESULT_ENUM( prefix, name, value ) prefix ## name = (value)
#endif /* ifndef RESULT_ENUM */
#define BT_RESULT_LIST( prefix ) \
RESULT_ENUM( prefix, SUCCESS, 0 ), /**< Success */ \
RESULT_ENUM( prefix, PARTIAL_RESULTS, 3 ), /**< Partial results */ \
RESULT_ENUM( prefix, BADARG, 5 ), /**< Bad Arguments */ \
RESULT_ENUM( prefix, BADOPTION, 6 ), /**< Mode not supported */ \
RESULT_ENUM( prefix, OUT_OF_HEAP_SPACE, 8 ), /**< Dynamic memory space exhausted */ \
RESULT_ENUM( prefix, UNKNOWN_EVENT, 8029 ), /**< Unknown event is received */ \
RESULT_ENUM( prefix, LIST_EMPTY, 8010 ), /**< List is empty */ \
RESULT_ENUM( prefix, ITEM_NOT_IN_LIST, 8011 ), /**< Item not found in the list */ \
RESULT_ENUM( prefix, PACKET_DATA_OVERFLOW, 8012 ), /**< Data overflow beyond the packet end */ \
RESULT_ENUM( prefix, PACKET_POOL_EXHAUSTED, 8013 ), /**< All packets in the pool is in use */ \
RESULT_ENUM( prefix, PACKET_POOL_FATAL_ERROR, 8014 ), /**< Packet pool fatal error such as permanent packet leak */ \
RESULT_ENUM( prefix, UNKNOWN_PACKET, 8015 ), /**< Unknown packet */ \
RESULT_ENUM( prefix, PACKET_WRONG_OWNER, 8016 ), /**< Packet is owned by another entity */ \
RESULT_ENUM( prefix, BUS_UNINITIALISED, 8017 ), /**< Bluetooth bus isn't initialised */ \
RESULT_ENUM( prefix, MPAF_UNINITIALISED, 8018 ), /**< MPAF framework isn't initialised */ \
RESULT_ENUM( prefix, RFCOMM_UNINITIALISED, 8019 ), /**< RFCOMM protocol isn't initialised */ \
RESULT_ENUM( prefix, STACK_UNINITIALISED, 8020 ), /**< SmartBridge isn't initialised */ \
RESULT_ENUM( prefix, SMART_APPL_UNINITIALISED, 8021 ), /**< Bluetooth stack isn't initialised */ \
RESULT_ENUM( prefix, ATT_CACHE_UNINITIALISED, 8022 ), /**< Attribute cache isn't initialised */ \
RESULT_ENUM( prefix, MAX_CONNECTIONS_REACHED, 8023 ), /**< Maximum number of connections is reached */ \
RESULT_ENUM( prefix, SOCKET_IN_USE, 8024 ), /**< Socket specified is in use */ \
RESULT_ENUM( prefix, SOCKET_NOT_CONNECTED, 8025 ), /**< Socket is not connected or connection failed */ \
RESULT_ENUM( prefix, ENCRYPTION_FAILED, 8026 ), /**< Encryption failed */ \
RESULT_ENUM( prefix, SCAN_IN_PROGRESS, 8027 ), /**< Scan is in progress */ \
RESULT_ENUM( prefix, CONNECT_IN_PROGRESS, 8028 ), /**< Connect is in progress */ \
RESULT_ENUM( prefix, DISCONNECT_IN_PROGRESS, 8029 ), /**< Disconnect is in progress */ \
RESULT_ENUM( prefix, DISCOVER_IN_PROGRESS, 8030 ), /**< Discovery is in progress */ \
RESULT_ENUM( prefix, GATT_TIMEOUT, 8031 ), /**< GATT timeout occured*/ \
RESULT_ENUM( prefix, ATTRIBUTE_VALUE_TOO_LONG, 8032 ), /**< Attribute value too long */ \
RESULT_ENUM( prefix, PENDING, 8100 ), /**< Pending */ \
RESULT_ENUM( prefix, BUSY, 8101 ), /**< Device busy with another command */ \
RESULT_ENUM( prefix, NO_RESOURCES, 8102 ), /**< No resources to issue command */ \
RESULT_ENUM( prefix, UNSUPPORTED, 8103 ), /**< Unsupported function */ \
RESULT_ENUM( prefix, ILLEGAL_VALUE, 8104 ), /**< Illegal parameter value */ \
RESULT_ENUM( prefix, WRONG_MODE, 8105 ), /**< Device in wrong mode for request */ \
RESULT_ENUM( prefix, UNKNOWN_ADDR, 8106 ), /**< Unknown remote BD address */ \
RESULT_ENUM( prefix, TIMEOUT, 8107 ), /**< Timeout */ \
RESULT_ENUM( prefix, BAD_VALUE_RET, 8108 ), /**< A bad value was received from HCI */ \
RESULT_ENUM( prefix, ERROR, 8109 ), /**< Error */ \
RESULT_ENUM( prefix, NOT_AUTHORIZED, 8110 ), /**< Authorization failed */ \
RESULT_ENUM( prefix, DEV_RESET, 8111 ), /**< Device has been reset */ \
RESULT_ENUM( prefix, CMD_STORED, 8112 ), /**< request is stored in control block */ \
RESULT_ENUM( prefix, ILLEGAL_ACTION, 8113 ), /**< state machine gets illegal command */ \
RESULT_ENUM( prefix, DELAY_CHECK, 8114 ), /**< delay the check on encryption */ \
RESULT_ENUM( prefix, SCO_BAD_LENGTH, 8115 ), /**< Bad SCO over HCI data length */ \
RESULT_ENUM( prefix, SUCCESS_NO_SECURITY, 8116 ), /**< security passed, no security set */ \
RESULT_ENUM( prefix, FAILED_ON_SECURITY, 8117 ), /**< security failed */ \
RESULT_ENUM( prefix, REPEATED_ATTEMPTS, 8118 ), /**< repeated attempts for LE security requests */ \
RESULT_ENUM( prefix, MODE4_LEVEL4_NOT_SUPPORTED,8119 ), /**< Connections Only Mode can't be supported */ \
RESULT_ENUM( prefix, USE_DEFAULT_SECURITY, 8120 ), /**< Use default security*/
/******************************************************
* Constants
******************************************************/
/** @cond !ADDTHIS*/
#define MBLE_ADDRESS_BYTE_SIZE 6
/** @endcond */
/******************************************************
* Enumerations
******************************************************/
/**
* MiCO Result Type
*/
typedef enum
{
BT_RESULT_LIST ( MICO_BT_ )
} mico_bt_result_t;
/******************************************************
* Type Definitions
******************************************************/
/******************************************************
* Structures
******************************************************/
/******************************************************
* Global Variables
******************************************************/
/******************************************************
* Function Declarations
******************************************************/
#ifdef __cplusplus
} /* extern "C" */
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,990 @@
/**
* UNPUBLISHED PROPRIETARY SOURCE CODE
* Copyright (c) 2016 MXCHIP Inc.
*
* 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 MXCHIP Corporation.
*
*/
/** @file
*
* MiCO Generic Attribute (GATT) Application Programming Interface
*/
#pragma once
#include "mico.h"
#include "gattdefs.h"
#include "mico_bt_dev.h"
#include "l2cdefs.h"
#include "mico_bt_types.h"
/** GATT Status Codes*/
enum mico_bt_gatt_status_e
{
MICO_BT_GATT_SUCCESS = 0x00, /**< Success */
MICO_BT_GATT_INVALID_HANDLE = 0x01, /**< Invalid Handle */
MICO_BT_GATT_READ_NOT_PERMIT = 0x02, /**< Read Not Permitted */
MICO_BT_GATT_WRITE_NOT_PERMIT = 0x03, /**< Write Not permitted */
MICO_BT_GATT_INVALID_PDU = 0x04, /**< Invalid PDU */
MICO_BT_GATT_INSUF_AUTHENTICATION = 0x05, /**< Insufficient Authentication */
MICO_BT_GATT_REQ_NOT_SUPPORTED = 0x06, /**< Request Not Supported */
MICO_BT_GATT_INVALID_OFFSET = 0x07, /**< Invalid Offset */
MICO_BT_GATT_INSUF_AUTHORIZATION = 0x08, /**< Insufficient Authorization */
MICO_BT_GATT_PREPARE_Q_FULL = 0x09, /**< Prepare Queue Full */
MICO_BT_GATT_NOT_FOUND = 0x0a, /**< Not Found */
MICO_BT_GATT_NOT_LONG = 0x0b, /**< Not Long Size */
MICO_BT_GATT_INSUF_KEY_SIZE = 0x0c, /**< Insufficient Key Size */
MICO_BT_GATT_INVALID_ATTR_LEN = 0x0d, /**< Invalid Attribute Length */
MICO_BT_GATT_ERR_UNLIKELY = 0x0e, /**< Error Unlikely */
MICO_BT_GATT_INSUF_ENCRYPTION = 0x0f, /**< Insufficient Encryption */
MICO_BT_GATT_UNSUPPORT_GRP_TYPE = 0x10, /**< Unsupported Group Type */
MICO_BT_GATT_INSUF_RESOURCE = 0x11, /**< Insufficient Resource */
MICO_BT_GATT_ILLEGAL_PARAMETER = 0x87, /**< Illegal Parameter */
MICO_BT_GATT_NO_RESOURCES = 0x80, /**< No Resources */
MICO_BT_GATT_INTERNAL_ERROR = 0x81, /**< Internal Error */
MICO_BT_GATT_WRONG_STATE = 0x82, /**< Wrong State */
MICO_BT_GATT_DB_FULL = 0x83, /**< DB Full */
MICO_BT_GATT_BUSY = 0x84, /**< Busy */
MICO_BT_GATT_ERROR = 0x85, /**< Error */
MICO_BT_GATT_CMD_STARTED = 0x86, /**< Command Started */
MICO_BT_GATT_PENDING = 0x88, /**< Pending */
MICO_BT_GATT_AUTH_FAIL = 0x89, /**< Authentication Fail */
MICO_BT_GATT_MORE = 0x8a, /**< More */
MICO_BT_GATT_INVALID_CFG = 0x8b, /**< Invalid Configuration */
MICO_BT_GATT_SERVICE_STARTED = 0x8c, /**< Service Started */
MICO_BT_GATT_ENCRYPED_MITM = MICO_BT_GATT_SUCCESS, /**< Encrypted MITM */
MICO_BT_GATT_ENCRYPED_NO_MITM = 0x8d, /**< Encrypted No MITM */
MICO_BT_GATT_NOT_ENCRYPTED = 0x8e, /**< Not Encrypted */
MICO_BT_GATT_CONGESTED = 0x8f, /**< Congested */
/* 0xE0 ~ 0xFC reserved for future use */
MICO_BT_GATT_CCC_CFG_ERR = 0xFD, /**< Improper Client Char Configuration */
MICO_BT_GATT_PRC_IN_PROGRESS = 0xFE, /**< Procedure Already in Progress */
MICO_BT_GATT_OUT_OF_RANGE = 0xFF, /**< Value Out of Range */
};
typedef uint8_t mico_bt_gatt_status_t; /**< GATT status (see #mico_bt_gatt_status_e) */
/** GATT Status Codes*/
enum mico_bt_gatt_app_interface_e
{
GATT_IF_FIXED_DB_GAP = 0x01,
GATT_IF_FIXED_DB_APP = 0x02,
GATT_IF_CLIENT = 0x03,
};
typedef uint8_t mico_bt_gatt_app_interface_t; /**< GATT status (see #mico_bt_gatt_status_e) */
/** GATT Operation Codes */
#define GATT_RSP_ERROR 0x01 /**< Error Response */
#define GATT_REQ_MTU 0x02 /**< Exchange MTU Request */
#define GATT_RSP_MTU 0x03 /**< Exchange MTU Response */
#define GATT_REQ_FIND_INFO 0x04 /**< Find Information Request */
#define GATT_RSP_FIND_INFO 0x05 /**< Find Information Response */
#define GATT_REQ_FIND_TYPE_VALUE 0x06 /**< Find By Type Value Request */
#define GATT_RSP_FIND_TYPE_VALUE 0x07 /**< Find By Type Value Response */
#define GATT_REQ_READ_BY_TYPE 0x08 /**< Read By Type Request */
#define GATT_RSP_READ_BY_TYPE 0x09 /**< Read By Type Response */
#define GATT_REQ_READ 0x0A /**< Read Request */
#define GATT_RSP_READ 0x0B /**< Read Response */
#define GATT_REQ_READ_BLOB 0x0C /**< Read Blob Request */
#define GATT_RSP_READ_BLOB 0x0D /**< Read Blob Response */
#define GATT_REQ_READ_MULTI 0x0E /**< Read Multiple Request */
#define GATT_RSP_READ_MULTI 0x0F /**< Read Multiple Response */
#define GATT_REQ_READ_BY_GRP_TYPE 0x10 /**< Read By Group Type Request */
#define GATT_RSP_READ_BY_GRP_TYPE 0x11 /**< Read By Group Type Response */
#define GATT_REQ_WRITE 0x12 /**< Write Request */
#define GATT_RSP_WRITE 0x13 /**< Write Request */
#define GATT_CMD_WRITE 0x52 /**< Write Command */
#define GATT_REQ_PREPARE_WRITE 0x16 /**< Prepare Write Request */
#define GATT_RSP_PREPARE_WRITE 0x17 /**< Prepare Write Response */
#define GATT_REQ_EXEC_WRITE 0x18 /**< Execute Write Request */
#define GATT_RSP_EXEC_WRITE 0x19 /**< Execute Write Response */
#define GATT_HANDLE_VALUE_NOTIF 0x1B /**< Handle Value Notification */
#define GATT_HANDLE_VALUE_IND 0x1D /**< Handle Value Indication */
#define GATT_HANDLE_VALUE_CONF 0x1E /**< Handle Value Confirmation */
#define GATT_OP_CODE_MAX (GATT_HANDLE_VALUE_CONF + 1) /**< Maximum opcode value */
#define GATT_SIGN_CMD_WRITE 0xD2 /**< changed in V4.0 1101-0010 (signed write) see write cmd above*/
/** GATT Disconnection reason */
enum mico_bt_gatt_disconn_reason_e {
GATT_CONN_UNKNOWN = 0, /**< Unknown reason */
GATT_CONN_L2C_FAILURE = 1, /**< General L2cap failure */
GATT_CONN_TIMEOUT = HCI_ERR_CONNECTION_TOUT, /**< Connection timeout */
GATT_CONN_TERMINATE_PEER_USER = HCI_ERR_PEER_USER, /**< Connection terminated by peer user */
GATT_CONN_TERMINATE_LOCAL_HOST = HCI_ERR_CONN_CAUSE_LOCAL_HOST, /**< Connection terminated by local host */
GATT_CONN_FAIL_ESTABLISH = HCI_ERR_CONN_FAILED_ESTABLISHMENT, /**< Connection fail to establish */
GATT_CONN_LMP_TIMEOUT = HCI_ERR_LMP_RESPONSE_TIMEOUT, /**< Connection fail due to LMP response tout */
GATT_CONN_CANCEL = L2CAP_CONN_CANCEL /**< L2CAP connection cancelled */
};
typedef uint16_t mico_bt_gatt_disconn_reason_t; /**< GATT disconnection reason (see #mico_bt_gatt_disconn_reason_e) */
/* default GATT MTU size over LE link
*/
#define GATT_DEF_BLE_MTU_SIZE 23
/* invalid connection ID
*/
#define GATT_INVALID_CONN_ID 0xFFFF
/** characteristic descriptor: client configuration value */
enum mico_bt_gatt_client_char_config_e
{
GATT_CLIENT_CONFIG_NONE = 0x0000, /**< Does not allow both notifications and indications */
GATT_CLIENT_CONFIG_NOTIFICATION = 0x0001, /**< Allows notifications */
GATT_CLIENT_CONFIG_INDICATION = 0x0002 /**< Allows indications */
};
typedef uint16_t mico_bt_gatt_client_char_config_t; /**< GATT client config (see #mico_bt_gatt_client_char_config_e) */
/** characteristic descriptor: server configuration value */
#define GATT_SERVER_CONFIG_NONE 0x0000 /**< No broadcast */
#define GATT_SERVER_CONFIG_BROADCAST 0x0001 /**< Broadcast */
typedef uint16_t mico_bt_gatt_server_char_config_t; /**< GATT server config (see #mico_bt_gatt_server_char_config_e) */
/** GATT Characteristic Properties Mask */
enum mico_bt_gatt_char_properties_e {
GATT_CHAR_PROPERTIES_BIT_BROADCAST = (1 << 0), /**< bit 0: Broadcast */
GATT_CHAR_PROPERTIES_BIT_READ = (1 << 1), /**< bit 1: Read */
GATT_CHAR_PROPERTIES_BIT_WRITE_NR = (1 << 2), /**< bit 2: Write (No Response) */
GATT_CHAR_PROPERTIES_BIT_WRITE = (1 << 3), /**< bit 3: Write */
GATT_CHAR_PROPERTIES_BIT_NOTIFY = (1 << 4), /**< bit 4: Notify */
GATT_CHAR_PROPERTIES_BIT_INDICATE = (1 << 5), /**< bit 5: Indicate */
GATT_CHAR_PROPERTIES_BIT_AUTH = (1 << 6), /**< bit 6: Authenticate */
GATT_CHAR_PROPERTIES_BIT_EXT_PROP = (1 << 7) /**< bit 7: Extended Properties */
};
typedef uint8_t mico_bt_gatt_char_properties_t; /**< GATT characteristic properties mask (see #mico_bt_gatt_char_properties_e) */
/*************************************************************************
* Macros for parsing results GATT discovery results
* (while handling GATT_DISCOVERY_RESULT_EVT)
****************************************************************************/
/* Discovery type: GATT_DISCOVER_SERVICES_ALL or GATT_DISCOVER_SERVICES_BY_UUID */
#define GATT_DISCOVERY_RESULT_SERVICE_START_HANDLE(p_event_data) (p_event_data->discovery_result.discovery_data.group_value.s_handle)
#define GATT_DISCOVERY_RESULT_SERVICE_END_HANDLE(p_event_data) (p_event_data->discovery_result.discovery_data.group_value.e_handle)
#define GATT_DISCOVERY_RESULT_SERVICE_UUID_LEN(p_event_data) (p_event_data->discovery_result.discovery_data.group_value.service_type.len)
#define GATT_DISCOVERY_RESULT_SERVICE_UUID16(p_event_data) (p_event_data->discovery_result.discovery_data.group_value.service_type.uu.uuid16)
#define GATT_DISCOVERY_RESULT_SERVICE_UUID32(p_event_data) (p_event_data->discovery_result.discovery_data.group_value.service_type.uu.uuid32)
#define GATT_DISCOVERY_RESULT_SERVICE_UUID128(p_event_data) (p_event_data->discovery_result.discovery_data.group_value.service_type.uu.uuid128)
/* Discovery type: GATT_DISCOVER_CHARACTERISTIC_DESCRIPTORS */
#define GATT_DISCOVERY_RESULT_CHARACTERISTIC_DESCRIPTOR_UUID_LEN(p_event_data) (p_event_data->discovery_result.discovery_data.char_descr_info.type.len)
#define GATT_DISCOVERY_RESULT_CHARACTERISTIC_DESCRIPTOR_UUID16(p_event_data) (p_event_data->discovery_result.discovery_data.char_descr_info.type.uu.uuid16)
#define GATT_DISCOVERY_RESULT_CHARACTERISTIC_DESCRIPTOR_UUID32(p_event_data) (p_event_data->discovery_result.discovery_data.char_descr_info.type.uu.uuid32)
#define GATT_DISCOVERY_RESULT_CHARACTERISTIC_DESCRIPTOR_UUID128(p_event_data) (p_event_data->discovery_result.discovery_data.char_descr_info.type.uu.uuid128)
#define GATT_DISCOVERY_RESULT_CHARACTERISTIC_DESCRIPTOR_VALUE_HANDLE(p_event_data) (p_event_data->discovery_result.discovery_data.char_descr_info.handle)
/* Discovery type: GATT_DISCOVER_CHARACTERISTICS */
#define GATT_DISCOVERY_RESULT_CHARACTERISTIC_VALUE_HANDLE(p_event_data) (p_event_data->discovery_result.discovery_data.characteristic_declaration.val_handle)
#define GATT_DISCOVERY_RESULT_CHARACTERISTIC_UUID_LEN(p_event_data) (p_event_data->discovery_result.discovery_data.characteristic_declaration.char_uuid.len)
#define GATT_DISCOVERY_RESULT_CHARACTERISTIC_UUID16(p_event_data) (p_event_data->discovery_result.discovery_data.characteristic_declaration.char_uuid.uu.uuid16)
#define GATT_DISCOVERY_RESULT_CHARACTERISTIC_UUID32(p_event_data) (p_event_data->discovery_result.discovery_data.characteristic_declaration.char_uuid.uu.uuid32)
#define GATT_DISCOVERY_RESULT_CHARACTERISTIC_UUID128(p_event_data) (p_event_data->discovery_result.discovery_data.characteristic_declaration.char_uuid.uu.uuid128)
/** Authentication requirement */
enum mico_bt_gatt_auth_req_e {
GATT_AUTH_REQ_NONE = 0, /**< No Authentication Required */
GATT_AUTH_REQ_NO_MITM = 1, /**< Unauthenticated encryption (No MITM) */
GATT_AUTH_REQ_MITM = 2, /**< Authenticated encryption (MITM) */
GATT_AUTH_REQ_SIGNED_NO_MITM = 3, /**< Signed Data (No MITM) */
GATT_AUTH_REQ_SIGNED_MITM = 4 /**< Signed Data (MITM) */
};
typedef uint8_t mico_bt_gatt_auth_req_t; /**< GATT authentication requirement (see #mico_bt_gatt_auth_req_e)*/
/** Attribute value, used for GATT write operations, and read response callbacks */
typedef struct
{
uint16_t handle; /**< Attribute handle */
uint16_t offset; /**< Attribute value offset, ignored if not needed for a command */
uint16_t len; /**< Length of attribute value */
mico_bt_gatt_auth_req_t auth_req; /**< Authentication requirement (see @link mico_bt_gatt_auth_req_e mico_bt_gatt_auth_req_t @endlink) */
uint8_t value[1]; /**< The attribute value (actual length is specified by 'len') */
} mico_bt_gatt_value_t;
/** GATT Write Execute request flags */
enum mico_bt_gatt_exec_flag_e {
GATT_PREP_WRITE_CANCEL = 0x00, /**< GATT_PREP_WRITE_CANCEL */
GATT_PREP_WRITE_EXEC = 0x01 /**< GATT_PREP_WRITE_EXEC */
};
typedef uint8_t mico_bt_gatt_exec_flag_t; /**< GATT execute flag (see #mico_bt_gatt_exec_flag_e) */
/** Attribute read request */
typedef struct
{
uint16_t handle; /**< Handle of attribute to read */
uint16_t offset; /**< Offset to read */
mico_bool_t is_long; /**< TRUE if long read */
uint16_t *p_val_len; /**< input and output parameter for value length */
uint8_t *p_val; /**< Value pointer */
} mico_bt_gatt_read_t;
/** Attribute write request */
typedef struct
{
uint16_t handle; /**< Handle of attribute to read */
mico_bool_t is_prep; /**< TRUE if this is a prepare write request */
uint16_t offset; /**< Offset to write */
uint16_t val_len; /**< Value length */
uint8_t *p_val; /**< Value pointer */
} mico_bt_gatt_write_t;
/** Attribute information for GATT attribute requests */
typedef union
{
mico_bt_gatt_read_t read_req; /**< Parameters for GATTS_REQ_TYPE_READ */
mico_bt_gatt_write_t write_req; /**< Parameters for GATTS_REQ_TYPE_WRITE */
uint16_t handle; /**< Parameters for GATTS_REQ_TYPE_CONF */
uint16_t mtu; /**< Parameters for GATTS_REQ_TYPE_MTU */
mico_bt_gatt_exec_flag_t exec_write; /**< Parameters for GATTS_REQ_TYPE_WRITE_EXEC */
} mico_bt_gatt_request_data_t;
/** GATT Attribute Request Type */
enum mico_bt_gatt_request_type_e
{
GATTS_REQ_TYPE_READ = 1, /**< Attribute read notification (attribute value internally read from GATT database) */
GATTS_REQ_TYPE_WRITE, /**< Attribute write notification (attribute value internally written to GATT database) */
GATTS_REQ_TYPE_PREP_WRITE, /**< Attribute Prepare Write Notification (Suspending write request before triggering actual execute write ) */
GATTS_REQ_TYPE_WRITE_EXEC, /**< Execute write request */
GATTS_REQ_TYPE_MTU, /**< MTU exchange information */
GATTS_REQ_TYPE_CONF, /**< Value confirmation */
};
typedef uint8_t mico_bt_gatt_request_type_t; /**< GATT Attribute Request Type (see #mico_bt_gatt_request_type_e) */
/** Discovery types */
enum mico_bt_gatt_discovery_type_e
{
GATT_DISCOVER_SERVICES_ALL = 1, /**< discover all services */
GATT_DISCOVER_SERVICES_BY_UUID, /**< discover service by UUID */
GATT_DISCOVER_INCLUDED_SERVICES, /**< discover an included service within a service */
GATT_DISCOVER_CHARACTERISTICS, /**< discover characteristics of a service with/without type requirement */
GATT_DISCOVER_CHARACTERISTIC_DESCRIPTORS, /**< discover characteristic descriptors of a character */
GATT_DISCOVER_MAX /* maximum discovery types */
};
typedef uint8_t mico_bt_gatt_discovery_type_t; /**< GATT Discovery type (see #mico_bt_gatt_discovery_type_e) */
/** Parameters used in a GATT Discovery */
typedef struct
{
mico_bt_uuid_t uuid; /**< Service or Characteristic UUID */
uint16_t s_handle; /**< Start handle for range to search */
uint16_t e_handle; /**< End handle for range to search */
}mico_bt_gatt_discovery_param_t;
/** GATT Read Types */
enum mico_bt_gatt_read_type_e
{
GATT_READ_BY_TYPE = 1, /**< Read by Type (service or characteristic UUIDs) */
GATT_READ_BY_HANDLE, /**< Read by Handle */
GATT_READ_MULTIPLE, /**< Read Multiple (array of handles) */
GATT_READ_CHAR_VALUE, /**< Read Characteristic Value */
GATT_READ_PARTIAL, /**< Read Partial */
GATT_READ_MAX
};
typedef uint8_t mico_bt_gatt_read_type_t; /**< GATT read type (see #mico_bt_gatt_read_type_e) */
/** Parameters for GATT_READ_BY_TYPE and GATT_READ_CHAR_VALUE */
typedef struct
{
mico_bt_gatt_auth_req_t auth_req; /**< Authentication requirement (see @link mico_bt_gatt_auth_req_e mico_bt_gatt_auth_req_t @endlink) */
uint16_t s_handle; /**< Starting handle */
uint16_t e_handle; /**< Ending handle */
mico_bt_uuid_t uuid; /**< uuid */
} mico_bt_gatt_read_by_type_t;
#define GATT_MAX_READ_MULTI_HANDLES 10 /**< Max attributes allowed in one GATT_READ_MULTIPLE request */
/** Parameters for GATT_READ_MULTIPLE */
typedef struct
{
mico_bt_gatt_auth_req_t auth_req; /**< authentication requirement (see @link mico_bt_gatt_auth_req_e mico_bt_gatt_auth_req_t @endlink) */
uint16_t num_handles; /**< number of handles to read */
uint16_t handles[GATT_MAX_READ_MULTI_HANDLES]; /**< handles list to be read */
} mico_bt_gatt_read_multi_t;
/** Parameters for GATT_READ_BY_HANDLE */
typedef struct
{
mico_bt_gatt_auth_req_t auth_req; /**< authentication requirement (see @link mico_bt_gatt_auth_req_e mico_bt_gatt_auth_req_t @endlink) */
uint16_t handle; /**< handle */
} mico_bt_gatt_read_by_handle_t;
/** Parameters for GATT_READ_PARTIAL */
typedef struct
{
mico_bt_gatt_auth_req_t auth_req; /**< authentication requirement (see @link mico_bt_gatt_auth_req_e mico_bt_gatt_auth_req_t @endlink) */
uint16_t handle; /**< handle */
uint16_t offset; /**< offset */
} mico_bt_gatt_read_partial_t;
/** Read request parameters - used when calling #mico_bt_gatt_send_read */
typedef union
{
mico_bt_gatt_read_by_type_t service; /**< Parameters for GATT_READ_BY_TYPE */
mico_bt_gatt_read_by_type_t char_type; /**< Parameters for GATT_READ_CHAR_VALUE */
mico_bt_gatt_read_multi_t read_multiple; /**< Parameters for GATT_READ_MULTIPLE */
mico_bt_gatt_read_by_handle_t by_handle; /**< Parameters for GATT_READ_BY_HANDLE */
mico_bt_gatt_read_partial_t partial; /**< Parameters for GATT_READ_PARTIAL */
} mico_bt_gatt_read_param_t;
/** Write request types - used when calling #mico_bt_gatt_send_write */
enum mico_bt_gatt_write_type_e
{
GATT_WRITE_NO_RSP = 1, /**< Write without response */
GATT_WRITE, /**< Write with response */
GATT_WRITE_PREPARE /**< Prepare to write (call #mico_bt_gatt_send_execute_write to execute the write) */
};
typedef uint8_t mico_bt_gatt_write_type_t; /**< GATT write type (see #mico_bt_gatt_write_type_e) */
/** Response data for read operations */
typedef struct
{
uint16_t handle; /**< handle */
uint16_t len; /**< length of response data */
uint16_t offset; /**< offset */
uint8_t *p_data; /**< attribute data */
} mico_bt_gatt_data_t;
/** Client Operation Complete response data (dependent on operation completed) */
typedef union
{
mico_bt_gatt_data_t att_value; /**< Response data for read operations (initiated using #mico_bt_gatt_send_read) */
uint16_t mtu; /**< Response data for configuration operations */
uint16_t handle; /**< Response data for write operations (initiated using #mico_bt_gatt_send_write) */
} mico_bt_gatt_operation_complete_rsp_t; /**< GATT operation complete response type */
/** GATT client operation type, used in client callback function
*/
enum mico_bt_gatt_optype_e
{
GATTC_OPTYPE_NONE = 0, /**< None */
GATTC_OPTYPE_DISCOVERY = 1, /**< Discovery */
GATTC_OPTYPE_READ = 2, /**< Read */
GATTC_OPTYPE_WRITE = 3, /**< Write */
GATTC_OPTYPE_EXE_WRITE = 4, /**< Execute Write */
GATTC_OPTYPE_CONFIG = 5, /**< Configure */
GATTC_OPTYPE_NOTIFICATION = 6, /**< Notification */
GATTC_OPTYPE_INDICATION = 7 /**< Indication */
};
/* GATT Client Operation Codes */
typedef uint8_t mico_bt_gatt_optype_t; /**< GATT operation type (see #mico_bt_gatt_optype_e) */
/** characteristic declaration */
typedef struct
{
mico_bt_gatt_char_properties_t characteristic_properties; /**< characteristic properties (see @link mico_bt_gatt_char_properties_e mico_bt_gatt_char_properties_t @endlink) */
uint16_t val_handle; /**< characteristic value attribute handle */
uint16_t handle; /**< characteristic declaration handle */
mico_bt_uuid_t char_uuid; /**< characteristic UUID type */
} mico_bt_gatt_char_declaration_t;
/** GATT group value */
typedef struct
{
mico_bt_uuid_t service_type; /**< group type */
uint16_t s_handle; /**< starting handle of the group */
uint16_t e_handle; /**< ending handle of the group */
} mico_bt_gatt_group_value_t;
/** included service attribute value */
typedef struct
{
mico_bt_uuid_t service_type; /**< included service UUID */
uint16_t handle; /**< included service handle */
uint16_t s_handle; /**< starting handle */
uint16_t e_handle; /**< ending handle */
} mico_bt_gatt_included_service_t;
/** characteristic descriptor information */
typedef struct
{
mico_bt_uuid_t type; /**< descriptor UUID type */
uint16_t handle; /**< descriptor attribute handle */
}mico_bt_gatt_char_descr_info_t;
/**
* Discovery result data
* Use GATT_DISCOVERY_RESULT_SERVICE_* or GATT_DISCOVERY_RESULT_CHARACTERISTIC_* macros to parse discovery data)
*/
typedef union
{
mico_bt_gatt_included_service_t included_service; /**< Result for GATT_DISCOVER_INCLUDED_SERVICES */
mico_bt_gatt_group_value_t group_value; /**< Result for GATT_DISCOVER_SERVICES_ALL or GATT_DISCOVER_SERVICES_BY_UUID */
mico_bt_gatt_char_declaration_t characteristic_declaration; /**< Result for GATT_DISCOVER_CHARACTERISTICS */
mico_bt_gatt_char_descr_info_t char_descr_info; /**< Result for GATT_DISCOVER_CHARACTERISTIC_DESCRIPTORS */
} mico_bt_gatt_discovery_data_t;
#define GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP 0 /* start a idle timer for this duration when no application need to use the link */
#define GATT_LINK_NO_IDLE_TIMEOUT 0xFFFF
#define GATT_INVALID_ACL_HANDLE 0xFFFF
#define GATT_HANDLE_IS_VALID(x) ((x) != 0)
typedef uint16_t mico_bt_gatt_appearance_t; /**< GATT appearance (see #gatt_appearance_e) */
/*****************************************************************************
* GATT Database Defintions
*****************************************************************************/
/* The permission bits (see Vol 3, Part F, 3.3.1.1) */
#define LEGATTDB_PERM_NONE (0x00)
#define LEGATTDB_PERM_VARIABLE_LENGTH (0x1 << 0)
#define LEGATTDB_PERM_READABLE (0x1 << 1)
#define LEGATTDB_PERM_WRITE_CMD (0x1 << 2)
#define LEGATTDB_PERM_WRITE_REQ (0x1 << 3)
#define LEGATTDB_PERM_AUTH_READABLE (0x1 << 4)
#define LEGATTDB_PERM_RELIABLE_WRITE (0x1 << 5)
#define LEGATTDB_PERM_AUTH_WRITABLE (0x1 << 6)
#define LEGATTDB_PERM_WRITABLE (LEGATTDB_PERM_WRITE_CMD | LEGATTDB_PERM_WRITE_REQ| LEGATTDB_PERM_AUTH_WRITABLE)
#define LEGATTDB_PERM_MASK (0x7f) /* All the permission bits. */
#define LEGATTDB_PERM_SERVICE_UUID_128 (0x1 << 7)
/* GATT Characteristic Properties */
#define LEGATTDB_CHAR_PROP_BROADCAST (0x1 << 0)
#define LEGATTDB_CHAR_PROP_READ (0x1 << 1)
#define LEGATTDB_CHAR_PROP_WRITE_NO_RESPONSE (0x1 << 2)
#define LEGATTDB_CHAR_PROP_WRITE (0x1 << 3)
#define LEGATTDB_CHAR_PROP_NOTIFY (0x1 << 4)
#define LEGATTDB_CHAR_PROP_INDICATE (0x1 << 5)
#define LEGATTDB_CHAR_PROP_AUTHD_WRITES (0x1 << 6)
#define LEGATTDB_CHAR_PROP_EXTENDED (0x1 << 7)
/* Conversion macros */
#define BIT16_TO_8( val ) \
(uint8_t)( (val) & 0xff),/* LSB */ \
(uint8_t)(( (val) >> 8 ) & 0xff) /* MSB */
/* UUID lengths */
#define LEGATTDB_UUID16_SIZE 2
#define LEGATTDB_UUID128_SIZE 16
/* Service and Characteristic macros */
#define ATTRIBUTE16( handle, permission, datalen, uuid ) \
BIT16_TO_8(handle), \
(uint8_t)(permission), \
(uint8_t)(datalen + 2), \
BIT16_TO_8(uuid)
#define PRIMARY_SERVICE_UUID16(handle, service) \
BIT16_TO_8((uint16_t)(handle)), \
LEGATTDB_PERM_READABLE, \
4, \
BIT16_TO_8((GATT_UUID_PRI_SERVICE)), \
BIT16_TO_8((service))
#define PRIMARY_SERVICE_UUID128(handle, service) \
BIT16_TO_8((uint16_t)(handle)), \
LEGATTDB_PERM_READABLE, \
18, \
BIT16_TO_8(GATT_UUID_PRI_SERVICE), \
service
#define SECONDARY_SERVICE_UUID16(handle, service) \
BIT16_TO_8((uint16_t)(handle)), \
LEGATTDB_PERM_READABLE, \
4, \
BIT16_TO_8((GATT_UUID_SEC_SERVICE)), \
BIT16_TO_8((service))
#define SECONDARY_SERVICE_UUID128(handle, service) \
BIT16_TO_8((uint16_t)(handle)), \
LEGATTDB_PERM_READABLE, \
18, \
BIT16_TO_8(GATT_UUID_SEC_SERVICE), \
service
#define INCLUDE_SERVICE_UUID16(handle, service_handle, end_group_handle, service) \
BIT16_TO_8((uint16_t)(handle)), \
LEGATTDB_PERM_READABLE, \
8, \
BIT16_TO_8(GATT_UUID_INCLUDE_SERVICE), \
BIT16_TO_8(service_handle), \
BIT16_TO_8(end_group_handle), \
BIT16_TO_8(service)
#define INCLUDE_SERVICE_UUID128(handle, service_handle, end_group_handle)\
BIT16_TO_8((uint16_t)(handle)), \
LEGATTDB_PERM_READABLE, \
6, \
BIT16_TO_8(GATT_UUID_INCLUDE_SERVICE), \
BIT16_TO_8(service_handle), \
BIT16_TO_8(end_group_handle)
#define CHARACTERISTIC_UUID16(handle, handle_value, uuid, properties, permission) \
BIT16_TO_8((uint16_t)(handle)), \
LEGATTDB_PERM_READABLE, \
0x07, \
BIT16_TO_8(GATT_UUID_CHAR_DECLARE), \
(uint8_t)(properties), \
BIT16_TO_8((uint16_t)(handle_value)), \
BIT16_TO_8(uuid), \
BIT16_TO_8((uint16_t)(handle_value)), \
(uint8_t)(permission), \
(uint8_t)(LEGATTDB_UUID16_SIZE), \
BIT16_TO_8(uuid)
#define CHARACTERISTIC_UUID128(handle, handle_value, uuid, properties, permission) \
BIT16_TO_8((uint16_t)(handle)), \
LEGATTDB_PERM_READABLE, \
21, \
BIT16_TO_8(GATT_UUID_CHAR_DECLARE), \
(uint8_t)(properties), \
BIT16_TO_8((uint16_t)(handle_value)), \
uuid, \
BIT16_TO_8((uint16_t)(handle_value)), \
(uint8_t)(permission | LEGATTDB_PERM_SERVICE_UUID_128), \
(uint8_t)(LEGATTDB_UUID128_SIZE), \
uuid
#define CHARACTERISTIC_UUID16_WRITABLE(handle, handle_value, uuid, properties, permission) \
BIT16_TO_8((uint16_t)(handle)), \
LEGATTDB_PERM_READABLE, \
0x07, \
BIT16_TO_8(GATT_UUID_CHAR_DECLARE), \
(uint8_t)(properties), \
BIT16_TO_8((uint16_t)(handle_value)), \
BIT16_TO_8(uuid), \
BIT16_TO_8((uint16_t)(handle_value)), \
(uint8_t)(permission), \
(uint8_t)(LEGATTDB_UUID16_SIZE), \
(uint8_t)(0), \
BIT16_TO_8(uuid)
#define CHARACTERISTIC_UUID128_WRITABLE(handle, handle_value, uuid, properties, permission) \
BIT16_TO_8((uint16_t)(handle)), \
LEGATTDB_PERM_READABLE, \
21, \
BIT16_TO_8(GATT_UUID_CHAR_DECLARE), \
(uint8_t)(properties), \
BIT16_TO_8((uint16_t)(handle_value)), \
uuid, \
BIT16_TO_8((uint16_t)(handle_value)), \
(uint8_t)(permission | LEGATTDB_PERM_SERVICE_UUID_128), \
(uint8_t)(LEGATTDB_UUID128_SIZE), \
(uint8_t)(0), \
uuid
#define CHAR_DESCRIPTOR_UUID16_WRITABLE(handle, uuid, permission) \
BIT16_TO_8((uint16_t)(handle)), \
(uint8_t)(permission), \
(uint8_t)(LEGATTDB_UUID16_SIZE), \
(uint8_t)(0), \
BIT16_TO_8(uuid)
#define CHAR_DESCRIPTOR_UUID16(handle, uuid, permission) \
BIT16_TO_8((uint16_t)(handle)), \
(uint8_t)(permission), \
(uint8_t)(LEGATTDB_UUID16_SIZE), \
BIT16_TO_8(uuid)
/** GATT events */
typedef enum
{
GATT_CONNECTION_STATUS_EVT, /**< GATT connection status change. Event data: #mico_bt_gatt_connection_status_t */
GATT_OPERATION_CPLT_EVT, /**< GATT operation complete. Event data: #mico_bt_gatt_event_data_t */
GATT_DISCOVERY_RESULT_EVT, /**< GATT attribute discovery result. Event data: #mico_bt_gatt_discovery_result_t */
GATT_DISCOVERY_CPLT_EVT, /**< GATT attribute discovery complete. Event data: #mico_bt_gatt_event_data_t */
GATT_ATTRIBUTE_REQUEST_EVT /**< GATT attribute request (from remote client). Event data: #mico_bt_gatt_attribute_request_t */
} mico_bt_gatt_evt_t;
/** Discovery result (used by GATT_DISCOVERY_RESULT_EVT notification) */
typedef struct
{
uint16_t conn_id; /**< ID of the connection */
mico_bt_gatt_discovery_type_t discovery_type; /**< Discovery type (see @link mico_bt_gatt_discovery_type_e mico_bt_gatt_discovery_type_t @endlink) */
mico_bt_gatt_discovery_data_t discovery_data; /**< Discovery data */
} mico_bt_gatt_discovery_result_t;
/** Discovery Complete (used by GATT_DISCOVERY_CPLT_EVT notification) */
typedef struct
{
uint16_t conn_id; /**< ID of the connection */
mico_bt_gatt_discovery_type_t disc_type; /**< Discovery type (see @link mico_bt_gatt_discovery_type_e mico_bt_gatt_discovery_type_t @endlink) */
mico_bt_gatt_status_t status; /**< Status of operation */
} mico_bt_gatt_discovery_complete_t;
/** Response to read/write/disc/config operations (used by GATT_OPERATION_CPLT_EVT notification) */
typedef struct
{
uint16_t conn_id; /**< ID of the connection */
mico_bt_gatt_optype_t op; /**< Type of operation completed (see @link mico_bt_gatt_optype_e mico_bt_gatt_optype_t @endlink) */
mico_bt_gatt_status_t status; /**< Status of operation */
mico_bt_gatt_operation_complete_rsp_t response_data; /**< Response data (dependent on optype) */
} mico_bt_gatt_operation_complete_t;
/** GATT connection status (used by GATT_CONNECTION_STATUS_EVT notification) */
typedef struct
{
uint8_t *bd_addr; /**< Remote device address */
mico_bt_ble_address_type_t addr_type; /**< Remmote device address type */
uint16_t conn_id; /**< ID of the connection */
mico_bool_t connected; /**< TRUE if connected, FALSE if disconnected */
mico_bt_gatt_disconn_reason_t reason; /**< Reason code (see @link mico_bt_gatt_disconn_reason_e mico_bt_gatt_disconn_reason_t @endlink) */
mico_bt_transport_t transport; /**< Transport type of the connection */
uint8_t link_role; /**< Link role on this connection */
} mico_bt_gatt_connection_status_t;
/** GATT attribute request (used by GATT_ATTRIBUTE_REQUEST_EVT notification) */
typedef struct
{
uint16_t conn_id; /**< ID of the connection */
mico_bt_gatt_request_type_t request_type; /**< Request type (see @link mico_bt_gatt_request_type_e mico_bt_gatt_request_type_t) */
mico_bt_gatt_request_data_t data; /**< Information about attribute being request (dependent on request type) */
} mico_bt_gatt_attribute_request_t;
/** Stuctures for GATT event notifications */
typedef union
{
mico_bt_gatt_discovery_result_t discovery_result; /**< Data for GATT_DISCOVERY_RESULT_EVT */
mico_bt_gatt_discovery_complete_t discovery_complete; /**< Data for GATT_DISCOVERY_CPLT_EVT */
mico_bt_gatt_operation_complete_t operation_complete; /**< Data for GATT_OPERATION_CPLT_EVT */
mico_bt_gatt_connection_status_t connection_status; /**< Data for GATT_CONNECTION_STATUS_EVT */
mico_bt_gatt_attribute_request_t attribute_request; /**< Data for GATT_ATTRIBUTE_REQUEST_EVT */
} mico_bt_gatt_event_data_t;
/**
* GATT event notification callback
*
* Callback for GATT event notifications
* Registered using mico_bt_gatt_register()
*
* @param event : Event ID
* @param p_event_data : Event data
*
* @return Status of event handling
*/
typedef mico_bt_gatt_status_t mico_bt_gatt_cback_t(mico_bt_gatt_evt_t event, mico_bt_gatt_event_data_t *p_event_data);
/*****************************************************************************
* External Function Declarations
****************************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @addtogroup micobt_gatt Generic Attribute (GATT)
* @ingroup micobt
*
* Generic Attribute (GATT) Functions.
*
* @{
*/
/****************************************************************************/
/**
* GATT Profile Server Functions
*
* @addtogroup server_api_functions Server
* @ingroup micobt_gatt
*
* <b> Server API Functions </b> sub module for @b GATT.
*
* @{
*/
/****************************************************************************/
/**
* Function mico_bt_gatt_db_init
*
* Initialize the GATT database
*
* @param[in] p_gatt_db : First element in GATT database array
* @param[in] gatt_db_size : Size (in bytes) of GATT database
*
* @return @link mico_bt_gatt_status_e mico_bt_gatt_status_t @endlink
*
*/
mico_bt_gatt_status_t mico_bt_gatt_db_init (const uint8_t *p_gatt_db, uint16_t gatt_db_size);
/**
*
* Function mico_bt_gatt_send_indication
*
* Send a handle value indication to a client
*
* @param[in] conn_id : connection identifier.
* @param[in] attr_handle : Attribute handle of this handle value indication.
* @param[in] val_len : Length of notification value passed, and return the length actually.
* @param[in] p_val : Notification Value.
*
* @return @link mico_bt_gatt_status_e mico_bt_gatt_status_t @endlink
*
*/
mico_bt_gatt_status_t mico_bt_gatt_send_indication (uint16_t conn_id, uint16_t attr_handle, uint16_t *val_len, uint8_t *p_val );
/**
* Function mico_bt_gatt_send_notification
*
* Send a handle value notification to a client.
*
* @param[in] conn_id : connection identifier.
* @param[in] attr_handle : Attribute handle of this handle value indication.
* @param[in] val_len : Length of notification value passed, and return the length actually.
* @param[in] p_val : Notification Value.
*
* @return @link mico_bt_gatt_status_e mico_bt_gatt_status_t @endlink
*
*/
mico_bt_gatt_status_t mico_bt_gatt_send_notification (uint16_t conn_id, uint16_t attr_handle, uint16_t *val_len, uint8_t *p_val );
/**
* Function mico_bt_gatt_send_response
*
* When application receives a Read Request, Write Request or Indication from the
* peer it can reply synchronously or return a MICO_BT_GATT_PENDING result code
* indicating to the stack that the message is not processed yet. In that case
* application should call this function to send data or just a confirmation to
* the peer.
*
* @param[in] status : Status of the operation to be send to the peer
* @param[in] conn_id : Connection handle
* @param[in] attr_handle : Attribute handle
* @param[in] attr_len : Length of the attribute to send
* @param[in] offset : Attribute value offset
* @param[in] p_attr : Attribute Value
*
* @return @link mico_bt_gatt_status_e mico_bt_gatt_status_t @endlink
*/
mico_bt_gatt_status_t mico_bt_gatt_send_response(mico_bt_gatt_status_t status, uint16_t conn_id,
uint16_t attr_handle, uint16_t attr_len, uint16_t offset, uint8_t* p_attr);
/**@} server_api_functions */
/*****************************************************************************/
/**
* GATT Profile Client Functions
*
* @addtogroup client_api_functions Client
* @ingroup micobt_gatt
*
* @{
*/
/*****************************************************************************/
/**
* Function mico_bt_gatt_configure_mtu
*
* Configure the ATT MTU size for a connection on an LE
* transport.
*
* @param[in] conn_id : GATT connection handle
* @param[in] mtu : New MTU size
*
* @return @link mico_bt_gatt_status_e mico_bt_gatt_status_t @endlink
*/
mico_bt_gatt_status_t mico_bt_gatt_configure_mtu (uint16_t conn_id, uint16_t mtu);
/**
* Function mico_bt_gatt_send_discover
*
* Start an attribute discovery on an ATT server.
* Discovery results are notified using <b> GATT_DISCOVERY_RESULT_EVT </b>;
* completion is notified using <b> GATT_DISCOVERY_CPLT_EVT </b> of #mico_bt_gatt_cback_t.
*
* @param[in] conn_id : GATT connection handle
* @param[in] discovery_type : Discover type
* @param[in] p_discovery_param : Discover parameter
*
* @return @link mico_bt_gatt_status_e mico_bt_gatt_status_t @endlink
*/
mico_bt_gatt_status_t mico_bt_gatt_send_discover (uint16_t conn_id,
mico_bt_gatt_discovery_type_t discovery_type,
mico_bt_gatt_discovery_param_t *p_discovery_param );
/**
* Function mico_bt_gatt_send_read
*
* Read from remote ATT server.
* Result is notified using <b> GATT_OPERATION_CPLT_EVT </b> of #mico_bt_gatt_cback_t.
*
* @param[in] conn_id : Connection handle
* @param[in] type : Type of the read
* @param[in] p_read : Pointer to the read request parameters
*
* @return @link mico_bt_gatt_status_e mico_bt_gatt_status_t @endlink
*
*/
mico_bt_gatt_status_t mico_bt_gatt_send_read (uint16_t conn_id, mico_bt_gatt_read_type_t type,
mico_bt_gatt_read_param_t *p_read);
/**
* Function mico_bt_gatt_send_write
*
* Write to remote ATT server.
* Result is notified using <b> GATT_OPERATION_CPLT_EVT </b> of #mico_bt_gatt_cback_t.
*
* @param[in] conn_id : Connection handle
* @param[in] type : Type of write
* @param[in] p_write : Pointer to the write parameters
*
* @return @link mico_bt_gatt_status_e mico_bt_gatt_status_t @endlink
*/
mico_bt_gatt_status_t mico_bt_gatt_send_write (uint16_t conn_id, mico_bt_gatt_write_type_t type,
mico_bt_gatt_value_t *p_write);
/**
* Function mico_bt_gatt_send_execute_write
*
* Send Execute Write request to remote ATT server.
*
* @param[in] conn_id : Connection handle
* @param[in] is_execute : <b>MICO_BT_TRUE </b> to execute, <b> MICO_BT_FALSE </b> to cancel
*
* @return @link mico_bt_gatt_status_e mico_bt_gatt_status_t @endlink
*
*/
mico_bt_gatt_status_t mico_bt_gatt_send_execute_write (uint16_t conn_id, mico_bool_t is_execute);
/**
* Function mico_bt_gatt_send_indication_confirm
*
* Send a handle value confirmation to remote ATT server.
* (in response to <b>GATTC_OPTYPE_INDICATION </b> of #mico_bt_gatt_cback_t)
*
* @param[in] conn_id : Connection handle
* @param[in] handle : Attribute handle
*
* @return @link mico_bt_gatt_status_e mico_bt_gatt_status_t @endlink
*/
mico_bt_gatt_status_t mico_bt_gatt_send_indication_confirm (uint16_t conn_id, uint16_t handle);
/**@} client_api_functions */
/*****************************************************************************/
/**
* GATT Profile Common Functions
*
* @addtogroup common_api_functions Common
* @ingroup micobt_gatt
*
* @{
*/
/*****************************************************************************/
/**
* Function mico_bt_gatt_register
*
* Register an application callback for GATT.
*
* @param[in] gatt_if : The GATT application interface
* @param[in] p_gatt_cback : The GATT notification callback
*
* @return @link mico_bt_gatt_status_e mico_bt_gatt_status_t @endlink
*
*/
mico_bt_gatt_status_t mico_bt_gatt_register (mico_bt_gatt_app_interface_t gatt_if, mico_bt_gatt_cback_t *p_gatt_cback);
/**
* Function mico_bt_gatt_deregister
*
* Deregister an application callback for GATT.
*
* @param[in] gatt_if : The GATT application interface
*
* @return @link mico_bt_gatt_status_e mico_bt_gatt_status_t @endlink
*
*/
mico_bt_gatt_status_t mico_bt_gatt_deregister (mico_bt_gatt_app_interface_t gatt_if);
/**
* Function mico_bt_gatt_le_connect
*
* Open GATT over LE connection to a remote device
* Result is notified using <b> GATT_CONNECTION_STATUS_EVT </b> of #mico_bt_gatt_cback_t.
*
* @param[in] bd_addr : Remote device address
* @param[in] bd_addr_type: Public or random address
* @param[in] conn_mode : connection scan mode
* @param[in] is_direct : Is direct connection or not
*
* @return <b> TRUE </b> : If connection started
* <b> FALSE </b> : If connection start failure
*
*/
mico_bool_t mico_bt_gatt_le_connect (mico_bt_device_address_t bd_addr,
mico_bt_ble_address_type_t bd_addr_type,
mico_bt_ble_conn_mode_t conn_mode,
mico_bool_t is_direct);
/**
* Function mico_bt_gatt_bredr_connect
*
* Open GATT over BR/EDR connection to a remote device
* Result is notified using <b> GATT_CONNECTION_STATUS_EVT </b> of #mico_bt_gatt_cback_t.
*
* @param[in] bd_addr : Remote device address
*
* @return <b> TRUE </b> : If connection started
* <b> FALSE </b> : If connection start failure
*
*/
mico_bool_t mico_bt_gatt_bredr_connect (mico_bt_device_address_t bd_addr);
/**
* Function mico_bt_gatt_cancel_connect
*
* Cancel initiating GATT connecton
*
* @param[in] bd_addr : Remote device addresss
* @param[in] is_direct : Is direct connection or not
*
* @return <b> TRUE </b> : If connection started
* <b> FALSE </b> : If connection start failure
*
*/
mico_bool_t mico_bt_gatt_cancel_connect (mico_bt_device_address_t bd_addr, mico_bool_t is_direct);
/**
* Function mico_bt_gatt_disconnect
*
* Close the specified GATT connection.
* Result is notified using <b> GATT_CONNECTION_STATUS_EVT </b> of #mico_bt_gatt_cback_t.
*
* @param[in] conn_id : GATT connection ID
*
* @return @link mico_bt_gatt_status_e mico_bt_gatt_status_t @endlink
*
*/
mico_bt_gatt_status_t mico_bt_gatt_disconnect (uint16_t conn_id);
/**
* Function mico_bt_gatt_listen
*
* Start or stop LE advertisement and listen for connection.
*
* @param[in] start : TRUE to add device to whitelist / FALSE to remove
* @param[in] bd_addr : Device to add/remove from whitelist
*
* @return <b> TRUE </b> : Success
* <b> FALSE </b> : Failure
*
*/
mico_bool_t mico_bt_gatt_listen (mico_bool_t start, mico_bt_device_address_t bd_addr);
/**@} common_api_functions*/
#ifdef __cplusplus
}
#endif
/**@} micobt_gatt */

View File

@@ -0,0 +1,326 @@
/**
* UNPUBLISHED PROPRIETARY SOURCE CODE
* Copyright (c) 2016 MXCHIP Inc.
*
* 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 MXCHIP Corporation.
*
*/
/** @file
*
* Human Interface Device Profile (HID) Device over BLE
*
*/
#pragma once
#include "mico.h"
#include "mico_bt_dev.h"
#include "hiddefs.h"
/******************************************************
* Constants
******************************************************/
/* HID-LE-Device Callback Events */
enum mico_bt_hidd_ble_cback_event_e
{
MICO_BT_HIDD_BLE_DEV_EVT_OPEN, /**< Connected to host with Interrupt and Control Data = 1 if Virtual Cable
Channels in OPEN state. pdata = Host BD-Addr.*/
MICO_BT_HIDD_BLE_DEV_EVT_CLOSE, /**< Connection with host is closed. Data=Reason Code. */
MICO_BT_HIDD_BLE_DEV_EVT_GET_REPORT, /**< Host sent GET_REPORT Data=Length pdata=structure
having details of get-report. */
MICO_BT_HIDD_BLE_DEV_EVT_SET_REPORT, /**< Host sent SET_REPORT Data=Length pdata=details. */
MICO_BT_HIDD_BLE_DEV_EVT_GET_PROTO, /**< Host sent GET_PROTOCOL Data=NA */
MICO_BT_HIDD_BLE_DEV_EVT_SET_PROTO, /**< Host sent SET_PROTOCOL Data=1 for Report, 0 for Boot */
MICO_BT_HIDD_BLE_DEV_EVT_DATA /**< General event data */
};
typedef uint8_t mico_bt_hidd_ble_cback_event_t; /**< HIDD BLE callback events */
/* GATT application error code for HID profile */
#define HIDD_LE_RPT_NOT_SUPT 0x8F /**< Report not supported */
/* HIDD type */
#define HIDD_LE_KB_TYPE 0x01 /**< bit 0 */
#define HIDD_LE_MICE_TYPE 0x02 /**< bit 1 */
#define HIDD_LE_OTHER_TYPE 0x80 /**< bit 7 */
typedef uint8_t mico_bt_hidd_ble_dev_t; /**< HIDD BLE device types */
#define HIDD_LE_PROTO_MODE_RPT 0x00 /**< Report protocol */
#define HIDD_LE_PROTO_MODE_BOOT 0x01 /**< Boot protocol */
typedef uint8_t mico_bt_hidd_ble_proto_t; /**< HIDD BLE protocol types */
/* LE HIDD report type */
#define HID_LE_RPT_TYPE_INPUT 0x01 /**< Input reports */
#define HID_LE_RPT_TYPE_OUTPUT 0x02 /**< Output reports */
#define HID_LE_RPT_TYPE_FEATURE 0x03 /**< Feature reports */
#define HID_LE_RPT_TYPE_KB_INPUT 0x04 /**< Keyboard input */
#define HID_LE_RPT_TYPE_KB_OUTPUT 0x05 /**< Keyboard output */
#define HID_LE_RPT_TYPE_MI_INPUT 0x06 /**< Mouse input */
typedef uint8_t mico_bt_hidd_ble_rpt_t; /**< HIDD BLE report types */
#define HID_LE_RPT_TYPE_MAX HID_LE_RPT_TYPE_FEATURE /**< Maximun report type */
/******************************************************
* Type Definitions
******************************************************/
enum mico_bt_hidd_ble_status
{
MICO_BT_HIDD_BLE_SUCCESS, /**< Success */
MICO_BT_HIDD_BLE_ERR_NOT_REGISTERED, /**< Not registered */
MICO_BT_HIDD_BLE_ERR_ALREADY_REGISTERED, /**< Alreadu registered */
MICO_BT_HIDD_BLE_ERR_NO_RESOURCES, /**< No resources */
MICO_BT_HIDD_BLE_ERR_NO_CONNECTION, /**< Not connection */
MICO_BT_HIDD_BLE_ERR_INVALID_PARAM, /**< Invalid parameter */
MICO_BT_HIDD_BLE_ERR_UNSUPPORTED, /**< Not supported */
MICO_BT_HIDD_BLE_ERR_UNKNOWN_COMMAND, /**< Unknown command */
MICO_BT_HIDD_BLE_ERR_CONGESTED, /**< Congested */
MICO_BT_HIDD_BLE_ERR_CONN_IN_PROCESS, /**< Connection in process */
MICO_BT_HIDD_BLE_ERR_ALREADY_CONN, /**< Already connected */
MICO_BT_HIDD_BLE_ERR_DISCONNECTING, /**< Disconnecting is process */
MICO_BT_HIDD_BLE_ERR_SET_CONNABLE_FAIL, /**< Set connectable failiure */
/* Device specific error codes */
MICO_BT_HIDD_BLE_ERR_HOST_UNKNOWN, /**< Host unknown */
MICO_BT_HIDD_BLE_ERR_L2CAP_FAILED, /**< L2CAP failed */
MICO_BT_HIDD_BLE_ERR_AUTH_FAILED, /**< Authentication failed */
MICO_BT_HIDD_BLE_ERR_SDP_BUSY, /**< SDP busy */
MICO_BT_HIDD_BLE_ERR_GATT, /**< GATT */
MICO_BT_HIDD_BLE_ERR_INVALID = 0xFF /**< Invalid */
};
typedef uint8_t mico_bt_hidd_ble_status_t; /**< HIDD BLE status codes */
/* report reference descriptor value */
typedef struct
{
uint8_t rpt_id; /**< Report ID */
mico_bt_hidd_ble_rpt_t rpt_type; /**< Report type */
} mico_bt_hidd_ble_rpt_ref_t; /**< HIDD BLE report reference */
/* LE HIDD registration information */
typedef struct
{
mico_bt_hidd_ble_dev_t dev_type; /**< Device type */
uint8_t num_rpt; /**< Number of reports */
uint16_t battery_handle; /**< Battery handle */
mico_bt_hidd_ble_rpt_ref_t *p_rpt_lst; /**< Pointer to the report reference */
mico_bt_hidd_ble_proto_t proto_cap; /**< Protocol capability */
} mico_bt_hidd_ble_dev_info_t; /**< HIDD BLE device info */
#define HIDD_LE_REMOTE_WAKE 0x01 /**< Remote wake */
#define HIDD_LE_NORMAL_CONN 0x02 /**< Normally connectable */
typedef struct
{
uint16_t dl_len; /**< Description length */
uint8_t *dsc_list; /**< Pointer to the description */
} mico_bt_hidd_ble_dscp_info_t; /**< HIDD BLE description info */
/* LE HIDD report map info */
typedef struct
{
uint16_t bcdHID; /**< HID info in BCD format */
uint8_t contry_code; /**< Country code */
uint8_t flags; /**< HID info in BCD format */
mico_bt_hidd_ble_dscp_info_t rpt_map; /**< Report map */
} mico_bt_hidd_ble_rpt_map_info_t; /**< HIDD BLE report map info */
#define HIDD_REPT_ID_BOOT_KB 1
#define HIDD_REPT_ID_BOOT_MOUSE 2
typedef struct
{
uint16_t event; /**< event */
uint16_t len; /**< length */
uint16_t offset; /**< offset */
uint16_t layer_specific; /**< lay_specific */
} mico_bt_hidd_bt_hdr_t; /**< General data in BT_HDR type */
/* LE HIDD report data */
typedef struct
{
mico_bt_hidd_bt_hdr_t hdr; /**< report data, assuming the first byte of data is report ID */
uint8_t rpt_id; /**< report ID */
} mico_bt_hidd_ble_rpt_data_t; /**< HIDD BLE report data */
/* LE HIDD get report data */
typedef struct
{
uint8_t rep_type; /**< HIDD BLE report type */
uint8_t rep_id; /**< HIDD BLE report ID */
} mico_bt_hidd_ble_get_rpt_data_t; /**< HIDD BLE get report data */
/* LE HIDD cback data */
typedef union
{
mico_bt_device_address_t host_bdaddr; /**< Host BD-ADDR */
mico_bt_hidd_ble_get_rpt_data_t get_rpt; /**< Get report */
mico_bt_hidd_ble_rpt_data_t *p_buffer; /**< General report data */
} mico_bt_hidd_ble_cback_data_t; /**< HIDD BLE callback data */
/**
* HIDD LE callback
*
* Callback for Human Interface Device Profile Device (HIDD)
*
* @param[in] event : Callback event
* @param[in] data : Integer data corresponding to the event
* @param[in] p_data : Callback data
*
* @return void
*/
typedef void (mico_bt_hidd_ble_cback_t) (uint8_t event,
uint32_t data,
mico_bt_hidd_ble_cback_data_t *p_data );
/* HIDD LE registration info */
typedef struct
{
mico_bt_device_address_t host_addr; /**< Host BD-ADDR */
mico_bt_hidd_ble_dev_info_t dev_info; /**< Device info */
mico_bt_hidd_ble_cback_t *app_cback; /**< Callback function */
} mico_bt_hidd_ble_reg_info_t; /**< HIDD BLE registration info */
/**
* @addtogroup hidd_le_api_functions HIDD over BLE
* @ingroup micobt
*
* HIDD LE Functions
*
* @{
*/
/******************************************************
* Function Declarations
******************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/**
* Function mico_bt_hidd_ble_init
*
* Initialize HIDD LE control block and trace variable.
*
* @param[in] None
* @param[out] None
*
* @return None
*/
void mico_bt_hidd_ble_init (void);
/**
* Function mico_bt_hidd_ble_register
*
* This function must be called at startup to register info related
* to HIDD over LE.
*
*
* @param[in] p_reg_info : SCO index to remove
* @param[out] None
*
* @return status code (see #mico_bt_hidd_ble_status_t)
*/
mico_bt_hidd_ble_status_t mico_bt_hidd_ble_register(mico_bt_hidd_ble_reg_info_t *p_reg_info);
/**
* Function mico_bt_hidd_ble_deregister
*
* Disable HIDD service.
*
* @param[in] None
* @param[out] None
*
* @return status code (see #mico_bt_hidd_ble_status_t)
*/
mico_bt_hidd_ble_status_t mico_bt_hidd_ble_deregister(void);
/**
* Function mico_bt_hidd_ble_connect
*
* Initiates a connection to the host.
*
* @param[in] None
* @param[out] None
*
* @return status code (see #mico_bt_hidd_ble_status_t)
*/
mico_bt_hidd_ble_status_t mico_bt_hidd_ble_connect(void);
/**
* Function mico_bt_hidd_ble_disconnect
*
* Disconnects from the host.
*
* @param[in] None
* @param[out] None
*
* @return status code (see #mico_bt_hidd_ble_status_t)
*/
mico_bt_hidd_ble_status_t mico_bt_hidd_ble_disconnect(void);
/**
* Function mico_bt_hidd_ble_send_report
*
* Sends report data to the host.
*
* @param[in] rep_type : Report type
* @param[in] rep_id : Report ID
* @param[in] len : Length of the data
* @param[in] offset : Offset of the data
* @param[in] p_rpt : Pointer to the report data
* @param[out] None
*
* @return status code (see #mico_bt_hidd_ble_status_t)
*/
mico_bt_hidd_ble_status_t mico_bt_hidd_ble_send_report(uint8_t rep_type, uint8_t rpt_id,
uint16_t len, uint16_t offset, uint8_t *p_rpt);
/**
* Function mico_bt_hidd_ble_hand_shake
*
* Acks a set report request
*
* @param[in] status code (see #mico_bt_hidd_ble_status_t)
* @param[out] None
*
* @return status code (see #mico_bt_hidd_ble_status_t)
*/
mico_bt_hidd_ble_status_t mico_bt_hidd_ble_hand_shake(mico_bt_hidd_ble_status_t status);
/**
* Function mico_bt_hidd_ble_rsp_get_protocol
*
* Responds to a get protocol mode request
*
* @param[in] cur_mode : Current protocol
* @param[out] None
*
* @return status code (see #mico_bt_hidd_ble_status_t)
*/
mico_bt_hidd_ble_status_t mico_bt_hidd_ble_rsp_get_protocol(mico_bt_hidd_ble_proto_t cur_mode);
/**
* Function mico_bt_hidd_ble_set_rsp_map_info
*
* This function shall be called at startup to configure the
* device HID information and report map
*
*
* @param[in] p_dev_info : Device map info
* @param[out] None
*
* @return status code (see #mico_bt_hidd_ble_status_t)
*/
mico_bt_hidd_ble_status_t mico_bt_hidd_ble_set_rsp_map_info(mico_bt_hidd_ble_rpt_map_info_t *p_dev_info);
#ifdef __cplusplus
}
#endif
/** @} micobt_hidd_ble */

View File

@@ -0,0 +1,84 @@
/**
* UNPUBLISHED PROPRIETARY SOURCE CODE
* Copyright (c) 2016 MXCHIP Inc.
*
* 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 MXCHIP Corporation.
*
*/
#pragma once
/* MiCO -> BTE Conversion */
#define int8_t INT8
#define int16_t INT16
#define int32_t INT32
#define uint8_t UINT8
#define uint16_t UINT16
#define uint32_t UINT32
#define mico_bool_t BOOLEAN
#define mico_bt_dev_status_t tBTM_STATUS
#define mico_bt_management_evt_t tBTM_EVENT
#define mico_bt_dev_class_t DEV_CLASS
#define mico_bt_device_address_t BD_ADDR
#define mico_bt_device_address_ptr_t BD_ADDR_PTR
#define mico_bt_dev_io_cap_t tBTM_IO_CAP
#define mico_bt_dev_oob_data_t tBTM_OOB_DATA
#define mico_bt_dev_le_auth_req_t tBTM_LE_AUTH_REQ
#define mico_bt_dev_le_key_type_t tBTM_LE_KEY_TYPE
#define mico_bt_dev_auth_req_t tBTM_AUTH_REQ
#define mico_bt_device_type_t tBT_DEVICE_TYPE
#define mico_bt_dev_bonded_device_info_t tBT_BONDED_DEVICE_INFO_TYPE
#define mico_bt_security_key_value_t tBTM_SEC_KEY_VALUE
#define mico_bt_transport_t tBT_TRANSPORT
#define mico_bt_ble_address_t tBLE_BD_ADDR
#define mico_bt_ble_address_type_t tBLE_ADDR_TYPE
#define mico_bt_ble_conn_mode_t tBLE_CONN_MODE
#define mico_bt_dev_passkey_entry_type_t tBTM_SP_KEY_TYPE
#define mico_bt_connection_status_change_cback_t tBTM_ACL_DB_CHANGE_CB /* modified from bte */
#define mico_bt_dev_inq_parms_t tBTM_INQ_PARMS /* modified from bte */
#define mico_bt_dev_inquiry_scan_result_t tBTM_INQ_RESULTS /* modified from bte */
#define mico_bt_inquiry_result_cback_t tBTM_INQ_RESULTS_CB
#define mico_bt_dev_vendor_specific_command_complete_cback_t tBTM_VSC_CMPL_CB
#ifndef mico_bt_dev_vendor_specific_command_complete_params_t
#define mico_bt_dev_vendor_specific_command_complete_params_t tBTM_VSC_CMPL
#endif
#define mico_bt_ble_advert_mask_t tBTM_BLE_AD_MASK
#define mico_bt_ble_advert_data_t tBTM_BLE_ADV_DATA
#define mico_bt_ble_conn_type_t tBTM_BLE_CONN_TYPE
#define mico_bt_ble_selective_conn_cback_t tBTM_BLE_SEL_CBACK
#define mico_bt_ble_scan_type_t tBTM_BLE_SCAN_TYPE /* new */
#define mico_bt_ble_advert_mode_t tBTM_BLE_AVERT_MODE /* new */
#define mico_bt_ble_scan_result_cback_t tBTM_BLE_SCAN_RESULT_CBACK /* new */
#define mico_bt_ble_scan_results_t tBTM_BLE_SCAN_RESULT /* new */
#define mico_bt_ble_scan_mode_t tBTM_BLE_SCAN_MODE
#define mico_bt_ble_advert_chnl_map_t tBTM_BLE_ADV_CHNL_MAP
#define mico_dev_ble_signature_t BLE_SIGNATURE
#define mico_bt_ble_advert_filter_policy_t tBTM_BLE_AFP
#define mico_bt_device_link_keys_t tBTM_PAIRED_DEVICE_LINK_KEYS
#define mico_bt_local_identity_keys_t tBTM_LOCAL_IDENTITY_KEYS
/* l2cap mico-to-bte translation */
#define mico_bt_l2c_appl_info_t tL2CAP_APPL_INFO
#define mico_bt_l2c_fixed_chnl_reg_t tL2CAP_FIXED_CHNL_REG
#define mico_bt_l2cap_le_appl_information_t tL2CAP_LE_APPL_INFO
#define mico_bt_l2c_cfg_info_t tL2CAP_CFG_INFO
#define mico_bt_l2c_ch_cfg_bits_t tL2CAP_CH_CFG_BITS
#define mico_bt_l2cap_ertm_information_t tL2CAP_ERTM_INFO
#define mico_bt_l2cap_chnl_priority_t tL2CAP_CHNL_PRIORITY
#define mico_bt_l2cap_nocp_cback_t tL2CA_NOCP_CB
#define mico_bt_l2cap_chnl_data_rate_t tL2CAP_CHNL_DATA_RATE
#define mico_bt_gatt_appearance_t tGATT_APPEARANCE
#define mico_bt_gatt_status_t tGATT_STATUS
#define mico_bt_gatt_write_t tGATT_WRITE_REQ
#define mico_bt_gatt_read_t tGATT_READ_REQ
#define mico_bt_gatt_exec_flag_t tGATT_EXEC_FLAG
#define mico_bt_hidd_status_t tHID_STATUS
#define mico_bt_hidd_reg_info_t tHID_DEV_REG_INFO
#define mico_bt_hidd_callback_t tHID_DEV_CBACK_DATA
#define mico_bt_sco_enh_esco_params_t tBTM_ENH_ESCO_PARAMS

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,50 @@
/**
* UNPUBLISHED PROPRIETARY SOURCE CODE
* Copyright (c) 2016 MXCHIP Inc.
*
* 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 MXCHIP Corporation.
*
*/
/** @file
*
* MiCO Bluetooth Low Energy (BLE) Functions
*
*/
#pragma once
#ifndef OFFSETOF
#define OFFSETOF( type, member ) ( (uintptr_t)&((type *)0)->member )
#endif /* OFFSETOF */
#define MICO_BT_PARA_LOCAL_KEY_DATA 65 /* BTM_SECURITY_LOCAL_KEY_DATA_LEN */
#define MICO_BT_DCT_NAME 249
#define MICO_BT_DCT_MAX_KEYBLOBS 146 /* Maximum size of key blobs to be stored := size of BR-EDR link keys + size of BLE keys*/
#define MICO_BT_DCT_ADDR_FIELD 6
#define MICO_BT_DCT_LENGTH_FIELD 2
#ifndef MICO_BT_DCT_MAX_DEVICES
#define MICO_BT_DCT_MAX_DEVICES 10 /* Maximum number of device records stored in nvram */
#endif
#define MICO_BT_DCT_ADDR_TYPE 1
#define MICO_BT_DCT_DEVICE_TYPE 1
/* Length of BD_ADDR + 2bytes length field */
#define MICO_BT_DCT_ENTRY_HDR_LENGTH (MICO_BT_DCT_ADDR_FIELD + MICO_BT_DCT_LENGTH_FIELD + MICO_BT_DCT_ADDR_TYPE + MICO_BT_DCT_DEVICE_TYPE)
#define MICO_BT_DCT_LOCAL_KEY_OFFSET OFFSETOF( mico_bt_config_t, bluetooth_local_key )
#define MICO_BT_DCT_REMOTE_KEY_OFFSET OFFSETOF( mico_bt_config_t, bluetooth_remote_key )
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,329 @@
/**
* UNPUBLISHED PROPRIETARY SOURCE CODE
* Copyright (c) 2016 MXCHIP Inc.
*
* 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 MXCHIP Corporation.
*
*/
/** @file
*
* Bluetooth RFCOMM Application Programming Interface
*
*/
#pragma once
#include "mico.h"
//#include "mico_bt_dev.h"
/******************************************************
* Constants and Type definitions
******************************************************/
/** RFCOMM Port Event Masks */
typedef enum mico_bt_rfcomm_port_event_e
{
MICO_BT_RFCOMM_EV_RXCHAR = 0x00000001, /**< Any Character received */
MICO_BT_RFCOMM_EV_RXFLAG = 0x00000002, /**< Received certain character */
MICO_BT_RFCOMM_EV_TXEMPTY = 0x00000004, /**< Transmitt Queue Empty */
MICO_BT_RFCOMM_EV_CTS = 0x00000008, /**< CTS changed state */
MICO_BT_RFCOMM_EV_DSR = 0x00000010, /**< DSR changed state */
MICO_BT_RFCOMM_EV_RLSD = 0x00000020, /**< RLSD changed state */
MICO_BT_RFCOMM_EV_BREAK = 0x00000040, /**< BREAK received */
MICO_BT_RFCOMM_EV_ERR = 0x00000080, /**< Line status error occurred */
MICO_BT_RFCOMM_EV_RING = 0x00000100, /**< Ring signal detected */
MICO_BT_RFCOMM_EV_CTSS = 0x00000400, /**< CTS state */
MICO_BT_RFCOMM_EV_DSRS = 0x00000800, /**< DSR state */
MICO_BT_RFCOMM_EV_RLSDS = 0x00001000, /**< RLSD state */
MICO_BT_RFCOMM_EV_OVERRUN = 0x00002000, /**< receiver buffer overrun */
MICO_BT_RFCOMM_EV_TXCHAR = 0x00004000, /**< Any character transmitted */
MICO_BT_RFCOMM_EV_CONNECTED = 0x00000200, /**< RFCOMM connection established */
MICO_BT_RFCOMM_EV_CONNECT_ERR = 0x00008000, /**< Was not able to establish connection or disconnected */
MICO_BT_RFCOMM_EV_FC = 0x00010000, /**< data flow enabled flag changed by remote */
MICO_BT_RFCOMM_EV_FCS = 0x00020000, /**< data flow enable status true = enabled */
} mico_bt_rfcomm_port_event_t;
#define MICO_BT_RFCOMM_MASK_ALL (MICO_BT_RFCOMM_EV_RXCHAR | MICO_BT_RFCOMM_EV_TXEMPTY | MICO_BT_RFCOMM_EV_CTS | \
MICO_BT_RFCOMM_EV_DSR | MICO_BT_RFCOMM_EV_RLSD | MICO_BT_RFCOMM_EV_BREAK | \
MICO_BT_RFCOMM_EV_ERR | MICO_BT_RFCOMM_EV_RING | MICO_BT_RFCOMM_EV_CONNECT_ERR | \
MICO_BT_RFCOMM_EV_DSRS | MICO_BT_RFCOMM_EV_CTSS | MICO_BT_RFCOMM_EV_RLSDS | \
MICO_BT_RFCOMM_EV_RXFLAG | MICO_BT_RFCOMM_EV_TXCHAR | MICO_BT_RFCOMM_EV_OVERRUN | \
MICO_BT_RFCOMM_EV_FC | MICO_BT_RFCOMM_EV_FCS | MICO_BT_RFCOMM_EV_CONNECTED)
/** RFCOMM Result Codes */
enum mico_bt_rfcomm_result_e
{
MICO_BT_RFCOMM_SUCCESS, /**< Success */
MICO_BT_RFCOMM_ERROR, /**< Error */
MICO_BT_RFCOMM_ALREADY_OPENED, /**< Already Opened */
MICO_BT_RFCOMM_CMD_PENDING, /**< Command Pending */
MICO_BT_RFCOMM_APP_NOT_REGISTERED, /**< App Not Registered */
MICO_BT_RFCOMM_NO_MEM, /**< No Memory */
MICO_BT_RFCOMM_NO_RESOURCES, /**< No Resources */
MICO_BT_RFCOMM_BAD_BD_ADDR, /**< Bad BD Address */
MICO_BT_RFCOMM_RESULT_RESERVED0,
MICO_BT_RFCOMM_BAD_HANDLE, /**< Bad Handle */
MICO_BT_RFCOMM_NOT_OPENED, /**< Not Opened */
MICO_BT_RFCOMM_LINE_ERR, /**< Line Error */
MICO_BT_RFCOMM_START_FAILED, /**< Start Failed */
MICO_BT_RFCOMM_PAR_NEG_FAILED,
MICO_BT_RFCOMM_RFCOMM_NEG_FAILED,
MICO_BT_RFCOMM_SEC_FAILED,
MICO_BT_RFCOMM_PEER_CONNECTION_FAILED, /**< Peer Connection Failed */
MICO_BT_RFCOMM_PEER_FAILED, /**< Peer Failed */
MICO_BT_RFCOMM_PEER_TIMEOUT, /**< Peer Timeout */
MICO_BT_RFCOMM_CLOSED, /**< Closed */
MICO_BT_RFCOMM_TX_FULL,
MICO_BT_RFCOMM_LOCAL_CLOSED, /**< Local Closed */
MICO_BT_RFCOMM_LOCAL_TIMEOUT, /**< Local Timeout */
MICO_BT_RFCOMM_TX_QUEUE_DISABLED,
MICO_BT_RFCOMM_PAGE_TIMEOUT, /**< Page Timeout */
MICO_BT_RFCOMM_INVALID_SCN /**< Invalid SCN */
};
typedef int mico_bt_rfcomm_result_t; /**< RFCOMM result code (see #mico_bt_rfcomm_result_e) */
/** RFCOMM Signals */
enum mico_bt_rfcomm_signal_e
{
MICO_BT_RFCOMM_SET_DTRDSR=0x01, /** DTRDSR set */
MICO_BT_RFCOMM_CLR_DTRDSR, /** DTRDSR clear */
MICO_BT_RFCOMM_SET_CTSRTS, /** CTSRTS set */
MICO_BT_RFCOMM_CLR_CTSRTS, /** CTSRTS clear */
MICO_BT_RFCOMM_SET_RI, /** RI set (DCE only) */
MICO_BT_RFCOMM_CLR_RI, /** RI clear (DCE only) */
MICO_BT_RFCOMM_SET_DCD, /** DCD set (DCE only) */
MICO_BT_RFCOMM_CLR_DCD, /** DCD clear (DCE only) */
MICO_BT_RFCOMM_BREAK, /** BRK */
};
typedef uint8_t mico_bt_rfcomm_signal_t; /**< RFCOMM Signals (see #mico_bt_rfcomm_signal_e) */
/**
* Define the callback function prototypes for mico_bt_rfcomm_data_cback_t
*
* @param port_handle : A 16-bit unsigned integer returned by @link mico_bt_rfcomm_create_connection mico_bt_rfcomm_create_connection @endlink.
* @param *p_data : A pointer to the array of bytes received from the peer device.
* @param len : The length of the data received.
*/
typedef int (mico_bt_rfcomm_data_cback_t) (uint16_t port_handle, void *p_data, uint16_t len);
/**
* Port management callback
*
* @param code : Result code
* @param port_handle : Port handle from @link mico_bt_rfcomm_create_connection mico_bt_rfcomm_create_connection @endlink.
*/
typedef void (mico_bt_port_mgmt_cback_t) (mico_bt_rfcomm_result_t code, uint16_t port_handle);
/**
* Port event callback
*
* @param event : A 32-bit event code that contains a bit-mask of one or more events the caller would like to register.
* @param port_handle : Port handle from @link mico_bt_rfcomm_create_connection mico_bt_rfcomm_create_connection @endlink.
*/
typedef void (mico_bt_port_event_cback_t) (mico_bt_rfcomm_port_event_t event, uint16_t port_handle);
/**
* @addtogroup rfcomm_api_functions RFCOMM
* @ingroup micobt
*
* RFCOMM Functions
*
* @{
*/
/******************************************************
* Function Declarations
******************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/**
* Establish serial port connection to the peer device, or allow
* RFCOMM to accept a connection from peer devices.
*
* @note
* Server can call this function with the same scn parameter multiple times if
* it is ready to accept multiple simulteneous connections.
*
* DLCI for the connection is (scn * 2 + 1) if client originates connection on
* existing none initiator multiplexer channel. Otherwise it is (scn * 2).
* For the server DLCI can be changed later if client will be calling it using
* (scn * 2 + 1) dlci.
*
* @param[in] uuid : The Universal Unique Identifier (UUID) of the
* Class ID of the service being opened
* @param[in] scn : The Service Channel Number(SCN) as registered
* with the SDP (server) or obtained using SDP from
* the peer device (client)
* @param[in] is_server : TRUE if requesting application is a server
* @param[in] mtu : The maximum number of bytes transferred per frame
* If 0, a default size of L2CAP_MTU_SIZE minus
* 5 bytes is used
* @param[in] bd_addr : BD_ADDR of the peer (if client), NULL if server
* @param[in] p_mgmt_cb : Pointer to callback function to receive connection
* up/down events
* @param[out] p_handle : A pointer to the handle set by RFCOMM to be used in
* consecutive calls for this connection
*
* @return <b> MICO_BT_RFCOMM_SUCCESS </b> : If successful
* <b> MICO_BT_RFCOMM_ALREADY_OPENED </b> : If the client tries to establish a connection to the same BD_ADDR
* <b> MICO_BT_RFCOMM_NO_RESOURCES </b> : If there is not enough memory to allocate a control block structure
* <b> MICO_BT_RFCOMM_INVALID_SCN </b> : If Server Channel Number(SCN) is out of in range 1...30
*/
mico_bt_rfcomm_result_t mico_bt_rfcomm_create_connection (uint16_t uuid, uint8_t scn,
mico_bool_t is_server, uint16_t mtu,
mico_bt_device_address_t bd_addr,
uint16_t *p_handle,
mico_bt_port_mgmt_cback_t *p_mgmt_cb);
/**
* Close the specified connection.
*
* @param[in] handle : The connection handle returned by
* @link mico_bt_rfcomm_create_connection mico_bt_rfcomm_create_connection @endlink.
* @param[in] remove_server : (for server only) If TRUE, then also remove server; otherwise server remains enabled
* after connection is closed.
*
* @return <b> MICO_BT_RFCOMM_SUCCESS </b> : If successful
* <b> MICO_BT_RFCOMM_BAD_HANDLE </b> : If the handle is out of range
* <b> MICO_BT_RFCOMM_NOT_OPENED </b> : If the connection is not opened
*/
mico_bt_rfcomm_result_t mico_bt_rfcomm_remove_connection (uint16_t handle, mico_bool_t remove_server);
/**
* Set event callback the specified connection.
*
* @param[in] port_handle : A 16-bit unsigned integer returned by
* @link mico_bt_rfcomm_create_connection mico_bt_rfcomm_create_connection @endlink
* @param[in] p_port_cb : Address of the callback function which should
* be called from the RFCOMM when an event
* specified in the mask occurs
*
* @return <b> MICO_BT_RFCOMM_SUCCESS </b> : If successful
* <b> MICO_BT_RFCOMM_BAD_HANDLE </b> : If the handle is out of range
* <b> MICO_BT_RFCOMM_NOT_OPENED </b> : If the connection is not opened
*/
mico_bt_rfcomm_result_t mico_bt_rfcomm_set_event_callback (uint16_t port_handle, mico_bt_port_event_cback_t *p_port_cb);
/**
* Set event data callback the specified connection.
*
* @param[in] port_handle : A 16-bit unsigned integer returned by
* @link mico_bt_rfcomm_create_connection mico_bt_rfcomm_create_connection @endlink
* @param[in] p_cb : Address of the callback function which should
* be called from the RFCOMM when a data
* packet is received
*
* @return <b> MICO_BT_RFCOMM_SUCCESS </b> : If successful
* <b> MICO_BT_RFCOMM_BAD_HANDLE </b> : If the handle is out of range
* <b> MICO_BT_RFCOMM_NOT_OPENED </b> : If the connection is not opened
*/
mico_bt_rfcomm_result_t mico_bt_rfcomm_set_data_callback (uint16_t port_handle, mico_bt_rfcomm_data_cback_t *p_cb);
/**
* Set events for which to be notified
*
* @param[in] port_handle : A 16-bit unsigned integer returned by
* @link mico_bt_rfcomm_create_connection mico_bt_rfcomm_create_connection @endlink
* @param[in] mask : Event mask
*
* @return <b> MICO_BT_RFCOMM_SUCCESS </b> : If successful
* <b> MICO_BT_RFCOMM_BAD_HANDLE </b> : If the handle is out of range
* <b> MICO_BT_RFCOMM_NOT_OPENED </b> : If the connection is not opened
*/
mico_bt_rfcomm_result_t mico_bt_rfcomm_set_event_mask (uint16_t port_handle, mico_bt_rfcomm_port_event_t mask);
/**
* Send control signal to the peer device.
*
* @param[in] handle : The connection handle returned by
* @link mico_bt_rfcomm_create_connection mico_bt_rfcomm_create_connection @endlink
* @param[in] signal : Signal to send (see #mico_bt_rfcomm_signal_e)
*
* @return <b> MICO_BT_RFCOMM_SUCCESS </b> : If successful
* <b> MICO_BT_RFCOMM_BAD_HANDLE </b> : If the handle is out of range
* <b> MICO_BT_RFCOMM_NOT_OPENED </b> : If the connection is not opened
*/
mico_bt_rfcomm_result_t mico_bt_rfcomm_control (uint16_t handle, mico_bt_rfcomm_signal_t signal);
/**
* This function directs a specified connection to pass flow control message to the peer device.
* Enable flag passed shows if port can accept more data.
*
* @param[in] handle : The connection handle returned by
* @link mico_bt_rfcomm_create_connection mico_bt_rfcomm_create_connection @endlink
* @param[in] enable : Flow control setting
* TRUE Enable data flow
* FALSE Disable data flow
*
* @return <b> MICO_BT_RFCOMM_SUCCESS </b> : If successful
* <b> MICO_BT_RFCOMM_BAD_HANDLE </b> : If the handle is out of range
* <b> MICO_BT_RFCOMM_NOT_OPENED </b> : If the connection is not opened
*/
mico_bt_rfcomm_result_t mico_bt_rfcomm_flow_control (uint16_t handle, mico_bool_t enable);
/**
* This function directs a specified connection to pass flow control message to the peer device.
* Enable flag passed shows if port can accept more data.
*
* @param[in] handle : The connection handle returned by
* @link mico_bt_rfcomm_create_connection mico_bt_rfcomm_create_connection @endlink
* @param[in] p_data : Data to write
* @param[in] max_len : Byte count to write
* @param[out] p_len : Bytes written
*
* @return <b> MICO_BT_RFCOMM_SUCCESS </b> : If successful
* <b> MICO_BT_RFCOMM_BAD_HANDLE </b> : If the handle is out of range
* <b> MICO_BT_RFCOMM_NOT_OPENED </b> : If the connection is not opened
*/
mico_bt_rfcomm_result_t mico_bt_rfcomm_write_data (uint16_t handle, char *p_data, uint16_t max_len, uint16_t *p_len);
/**
* This function checks connection referenced by handle is up and running.
*
* @param[in] handle : The connection handle returned by
* @link mico_bt_rfcomm_create_connection mico_bt_rfcomm_create_connection @endlink
* @param[out] bd_addr : Peer BD Address
* @param[out] p_lcid : L2CAP's LCID
*
* @return <b> MICO_BT_RFCOMM_SUCCESS </b> : If successful
* <b> MICO_BT_RFCOMM_LINE_ERR </b> : If connection is not up and running
*/
//mico_bt_rfcomm_result_t mico_bt_rfcomm_check_connection (UINT16 handle, BD_ADDR bd_addr, UINT16 *p_lcid);
#ifdef MPAF_CUSTOM_STACK
/**
* This function allocates private pool to be used by RFCOMM.
*
* @param[in] buffer_size : size of buffer
* @param[out] buffer_cnt : buffers
*
* @return <b> MICO_BT_RFCOMM_SUCCESS </b> : If successful
* <b> MICO_BT_RFCOMM_ERROR </b> : If pool allocation fails
*/
mico_bt_rfcomm_result_t mico_bt_rfcomm_init(uint32_t buffer_size, uint32_t buffer_cnt);
/**
* This function enables flow control based on ACL buffer availability
*
* @param[in] peer_addr : Peer BD Address
*
* @return <b> MICO_TRUE </b> : If successful
* <b> MICO_FALSE </b> : If fails
*/
mico_bool_t mico_bt_rfcomm_control_data_flow(BD_ADDR peer_bda);
#endif
#ifdef __cplusplus
}
#endif
/**@} */

View File

@@ -0,0 +1,136 @@
/**
* UNPUBLISHED PROPRIETARY SOURCE CODE
* Copyright (c) 2016 MXCHIP Inc.
*
* 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 MXCHIP Corporation.
*
*/
/** @file
*
* Bluetooth Synchronous Connection Oriented Channel Application Programming Interface
*
*/
#ifdef SCO_ENABLE //oscar for mindray
#pragma once
#include "mico.h"
#include "mico_bt_dev.h"
/******************************************************
* Constants
******************************************************/
/******************************************************
* Type Definitions
******************************************************/
/* Subset for the enhanced setup/accept synchronous connection paramters
* See BT 4.1 or later HCI spec for details */
typedef struct
{
uint16_t max_latency; /**< Maximum latency (0x4-0xFFFE in msecs) */
uint16_t packet_types; /**< Packet Types */
uint8_t retrans_effort; /**< 0x00-0x02, 0xFF don't care */
mico_bool_t use_wbs; /**< True to use wide band, False to use narrow band */
} mico_bt_sco_params_t;
/**
* @addtogroup sco_api_functions Synchronous Connection Oriented (SCO) Channel
* @ingroup micobt
*
* SCO Functions
*
* @{
*/
/******************************************************
* Function Declarations
******************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/**
* Function mico_bt_sco_create_as_initiator
*
* Creates a synchronous connection oriented connection as initiator.
*
* @param[in] bd_addr : Peer bd_addr
* @param[in] p_params : Pointer to the SCO parameter structure
* @param[out] p_sco_index : SCO index returned
*
* @return <b> MICO_BT_UNKNOWN_ADDR </b> : Create connection failed, ACL connection is not up
* <b> MICO_BT_BUSY </b> : Create connection failed, another SCO is being
* conncted to the same BD address
* <b> MICO_BT_WRONG_MODE </b> : Create connection failed, wrong mode
* <b> MICO_BT_NO_RESOURCES </b> : Create connection failed, max SCO limit has been
* reached
* <b> BTM_CMD_STARTED </b> : Create connection successfully, "p_sco_index" is returned
*/
mico_bt_dev_status_t mico_bt_sco_create_as_initiator (mico_bt_device_address_t bd_addr,
uint16_t *p_sco_index,
mico_bt_sco_params_t *p_params);
/**
* Function mico_bt_sco_create_as_acceptor
*
* Creates a synchronous connection oriented connection as acceptor.
*
* @param[out] p_sco_index : SCO index returned
*
* @return <b> MICO_BT_UNKNOWN_ADDR </b> : Create connection failed, ACL connection is not up or
* address is invalid
* <b> MICO_BT_BUSY </b> : Create connection failed, a SCO connection is already
* conncted to the same BD address
* <b> MICO_BT_WRONG_MODE </b> : Create connection failed, link in park mode or
* automatic un-park is not supported
* <b> MICO_BT_NO_RESOURCES </b> : Create connection failed, max SCO limit has been
* reached
* <b> BTM_CMD_STARTED </b> : Create connection successfully, "p_sco_index" is returned
*/
mico_bt_dev_status_t mico_bt_sco_create_as_acceptor (uint16_t *p_sco_index);
/**
* Function mico_bt_sco_remove
*
* Removes a specific synchronous connection oriented connection.
*
* @param[in] sco_index : SCO index to remove
*
* @return <b> MICO_BT_UNKNOWN_ADDR </b> : Remove connection failed, invalid SCO index
* <b> MICO_BT_NO_RESOURCES </b> : Remove connection failed, no resource
* <b> MICO_BT_SUCCESS </b> : Remove connection successfully, device is still
* listening for incoming connection
* <b> BTM_CMD_STARTED </b> : Remove connection successfully
*/
mico_bt_dev_status_t mico_bt_sco_remove (uint16_t sco_index);
/**
* Function mico_bt_sco_accept_connection
*
* Called to handle (e)SCO connection request event (mico_bt_sco_connect_request_event).
*
*
* @param[in] sco_index : SCO index to remove
*
* @param[in] HCI status code : HCI_SUCCESS 0x00
* HCI_ERR_HOST_REJECT_RESOURCES 0x0D
* HCI_ERR_HOST_REJECT_SECURITY 0x0E
* HCI_ERR_HOST_REJECT_DEVICE 0x0F
* @param[in] p_params : Pointer to the SCO parameter structure
*
*/
void mico_bt_sco_accept_connection (uint16_t sco_index, uint8_t hci_status,
mico_bt_sco_params_t *p_params);
#ifdef __cplusplus
}
#endif
/** @} micobt_sco */
#endif

View File

@@ -0,0 +1,536 @@
/**
* UNPUBLISHED PROPRIETARY SOURCE CODE
* Copyright (c) 2016 MXCHIP Inc.
*
* 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 MXCHIP Corporation.
*
*/
/** @file
*
* Bluetooth SDP Application Programming Interface
*
*/
#pragma once
#include "mico_bt_dev.h"
#include "sdpdefs.h"
/*****************************************************************************
* Constants
****************************************************************************/
/** SDP result - Success code and error codes */
enum mico_bt_sdp_result_t
{
MICO_BT_SDP_SUCCESS = MICO_BT_SUCCESS, /**< SDP - Result: Success */
MICO_BT_SDP_INVALID_VERSION = 0x0001, /**< SDP - invalid version */
MICO_BT_SDP_INVALID_SERV_REC_HDL = 0x0002, /**< SDP - invalid service record */
MICO_BT_SDP_INVALID_REQ_SYNTAX = 0x0003, /**< SDP - invalid request syntax */
MICO_BT_SDP_INVALID_PDU_SIZE = 0x0004, /**< SDP - invalid PDU size */
MICO_BT_SDP_INVALID_CONT_STATE = 0x0005, /**< SDP - invalid controller state */
MICO_BT_SDP_NO_RESOURCES = 0x0006, /**< SDP - no resources */
MICO_BT_SDP_DI_REG_FAILED = 0x0007, /**< SDP - registration failed */
MICO_BT_SDP_DI_DISC_FAILED = 0x0008, /**< SDP - discovery failed */
MICO_BT_SDP_NO_DI_RECORD_FOUND = 0x0009, /**< SDP - no record found */
MICO_BT_SDP_ERR_ATTR_NOT_PRESENT = 0x000A, /**< SDP - no attribute present */
MICO_BT_SDP_ILLEGAL_PARAMETER = 0x000B, /**< SDP - Illegal parameter */
MICO_BT_SDP_NO_RECS_MATCH = 0xFFF0, /**< SDP - No records match */
MICO_BT_SDP_CONN_FAILED = 0xFFF1, /**< SDP - Connection failed */
MICO_BT_SDP_CFG_FAILED = 0xFFF2, /**< SDP - Configuration failed */
MICO_BT_SDP_GENERIC_ERROR = 0xFFF3, /**< SDP - Generic error */
MICO_BT_SDP_DB_FULL = 0xFFF4, /**< SDP - DB full */
MICO_BT_SDP_INVALID_PDU = 0xFFF5, /**< SDP - Invalid PDU */
MICO_BT_SDP_SECURITY_ERR = 0xFFF6, /**< SDP - Security Error */
MICO_BT_SDP_CONN_REJECTED = 0xFFF7, /**< SDP - Connection rejected */
MICO_BT_SDP_CANCEL = 0xFFF8 /**< SDP - cancel */
};
/* Define the PSM that SDP uses */
#define SDP_PSM 0x0001
/* Masks for attr_value field of mico_bt_sdp_discovery_attribute_t */
#define SDP_DISC_ATTR_LEN_MASK 0x0FFF
#define SDP_DISC_ATTR_TYPE(len_type) (len_type >> 12)
#define SDP_DISC_ATTR_LEN(len_type) (len_type & SDP_DISC_ATTR_LEN_MASK)
/* Maximum number of protocol list items (list_elem in mico_bt_sdp_protocol_elem_t) */
#define SDP_MAX_LIST_ELEMS 3
/*****************************************************************************
* Type Definitions
****************************************************************************/
/**
* Function mico_bt_sdp_discovery_complete_cback_t
*
* Service discovery complete callback.
*
* If discovery was successful, the discovery results database (provided when #mico_bt_sdp_service_search_request
* or #mico_bt_sdp_service_search_attribute_request was called) will be filled.
*
* Use the mico_bt_sdp_find_* utility functions to parse the results.
*
* @param[in] sdp_result : SDP result code (see #mico_bt_sdp_result_t)
*
* @return Nothing
*
*/
typedef void (mico_bt_sdp_discovery_complete_cback_t) (uint16_t sdp_result);
/** Attribute value */
typedef struct
{
union
{
uint8_t u8; /**< 8-bit integer */
uint16_t u16; /**< 16-bit integer */
uint32_t u32; /**< 32-bit integer */
uint8_t array[4]; /**< Variable length field */
struct t_sdp_discovery_attr *p_sub_attr; /**< Addr of first sub-attr (list)*/
} v;
} mico_bt_sdp_discovery_attribute_value_t;
/** SDP Attribute */
typedef struct t_sdp_discovery_attr
{
struct t_sdp_disc_attr *p_next_attr; /**< Addr of next linked attr */
uint16_t attr_id; /**< Attribute ID */
uint16_t attr_len_type; /**< Length and type fields */
mico_bt_sdp_discovery_attribute_value_t attr_value; /**< Variable length entry data */
} mico_bt_sdp_discovery_attribute_t;
/** Discovery record from SDP search result */
typedef struct sdp_discovery_record_t
{
mico_bt_sdp_discovery_attribute_t *p_first_attr; /**< First attribute of record */
struct sdp_discovery_record_t *p_next_rec; /**< Addr of next linked record */
uint32_t time_read; /**< The time the record was read */
mico_bt_device_address_t remote_bd_addr; /**< Remote BD address */
} mico_bt_sdp_discovery_record_t;
/** Discovery database (used for performing service searches and holding search results) */
typedef struct
{
uint32_t mem_size; /**< Memory size of the DB */
uint32_t mem_free; /**< Memory still available */
mico_bt_sdp_discovery_record_t *p_first_rec; /**< Addr of first record in DB */
uint16_t num_uuid_filters; /**< Number of UUIds to filter */
mico_bt_uuid_t uid_filters[SDP_MAX_UUID_FILTERS]; /**< UUIDs to filter */
uint16_t num_attr_filters; /**< Number of attribute filters */
uint16_t attr_filters[SDP_MAX_ATTR_FILTERS]; /**< Attributes to filter */
uint8_t *p_free_mem; /**< Pointer to free memory */
}mico_bt_sdp_discovery_db_t;
/** This structure is used to add protocol lists and find protocol elements */
typedef struct
{
uint16_t protocol_uuid; /**< The protocol uuid */
uint16_t num_params; /**< Number of parameters */
uint16_t params[SDP_MAX_PROTOCOL_PARAMS]; /**< Contents of protocol parameters */
} mico_bt_sdp_protocol_elem_t;
/*****************************************************************************
* SDP Server Database Macros
****************************************************************************/
#define SDP_UINT1(value) (value)
#define SDP_UINT2(value) (value) >> 8, (value) & 0xff
#define SDP_UINT4(value) (value) >> 24, ((value) >> 16) & 0xff, ((value) >> 8) & 0xff, (value) & 0xff
#define SDP_UINT8(value) (value) >> 56, ((value) >> 48) & 0xff, ((value >> 40) >> 8) & 0xff, \
(value >> 32) & 0xff, ((value) >> 24) & 0xff, ((value) >> 16) & 0xff, \
((value) >> 8) & 0xff, (value) & 0xff
#define SDP_BOOLEAN SDP_UINT1
#define SDP_ATTR_VALUE_UINT1(value) (UINT_DESC_TYPE << 3) | SIZE_ONE_BYTE, SDP_UINT1(value)
#define SDP_ATTR_VALUE_UINT2(value) (UINT_DESC_TYPE << 3) | SIZE_TWO_BYTES, SDP_UINT2(value)
#define SDP_ATTR_VALUE_UINT4(value) (UINT_DESC_TYPE << 3) | SIZE_FOUR_BYTES, SDP_UINT4(value)
#define SDP_ATTR_VALUE_UINT8(value) (UINT_DESC_TYPE << 3) | SIZE_EIGHT_BYTES, SDP_UINT8(value)
#define SDP_ATTR_VALUE_BOOLEAN(value) (BOOLEAN_DESC_TYPE << 3), SDP_UINT1(value)
#define SDP_ATTR_VALUE_TEXT (TEXT_STR_DESC_TYPE << 3) | SIZE_IN_NEXT_BYTE
#define SDP_ATTR_UINT1(id, value) SDP_ATTR_ID(id), SDP_ATTR_VALUE_UINT1(value)
#define SDP_ATTR_UINT2(id, value) SDP_ATTR_ID(id), SDP_ATTR_VALUE_UINT2(value)
#define SDP_ATTR_UINT4(id, value) SDP_ATTR_ID(id), SDP_ATTR_VALUE_UINT4(value)
#define SDP_ATTR_UINT8(id, value) SDP_ATTR_ID(id), SDP_ATTR_VALUE_UINT8(value)
#define SDP_ATTR_BOOLEAN(id, value) SDP_ATTR_ID(id), SDP_ATTR_VALUE_BOOLEAN(value)
#define SDP_ATTR_ID SDP_ATTR_VALUE_UINT2
#define SDP_ATTR_UUID16(uuid) ((UUID_DESC_TYPE << 3) | SIZE_TWO_BYTES), SDP_UINT2(uuid)
#define SDP_ATTR_UUID128(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16) \
((UUID_DESC_TYPE << 3) | SIZE_SIXTEEN_BYTES), \
x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16
#define SDP_ATTR_TEXT(id, len) SDP_ATTR_ID(id), SDP_ATTR_VALUE_TEXT, (len)
#define SDP_ATTR_SEQUENCE_1(length) ((DATA_ELE_SEQ_DESC_TYPE << 3) | SIZE_IN_NEXT_BYTE), (length)
#define SDP_ATTR_SEQUENCE_2(length) ((DATA_ELE_SEQ_DESC_TYPE << 3) | SIZE_IN_NEXT_WORD), SDP_UINT2(length)
#define SDP_ATTR_SEQUENCE_4(length) ((DATA_ELE_SEQ_DESC_TYPE << 3) | SIZE_IN_NEXT_LONG), SDP_UINT4(length)
/* Service Record Handle 0x0000 */
#define SDP_ATTR_RECORD_HANDLE(handle) SDP_ATTR_UINT4(ATTR_ID_SERVICE_RECORD_HDL, handle)
/* Service Class ID List 0x0001 */
#define SDP_ATTR_CLASS_ID(uuid) \
SDP_ATTR_ID(ATTR_ID_SERVICE_CLASS_ID_LIST), SDP_ATTR_SEQUENCE_1(3), \
SDP_ATTR_UUID16(uuid)
#define SDP_ATTR_CLASS_ID128(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16) \
SDP_ATTR_ID(ATTR_ID_SERVICE_CLASS_ID_LIST), SDP_ATTR_SEQUENCE_1(17), \
SDP_ATTR_UUID128(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16)
/* Service Record State 0x0002 */
#define SDP_ATTR_SERVICE_RECORD_STATE(state) \
SDP_ATTR_UINT4(ATTR_ID_SERVICE_RECORD_STATE, state)
/* Service ID 0x0003 */
#define SDP_ATTR_SERVICE_ID(uuid) \
SDP_ATTR_ID(ATTR_ID_SERVICE_ID), SDP_ATTR_SEQUENCE_1(3), \
SDP_ATTR_UUID16(uuid)
/* Protocol Descriptor List 0x0004 for L2CAP */
#define SDP_ATTR_PROTOCOL_DESC_LIST(l2cap_chan) \
SDP_ATTR_ID(ATTR_ID_PROTOCOL_DESC_LIST), SDP_ATTR_SEQUENCE_1(13), \
SDP_ATTR_SEQUENCE_1(6), \
SDP_ATTR_UUID16(UUID_PROTOCOL_L2CAP), \
SDP_ATTR_VALUE_UINT2(1), \
SDP_ATTR_SEQUENCE_1(3), \
SDP_ATTR_UUID16(l2cap_chan)
/* Protocol Descriptor List 0x0004 for RFCOMM */
#define SDP_ATTR_RFCOMM_PROTOCOL_DESC_LIST(scn) \
SDP_ATTR_ID(ATTR_ID_PROTOCOL_DESC_LIST), SDP_ATTR_SEQUENCE_1(12), \
SDP_ATTR_SEQUENCE_1(3), \
SDP_ATTR_UUID16(UUID_PROTOCOL_L2CAP), \
SDP_ATTR_SEQUENCE_1(5), \
SDP_ATTR_UUID16(UUID_PROTOCOL_RFCOMM), \
SDP_ATTR_VALUE_UINT1(scn)
/* Browse Group List 0x0005 */
#define SDP_ATTR_BROWSE_LIST \
SDP_ATTR_ID(ATTR_ID_BROWSE_GROUP_LIST), SDP_ATTR_SEQUENCE_1(3), \
SDP_ATTR_UUID16(UUID_SERVCLASS_PUBLIC_BROWSE_GROUP)
/* Language Base 0x0006 */
#define SDP_ATTR_LANGUAGE_BASE_ATTR_ID_LIST \
SDP_ATTR_ID(ATTR_ID_LANGUAGE_BASE_ATTR_ID_LIST), SDP_ATTR_SEQUENCE_1(9), \
SDP_ATTR_VALUE_UINT2(LANG_ID_CODE_ENGLISH), \
SDP_ATTR_VALUE_UINT2(LANG_ID_CHAR_ENCODE_UTF8), \
SDP_ATTR_VALUE_UINT2(LANGUAGE_BASE_ID)
/* Service Info Time to Live 0x0007 */
#define SDP_ATTR_SERVICE_INFO_TIME_TO_LIVE(seconds) \
SDP_ATTR_UINT4(ATTR_ID_SERVICE_INFO_TIME_TO_LIVE, seconds)
/* Service Availability 0x0008 */
#define SDP_ATTR_SERVICE_AVAILABILITY(availability) \
SDP_ATTR_UINT1(ATTR_ID_SERVICE_AVAILABILITY, availability)
/* BT Profile Descriptor List 0x0009 */
#define SDP_ATTR_PROFILE_DESC_LIST(uuid, version) \
SDP_ATTR_ID(ATTR_ID_BT_PROFILE_DESC_LIST), SDP_ATTR_SEQUENCE_1(8), \
SDP_ATTR_SEQUENCE_1(6), \
SDP_ATTR_UUID16(uuid), \
SDP_ATTR_VALUE_UINT2(version)
/* Documentation URL 0x000A */
#define SDP_ATTR_DOCUMENTATION_URL(len) \
SDP_ATTR_TEXT(ATTR_ID_DOCUMENTATION_URL, len)
/* Client Executable URL 0x000B */
#define SDP_ATTR_CLIENT_EXECUTABLE_URL(len) \
SDP_ATTR_TEXT(ATTR_ID_CLIENT_EXE_URL, len)
/* Icon URL 0x000C */
#define SDP_ATTR_ICON_URL(len) \
SDP_ATTR_TEXT(ATTR_ID_ICON_URL, len)
/* Service Name LANGUAGE_BASE_ID (0x0100) + 0x0000 = 0x0100 */
#define SDP_ATTR_SERVICE_NAME(len) \
SDP_ATTR_TEXT(ATTR_ID_SERVICE_NAME, len)
/* Service Description LANGUAGE_BASE_ID (0x0100) + 0x0001 = 0x0101 */
#define SDP_ATTR_SERVICE_DESCRIPTION(len) \
SDP_ATTR_TEXT(ATTR_ID_SERVICE_DESCRIPTION, len)
/* Provider Name LANGUAGE_BASE_ID (0x0100) + 0x0002 = 0x0102 */
#define SDP_ATTR_PROVIDER_NAME(len) \
SDP_ATTR_TEXT(ATTR_ID_PROVIDER_NAME, len)
/* Group ID 0x0200 */
#define SDP_ATTR_GROUP_ID(uuid) \
SDP_ATTR_ID(ATTR_ID_GROUP_ID), SDP_ATTR_SEQUENCE_1(3), \
SDP_ATTR_UUID16(uuid)
/* Version Number List 0x0200 */
#define SDP_ATTR_VERSION_NUMBER_LIST(version) \
SDP_ATTR_UINT2(ATTR_ID_SPECIFICATION_ID, version)
/* Service Database State 0x0201 */
#define SDP_ATTR_SERVICE_DATABASE_STATE(state) \
SDP_ATTR_UINT4(ATTR_ID_VENDOR_ID, state)
/*************************************************************************//**
* @addtogroup sdp_api_functions Service Discovery (SDP)
* @ingroup micobt
*
* Service Discovery (SDP) Functions.
*
* @{
****************************************************************************/
/******************************************************
* Function Declarations
******************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/* SDP Server APIs */
/**
*
* Function mico_bt_sdp_db_init
*
* Initialize local SDP server database (database generated using
* MiCO Smart/SmartReady Designer)
*
* @param[in] p_sdp_db: First element in database array
* @param[in] size: size (in bytes) of SDP database
*
* @return TRUE if successful, FALSE otherwise
*
**/
mico_bool_t mico_bt_sdp_db_init (uint8_t *p_sdp_db, uint16_t size);
/* SDP Client APIs */
/**
*
* Function mico_bt_sdp_init_discovery_db
*
* Initialize discovery database prior to performing service
* discovery (using #mico_bt_sdp_service_search_request or
* #mico_bt_sdp_service_search_request).
*
* Provides a list of UUIDs and/or attribute IDs to search for.
*
* @param[in] p_db : Discovery database to initialize
* @param[in] len : size of discovery database
* @param[in] num_uuid : Number of UUIDs in p_uuid_list
* @param[in] p_uuid_list : UUIDs to add to discovery database
* @param[in] num_attr : Number of attributes in p_attr_list
* @param[in] p_attr_list : Attributes to add to discovery database
*
* @return TRUE if successful, FALSE if one or more parameters are bad
*
**/
mico_bool_t mico_bt_sdp_init_discovery_db (mico_bt_sdp_discovery_db_t *p_db, uint32_t len,
uint16_t num_uuid,
mico_bt_uuid_t *p_uuid_list,
uint16_t num_attr,
uint16_t *p_attr_list);
/**
*
* Function mico_bt_sdp_cancel_service_search
*
* Cancel service search request
*
* @param[in] p_db : Discovery database of the request being cancelled
*
* @return TRUE if discovery cancelled, FALSE if a matching activity is not found.
*
**/
mico_bool_t mico_bt_sdp_cancel_service_search (mico_bt_sdp_discovery_db_t *p_db);
/**
*
* Function mico_bt_sdp_service_search_request
*
* Initiate service search on remote device
*
* @param[in] p_bd_addr : Remote device address
* @param[in] p_db : Discovery database of UUIDs and attribute IDs to search for (intialized using #mico_bt_sdp_init_discovery_db)
* @param[in] p_cb : Callback for discovery results
*
* @return TRUE if discovery started, FALSE if failed.
*
**/
mico_bool_t mico_bt_sdp_service_search_request (uint8_t *p_bd_addr,
mico_bt_sdp_discovery_db_t *p_db,
mico_bt_sdp_discovery_complete_cback_t *p_cb);
/**
*
* Function mico_bt_sdp_service_search_attribute_request
*
* Initiate combined service search and attribute request on remote device
*
* @param[in] p_bd_addr : Remote device address
* @param[in] p_db : Discovery database of UUIDs and attribute IDs to search for (intialized using #mico_bt_sdp_init_discovery_db)
* @param[in] p_cb : Callback for discovery results
*
* @return TRUE if discovery started, FALSE if failed.
*
**/
mico_bool_t mico_bt_sdp_service_search_attribute_request (uint8_t *p_bd_addr,
mico_bt_sdp_discovery_db_t *p_db,
mico_bt_sdp_discovery_complete_cback_t *p_cb);
/* API of utilities to find data in the local discovery database */
/**
*
* Function mico_bt_sdp_find_attribute_in_db
*
* Parse results from service search. Look next record in discovery database
* containing attribute ID.
*
* @param[in] p_db : Discovery results database
* @param[in] attr_id : Attribute ID to find
* @param[in] p_start_rec : Starting record to search from (if NULL, start from beginning of database)
*
* @return Pointer to matching record, or NULL
*
**/
mico_bt_sdp_discovery_record_t *mico_bt_sdp_find_attribute_in_db (mico_bt_sdp_discovery_db_t *p_db,
uint16_t attr_id,
mico_bt_sdp_discovery_record_t *p_start_rec);
/**
*
* Function mico_bt_sdp_find_attribute_in_rec
*
* Parse SDP record. Look for requested attribute in the service record.
*
* @param[in] p_rec : Service record
* @param[in] attr_id : Attribute ID to find
*
* @return Pointer to matching attribute entry, or NULL
*
**/
mico_bt_sdp_discovery_attribute_t *mico_bt_sdp_find_attribute_in_rec (mico_bt_sdp_discovery_record_t *p_rec,
uint16_t attr_id);
/**
*
* Function mico_bt_sdp_find_service_in_db
*
* Parse results from service search. Look next record in discovery database
* containing requested service UUID (specified using uint16_t)
*
* @param[in] p_db : Discovery results database
* @param[in] service_uuid: Service to find
* @param[in] p_start_rec : Starting record to search from (if NULL, start from beginning of database)
*
* @return Pointer to matching record, or NULL
*
**/
mico_bt_sdp_discovery_record_t *mico_bt_sdp_find_service_in_db (mico_bt_sdp_discovery_db_t *p_db,
uint16_t service_uuid,
mico_bt_sdp_discovery_record_t *p_start_rec);
/**
*
* Function mico_bt_sdp_find_service_uuid_in_db
*
* Parse results from service search. Look next record in discovery database
* containing requested service UUID (specified using mico_bt_uuid_t structure)
*
* @param[in] p_db : Discovery results database
* @param[in] p_uuid : Service to find
* @param[in] p_start_rec : Starting record to search from (if NULL, start from beginning of database)
*
* @return Pointer to matching record, or NULL
*
**/
mico_bt_sdp_discovery_record_t *mico_bt_sdp_find_service_uuid_in_db (mico_bt_sdp_discovery_db_t *p_db,
mico_bt_uuid_t *p_uuid,
mico_bt_sdp_discovery_record_t *p_start_rec);
/**
*
* Function mico_bt_sdp_find_protocol_list_elem_in_rec
*
* Parse SDP record. Look for requested protocol list element in the service record.
*
* @param[in] p_rec : Service record
* @param[in] layer_uuid : protocol list element to find
* @param[out] p_elem : protocol list element (if found)
*
* @return TRUE if found, else FALSE
*
**/
mico_bool_t mico_bt_sdp_find_protocol_list_elem_in_rec (mico_bt_sdp_discovery_record_t *p_rec,
uint16_t layer_uuid,
mico_bt_sdp_protocol_elem_t *p_elem);
/**
*
* Function mico_bt_sdp_find_protocol_lists_elem_in_rec
*
* Parse SDP record. Look for requested protocol lists element in the service record.
*
* @param[in] p_rec : Service record
* @param[in] layer_uuid : protocol lists element to find
* @param[out] p_elem : protocol lists element (if found)
*
* @return TRUE if found, else FALSE
*
**/
mico_bool_t mico_bt_sdp_find_protocol_lists_elem_in_rec (mico_bt_sdp_discovery_record_t *p_rec,
uint16_t layer_uuid,
mico_bt_sdp_protocol_elem_t *p_elem);
/**
*
* Function mico_bt_sdp_find_profile_version_in_rec
*
* Parse SDP record. Look for version of requested profile.
*
* @param[in] p_rec : Service record
* @param[in] profile_uuid: Profile to find
* @param[out] p_version : Major/minor version of profile (if found)
*
* @return TRUE if found, FALSE if not
*
**/
mico_bool_t mico_bt_sdp_find_profile_version_in_rec (mico_bt_sdp_discovery_record_t *p_rec,
uint16_t profile_uuid,
uint16_t *p_version);
/**
*
* Function mico_bt_sdp_find_service_uuid_in_rec
*
* Parse SDP record. Look for service UUID
*
* @param[in] p_rec : Service record
* @param[out] p_uuid : Service UUID of the record
*
* @return TRUE if found, FALSE if not
*
**/
mico_bool_t mico_bt_sdp_find_service_uuid_in_rec(mico_bt_sdp_discovery_record_t *p_rec, mico_bt_uuid_t *p_uuid);
#ifdef __cplusplus
}
#endif
/**@} sdp_api_functions */

View File

@@ -0,0 +1,88 @@
/**
* UNPUBLISHED PROPRIETARY SOURCE CODE
* Copyright (c) 2016 MXCHIP Inc.
*
* 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 MXCHIP Corporation.
*
*/
/** @file
*
* Bluetooth Management (BTM) Application Programming Interface
*
* The BTM consists of several management entities:
* 1. Device Control - controls the local device
* 2. Device Discovery - manages inquiries, discover database
* 3. ACL Channels - manages ACL connections (BR/EDR and LE)
* 4. SCO Channels - manages SCO connections
* 5. Security - manages all security functionality
* 6. Power Management - manages park, sniff, hold, etc.
*
* @defgroup micobt Bluetooth
*
* MiCO Bluetooth Framework Functions
*/
#pragma once
#include "mico_bt_dev.h"
#include "mico_bt_cfg.h"
/******************************************************
* Function Declarations
******************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************************/
/**
* Framework Management Functions
*
* @addtogroup micobt_Framework Framework
* @ingroup micobt
*
* @{
*/
/****************************************************************************/
/**
* Function mico_bt_stack_init
*
* Initialize the Bluetooth controller and stack; register
* callback for Bluetooth event notification.
*
* @param[in] p_bt_management_cback : Callback for receiving Bluetooth management events
* @param[in] p_bt_cfg_settings : Bluetooth stack configuration
* @param[in] mico_bt_cfg_buf_pools : Buffer pool configuration
*
* @return MICO_BT_SUCCESS : on success;
* MICO_BT_FAILED : if an error occurred
*/
mico_bt_result_t mico_bt_stack_init(mico_bt_management_cback_t *p_bt_management_cback,
const mico_bt_cfg_settings_t *p_bt_cfg_settings,
const mico_bt_cfg_buf_pool_t mico_bt_cfg_buf_pools[MICO_BT_CFG_NUM_BUF_POOLS]);
/**
* Function mico_bt_stack_deinit
*
* De-initialize the Bluetooth controller and stack.
*
* @return MICO_BT_SUCCESS : on success;
* MICO_BT_ERROR : if an error occurred
*/
OSStatus mico_bt_stack_deinit(void);
/**@} micobt_Framework */
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,124 @@
/**
* UNPUBLISHED PROPRIETARY SOURCE CODE
* Copyright (c) 2016 MXCHIP Inc.
*
* 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 MXCHIP Corporation.
*
*/
/** @file
*
* Generic types
*
*/
#pragma once
#include "common.h"
#include "data_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define BD_ADDR_LEN 6
typedef uint8_t mico_bt_device_address_t[BD_ADDR_LEN]; /**< Device address length */
typedef uint8_t *mico_bt_device_address_ptr_t; /**< Device address Pointer */
#define DEV_CLASS_LEN 3
typedef uint8_t mico_bt_dev_class_t[DEV_CLASS_LEN]; /**< Device class */
#define MAX_UUID_SIZE 16 /**< Maximum UUID size - 16 bytes, and structure to hold any type of UUID. */
/** UUID Type */
typedef struct
{
#define LEN_UUID_16 2
#define LEN_UUID_32 4
#define LEN_UUID_128 16
uint16_t len; /**< UUID length */
union
{
uint16_t uuid16; /**< 16-bit UUID */
uint32_t uuid32; /**< 32-bit UUID */
uint8_t uuid128[MAX_UUID_SIZE]; /**< 128-bit UUID */
} uu;
} mico_bt_uuid_t;
#define BT_OCTET16_LEN 16 /**< length: 16 */
typedef uint8_t BT_OCTET16[BT_OCTET16_LEN]; /**< octet array: size 16 */
#define BT_OCTET32_LEN 32
typedef uint8_t BT_OCTET32[BT_OCTET32_LEN]; /* octet array: size 32 */
/** Bluetooth QoS defintions */
typedef struct {
uint8_t qos_flags; /**< TBD */
uint8_t service_type; /**< service type (NO_TRAFFIC, BEST_EFFORT, or GUARANTEED) */
uint32_t token_rate; /**< token rate (bytes/second) */
uint32_t token_bucket_size; /**< token bucket size (bytes) */
uint32_t peak_bandwidth; /**< peak bandwidth (bytes/second) */
uint32_t latency; /**< latency (microseconds) */
uint32_t delay_variation; /**< delay variation (microseconds) */
} mico_bt_flow_spec_t;
/* Values for smico_bt_flow_spec_t service_type */
#define NO_TRAFFIC 0
#define BEST_EFFORT 1
#define GUARANTEED 2
/**
* @anchor MICO_BT_TRANSPORT_TYPE
* @name Transport types
* @{
*/
#define BT_TRANSPORT_BR_EDR 1 /**< BR/EDR transport */
#define BT_TRANSPORT_LE 2 /**< BLE transport */
typedef uint8_t mico_bt_transport_t; /**< Transport type (see @ref MICO_BT_TRANSPORT_TYPE "BT Transport Types") */
/**
* @anchor MICO_BT_DEVICE_TYPE
* @name Device Types
* @{
*/
#define BT_DEVICE_TYPE_BREDR 0x01 /**< BR/EDR device */
#define BT_DEVICE_TYPE_BLE 0x02 /**< LE device */
#define BT_DEVICE_TYPE_BREDR_BLE 0x03 /**< Dual Mode device */
typedef uint8_t mico_bt_device_type_t; /**< Bluetooth device type (see @ref MICO_BT_DEVICE_TYPE "BT Device Types") */
/** @} MICO_BT_DEVICE_TYPE */
/**
* @anchor MICO_BT_ADDR_TYPE
* @name Address Types
* @{
*/
#define BLE_ADDR_PUBLIC 0x00 /**< Public address */
#define BLE_ADDR_RANDOM 0x01 /**< Random address */
#define BLE_ADDR_PUBLIC_ID 0x02 /**< Public ID */
#define BLE_ADDR_RANDOM_ID 0x03 /**< Random ID */
typedef uint8_t mico_bt_ble_address_type_t; /**< BLE device address type (see @ref MICO_BT_ADDR_TYPE "BT Address Types")*/
#define BLE_ADDR_TYPE_MASK (BLE_ADDR_RANDOM | BLE_ADDR_PUBLIC)
/** @} MICO_BT_ADDR_TYPE */
typedef struct
{
mico_bt_ble_address_type_t type;
mico_bt_device_address_t bda;
} mico_bt_ble_address_t;
#define LINK_KEY_LEN 16
typedef uint8_t mico_bt_link_key_t[LINK_KEY_LEN];
#define BT_ROLE_MASTER 0x00
#define BT_ROLE_SLAVE 0x01
typedef uint8_t mico_bt_ble_link_role_t;
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,337 @@
/****************************************************************************
**
** Name: sdp_defs.h
**
** Function this file contains the definitions for the SDP API
**
******************************************************************************/
#ifndef SDP_DEFS_H
#define SDP_DEFS_H
/* Define the service attribute IDs.
*/
#define ATTR_ID_SERVICE_RECORD_HDL 0x0000
#define ATTR_ID_SERVICE_CLASS_ID_LIST 0x0001
#define ATTR_ID_SERVICE_RECORD_STATE 0x0002
#define ATTR_ID_SERVICE_ID 0x0003
#define ATTR_ID_PROTOCOL_DESC_LIST 0x0004
#define ATTR_ID_BROWSE_GROUP_LIST 0x0005
#define ATTR_ID_LANGUAGE_BASE_ATTR_ID_LIST 0x0006
#define ATTR_ID_SERVICE_INFO_TIME_TO_LIVE 0x0007
#define ATTR_ID_SERVICE_AVAILABILITY 0x0008
#define ATTR_ID_BT_PROFILE_DESC_LIST 0x0009
#define ATTR_ID_DOCUMENTATION_URL 0x000A
#define ATTR_ID_CLIENT_EXE_URL 0x000B
#define ATTR_ID_ICON_URL 0x000C
#define ATTR_ID_ADDITION_PROTO_DESC_LISTS 0x000D
#define LANGUAGE_BASE_ID 0x0100
#define ATTR_ID_SERVICE_NAME LANGUAGE_BASE_ID + 0x0000
#define ATTR_ID_SERVICE_DESCRIPTION LANGUAGE_BASE_ID + 0x0001
#define ATTR_ID_PROVIDER_NAME LANGUAGE_BASE_ID + 0x0002
/* Device Identification (DI)
*/
#define ATTR_ID_SPECIFICATION_ID 0x0200
#define ATTR_ID_VENDOR_ID 0x0201
#define ATTR_ID_PRODUCT_ID 0x0202
#define ATTR_ID_PRODUCT_VERSION 0x0203
#define ATTR_ID_PRIMARY_RECORD 0x0204
#define ATTR_ID_VENDOR_ID_SOURCE 0x0205
#define BLUETOOTH_DI_SPECIFICATION 0x0103 /* 1.3 */
#define DI_VENDOR_ID_DEFAULT 0xFFFF
#define DI_VENDOR_ID_SOURCE_BTSIG 0x0001
#define DI_VENDOR_ID_SOURCE_USBIF 0x0002
#define ATTR_ID_IP_SUBNET 0x0200 /* PAN Profile (***) */
#define ATTR_ID_VERSION_NUMBER_LIST 0x0200
#define ATTR_ID_GROUP_ID 0x0200
#define ATTR_ID_SERVICE_DATABASE_STATE 0x0201
#define ATTR_ID_SERVICE_VERSION 0x0300
#define ATTR_ID_HCRP_1284ID 0x0300
#define ATTR_ID_SUPPORTED_DATA_STORES 0x0301
#define ATTR_ID_NETWORK 0x0301
#define ATTR_ID_EXTERNAL_NETWORK 0x0301
#define ATTR_ID_FAX_CLASS_1_SUPPORT 0x0302
#define ATTR_ID_REMOTE_AUDIO_VOLUME_CONTROL 0x0302
#define ATTR_ID_DEVICE_NAME 0x0302
#define ATTR_ID_SUPPORTED_FORMATS_LIST 0x0303
#define ATTR_ID_FAX_CLASS_2_0_SUPPORT 0x0303
#define ATTR_ID_FAX_CLASS_2_SUPPORT 0x0304
#define ATTR_ID_FRIENDLY_NAME 0x0304
#define ATTR_ID_AUDIO_FEEDBACK_SUPPORT 0x0305
#define ATTR_ID_NETWORK_ADDRESS 0x0306
#define ATTR_ID_DEVICE_LOCATION 0x0306
#define ATTR_ID_WAP_GATEWAY 0x0307
#define ATTR_ID_HOME_PAGE_URL 0x0308
#define ATTR_ID_WAP_STACK_TYPE 0x0309
#define ATTR_ID_IMG_SUPPORTED_CAPABILITIES 0x0310 /* Imaging Profile */
#define ATTR_ID_SUPPORTED_FEATURES 0x0311 /* HFP, BIP */
#define ATTR_ID_IMG_SUPPORTED_FUNCTIONS 0x0312 /* Imaging Profile */
#define ATTR_ID_IMG_TOT_DATA_CAPABILITY 0x0313 /* Imaging Profile */
#define ATTR_ID_SUPPORTED_REPOSITORIES 0x0314 /* Phone book access Profile */
#define ATTR_ID_INSTANCE_ID 0x0315 /* MAP, CTN profile */
#define ATTR_ID_SUPPORTED_MSG_TYPE 0x0316 /* MAP profile */
/* MAP 1.2 uses this, but PBAP 1.2 and GPP, and
** other profiles can also use this generic 32-bit mask
*/
#define ATTR_ID_SUPPORTED_FEATURES_32 0x0317 /* 32-bit supported features */
/* These values are for the BPP profile */
#define ATTR_ID_DOCUMENT_FORMATS_SUPPORTED 0x0350
#define ATTR_ID_CHARACTER_REPERTOIRES_SUPPORTED 0x0352
#define ATTR_ID_XHTML_IMAGE_FORMATS_SUPPORTED 0x0354
#define ATTR_ID_COLOR_SUPPORTED 0x0356
#define ATTR_ID_1284ID 0x0358
#define ATTR_ID_PRINTER_NAME 0x035A
#define ATTR_ID_PRINTER_LOCATION 0x035C
#define ATTR_ID_DUPLEX_SUPPORTED 0x035E
#define ATTR_ID_MEDIA_TYPES_SUPPORTED 0x0360
#define ATTR_ID_MAX_MEDIA_WIDTH 0x0362
#define ATTR_ID_MAX_MEDIA_LENGTH 0x0364
#define ATTR_ID_ENHANCED_LAYOUT_SUPPORTED 0x0366
#define ATTR_ID_RUI_FORMATS_SUPPORTED 0x0368
#define ATTR_ID_RUI_REF_PRINTING_SUPPORTED 0x0370 /* Boolean */
#define ATTR_ID_RUI_DIRECT_PRINTING_SUPPORTED 0x0372 /* Boolean */
#define ATTR_ID_REF_PRINTING_TOP_URL 0x0374
#define ATTR_ID_DIRECT_PRINTING_TOP_URL 0x0376
#define ATTR_ID_PRINTER_ADMIN_RUI_TOP_URL 0x0378
#define ATTR_ID_BPP_DEVICE_NAME 0x037A
/* These values are for the PAN profile */
#define ATTR_ID_SECURITY_DESCRIPTION 0x030A
#define ATTR_ID_NET_ACCESS_TYPE 0x030B
#define ATTR_ID_MAX_NET_ACCESS_RATE 0x030C
#define ATTR_ID_IPV4_SUBNET 0x030D
#define ATTR_ID_IPV6_SUBNET 0x030E
#define ATTR_ID_PAN_SECURITY 0x0400
/* These values are for HID profile */
#define ATTR_ID_HID_DEVICE_RELNUM 0x0200
#define ATTR_ID_HID_PARSER_VERSION 0x0201
#define ATTR_ID_HID_DEVICE_SUBCLASS 0x0202
#define ATTR_ID_HID_COUNTRY_CODE 0x0203
#define ATTR_ID_HID_VIRTUAL_CABLE 0x0204
#define ATTR_ID_HID_RECONNECT_INITIATE 0x0205
#define ATTR_ID_HID_DESCRIPTOR_LIST 0x0206
#define ATTR_ID_HID_LANGUAGE_ID_BASE 0x0207
#define ATTR_ID_HID_SDP_DISABLE 0x0208
#define ATTR_ID_HID_BATTERY_POWER 0x0209
#define ATTR_ID_HID_REMOTE_WAKE 0x020A
#define ATTR_ID_HID_PROFILE_VERSION 0x020B
#define ATTR_ID_HID_LINK_SUPERVISION_TO 0x020C
#define ATTR_ID_HID_NORMALLY_CONNECTABLE 0x020D
#define ATTR_ID_HID_BOOT_DEVICE 0x020E
#define ATTR_ID_HID_SSR_HOST_MAX_LAT 0x020F
#define ATTR_ID_HID_SSR_HOST_MIN_TOUT 0x0210
/* These values are for the HDP profile */
#define ATTR_ID_HDP_SUP_FEAT_LIST 0x0200 /* Supported features list */
#define ATTR_ID_HDP_DATA_EXCH_SPEC 0x0301 /* Data exchange specification */
#define ATTR_ID_HDP_MCAP_SUP_PROC 0x0302 /* MCAP supported procedures */
/* These values are for GOEP */
#define ATTR_ID_OBX_OVR_L2CAP_PSM 0x0200
/* MultiProfile Attribute IDs */
#define BTA_MPS_UUID_MPSD_SCENARIOS ((UINT16) 0x200)
#define BTA_MPS_UUID_MPMD_SCENARIOS ((UINT16) 0x201)
#define BTA_MPS_UUID_PPD_SUPPORTED ((UINT16) 0x202)
/* Define common 16-bit protocol UUIDs
*/
#define UUID_PROTOCOL_SDP 0x0001
#define UUID_PROTOCOL_UDP 0x0002
#define UUID_PROTOCOL_RFCOMM 0x0003
#define UUID_PROTOCOL_TCP 0x0004
#define UUID_PROTOCOL_TCS_BIN 0x0005
#define UUID_PROTOCOL_TCS_AT 0x0006
#define UUID_PROTOCOL_OBEX 0x0008
#define UUID_PROTOCOL_IP 0x0009
#define UUID_PROTOCOL_FTP 0x000A
#define UUID_PROTOCOL_HTTP 0x000C
#define UUID_PROTOCOL_WSP 0x000E
#define UUID_PROTOCOL_BNEP 0x000F
#define UUID_PROTOCOL_UPNP 0x0010
#define UUID_PROTOCOL_HIDP 0x0011
#define UUID_PROTOCOL_HCRP_CTRL 0x0012
#define UUID_PROTOCOL_HCRP_DATA 0x0014
#define UUID_PROTOCOL_HCRP_NOTIF 0x0016
#define UUID_PROTOCOL_AVCTP 0x0017
#define UUID_PROTOCOL_AVDTP 0x0019
#define UUID_PROTOCOL_CMTP 0x001B
#define UUID_PROTOCOL_UDI 0x001D
#define UUID_PROTOCOL_MCAP_CTRL 0x001E
#define UUID_PROTOCOL_MCAP_DATA 0x001F
#define UUID_PROTOCOL_L2CAP 0x0100
#define UUID_PROTOCOL_ATT 0x0007
/* Define common 16-bit service class UUIDs
*/
#define UUID_SERVCLASS_SERVICE_DISCOVERY_SERVER 0X1000
#define UUID_SERVCLASS_BROWSE_GROUP_DESCRIPTOR 0X1001
#define UUID_SERVCLASS_PUBLIC_BROWSE_GROUP 0X1002
#define UUID_SERVCLASS_SERIAL_PORT 0X1101
#define UUID_SERVCLASS_LAN_ACCESS_USING_PPP 0X1102
#define UUID_SERVCLASS_DIALUP_NETWORKING 0X1103
#define UUID_SERVCLASS_IRMC_SYNC 0X1104
#define UUID_SERVCLASS_OBEX_OBJECT_PUSH 0X1105
#define UUID_SERVCLASS_OBEX_FILE_TRANSFER 0X1106
#define UUID_SERVCLASS_IRMC_SYNC_COMMAND 0X1107
#define UUID_SERVCLASS_HEADSET 0X1108
#define UUID_SERVCLASS_CORDLESS_TELEPHONY 0X1109
#define UUID_SERVCLASS_AUDIO_SOURCE 0X110A
#define UUID_SERVCLASS_AUDIO_SINK 0X110B
#define UUID_SERVCLASS_AV_REM_CTRL_TARGET 0X110C /* Audio/Video Control profile */
#define UUID_SERVCLASS_ADV_AUDIO_DISTRIBUTION 0X110D /* Advanced Audio Distribution profile */
#define UUID_SERVCLASS_AV_REMOTE_CONTROL 0X110E /* Audio/Video Control profile */
#define UUID_SERVCLASS_AV_REM_CTRL_CONTROL 0X110F /* Audio/Video Control profile */
#define UUID_SERVCLASS_INTERCOM 0X1110
#define UUID_SERVCLASS_FAX 0X1111
#define UUID_SERVCLASS_HEADSET_AUDIO_GATEWAY 0X1112
#define UUID_SERVCLASS_WAP 0X1113
#define UUID_SERVCLASS_WAP_CLIENT 0X1114
#define UUID_SERVCLASS_PANU 0X1115 /* PAN profile */
#define UUID_SERVCLASS_NAP 0X1116 /* PAN profile */
#define UUID_SERVCLASS_GN 0X1117 /* PAN profile */
#define UUID_SERVCLASS_DIRECT_PRINTING 0X1118 /* BPP profile */
#define UUID_SERVCLASS_REFERENCE_PRINTING 0X1119 /* BPP profile */
#define UUID_SERVCLASS_IMAGING 0X111A /* Imaging profile */
#define UUID_SERVCLASS_IMAGING_RESPONDER 0X111B /* Imaging profile */
#define UUID_SERVCLASS_IMAGING_AUTO_ARCHIVE 0X111C /* Imaging profile */
#define UUID_SERVCLASS_IMAGING_REF_OBJECTS 0X111D /* Imaging profile */
#define UUID_SERVCLASS_HF_HANDSFREE 0X111E /* Handsfree profile */
#define UUID_SERVCLASS_AG_HANDSFREE 0X111F /* Handsfree profile */
#define UUID_SERVCLASS_DIR_PRT_REF_OBJ_SERVICE 0X1120 /* BPP profile */
#define UUID_SERVCLASS_REFLECTED_UI 0X1121 /* BPP profile */
#define UUID_SERVCLASS_BASIC_PRINTING 0X1122 /* BPP profile */
#define UUID_SERVCLASS_PRINTING_STATUS 0X1123 /* BPP profile */
#define UUID_SERVCLASS_HUMAN_INTERFACE 0X1124 /* HID profile */
#define UUID_SERVCLASS_CABLE_REPLACEMENT 0X1125 /* HCRP profile */
#define UUID_SERVCLASS_HCRP_PRINT 0X1126 /* HCRP profile */
#define UUID_SERVCLASS_HCRP_SCAN 0X1127 /* HCRP profile */
#define UUID_SERVCLASS_COMMON_ISDN_ACCESS 0X1128 /* CAPI Message Transport Protocol*/
#define UUID_SERVCLASS_VIDEO_CONFERENCING_GW 0X1129 /* Video Conferencing profile */
#define UUID_SERVCLASS_UDI_MT 0X112A /* Unrestricted Digital Information profile */
#define UUID_SERVCLASS_UDI_TA 0X112B /* Unrestricted Digital Information profile */
#define UUID_SERVCLASS_VCP 0X112C /* Video Conferencing profile */
#define UUID_SERVCLASS_SAP 0X112D /* SIM Access profile */
#define UUID_SERVCLASS_PBAP_PCE 0X112E /* Phonebook Access - PCE */
#define UUID_SERVCLASS_PBAP_PSE 0X112F /* Phonebook Access - PSE */
#define UUID_SERVCLASS_PHONE_ACCESS 0x1130
#define UUID_SERVCLASS_HEADSET_HS 0x1131 /* Headset - HS, from HSP v1.2 */
#define UUID_SERVCLASS_MAP_PROFILE 0X1134 /* MAP profile UUID */
#define UUID_SERVCLASS_MESSAGE_ACCESS 0X1132 /* Message Access Service UUID */
#define UUID_SERVCLASS_MESSAGE_NOTIFICATION 0X1133 /* Message Notification Service UUID */
#define UUID_SERVCLASS_3DD 0x1137 /* 3D Sync (Display role) */
#define UUID_SERVCLASS_3DG 0x1138 /* 3D Sync (Glasses role) */
#define UUID_SERVCLASS_3DS 0x1139 /* 3D Sync Profile */
#define UUID_PROFILE_MULTIPROFILE 0X113A /* Multiprofile Profile UUID */
#define UUID_SERVCLASS_MULTIPROFILE 0X113B /* Multiprofile Service UUID */
#define UUID_SERVCLASS_CAS 0x113C /* CTN Access Service */
#define UUID_SERVCLASS_CNS 0x113D /* CTN Notification Service */
#define UUID_SERVCLASS_CTN 0x113E /* Calendar Tasks and Notes Profile (CTN) */
#define UUID_SERVCLASS_PNP_INFORMATION 0X1200 /* Device Identification */
#define UUID_SERVCLASS_GENERIC_NETWORKING 0X1201
#define UUID_SERVCLASS_GENERIC_FILETRANSFER 0X1202
#define UUID_SERVCLASS_GENERIC_AUDIO 0X1203
#define UUID_SERVCLASS_GENERIC_TELEPHONY 0X1204
#define UUID_SERVCLASS_UPNP_SERVICE 0X1205 /* UPNP_Service [ESDP] */
#define UUID_SERVCLASS_UPNP_IP_SERVICE 0X1206 /* UPNP_IP_Service [ESDP] */
#define UUID_SERVCLASS_ESDP_UPNP_IP_PAN 0X1300 /* UPNP_IP_PAN [ESDP] */
#define UUID_SERVCLASS_ESDP_UPNP_IP_LAP 0X1301 /* UPNP_IP_LAP [ESDP] */
#define UUID_SERVCLASS_ESDP_UPNP_IP_L2CAP 0X1302 /* UPNP_L2CAP [ESDP] */
#define UUID_SERVCLASS_VIDEO_SOURCE 0X1303 /* Video Distribution Profile (VDP) */
#define UUID_SERVCLASS_VIDEO_SINK 0X1304 /* Video Distribution Profile (VDP) */
#define UUID_SERVCLASS_VIDEO_DISTRIBUTION 0X1305 /* Video Distribution Profile (VDP) */
#define UUID_SERVCLASS_HDP_PROFILE 0X1400 /* Health Device profile (HDP) */
#define UUID_SERVCLASS_HDP_SOURCE 0X1401 /* Health Device profile (HDP) */
#define UUID_SERVCLASS_HDP_SINK 0X1402 /* Health Device profile (HDP) */
#define UUID_SERVCLASS_GAP_SERVER 0x1800
#define UUID_SERVCLASS_GATT_SERVER 0x1801
#define UUID_SERVCLASS_IMMEDIATE_ALERT 0x1802 /* immediate alert */
#define UUID_SERVCLASS_LINKLOSS 0x1803 /* Link Loss Alert */
#define UUID_SERVCLASS_TX_POWER 0x1804 /* TX power */
#define UUID_SERVCLASS_CURRENT_TIME 0x1805 /* Link Loss Alert */
#define UUID_SERVCLASS_DST_CHG 0x1806 /* DST Time change */
#define UUID_SERVCLASS_REF_TIME_UPD 0x1807 /* reference time update */
#define UUID_SERVCLASS_THERMOMETER 0x1809 /* Thermometer UUID */
#define UUID_SERVCLASS_DEVICE_INFO 0x180A /* device info service */
#define UUID_SERVCLASS_NWA 0x180B /* Network availability */
#define UUID_SERVCLASS_HEART_RATE 0x180D /* Heart Rate service */
#define UUID_SERVCLASS_PHALERT 0x180E /* phone alert service */
#define UUID_SERVCLASS_BATTERY 0x180F /* battery service */
#define UUID_SERVCLASS_BPM 0x1810 /* blood pressure service */
#define UUID_SERVCLASS_ALERT_NOTIFICATION 0x1811 /* alert notification service */
#define UUID_SERVCLASS_LE_HID 0x1812 /* HID over LE */
#define UUID_SERVCLASS_SCAN_PARAM 0x1813 /* Scan Parameter service */
#define UUID_SERVCLASS_GLUCOSE 0x1808 /* Glucose Meter Service */
#define UUID_SERVCLASS_RSC 0x1814 /* Runners Speed and Cadence Service */
#define UUID_SERVCLASS_CSC 0x1816 /* Cycling Speed and Cadence Service */
#define UUID_SERVCLASS_CP 0x1818 /* Cycling Power Service (pre-Adoption IOP) */
#define UUID_SERVCLASS_LN 0x1819 /* Location and Navigation Service (pre-Adoption IOP) */
#define UUID_SERVCLASS_HPS 0x7F10 /* HTTP Proxy Service */
#define UUID_SERVCLASS_TEST_SERVER 0x9000 /* Test Group UUID */
#if (BTM_WBS_INCLUDED == TRUE )
#define UUID_CODEC_CVSD 0x0001 /* CVSD */
#define UUID_CODEC_MSBC 0x0002 /* mSBC */
#endif
#define UUID_HF_IND_EDS 0x0001 /* HF indicator for enhanced driver safety */
/* Define all the 'Descriptor Type' values.
*/
#define NULL_DESC_TYPE 0
#define UINT_DESC_TYPE 1
#define TWO_COMP_INT_DESC_TYPE 2
#define UUID_DESC_TYPE 3
#define TEXT_STR_DESC_TYPE 4
#define BOOLEAN_DESC_TYPE 5
#define DATA_ELE_SEQ_DESC_TYPE 6
#define DATA_ELE_ALT_DESC_TYPE 7
#define URL_DESC_TYPE 8
/* Define all the "Descriptor Size" values.
*/
#define SIZE_ONE_BYTE 0
#define SIZE_TWO_BYTES 1
#define SIZE_FOUR_BYTES 2
#define SIZE_EIGHT_BYTES 3
#define SIZE_SIXTEEN_BYTES 4
#define SIZE_IN_NEXT_BYTE 5
#define SIZE_IN_NEXT_WORD 6
#define SIZE_IN_NEXT_LONG 7
/* Language Encoding Constants */
#define LANG_ID_CODE_ENGLISH ((UINT16) 0x656e) /* "en" */
#define LANG_ID_CHAR_ENCODE_UTF8 ((UINT16) 0x006a) /* UTF-8 */
/* Constants used for display purposes only. These define ovelapping attribute values */
#define ATTR_ID_VERS_OR_GRP_OR_DRELNUM_OR_IPSUB_OR_SPECID_OR_MPSD 0x0200
#define ATTR_ID_VEND_ID_OR_SERVICE_DB_STATE_OR_PARSE_VER_OR_MPMD 0x0201
#define ATTR_ID_PROD_ID_OR_HID_DEV_SUBCLASS_OR_MPSPP 0x0202
#define ATTR_ID_PROD_VER_OR_HID_COUNTRY_CODE 0x0203
#define ATTR_ID_PRIMARY_REC_OR_HID_VIRTUAL_CABLE 0x0204
#define ATTR_ID_DI_VENDOR_ID_SOURCE_OR_HID_INIT_RECONNECT 0x0205
#define ATTR_ID_SERV_VERS_OR_1284ID 0x0300
#define ATTR_ID_DATA_STORES_OR_NETWORK 0x0301
#define ATTR_ID_FAX_1_OR_AUD_VOL_OR_DEV_NAME 0x0302
#define ATTR_ID_FORMATS_OR_FAX_2_0 0x0303
#define ATTR_ID_FAX_CLASS_2_OR_FRIENDLY_NAME 0x0304
#define ATTR_ID_NETADDRESS_OR_DEVLOCATION 0x0306
#endif