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

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

#ifdef __cplusplus
extern "C" {
#endif

struct bt_mesh_etn_fota_upd_srv;

extern const struct bt_mesh_model_op _bt_mesh_etn_fota_upd_srv_op[];
extern const struct bt_mesh_model_cb _bt_mesh_etn_fota_upd_srv_cb;

/** @def BT_MESH_MODEL_ETN_FOTA_UPD_SRV
 *
 * @brief eaton mesh fota update server model composition data entry.
 *
 * @param[in] _blbsrv Pointer to a @ref bt_mesh_etn_fota_upd_srv instance.
 */
#define BT_MESH_MODEL_ETN_FOTA_UPD_SRV(_updsrv)                                \
	BT_MESH_MODEL_VND_CB(BT_MESH_COMPANY_ID_EATON,                       \
			     BT_MESH_MODEL_ID_ETN_FOTA_UPD_SRV,             \
			     _bt_mesh_etn_fota_upd_srv_op, &(_updsrv)->pub,    \
			     BT_MESH_MODEL_USER_DATA(                          \
				struct bt_mesh_etn_fota_upd_srv, _updsrv),     \
			     &_bt_mesh_etn_fota_upd_srv_cb)

/** Bluetooth Mesh firmware update server model handlers. */
struct bt_mesh_etn_fota_upd_srv_handlers
{
	void( *const start )( struct bt_mesh_etn_fota_upd_srv *updsrv );

	void( *const server_state_get )( enum fota_upd_srv_state *server_state );

	void( *const image_progress_get )( uint8_t *progress_in_percent );

	void ( *const error_reporting )( struct bt_mesh_etn_fota_upd_srv *updsrv, struct bt_mesh_msg_ctx *ctx, struct etn_fota_error *err_report );
};

struct bt_mesh_etn_fota_upd_srv
{
	struct bt_mesh_model *model;
	struct bt_mesh_model_pub pub;
	struct net_buf_simple pub_msg;
	uint8_t buf[BT_MESH_ETN_FOTA_UPD_PROGRESS_GET_MSG_MINLEN];
	const struct bt_mesh_etn_fota_upd_srv_handlers *handlers;
};

#ifdef __cplusplus
}
#endif

#endif