13deb3ec6SMatthias Ringwald /* 23deb3ec6SMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH 33deb3ec6SMatthias Ringwald * 43deb3ec6SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 53deb3ec6SMatthias Ringwald * modification, are permitted provided that the following conditions 63deb3ec6SMatthias Ringwald * are met: 73deb3ec6SMatthias Ringwald * 83deb3ec6SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 93deb3ec6SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 103deb3ec6SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 113deb3ec6SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 123deb3ec6SMatthias Ringwald * documentation and/or other materials provided with the distribution. 133deb3ec6SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 143deb3ec6SMatthias Ringwald * contributors may be used to endorse or promote products derived 153deb3ec6SMatthias Ringwald * from this software without specific prior written permission. 163deb3ec6SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 173deb3ec6SMatthias Ringwald * personal benefit and not for any commercial purpose or for 183deb3ec6SMatthias Ringwald * monetary gain. 193deb3ec6SMatthias Ringwald * 203deb3ec6SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 213deb3ec6SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 223deb3ec6SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 233deb3ec6SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 243deb3ec6SMatthias Ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 253deb3ec6SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 263deb3ec6SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 273deb3ec6SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 283deb3ec6SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 293deb3ec6SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 303deb3ec6SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 313deb3ec6SMatthias Ringwald * SUCH DAMAGE. 323deb3ec6SMatthias Ringwald * 333deb3ec6SMatthias Ringwald * Please inquire about commercial licensing options at 343deb3ec6SMatthias Ringwald * [email protected] 353deb3ec6SMatthias Ringwald * 363deb3ec6SMatthias Ringwald */ 373deb3ec6SMatthias Ringwald 383deb3ec6SMatthias Ringwald /** 393deb3ec6SMatthias Ringwald * Helper to construct ATT DB at runtime 403deb3ec6SMatthias Ringwald * (BTstack GATT Compiler is not used) 413deb3ec6SMatthias Ringwald */ 423deb3ec6SMatthias Ringwald 433deb3ec6SMatthias Ringwald #ifndef __ATT_DB_UTIL 443deb3ec6SMatthias Ringwald #define __ATT_DB_UTIL 453deb3ec6SMatthias Ringwald 467907f069SMatthias Ringwald #include "btstack_config.h" 473deb3ec6SMatthias Ringwald # 483deb3ec6SMatthias Ringwald #ifdef HAVE_MALLOC 493deb3ec6SMatthias Ringwald #else 503deb3ec6SMatthias Ringwald #endif 513deb3ec6SMatthias Ringwald 523deb3ec6SMatthias Ringwald #include <stdint.h> 533deb3ec6SMatthias Ringwald 543deb3ec6SMatthias Ringwald #if defined __cplusplus 553deb3ec6SMatthias Ringwald extern "C" { 563deb3ec6SMatthias Ringwald #endif 573deb3ec6SMatthias Ringwald 583deb3ec6SMatthias Ringwald /* API_START */ 593deb3ec6SMatthias Ringwald 603deb3ec6SMatthias Ringwald /** 613deb3ec6SMatthias Ringwald * @brief Init ATT DB storage 623deb3ec6SMatthias Ringwald */ 633deb3ec6SMatthias Ringwald void att_db_util_init(void); 643deb3ec6SMatthias Ringwald 653deb3ec6SMatthias Ringwald /** 663deb3ec6SMatthias Ringwald * @brief Add primary service for 16-bit UUID 67*4e5e1eb0SMatthias Ringwald * @returns attribute handle for the new service definition 683deb3ec6SMatthias Ringwald */ 69*4e5e1eb0SMatthias Ringwald uint16_t att_db_util_add_service_uuid16(uint16_t udid16); 703deb3ec6SMatthias Ringwald 713deb3ec6SMatthias Ringwald /** 723deb3ec6SMatthias Ringwald * @brief Add primary service for 128-bit UUID 73*4e5e1eb0SMatthias Ringwald * @returns attribute handle for the new service definition 743deb3ec6SMatthias Ringwald */ 75*4e5e1eb0SMatthias Ringwald uint16_t att_db_util_add_service_uuid128(uint8_t * udid128); 763deb3ec6SMatthias Ringwald 773deb3ec6SMatthias Ringwald /** 783deb3ec6SMatthias Ringwald * @brief Add Characteristic with 16-bit UUID, properties, and data 79*4e5e1eb0SMatthias Ringwald * @returns attribute handle of the new characteristic value declaration 809f28d85dSMatthias Ringwald * @note If properties contains ATT_PROPERTY_NOTIFY or ATT_PROPERTY_INDICATE flags, a Client Configuration Characteristic Descriptor (CCCD) 819f28d85dSMatthias Ringwald * is created as well. The attribute value handle of the CCCD is the attribute value handle plus 1 82591423b2SMatthias Ringwald * @see ATT_PROPERTY_* in ble/att_db.h 833deb3ec6SMatthias Ringwald */ 843deb3ec6SMatthias Ringwald uint16_t att_db_util_add_characteristic_uuid16(uint16_t udid16, uint16_t properties, uint8_t * data, uint16_t data_len); 853deb3ec6SMatthias Ringwald 863deb3ec6SMatthias Ringwald /** 873deb3ec6SMatthias Ringwald * @brief Add Characteristic with 128-bit UUID, properties, and data 88*4e5e1eb0SMatthias Ringwald * @returns attribute handle of the new characteristic value declaration 899f28d85dSMatthias Ringwald * @note If properties contains ATT_PROPERTY_NOTIFY or ATT_PROPERTY_INDICATE flags, a Client Configuration Characteristic Descriptor (CCCD) 909f28d85dSMatthias Ringwald * is created as well. The attribute value handle of the CCCD is the attribute value handle plus 1 91591423b2SMatthias Ringwald * @see ATT_PROPERTY_* in ble/att_db.h 923deb3ec6SMatthias Ringwald */ 933deb3ec6SMatthias Ringwald uint16_t att_db_util_add_characteristic_uuid128(uint8_t * udid128, uint16_t properties, uint8_t * data, uint16_t data_len); 943deb3ec6SMatthias Ringwald 953deb3ec6SMatthias Ringwald /** 969f28d85dSMatthias Ringwald * @brief Add descriptor with 16-bit UUID, properties, and data 97*4e5e1eb0SMatthias Ringwald * @returns attribute handle of the new descriptor 989f28d85dSMatthias Ringwald * @see ATT_PROPERTY_* in ble/att_db.h 999f28d85dSMatthias Ringwald */ 1009f28d85dSMatthias Ringwald uint16_t att_db_util_add_descriptor_uuid16(uint16_t uuid16, uint16_t properties, uint8_t * data, uint16_t data_len); 1019f28d85dSMatthias Ringwald 1029f28d85dSMatthias Ringwald /** 1039f28d85dSMatthias Ringwald * @brief Add descriptor with 128-bit UUID, properties, and data 104*4e5e1eb0SMatthias Ringwald * @returns attribute handle of the new characteristic descriptor declaration 1059f28d85dSMatthias Ringwald * @see ATT_PROPERTY_* in ble/att_db.h 1069f28d85dSMatthias Ringwald */ 1079f28d85dSMatthias Ringwald uint16_t att_db_util_add_descriptor_uuid128(uint8_t * udid128, uint16_t properties, uint8_t * data, uint16_t data_len); 1089f28d85dSMatthias Ringwald 1099f28d85dSMatthias Ringwald /** 1103deb3ec6SMatthias Ringwald * @brief Get address of constructed ATT DB 1113deb3ec6SMatthias Ringwald */ 1123deb3ec6SMatthias Ringwald uint8_t * att_db_util_get_address(void); 1133deb3ec6SMatthias Ringwald 1143deb3ec6SMatthias Ringwald /** 1153deb3ec6SMatthias Ringwald * @brief Get size of constructed ATT DB 1163deb3ec6SMatthias Ringwald */ 1173deb3ec6SMatthias Ringwald uint16_t att_db_util_get_size(void); 1183deb3ec6SMatthias Ringwald 1193deb3ec6SMatthias Ringwald /* API_END */ 1203deb3ec6SMatthias Ringwald 1213deb3ec6SMatthias Ringwald #if defined __cplusplus 1223deb3ec6SMatthias Ringwald } 1233deb3ec6SMatthias Ringwald #endif 1243deb3ec6SMatthias Ringwald #endif 125