Battery Service declarations.
Copyright (c) 2017-2018 Microchip Technology Inc. and its subsidiaries.
#include "at_ble_api.h"
#include "ble_manager.h"
Data Structures | |
struct | bat_gatt_service_handler |
Macros | |
#define | BAT_CHAR_PRESENTATION_FORMAT_DESCRIPTOR 0x1000 |
Characteristic presentation format descriptor. More... | |
#define | BAT_CHAR_PRESENTATION_FORMAT_EXPONENT 0x00 |
Characteristic presentation format exponent. More... | |
#define | BAT_CHAR_PRESENTATION_FORMAT_NAMESPACE 0x01 |
Characteristic presentation format namespace. More... | |
#define | BAT_CHAR_PRESENTATION_FORMAT_UNIT BAT_SERVICE_UUID |
Characteristic presentation format unit. More... | |
#define | BAT_CHAR_PRESENTATION_FORMAT_VALUE 0x04 |
characteristic presentation format value More... | |
Typedefs | |
typedef struct bat_gatt_service_handler | bat_gatt_service_handler_t |
Functions | |
at_ble_status_t | bat_char_changed_event (bat_gatt_service_handler_t *battery_service, at_ble_characteristic_changed_t *characteristic_changed_param) |
function to check the client characteristic configuration value. More... | |
void | bat_init_service (bat_gatt_service_handler_t *battery_serv, uint8_t *battery_value) |
Battery service and characteristic initialization(Called only once by user). More... | |
at_ble_status_t | bat_primary_service_define (bat_gatt_service_handler_t *battery_service) |
Register a battery service instance inside stack. More... | |
at_ble_status_t | bat_update_char_value (at_ble_handle_t conn_handle, bat_gatt_service_handler_t *battery_serv, uint8_t char_data, bool notify) |
Update the battery characteristic value after defining the services using bat_primary_service_define. More... | |
#define BAT_CHAR_PRESENTATION_FORMAT_DESCRIPTOR 0x1000 |
Characteristic presentation format descriptor.
#define BAT_CHAR_PRESENTATION_FORMAT_EXPONENT 0x00 |
Characteristic presentation format exponent.
#define BAT_CHAR_PRESENTATION_FORMAT_NAMESPACE 0x01 |
Characteristic presentation format namespace.
#define BAT_CHAR_PRESENTATION_FORMAT_UNIT BAT_SERVICE_UUID |
Characteristic presentation format unit.
#define BAT_CHAR_PRESENTATION_FORMAT_VALUE 0x04 |
characteristic presentation format value
typedef struct bat_gatt_service_handler bat_gatt_service_handler_t |
at_ble_status_t bat_char_changed_event | ( | bat_gatt_service_handler_t * | battery_service, |
at_ble_characteristic_changed_t * | characteristic_changed_param | ||
) |
function to check the client characteristic configuration value.
[in] | battery_service | battery service instance |
[in] | characteristic_changed_param | characteristic changed at_ble_characteristic_changed_t |
References AT_BLE_FAILURE, AT_BLE_PRF_NTF_DISABLED, AT_BLE_SUCCESS, at_ble_characteristic_changed_t::char_handle, at_ble_characteristic_changed_t::char_new_value, at_ble_characteristic_t::client_config_handle, bat_gatt_service_handler::serv_chars, and status.
Referenced by ble_char_changed_app_event().
void bat_init_service | ( | bat_gatt_service_handler_t * | battery_serv, |
uint8_t * | battery_value | ||
) |
Battery service and characteristic initialization(Called only once by user).
[in] | battery_serv | battery service instance |
Battery service and characteristic initialization(Called only once by user).
References ALL_UNUSED, AT_BLE_ATTR_NO_PERMISSIONS, AT_BLE_ATTR_READABLE_NO_AUTHN_NO_AUTHR, AT_BLE_ATTR_READABLE_REQ_AUTHN_NO_AUTHR, AT_BLE_ATTR_WRITABLE_NO_AUTHN_NO_AUTHR, AT_BLE_ATTR_WRITABLE_REQ_AUTHN_NO_AUTHR, AT_BLE_CHAR_NOTIFY, AT_BLE_CHAR_READ, AT_BLE_PRES_FORMAT_UINT8, AT_BLE_UUID_16, BAT_CHAR_BAT_LEVEL_UUID, BAT_CHAR_PRESENTATION_FORMAT_DESCRIPTOR, BAT_CHAR_PRESENTATION_FORMAT_EXPONENT, BAT_CHAR_PRESENTATION_FORMAT_NAMESPACE, BAT_CHAR_PRESENTATION_FORMAT_UNIT, BAT_SERVICE_UUID, at_ble_characteristic_t::char_val_handle, at_ble_characteristic_t::client_config_handle, at_ble_characteristic_t::client_config_permissions, at_ble_char_presentation_t::description, at_ble_char_presentation_t::exponent, at_ble_char_presentation_t::format, at_ble_characteristic_t::init_value, at_ble_char_presentation_t::name_space, NULL, presentation_format, at_ble_characteristic_t::presentation_format, at_ble_characteristic_t::properties, bat_gatt_service_handler::serv_chars, bat_gatt_service_handler::serv_handle, bat_gatt_service_handler::serv_uuid, at_ble_characteristic_t::server_config_handle, at_ble_characteristic_t::server_config_permissions, at_ble_uuid_t::type, at_ble_char_presentation_t::unit, at_ble_characteristic_t::user_desc, at_ble_characteristic_t::user_desc_handle, at_ble_characteristic_t::user_desc_len, at_ble_characteristic_t::user_desc_max_len, at_ble_characteristic_t::user_desc_permissions, at_ble_uuid_t::uuid, at_ble_characteristic_t::uuid, at_ble_characteristic_t::value_init_len, at_ble_characteristic_t::value_max_len, and at_ble_characteristic_t::value_permissions.
at_ble_status_t bat_primary_service_define | ( | bat_gatt_service_handler_t * | battery_service | ) |
Register a battery service instance inside stack.
[in] | battery_service | battery service instance |
Register a battery service instance inside stack.
References at_ble_primary_service_define(), NULL, bat_gatt_service_handler::serv_chars, bat_gatt_service_handler::serv_handle, and bat_gatt_service_handler::serv_uuid.
at_ble_status_t bat_update_char_value | ( | at_ble_handle_t | conn_handle, |
bat_gatt_service_handler_t * | battery_serv, | ||
uint8_t | char_data, | ||
bool | notify | ||
) |
Update the battery characteristic value after defining the services using bat_primary_service_define.
[in] | conn_handle | connection handle |
[in] | battery_serv | battery service instance |
[in] | char_data | New battery level |
[in] | notify | flag to send the notification |
Update the battery characteristic value after defining the services using bat_primary_service_define.
References at_ble_characteristic_value_set(), at_ble_notification_send(), AT_BLE_SUCCESS, at_ble_characteristic_t::char_val_handle, DBG_LOG, DBG_LOG_DEV, bat_gatt_service_handler::serv_chars, and status.