/**
 *****************************************************************************************
 *	@file etn_mesh_fota_dis_srv.h
 *
 *	@brief eaton ble mesh fota firmware distribution model header file
 *
 *	@details this custom model from eaton, used to for firmware distribution server model
 *
 *	@version C Style Guide Version 1.0
 *
 *	@copyright 2022 Eaton Corporation. All Rights Reserved.
 *
 *****************************************************************************************
 */
#ifndef ETN_MESH_FOTA_DIS_SRV_H
#define ETN_MESH_FOTA_DIS_SRV_H

/*
 *****************************************************************************************
 *		Headers
 *****************************************************************************************
 */
#include <bluetooth/mesh/model_types.h>
#include <etn_mesh_fota_dis.h>
#include <etn_mesh_fota.h>

#ifdef __cplusplus
extern "C" {
#endif

struct bt_mesh_etn_fota_dis_srv;

extern const struct bt_mesh_model_op _bt_mesh_etn_fota_dis_srv_op[];
extern const struct bt_mesh_model_cb _bt_mesh_etn_fota_dis_srv_cb;

/** @def BT_MESH_MODEL_ETN_FOTA_DIS_SRV
 * @brief BLE Mesh firmware distribution server model composition data entry.
 * @param[in] _dsrv Pointer to a @ref bt_mesh_etn_fota_dis_srv instance from handler definition.
 */
#define BT_MESH_MODEL_ETN_FOTA_DIS_SRV( _dissrv )                                          \
	BT_MESH_MODEL_VND_CB( BT_MESH_COMPANY_ID_EATON,       \
						  BT_MESH_MODEL_ID_ETN_FOTA_DIS_SRV,                      \
						  _bt_mesh_etn_fota_dis_srv_op, &( _dissrv )->pub,                   \
						  BT_MESH_MODEL_USER_DATA( struct bt_mesh_etn_fota_dis_srv, _dissrv ),                        \
						  &_bt_mesh_etn_fota_dis_srv_cb )

/** BLE Mesh firmware distribution server model handlers' declaration. */
struct bt_mesh_etn_fota_dis_srv_handlers
{
	void( *const start )( struct bt_mesh_etn_fota_dis_srv* dissrv );

	void( *const dfu_start )( enum fota_dis_cmd_status *dfu_cmd_reply, enum fota_dis_srv_state *model_state );

	void( *const metadata_get )( enum fota_dis_srv_metadata_status *metadata_reply, enum fota_dis_srv_state *model_state, struct fota_dis_metadata *meta_data );

	void( *const distribn_get )( enum fota_dis_list_status *dstrbn_list_reply, enum fota_dis_srv_state *model_state, uint64_t *distribution_list );

	void( *const server_state_get )( enum fota_dis_srv_state *model_state );

	void ( *const error_reporting )( struct bt_mesh_etn_fota_dis_srv *dissrv, struct bt_mesh_msg_ctx *ctx, struct etn_fota_error *err_report );

};

/**
 * @brief	BLE Mesh firmware distribution server model context.
 * @details	Context structure of firmware distribution server model.
 */
struct bt_mesh_etn_fota_dis_srv
{
	struct bt_mesh_model *model;							// Access model pointer
	struct bt_mesh_model_pub pub;							// Publish parameters
	struct net_buf_simple pub_msg;							// Publication message
	uint8_t buf[BT_MESH_MODEL_BUF_LEN( BT_MESH_ETN_FOTA_DIS_IMAGE_METADATA_GET_OP, BT_MESH_ETN_FOTA_SRV_MESSAGE_MAXLEN )];	//
																														//
																														// Publication
																														//
																														// message
																														//
																														// buffer
	const struct bt_mesh_etn_fota_dis_srv_handlers *handlers;	// Handler function structure
};

#ifdef __cplusplus
}
#endif

#endif