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

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

struct bt_mesh_etn_fota_upd_cli;

extern const struct bt_mesh_model_op _bt_mesh_etn_fota_upd_cli_op[];
extern const struct bt_mesh_model_cb _bt_mesh_etn_fota_upd_cli_cb;

/** @def BT_MESH_MODEL_ETN_FOTA_UPD_CLI
 *
 * @brief eaton mesh fota update client model composition data entry.
 *
 * @param[in] _updcli Pointer to a @ref bt_mesh_etn_fota_upd_cli instance.
 */
#define BT_MESH_MODEL_ETN_FOTA_UPD_CLI(_updcli)                                \
	BT_MESH_MODEL_VND_CB(BT_MESH_COMPANY_ID_EATON,                       \
			     BT_MESH_MODEL_ID_ETN_FOTA_UPD_CLI,             \
			     _bt_mesh_etn_fota_upd_cli_op, &(_updcli)->pub,    \
			     BT_MESH_MODEL_USER_DATA(                          \
				struct bt_mesh_etn_fota_upd_cli, _updcli),     \
			     &_bt_mesh_etn_fota_upd_cli_cb)

/** Bluetooth Mesh firmware update client model handlers. */
struct bt_mesh_etn_fota_upd_cli_handlers
{
	void( *const start )( struct bt_mesh_etn_fota_upd_cli *updcli );

	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_cli *updcli, struct bt_mesh_msg_ctx *ctx, struct etn_fota_error *err_report );
};

struct bt_mesh_etn_fota_upd_cli
{
	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_ETN_FOTA_UPD_PROGRESS_GET_MSG_MINLEN];	// Publication message buffer
	const struct bt_mesh_etn_fota_upd_cli_handlers *handlers;	// Handler function structure
};

int bt_mesh_etn_fota_upd_cli_progress_get_send(struct bt_mesh_etn_fota_upd_cli *updcli, uint16_t addr);
int bt_mesh_etn_fota_upd_cli_server_state_get_send(struct bt_mesh_etn_fota_upd_cli *updcli, uint16_t addr);

#ifdef __cplusplus
}
#endif

#endif