Birkbeck College Mobile and Ubiquitous Computing IoT Lab Exercise 2

Dependencies:   BLE_API_Native_blog

Committer:
gkroussos
Date:
Sat Mar 07 16:34:53 2015 +0000
Revision:
0:e8fdba0ed044
MUC IoT Workshop v1.0

Who changed what in which revision?

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