gjhn

Dependents:   BLE_GENERALE

Fork of X_NUCLEO_IDB0XA1 by ST

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers bluenrg_gatt_server.h Source File

bluenrg_gatt_server.h

00001 /******************** (C) COPYRIGHT 2012 STMicroelectronics ********************
00002 * File Name          : bluenrg_gatt_server.h
00003 * Author             : AMS - HEA&RF BU
00004 * Version            : V1.0.0
00005 * Date               : 19-July-2012
00006 * Description        : Header file for BlueNRG's GATT server layer.
00007 ********************************************************************************
00008 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00009 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
00010 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
00011 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
00012 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
00013 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00014 *******************************************************************************/
00015 
00016 #ifndef __BNRG_GATT_SERVER_H__
00017 #define __BNRG_GATT_SERVER_H__
00018 
00019 #include "ble_compiler.h"
00020 #include "ble_status.h"
00021 
00022 /**
00023  *@addtogroup GATT GATT
00024  *@{
00025  */
00026 
00027 /**
00028  * @anchor Well-Known_UUIDs
00029  * @name Well-Known UUIDs
00030  * @{
00031  */
00032 #define PRIMARY_SERVICE_UUID                       (0x2800)
00033 #define SECONDARY_SERVICE_UUID                     (0x2801)
00034 #define INCLUDE_SERVICE_UUID                       (0x2802)
00035 #define CHARACTERISTIC_UUID                        (0x2803)
00036 #define CHAR_EXTENDED_PROP_DESC_UUID               (0x2900)
00037 #define CHAR_USER_DESC_UUID                        (0x2901)
00038 #define CHAR_CLIENT_CONFIG_DESC_UUID               (0x2902)
00039 #define CHAR_SERVER_CONFIG_DESC_UUID               (0x2903)
00040 #define CHAR_FORMAT_DESC_UUID                      (0x2904)
00041 #define CHAR_AGGR_FMT_DESC_UUID                    (0x2905)
00042 #define GATT_SERVICE_UUID                          (0x1801)
00043 #define GAP_SERVICE_UUID                           (0x1800)
00044 #define SERVICE_CHANGED_UUID                       (0x2A05)
00045 /**
00046  * @}
00047  */
00048 
00049 /**
00050  * @anchor Access_permissions
00051  * @name Access permissions
00052  * Access permissions for an attribute
00053  * @{
00054  */
00055 #define ATTR_NO_ACCESS                             (0x00)
00056 #define ATTR_ACCESS_READ_ONLY                      (0x01) 
00057 #define ATTR_ACCESS_WRITE_REQ_ONLY                 (0x02)
00058 #define ATTR_ACCESS_READ_WRITE                     (0x03)
00059 #define ATTR_ACCESS_WRITE_WITHOUT_RESPONSE         (0x04)
00060 #define ATTR_ACCESS_SIGNED_WRITE_ALLOWED           (0x08)
00061 /**
00062  * Allows all write procedures
00063  */
00064 #define ATTR_ACCESS_WRITE_ANY                      (0x0E)
00065 /**
00066  * @}
00067  */
00068 
00069 /**
00070  * @anchor Char_properties
00071  * @name Characteristic properties.
00072  * @{
00073  */
00074 #define CHAR_PROP_BROADCAST                     (0x01)
00075 #define CHAR_PROP_READ                          (0x02)
00076 #define CHAR_PROP_WRITE_WITHOUT_RESP            (0x04)
00077 #define CHAR_PROP_WRITE                         (0x08)
00078 #define CHAR_PROP_NOTIFY                        (0x10)
00079 #define CHAR_PROP_INDICATE                      (0x20)
00080 #define CHAR_PROP_SIGNED_WRITE                  (0x40)
00081 #define CHAR_PROP_EXT                           (0x80)
00082 /**
00083  * @}
00084  */
00085 
00086 
00087 /**
00088  * @anchor Security_permissions
00089  * @name Security permissions for an attribute.
00090  * @{
00091  */
00092 #define ATTR_PERMISSION_NONE                       (0x00) /**< No security. */
00093 #define ATTR_PERMISSION_AUTHEN_READ                (0x01) /**< Need authentication to read */
00094 #define ATTR_PERMISSION_AUTHOR_READ                (0x02) /**< Need authorization to read */
00095 #define ATTR_PERMISSION_ENCRY_READ                 (0x04) /**< Link must be encrypted to read */
00096 #define ATTR_PERMISSION_AUTHEN_WRITE               (0x08) /**< Need authentication to write */
00097 #define ATTR_PERMISSION_AUTHOR_WRITE               (0x10) /**< Need authorization to write */
00098 #define ATTR_PERMISSION_ENCRY_WRITE                (0x20) /**< Link must be encrypted for write */
00099 /**
00100  * @}
00101  */
00102 
00103 /**
00104  * @anchor UUID_Types
00105  * @name Type of UUID (16 bit or 128 bit).
00106  * @{
00107  */
00108 #define UUID_TYPE_16                               (0x01)
00109 #define UUID_TYPE_128                              (0x02)
00110 /**
00111  * @}
00112  */
00113 
00114 /**
00115  * @anchor Service_type
00116  * @name Type of service (primary or secondary)
00117  * @{
00118  */
00119 #define PRIMARY_SERVICE                            (0x01)
00120 #define SECONDARY_SERVICE                          (0x02)
00121 /**
00122  * @}
00123  */
00124 
00125 /**
00126  * @anchor Gatt_Event_Mask
00127  * @name Gatt Event Mask
00128  * Type of event generated by GATT server
00129  * @{
00130  */
00131 #define GATT_DONT_NOTIFY_EVENTS                       (0x00) /**< Do not notify events. */
00132 #define GATT_NOTIFY_ATTRIBUTE_WRITE                   (0x01) /**< The application will be notified when a client writes to this attribute.
00133                                                                   An @ref EVT_BLUE_GATT_ATTRIBUTE_MODIFIED will be issued. */
00134 #define GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP  (0x02) /**< The application will be notified when a write request, a write cmd
00135                                                                     or a signed write cmd are received by the server for this attribute.
00136                                                                     An @ref EVT_BLUE_GATT_WRITE_PERMIT_REQ will be issued. */
00137 #define GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP   (0x04) /**< The application will be notified when a read request of any type is
00138                                                                   received for this attribute. An @ref EVT_BLUE_GATT_READ_PERMIT_REQ will be issued. */
00139 /**
00140  * @}
00141  */
00142 
00143 /** 
00144  * @name Type of characteristic length
00145  * See aci_gatt_add_char()
00146  * @{
00147  */
00148 #define CHAR_VALUE_LEN_CONSTANT           (0x00)
00149 #define CHAR_VALUE_LEN_VARIABLE           (0x01)
00150 /**
00151  * @}
00152  */
00153 
00154 
00155 /**
00156  * @name Encryption key size
00157  * @{
00158  */
00159 /**
00160  * Minimum encryption key size
00161  */
00162 #define MIN_ENCRY_KEY_SIZE                (7)
00163 
00164 /**
00165  * Maximum encryption key size
00166  */
00167 #define MAX_ENCRY_KEY_SIZE                (0x10)
00168 /**
00169  * @}
00170  */
00171 
00172 /**
00173  * @name Characteristic Presentation Format
00174  * @{
00175  */
00176 typedef __packed struct _charactFormat {
00177     uint8_t format;
00178     int8_t exp;
00179     uint16_t unit;
00180     uint8_t name_space;
00181     uint16_t desc;
00182 } PACKED charactFormat;
00183 
00184 /**
00185  * @}
00186  */
00187 
00188 /**
00189  * @name Format
00190  * @{
00191  */
00192 #define FORMAT_UINT8         0x04
00193 #define FORMAT_UINT16        0x06
00194 #define FORMAT_SINT16        0x0E
00195 #define FORMAT_SINT24        0x0F
00196 /**
00197  * @}
00198  */
00199 
00200 /**
00201  * @name Unit
00202  * @{
00203  */
00204 #define UNIT_UNITLESS        0x2700
00205 #define UNIT_TEMP_CELSIUS    0x272F
00206 #define UNIT_PRESSURE_BAR    0x2780
00207 /**
00208  * @}
00209  */
00210 
00211 
00212 /**
00213  * ATT MTU size
00214  */
00215 #define ATT_MTU       (23)
00216 
00217 /**
00218  * @}
00219  */
00220 
00221 
00222 
00223 #endif /* __BNRG_GATT_SERVER_H__ */