
#ifndef OUR_SERVICE_H__
#define OUR_SERVICE_H__

#ifdef __cplusplus
extern "C" {
#endif
 
#include <stdint.h>
	
#include "ble.h"
#include "ble_srv_common.h"

// FROM_SERVICE_TUTORIAL: Defining 16-bit service and 128-bit base UUIDs
#define BLE_UUID_TPC_BASE_UUID              { { 0x23, 0xD1, 0x13, 0xEF, 0x5F, 0x78, 0x23, 0x15, \
												0xDE, 0xEF, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00 } } // 128-bit base UUID
#define BLE_UUID_TPC_SERVICE_UUID            0xF00D // Just a random, but recognizable value

// ALREADY_DONE_FOR_YOU: Defining 16-bit characteristic UUID
#define BLE_UUID_TPC_CHARACTERISTC_UUID      0xF00E // Just a random, but recognizable value

typedef struct ble_tpls_s ble_tpls_t;

typedef void ( *ble_tx_power_level_handler_t )( ble_tpls_t *p_tpls, int8_t new_value );

struct ble_tpls_s
{
	uint8_t 						uuid_type;				/**< UUID type */
    uint16_t                    	conn_handle;    		/**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection).*/
    uint16_t                    	service_handle; 		/**< Handle  of Tx Power Level Service (as provided by the BLE stack). */
	ble_gatts_char_handles_t 		char_handles;			/**< Handles of Tx Power Level Service (as provided by the BLE stack). */
	ble_tx_power_level_handler_t	tx_power_level_handler;	/**< Handler of tx power level change */
};
//

typedef struct
{
	int8_t 					tx_power_level;					/**< Initial value of the TX Power Level characteristic (in dBm). */
	ble_srv_security_mode_t	tpls_att_md;					/**< Initial Security Setting for TX Power Service Characteristics. */
} ble_tpls_init_t;

/**@brief Function for handling BLE Stack events related to our service and characteristic.
 *
 * @details Handles all events from the BLE stack of interest to Our Service.
 *
 * @param[in]   p_our_service       Our Service structure.
 * @param[in]   p_ble_evt  Event received from the BLE stack.
 */
//void ble_tpls_on_ble_evt( ble_tpls_t * ble_tpcs, ble_evt_t const * p_ble_evt);
void ble_tpls_on_ble_evt( ble_evt_t const * p_ble_evt, void * p_context );

/**@brief Function for initializing our new service.
 *
 * @param[in]   p_our_service       Pointer to Our Service structure.
 */
uint32_t ble_tpls_init( ble_tpls_t * ble_tpcs, ble_tpls_init_t const * p_tpls );

 
#ifdef __cplusplus
}
#endif
 
#endif  /* _ OUR_SERVICE_H__ */
