123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- #ifndef BLE_OWNED_H__
- #define BLE_OWNED_H__
- #include <stdint.h>
- #include <stdbool.h>
- #include <stdlib.h>
- #include "ble.h"
- #include "ble_srv_common.h"
- #include "nrf_sdh_ble.h"
- #include "ble_config.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- /**@brief Macro for defining a ble_bis instance.
- *
- * @param _name Name of the instance.
- * @hideinitializer
- */
- #define BLE_OWNED_DEF(_name) \
- static ble_owned_t _name; \
- NRF_SDH_BLE_OBSERVER(_name ## _obs, \
- BLE_OWNED_BLE_OBSERVER_PRIO, \
- ble_evt_handler, &_name)
- #ifndef BLE_UUID_OWNED_BASE
- #ifdef BLE_UUID_WECHAT_SERVICE
- #define BLE_UUID_OWNED_BASE BLE_UUID_WECHAT_SERVICE
- #else
- #define BLE_UUID_OWNED_BASE 0xFEE7
- #endif
- #endif
- #ifndef BLE_UUID_INDICATE_CHARACTERISTICS
- #define BLE_UUID_INDICATE_CHARACTERISTICS 0xFECA
- #endif
- #ifndef BLE_OWNED_MAX_DATA_LEN
- #define BLE_OWNED_MAX_DATA_LEN 64
- #endif
- // Forward declaration of the ble_owned_t type.
- typedef struct ble_owned_s ble_owned_t;
- typedef bool (*ble_owned_indicate_handler_t) (ble_owned_t * p_owned, ble_evt_t const * p_ble_evt);
- /** @brief Owned business Service init structure. This structure contains all options and data needed for
- * initialization of the service.*/
- typedef struct
- {
- ble_owned_indicate_handler_t owned_indicate_handler; /**< Event handler to be called when the owned business Characteristic is indicated. */
- } ble_owned_init_t;
- /**@brief LED Button Service structure. This structure contains various status information for the service. */
- struct ble_owned_s
- {
- uint16_t service_handle; /**< Handle of Owned business Service (as provided by the BLE stack). */
- uint16_t conn_handle;
- ble_gatts_char_handles_t owned_indicate_handles; /**< Handles related to the owned business Characteristic. */
- ble_owned_indicate_handler_t owned_indicate_handler; /**< Event handler to be called when the owned business Characteristic is indicated. */
- };
- /**@brief Function for initializing the Owned Business Service.
- *
- * @param[out] p_owned Owned Business Service structure. This structure must be supplied by
- * the application. It is initialized by this function and will later
- * be used to identify this particular service instance.
- * @param[in] p_owned_init Information needed to initialize the service.
- *
- * @retval NRF_SUCCESS If the service was initialized successfully. Otherwise, an error code is returned.
- */
- uint32_t ble_owned_init(ble_owned_t * p_owned, ble_owned_init_t const * p_owned_init);
- /**@brief Function for handling the application's BLE stack events.
- *
- * @details This function handles all events from the BLE stack that are of interest to the Owned Service.
- *
- * @param[in] p_ble_evt Event received from the BLE stack.
- * @param[in] p_context Owned Business Service structure.
- */
- void ble_owned_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context);
- /**@brief Function for sending a owned business notification.
- *
- * @param[in] p_owned Owned Service structure.
- * @param[in] data New Data.
- * @param[in] len Data length.
- *
- * @retval NRF_SUCCESS If the notification was sent successfully. Otherwise, an error code is returned.
- */
- uint32_t ble_owned_indicate_data_chunk(ble_owned_t * p_owned, uint8_t *data,uint16_t len);
- #ifdef __cplusplus
- }
- #endif
- #endif // BLE_OWNED_H__
- /** @} */
|