185a677ecSMatthias Ringwald /* 285a677ecSMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH 385a677ecSMatthias Ringwald * 485a677ecSMatthias Ringwald * Redistribution and use in source and binary forms, with or without 585a677ecSMatthias Ringwald * modification, are permitted provided that the following conditions 685a677ecSMatthias Ringwald * are met: 785a677ecSMatthias Ringwald * 885a677ecSMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 985a677ecSMatthias Ringwald * notice, this list of conditions and the following disclaimer. 1085a677ecSMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 1185a677ecSMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 1285a677ecSMatthias Ringwald * documentation and/or other materials provided with the distribution. 1385a677ecSMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 1485a677ecSMatthias Ringwald * contributors may be used to endorse or promote products derived 1585a677ecSMatthias Ringwald * from this software without specific prior written permission. 1685a677ecSMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 1785a677ecSMatthias Ringwald * personal benefit and not for any commercial purpose or for 1885a677ecSMatthias Ringwald * monetary gain. 1985a677ecSMatthias Ringwald * 2085a677ecSMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 2185a677ecSMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2285a677ecSMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*2fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 24*2fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 2585a677ecSMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 2685a677ecSMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 2785a677ecSMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 2885a677ecSMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 2985a677ecSMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 3085a677ecSMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3185a677ecSMatthias Ringwald * SUCH DAMAGE. 3285a677ecSMatthias Ringwald * 3385a677ecSMatthias Ringwald * Please inquire about commercial licensing options at 3485a677ecSMatthias Ringwald * [email protected] 3585a677ecSMatthias Ringwald * 3685a677ecSMatthias Ringwald */ 37fe5a6c4eSMilanka Ringwald 38fe5a6c4eSMilanka Ringwald /** 39fe5a6c4eSMilanka Ringwald * @title Battery Service Server 40fe5a6c4eSMilanka Ringwald * 41fe5a6c4eSMilanka Ringwald */ 42fe5a6c4eSMilanka Ringwald 4380e33422SMatthias Ringwald #ifndef BATTERY_SERVICE_SERVER_H 4480e33422SMatthias Ringwald #define BATTERY_SERVICE_SERVER_H 4585a677ecSMatthias Ringwald 4685a677ecSMatthias Ringwald #include <stdint.h> 4785a677ecSMatthias Ringwald 4885a677ecSMatthias Ringwald #if defined __cplusplus 4985a677ecSMatthias Ringwald extern "C" { 5085a677ecSMatthias Ringwald #endif 5185a677ecSMatthias Ringwald 5285a677ecSMatthias Ringwald /** 531ea30d1bSMilanka Ringwald * @text The Battery Service allows to query your device's battery level in a standardized way. 541ea30d1bSMilanka Ringwald * 557a38be12SMilanka Ringwald * To use with your application, add `#import <battery_service.gatt>` to your .gatt file. 561ea30d1bSMilanka Ringwald * After adding it to your .gatt file, you call *battery_service_server_init(value)* with the 571ea30d1bSMilanka Ringwald * current value of your battery. The valid range for the battery level is 0-100. 581ea30d1bSMilanka Ringwald * 591ea30d1bSMilanka Ringwald * If the battery level changes, you can call *battery_service_server_set_battery_value(value)*. 601ea30d1bSMilanka Ringwald * The service supports sending Notifications if the client enables them. 6185a677ecSMatthias Ringwald */ 6285a677ecSMatthias Ringwald 6385a677ecSMatthias Ringwald /* API_START */ 6485a677ecSMatthias Ringwald 6585a677ecSMatthias Ringwald /** 6685a677ecSMatthias Ringwald * @brief Init Battery Service Server with ATT DB 6785a677ecSMatthias Ringwald * @param battery_value in range 0-100 6885a677ecSMatthias Ringwald */ 6985a677ecSMatthias Ringwald void battery_service_server_init(uint8_t battery_value); 7085a677ecSMatthias Ringwald 7185a677ecSMatthias Ringwald /** 7285a677ecSMatthias Ringwald * @brief Update battery value 7385a677ecSMatthias Ringwald * @note triggers notifications if subscribed 7485a677ecSMatthias Ringwald * @param battery_value in range 0-100 7585a677ecSMatthias Ringwald */ 7685a677ecSMatthias Ringwald void battery_service_server_set_battery_value(uint8_t battery_value); 7785a677ecSMatthias Ringwald 7885a677ecSMatthias Ringwald /* API_END */ 7985a677ecSMatthias Ringwald 8085a677ecSMatthias Ringwald #if defined __cplusplus 8185a677ecSMatthias Ringwald } 8285a677ecSMatthias Ringwald #endif 8385a677ecSMatthias Ringwald 8485a677ecSMatthias Ringwald #endif 8585a677ecSMatthias Ringwald 86