Nordic stack and drivers for the mbed BLE API

Dependents:   BLE_Health_Thermometer2

Fork of nRF51822 by Nordic Semiconductor

Committer:
Rohit Grover
Date:
Thu May 29 09:51:36 2014 +0100
Revision:
14:5ca08f962e4f
Parent:
0:eff01767de02
Child:
37:c29c330d942c
use accessors for GattCharacteristic

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 0:eff01767de02 1 /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
bogdanm 0:eff01767de02 2 *
bogdanm 0:eff01767de02 3 * The information contained herein is confidential property of Nordic Semiconductor. The use,
bogdanm 0:eff01767de02 4 * copying, transfer or disclosure of such information is prohibited except by express written
bogdanm 0:eff01767de02 5 * agreement with Nordic Semiconductor.
bogdanm 0:eff01767de02 6 *
bogdanm 0:eff01767de02 7 */
bogdanm 0:eff01767de02 8 /**
bogdanm 0:eff01767de02 9 @addtogroup BLE_COMMON
bogdanm 0:eff01767de02 10 @{
bogdanm 0:eff01767de02 11 @defgroup ble_types Common types and macro definitions
bogdanm 0:eff01767de02 12 @{
bogdanm 0:eff01767de02 13
bogdanm 0:eff01767de02 14 @brief Common types and macro definitions for the S110 SoftDevice.
bogdanm 0:eff01767de02 15 */
bogdanm 0:eff01767de02 16
bogdanm 0:eff01767de02 17 #ifndef BLE_TYPES_H__
bogdanm 0:eff01767de02 18 #define BLE_TYPES_H__
bogdanm 0:eff01767de02 19
bogdanm 0:eff01767de02 20 #include <stdint.h>
bogdanm 0:eff01767de02 21 #include "nordic_global.h"
bogdanm 0:eff01767de02 22
bogdanm 0:eff01767de02 23 /** @addtogroup BLE_COMMON_DEFINES Defines
bogdanm 0:eff01767de02 24 * @{ */
bogdanm 0:eff01767de02 25
bogdanm 0:eff01767de02 26 /** @defgroup BLE_CONN_HANDLES BLE Connection Handles
bogdanm 0:eff01767de02 27 * @{ */
bogdanm 0:eff01767de02 28 #define BLE_CONN_HANDLE_INVALID 0xFFFF /**< Invalid Connection Handle. */
bogdanm 0:eff01767de02 29 #define BLE_CONN_HANDLE_ALL 0xFFFE /**< Applies to all Connection Handles. */
bogdanm 0:eff01767de02 30 /** @} */
bogdanm 0:eff01767de02 31
bogdanm 0:eff01767de02 32
bogdanm 0:eff01767de02 33 /** @defgroup BLE_UUID_VALUES Assigned Values for BLE UUIDs
bogdanm 0:eff01767de02 34 * @{ */
bogdanm 0:eff01767de02 35 /* Generic UUIDs, applicable to all services */
bogdanm 0:eff01767de02 36 #define BLE_UUID_UNKNOWN 0x0000 /**< Reserved UUID. */
bogdanm 0:eff01767de02 37 #define BLE_UUID_SERVICE_PRIMARY 0x2800 /**< Primary Service. */
bogdanm 0:eff01767de02 38 #define BLE_UUID_SERVICE_SECONDARY 0x2801 /**< Secondary Service. */
bogdanm 0:eff01767de02 39 #define BLE_UUID_SERVICE_INCLUDE 0x2802 /**< Include. */
bogdanm 0:eff01767de02 40 #define BLE_UUID_CHARACTERISTIC 0x2803 /**< Characteristic. */
bogdanm 0:eff01767de02 41 #define BLE_UUID_DESCRIPTOR_CHAR_EXT_PROP 0x2900 /**< Characteristic Extended Properties Descriptor. */
bogdanm 0:eff01767de02 42 #define BLE_UUID_DESCRIPTOR_CHAR_USER_DESC 0x2901 /**< Characteristic User Description Descriptor. */
bogdanm 0:eff01767de02 43 #define BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG 0x2902 /**< Client Characteristic Configuration Descriptor. */
bogdanm 0:eff01767de02 44 #define BLE_UUID_DESCRIPTOR_SERVER_CHAR_CONFIG 0x2903 /**< Server Characteristic Configuration Descriptor. */
bogdanm 0:eff01767de02 45 #define BLE_UUID_DESCRIPTOR_CHAR_PRESENTATION_FORMAT 0x2904 /**< Characteristic Presentation Format Descriptor. */
bogdanm 0:eff01767de02 46 #define BLE_UUID_DESCRIPTOR_CHAR_AGGREGATE_FORMAT 0x2905 /**< Characteristic Aggregate Format Descriptor. */
bogdanm 0:eff01767de02 47 /* GATT specific UUIDs */
bogdanm 0:eff01767de02 48 #define BLE_UUID_GATT 0x1801 /**< Generic Attribute Profile. */
bogdanm 0:eff01767de02 49 #define BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED 0x2A05 /**< Service Changed Characteristic. */
bogdanm 0:eff01767de02 50 /* GAP specific UUIDs */
bogdanm 0:eff01767de02 51 #define BLE_UUID_GAP 0x1800 /**< Generic Access Profile. */
bogdanm 0:eff01767de02 52 #define BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME 0x2A00 /**< Device Name Characteristic. */
bogdanm 0:eff01767de02 53 #define BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE 0x2A01 /**< Appearance Characteristic. */
bogdanm 0:eff01767de02 54 #define BLE_UUID_GAP_CHARACTERISTIC_PPF 0x2A02 /**< Peripheral Privacy Flag Characteristic. */
bogdanm 0:eff01767de02 55 #define BLE_UUID_GAP_CHARACTERISTIC_RECONN_ADDR 0x2A03 /**< Reconnection Address Characteristic. */
bogdanm 0:eff01767de02 56 #define BLE_UUID_GAP_CHARACTERISTIC_PPCP 0x2A04 /**< Peripheral Preferred Connection Parameters Characteristic. */
bogdanm 0:eff01767de02 57 /** @} */
bogdanm 0:eff01767de02 58
bogdanm 0:eff01767de02 59
bogdanm 0:eff01767de02 60 /** @defgroup BLE_UUID_TYPES Types of UUID
bogdanm 0:eff01767de02 61 * @{ */
bogdanm 0:eff01767de02 62 #define BLE_UUID_TYPE_UNKNOWN 0x00 /**< Invalid UUID type. */
bogdanm 0:eff01767de02 63 #define BLE_UUID_TYPE_BLE 0x01 /**< Bluetooth SIG UUID (16-bit). */
bogdanm 0:eff01767de02 64 #define BLE_UUID_TYPE_VENDOR_BEGIN 0x02 /**< Vendor UUID types start at this index (128-bit). */
bogdanm 0:eff01767de02 65 /** @} */
bogdanm 0:eff01767de02 66
bogdanm 0:eff01767de02 67
bogdanm 0:eff01767de02 68 /** @defgroup BLE_APPEARANCES Bluetooth Appearance values
bogdanm 0:eff01767de02 69 * @note Retrieved from http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml
bogdanm 0:eff01767de02 70 * @{ */
bogdanm 0:eff01767de02 71 #define BLE_APPEARANCE_UNKNOWN 0 /**< Unknown. */
bogdanm 0:eff01767de02 72 #define BLE_APPEARANCE_GENERIC_PHONE 64 /**< Generic Phone. */
bogdanm 0:eff01767de02 73 #define BLE_APPEARANCE_GENERIC_COMPUTER 128 /**< Generic Computer. */
bogdanm 0:eff01767de02 74 #define BLE_APPEARANCE_GENERIC_WATCH 192 /**< Generic Watch. */
bogdanm 0:eff01767de02 75 #define BLE_APPEARANCE_WATCH_SPORTS_WATCH 193 /**< Watch: Sports Watch. */
bogdanm 0:eff01767de02 76 #define BLE_APPEARANCE_GENERIC_CLOCK 256 /**< Generic Clock. */
bogdanm 0:eff01767de02 77 #define BLE_APPEARANCE_GENERIC_DISPLAY 320 /**< Generic Display. */
bogdanm 0:eff01767de02 78 #define BLE_APPEARANCE_GENERIC_REMOTE_CONTROL 384 /**< Generic Remote Control. */
bogdanm 0:eff01767de02 79 #define BLE_APPEARANCE_GENERIC_EYE_GLASSES 448 /**< Generic Eye-glasses. */
bogdanm 0:eff01767de02 80 #define BLE_APPEARANCE_GENERIC_TAG 512 /**< Generic Tag. */
bogdanm 0:eff01767de02 81 #define BLE_APPEARANCE_GENERIC_KEYRING 576 /**< Generic Keyring. */
bogdanm 0:eff01767de02 82 #define BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 640 /**< Generic Media Player. */
bogdanm 0:eff01767de02 83 #define BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 704 /**< Generic Barcode Scanner. */
bogdanm 0:eff01767de02 84 #define BLE_APPEARANCE_GENERIC_THERMOMETER 768 /**< Generic Thermometer. */
bogdanm 0:eff01767de02 85 #define BLE_APPEARANCE_THERMOMETER_EAR 769 /**< Thermometer: Ear. */
bogdanm 0:eff01767de02 86 #define BLE_APPEARANCE_GENERIC_HEART_RATE_SENSOR 832 /**< Generic Heart rate Sensor. */
bogdanm 0:eff01767de02 87 #define BLE_APPEARANCE_HEART_RATE_SENSOR_HEART_RATE_BELT 833 /**< Heart Rate Sensor: Heart Rate Belt. */
bogdanm 0:eff01767de02 88 #define BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 896 /**< Generic Blood Pressure. */
bogdanm 0:eff01767de02 89 #define BLE_APPEARANCE_BLOOD_PRESSURE_ARM 897 /**< Blood Pressure: Arm. */
bogdanm 0:eff01767de02 90 #define BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 898 /**< Blood Pressure: Wrist. */
bogdanm 0:eff01767de02 91 #define BLE_APPEARANCE_GENERIC_HID 960 /**< Human Interface Device (HID). */
bogdanm 0:eff01767de02 92 #define BLE_APPEARANCE_HID_KEYBOARD 961 /**< Keyboard (HID Subtype). */
bogdanm 0:eff01767de02 93 #define BLE_APPEARANCE_HID_MOUSE 962 /**< Mouse (HID Subtype). */
bogdanm 0:eff01767de02 94 #define BLE_APPEARANCE_HID_JOYSTICK 963 /**< Joystiq (HID Subtype). */
bogdanm 0:eff01767de02 95 #define BLE_APPEARANCE_HID_GAMEPAD 964 /**< Gamepad (HID Subtype). */
bogdanm 0:eff01767de02 96 #define BLE_APPEARANCE_HID_DIGITIZERSUBTYPE 965 /**< Digitizer Tablet (HID Subtype). */
bogdanm 0:eff01767de02 97 #define BLE_APPEARANCE_HID_CARD_READER 966 /**< Card Reader (HID Subtype). */
bogdanm 0:eff01767de02 98 #define BLE_APPEARANCE_HID_DIGITAL_PEN 967 /**< Digital Pen (HID Subtype). */
bogdanm 0:eff01767de02 99 #define BLE_APPEARANCE_HID_BARCODE 968 /**< Barcode Scanner (HID Subtype). */
bogdanm 0:eff01767de02 100 #define BLE_APPEARANCE_GENERIC_GLUCOSE_METER 1024 /**< Generic Glucose Meter. */
bogdanm 0:eff01767de02 101 #define BLE_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR 1088 /**< Generic Running Walking Sensor. */
bogdanm 0:eff01767de02 102 #define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_IN_SHOE 1089 /**< Running Walking Sensor: In-Shoe. */
bogdanm 0:eff01767de02 103 #define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_SHOE 1090 /**< Running Walking Sensor: On-Shoe. */
bogdanm 0:eff01767de02 104 #define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_HIP 1091 /**< Running Walking Sensor: On-Hip. */
bogdanm 0:eff01767de02 105 #define BLE_APPEARANCE_GENERIC_CYCLING 1152 /**< Generic Cycling. */
bogdanm 0:eff01767de02 106 #define BLE_APPEARANCE_CYCLING_CYCLING_COMPUTER 1153 /**< Cycling: Cycling Computer. */
bogdanm 0:eff01767de02 107 #define BLE_APPEARANCE_CYCLING_SPEED_SENSOR 1154 /**< Cycling: Speed Sensor. */
bogdanm 0:eff01767de02 108 #define BLE_APPEARANCE_CYCLING_CADENCE_SENSOR 1155 /**< Cycling: Cadence Sensor. */
bogdanm 0:eff01767de02 109 #define BLE_APPEARANCE_CYCLING_POWER_SENSOR 1156 /**< Cycling: Power Sensor. */
bogdanm 0:eff01767de02 110 #define BLE_APPEARANCE_CYCLING_SPEED_CADENCE_SENSOR 1157 /**< Cycling: Speed and Cadence Sensor. */
bogdanm 0:eff01767de02 111 /** @} */
bogdanm 0:eff01767de02 112
bogdanm 0:eff01767de02 113 /** @brief Set .type and .uuid fields of ble_uuid_struct to specified uuid value. */
bogdanm 0:eff01767de02 114 #define BLE_UUID_BLE_ASSIGN(instance, value) do {\
bogdanm 0:eff01767de02 115 instance.type = BLE_UUID_TYPE_BLE; \
bogdanm 0:eff01767de02 116 instance.uuid = value;} while(0)
bogdanm 0:eff01767de02 117
bogdanm 0:eff01767de02 118 /** @brief Copy type and uuid members from src to dst ble_uuid_t pointer. Both pointers must be valid/non-null. */
bogdanm 0:eff01767de02 119 #define BLE_UUID_COPY_PTR(dst, src) do {\
bogdanm 0:eff01767de02 120 (dst)->type = (src)->type; \
bogdanm 0:eff01767de02 121 (dst)->uuid = (src)->uuid;} while(0)
bogdanm 0:eff01767de02 122
bogdanm 0:eff01767de02 123 /** @brief Copy type and uuid members from src to dst ble_uuid_t struct. */
bogdanm 0:eff01767de02 124 #define BLE_UUID_COPY_INST(dst, src) do {\
bogdanm 0:eff01767de02 125 (dst).type = (src).type; \
bogdanm 0:eff01767de02 126 (dst).uuid = (src).uuid;} while(0)
bogdanm 0:eff01767de02 127
bogdanm 0:eff01767de02 128 /** @brief Compare for equality both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */
bogdanm 0:eff01767de02 129 #define BLE_UUID_EQ(p_uuid1, p_uuid2) \
bogdanm 0:eff01767de02 130 (((p_uuid1)->type == (p_uuid2)->type) && ((p_uuid1)->uuid == (p_uuid2)->uuid))
bogdanm 0:eff01767de02 131
bogdanm 0:eff01767de02 132 /** @brief Compare for difference both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */
bogdanm 0:eff01767de02 133 #define BLE_UUID_NEQ(p_uuid1, p_uuid2) \
bogdanm 0:eff01767de02 134 (((p_uuid1)->type != (p_uuid2)->type) || ((p_uuid1)->uuid != (p_uuid2)->uuid))
bogdanm 0:eff01767de02 135
bogdanm 0:eff01767de02 136 /** @} */
bogdanm 0:eff01767de02 137
bogdanm 0:eff01767de02 138 /** @brief 128 bit UUID values. */
bogdanm 0:eff01767de02 139 typedef struct
bogdanm 0:eff01767de02 140 {
bogdanm 0:eff01767de02 141 unsigned char uuid128[16];
bogdanm 0:eff01767de02 142 } ble_uuid128_t;
bogdanm 0:eff01767de02 143
bogdanm 0:eff01767de02 144 /** @brief Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs. */
bogdanm 0:eff01767de02 145 typedef struct
bogdanm 0:eff01767de02 146 {
bogdanm 0:eff01767de02 147 uint16_t uuid; /**< 16-bit UUID value or octets 12-13 of 128-bit UUID. */
bogdanm 0:eff01767de02 148 uint8_t type; /**< UUID type, see @ref BLE_UUID_TYPES. If type is BLE_UUID_TYPE_UNKNOWN, the value of uuid is undefined. */
bogdanm 0:eff01767de02 149 } ble_uuid_t;
bogdanm 0:eff01767de02 150
bogdanm 0:eff01767de02 151
bogdanm 0:eff01767de02 152
bogdanm 0:eff01767de02 153 #endif /* BLE_TYPES_H__ */
bogdanm 0:eff01767de02 154
bogdanm 0:eff01767de02 155 /**
bogdanm 0:eff01767de02 156 @}
bogdanm 0:eff01767de02 157 @}
bogdanm 0:eff01767de02 158 */