Added support for obtaining BLE device name by parsing advertising data.

Fork of BLE_BlueNRG by Mridupawan Das

Committer:
mridup
Date:
Mon Jul 21 08:28:47 2014 +0000
Revision:
2:a2b623661316
Latest Changes 21/07

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mridup 2:a2b623661316 1 /******************** (C) COPYRIGHT 2012 STMicroelectronics ********************
mridup 2:a2b623661316 2 * File Name : gatt_server.h
mridup 2:a2b623661316 3 * Author : AMS - HEA&RF BU
mridup 2:a2b623661316 4 * Version : V1.0.0
mridup 2:a2b623661316 5 * Date : 19-July-2012
mridup 2:a2b623661316 6 * Description : Header file for BlueNRG's GATT server layer.
mridup 2:a2b623661316 7 ********************************************************************************
mridup 2:a2b623661316 8 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
mridup 2:a2b623661316 9 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
mridup 2:a2b623661316 10 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
mridup 2:a2b623661316 11 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
mridup 2:a2b623661316 12 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
mridup 2:a2b623661316 13 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
mridup 2:a2b623661316 14 *******************************************************************************/
mridup 2:a2b623661316 15
mridup 2:a2b623661316 16 #ifndef __GATT_SERV_H__
mridup 2:a2b623661316 17 #define __GATT_SERV_H__
mridup 2:a2b623661316 18
mridup 2:a2b623661316 19 #include "compiler.h"
mridup 2:a2b623661316 20 #include "ble_status.h"
mridup 2:a2b623661316 21
mridup 2:a2b623661316 22 /**
mridup 2:a2b623661316 23 * UUID table
mridup 2:a2b623661316 24 */
mridup 2:a2b623661316 25 #define PRIMARY_SERVICE_UUID (0x2800)
mridup 2:a2b623661316 26 #define SECONDARY_SERVICE_UUID (0x2801)
mridup 2:a2b623661316 27 #define INCLUDE_SERVICE_UUID (0x2802)
mridup 2:a2b623661316 28 #define CHARACTERISTIC_UUID (0x2803)
mridup 2:a2b623661316 29 #define CHAR_EXTENDED_PROP_DESC_UUID (0x2900)
mridup 2:a2b623661316 30 #define CHAR_USER_DESC_UUID (0x2901)
mridup 2:a2b623661316 31 #define CHAR_CLIENT_CONFIG_DESC_UUID (0x2902)
mridup 2:a2b623661316 32 #define CHAR_SERVER_CONFIG_DESC_UUID (0x2903)
mridup 2:a2b623661316 33 #define CHAR_FORMAT_DESC_UUID (0x2904)
mridup 2:a2b623661316 34 #define CHAR_AGGR_FMT_DESC_UUID (0x2905)
mridup 2:a2b623661316 35 #define GATT_SERVICE_UUID (0x1801)
mridup 2:a2b623661316 36 #define GAP_SERVICE_UUID (0x1800)
mridup 2:a2b623661316 37 #define SERVICE_CHANGED_UUID (0x2A05)
mridup 2:a2b623661316 38
mridup 2:a2b623661316 39 /******************************************************************************
mridup 2:a2b623661316 40 * Types
mridup 2:a2b623661316 41 *****************************************************************************/
mridup 2:a2b623661316 42
mridup 2:a2b623661316 43 /**
mridup 2:a2b623661316 44 * Access permissions
mridup 2:a2b623661316 45 * for an attribute
mridup 2:a2b623661316 46 */
mridup 2:a2b623661316 47 typedef tHalUint8 tAttrAccessFlags;
mridup 2:a2b623661316 48 #define ATTR_NO_ACCESS (0x00)
mridup 2:a2b623661316 49 #define ATTR_ACCESS_READ_ONLY (0x01)
mridup 2:a2b623661316 50 #define ATTR_ACCESS_WRITE_REQ_ONLY (0x02)
mridup 2:a2b623661316 51 #define ATTR_ACCESS_READ_WRITE (0x03)
mridup 2:a2b623661316 52 #define ATTR_ACCESS_WRITE_WITHOUT_RESPONSE (0x04)
mridup 2:a2b623661316 53 #define ATTR_ACCESS_SIGNED_WRITE_ALLOWED (0x08)
mridup 2:a2b623661316 54
mridup 2:a2b623661316 55 /**
mridup 2:a2b623661316 56 * Allows all write procedures
mridup 2:a2b623661316 57 */
mridup 2:a2b623661316 58 #define ATTR_ACCESS_WRITE_ANY (0x0E)
mridup 2:a2b623661316 59
mridup 2:a2b623661316 60 /**
mridup 2:a2b623661316 61 * Characteristic properties.
mridup 2:a2b623661316 62 */
mridup 2:a2b623661316 63 #define CHAR_PROP_BROADCAST (0x01)
mridup 2:a2b623661316 64 #define CHAR_PROP_READ (0x02)
mridup 2:a2b623661316 65 #define CHAR_PROP_WRITE_WITHOUT_RESP (0x04)
mridup 2:a2b623661316 66 #define CHAR_PROP_WRITE (0x08)
mridup 2:a2b623661316 67 #define CHAR_PROP_NOTIFY (0x10)
mridup 2:a2b623661316 68 #define CHAR_PROP_INDICATE (0x20)
mridup 2:a2b623661316 69 #define CHAR_PROP_SIGNED_WRITE (0x40)
mridup 2:a2b623661316 70 #define CHAR_PROP_EXT (0x80)
mridup 2:a2b623661316 71
mridup 2:a2b623661316 72 /**
mridup 2:a2b623661316 73 * Security permissions
mridup 2:a2b623661316 74 * for an attribute
mridup 2:a2b623661316 75 */
mridup 2:a2b623661316 76 typedef tHalUint8 tAttrSecurityFlags;
mridup 2:a2b623661316 77 #define ATTR_PERMISSION_NONE (0x00)
mridup 2:a2b623661316 78 #define ATTR_PERMISSION_AUTHEN_READ (0x01)
mridup 2:a2b623661316 79 #define ATTR_PERMISSION_AUTHOR_READ (0x02)
mridup 2:a2b623661316 80 #define ATTR_PERMISSION_ENCRY_READ (0x04)
mridup 2:a2b623661316 81 #define ATTR_PERMISSION_AUTHEN_WRITE (0x08)
mridup 2:a2b623661316 82 #define ATTR_PERMISSION_AUTHOR_WRITE (0x10)
mridup 2:a2b623661316 83 #define ATTR_PERMISSION_ENCRY_WRITE (0x20)
mridup 2:a2b623661316 84
mridup 2:a2b623661316 85 /**
mridup 2:a2b623661316 86 * Type of UUID
mridup 2:a2b623661316 87 * (16 bit or 128 bit)
mridup 2:a2b623661316 88 */
mridup 2:a2b623661316 89 typedef tHalUint8 tUuidType;
mridup 2:a2b623661316 90 #define UUID_TYPE_16 (0x01)
mridup 2:a2b623661316 91 #define UUID_TYPE_128 (0x02)
mridup 2:a2b623661316 92
mridup 2:a2b623661316 93 /**
mridup 2:a2b623661316 94 * Type of service
mridup 2:a2b623661316 95 * (primary or secondary)
mridup 2:a2b623661316 96 */
mridup 2:a2b623661316 97 typedef tHalUint8 tServiceType;
mridup 2:a2b623661316 98 #define PRIMARY_SERVICE (0x01)
mridup 2:a2b623661316 99 #define SECONDARY_SERVICE (0x02)
mridup 2:a2b623661316 100
mridup 2:a2b623661316 101 /**
mridup 2:a2b623661316 102 * Type of event generated by
mridup 2:a2b623661316 103 * Gatt server
mridup 2:a2b623661316 104 */
mridup 2:a2b623661316 105 typedef tHalUint8 tGattServerEvent;
mridup 2:a2b623661316 106 #define GATT_SERVER_ATTR_WRITE (0x01)
mridup 2:a2b623661316 107 #define GATT_INTIMATE_AND_WAIT_FOR_APPL_AUTH (0x02)
mridup 2:a2b623661316 108 #define GATT_INTIMATE_APPL_WHEN_READ_N_WAIT (0x04)
mridup 2:a2b623661316 109 #define GATT_SERVER_ATTR_READ_WRITE GATT_SERVER_ATTR_WRITE|GATT_INTIMATE_APPL_WHEN_READ_N_WAIT
mridup 2:a2b623661316 110
mridup 2:a2b623661316 111
mridup 2:a2b623661316 112 /**
mridup 2:a2b623661316 113 * Min encryption key size
mridup 2:a2b623661316 114 */
mridup 2:a2b623661316 115 #define MIN_ENCRY_KEY_SIZE (7)
mridup 2:a2b623661316 116
mridup 2:a2b623661316 117 /**
mridup 2:a2b623661316 118 * Max encryption key size
mridup 2:a2b623661316 119 */
mridup 2:a2b623661316 120 #define MAX_ENCRY_KEY_SIZE (0x10)
mridup 2:a2b623661316 121
mridup 2:a2b623661316 122
mridup 2:a2b623661316 123 typedef __packed struct _charactFormat {
mridup 2:a2b623661316 124 tHalUint8 format;
mridup 2:a2b623661316 125 tHalInt8 exp;
mridup 2:a2b623661316 126 tHalUint16 unit;
mridup 2:a2b623661316 127 tHalUint8 name_space;
mridup 2:a2b623661316 128 tHalUint16 desc;
mridup 2:a2b623661316 129 } PACKED charactFormat;
mridup 2:a2b623661316 130
mridup 2:a2b623661316 131 #define FORMAT_UINT8 0x04
mridup 2:a2b623661316 132 #define FORMAT_UINT16 0x06
mridup 2:a2b623661316 133 #define FORMAT_SINT16 0x0E
mridup 2:a2b623661316 134 #define FORMAT_SINT24 0x0F
mridup 2:a2b623661316 135
mridup 2:a2b623661316 136
mridup 2:a2b623661316 137 #define UNIT_UNITLESS 0x2700
mridup 2:a2b623661316 138 #define UNIT_TEMP_CELSIUS 0x272F
mridup 2:a2b623661316 139 #define UNIT_PRESSURE_BAR 0x2780
mridup 2:a2b623661316 140
mridup 2:a2b623661316 141
mridup 2:a2b623661316 142 /*
mridup 2:a2b623661316 143 * Default MTU size
mridup 2:a2b623661316 144 */
mridup 2:a2b623661316 145 #define ATT_DEFAULT_MTU (23)
mridup 2:a2b623661316 146
mridup 2:a2b623661316 147
mridup 2:a2b623661316 148 #endif /* __GATT_SERVER_H__ */