/*********************************************************************
*                     SEGGER Microcontroller GmbH                    *
*        Solutions for real time microcontroller applications        *
**********************************************************************
*                                                                    *
*        (c) 1996 - 2022  SEGGER Microcontroller GmbH                *
*                                                                    *
*        Internet: www.segger.com    Support:  support@segger.com    *
*                                                                    *
**********************************************************************
----------------------------------------------------------------------
File        : ID_SCREEN_HHT_NET_SETT_UPDATE_Slots.c
Purpose     : AppWizard managed file, function content could be changed
---------------------------END-OF-HEADER------------------------------
*/

#include "Application.h"
#include "../Generated/Resource.h"
#include "../Generated/ID_SCREEN_HHT_NET_SETTINGS.h"
#include "../Generated/ID_SCREEN_HHT_NET_SETT_UPDATE.h"
#include "../utilities/fsl_debug_console.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

/*** Begin of user code area ***/
/*** End of user code area ***/

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       cbID_SCREEN_HHT_NET_SETT_UPDATE
*/
void cbID_SCREEN_HHT_NET_SETT_UPDATE(WM_MESSAGE * pMsg) {
  GUI_USE_PARA(pMsg);
}

/*********************************************************************
*
*       ID_SCREEN_HHT_NET_SETTINGS__ID_EDIT_HHT_IP_ADDR_VAL__WM_NOTIFICATION_VALUE_CHANGED__ID_EDIT_HHT_IP_ADDR_VAL__APPW_JOB_SETVALUE
*/
void ID_SCREEN_HHT_NET_SETTINGS__ID_EDIT_HHT_IP_ADDR_VAL__WM_NOTIFICATION_VALUE_CHANGED__ID_EDIT_HHT_IP_ADDR_VAL__APPW_JOB_SETVALUE(APPW_ACTION_ITEM * pAction, WM_HWIN hScreen, WM_MESSAGE * pMsg, int * pResult) {
  GUI_USE_PARA(pAction);
  GUI_USE_PARA(hScreen);
  GUI_USE_PARA(pMsg);
  GUI_USE_PARA(pResult);
}

/*********************************************************************
*
*       ID_SCREEN_HHT_NET_SETTINGS__ID_EDIT_HHT_SNET_ADDR_VAL__WM_NOTIFICATION_VALUE_CHANGED__ID_EDIT_HHT_SNET_ADDR_VAL__APPW_JOB_SETVALUE
*/
void ID_SCREEN_HHT_NET_SETTINGS__ID_EDIT_HHT_SNET_ADDR_VAL__WM_NOTIFICATION_VALUE_CHANGED__ID_EDIT_HHT_SNET_ADDR_VAL__APPW_JOB_SETVALUE(APPW_ACTION_ITEM * pAction, WM_HWIN hScreen, WM_MESSAGE * pMsg, int * pResult) {
  GUI_USE_PARA(pAction);
  GUI_USE_PARA(hScreen);
  GUI_USE_PARA(pMsg);
  GUI_USE_PARA(pResult);
}

/*********************************************************************
*
*       ID_SCREEN_HHT_NET_SETTINGS__ID_EDIT_HHT_GW_ADDR_VAL__WM_NOTIFICATION_VALUE_CHANGED__ID_EDIT_HHT_GW_ADDR_VAL__APPW_JOB_SETVALUE
*/
void ID_SCREEN_HHT_NET_SETTINGS__ID_EDIT_HHT_GW_ADDR_VAL__WM_NOTIFICATION_VALUE_CHANGED__ID_EDIT_HHT_GW_ADDR_VAL__APPW_JOB_SETVALUE(APPW_ACTION_ITEM * pAction, WM_HWIN hScreen, WM_MESSAGE * pMsg, int * pResult) {
  GUI_USE_PARA(pAction);
  GUI_USE_PARA(hScreen);
  GUI_USE_PARA(pMsg);
  GUI_USE_PARA(pResult);
}

/*********************************************************************
*
*       ID_SCREEN_HHT_NET_SETTINGS__ID_BUTTON_BACK_HHT_NETT_SETT__WM_NOTIFICATION_CLICKED
*/
void ID_SCREEN_HHT_NET_SETTINGS__ID_BUTTON_BACK_HHT_NETT_SETT__WM_NOTIFICATION_CLICKED(APPW_ACTION_ITEM * pAction, WM_HWIN hScreen, WM_MESSAGE * pMsg, int * pResult) {
  GUI_USE_PARA(pAction);
  GUI_USE_PARA(hScreen);
  GUI_USE_PARA(pMsg);
  GUI_USE_PARA(pResult);
}

/*********************************************************************
*
*       ID_SCREEN_HHT_NET_SETT_UPDATE__ID_BUTTON_HHT_IP_UPDATE_SAVE__WM_NOTIFICATION_CLICKED
*/
void ID_SCREEN_HHT_NET_SETT_UPDATE__ID_BUTTON_HHT_IP_UPDATE_SAVE__WM_NOTIFICATION_CLICKED(APPW_ACTION_ITEM * pAction, WM_HWIN hScreen, WM_MESSAGE * pMsg, int * pResult) {

	APPW_GetText(ID_SCREEN_HHT_NET_SETT_UPDATE, ID_EDIT_HHT_IP_ADDR_VAL, gui_update_HHT_net_IP_Addr, sizeof(gui_update_HHT_net_IP_Addr));
	APPW_GetText(ID_SCREEN_HHT_NET_SETT_UPDATE, ID_EDIT_HHT_SNET_ADDR_VAL, gui_update_HHT_net_SubNet_Addr, sizeof(gui_update_HHT_net_SubNet_Addr));
	APPW_GetText(ID_SCREEN_HHT_NET_SETT_UPDATE, ID_EDIT_HHT_GW_ADDR_VAL, gui_update_HHT_net_gateway_Addr, sizeof(gui_update_HHT_net_gateway_Addr));

	strcpy(gui_update_HHT_net_IP_Addr_validate,gui_update_HHT_net_IP_Addr);
	strcpy(gui_update_HHT_net_SubNet_Addr_validate,gui_update_HHT_net_SubNet_Addr);
	strcpy(gui_update_HHT_net_gateway_Addr_validate,gui_update_HHT_net_gateway_Addr);

	if((validate_HHT_ip(gui_update_HHT_net_IP_Addr_validate)==1) &&
			(validate_HHT_ip(gui_update_HHT_net_SubNet_Addr_validate)==1) &&
			(validate_HHT_ip(gui_update_HHT_net_gateway_Addr_validate)==1))
		{
			HHT_Net_Sett_Save_Flag =1;
			HHT_Net_Validate_Flag =1;
		}
		else
		{
			HHT_Net_Sett_Save_Flag =0;
			HHT_Net_Validate_Flag=2;
		}
	if(HHT_Net_Sett_Save_Flag==1 && HHT_Net_Validate_Flag==1)
	{
		APPW_SetText(ID_SCREEN_HHT_NET_SETTINGS, ID_TEXT_HHT_NET_IP_ADDR_DISP, "");
		APPW_SetText(ID_SCREEN_HHT_NET_SETTINGS, ID_TEXT_HHT_NET_IP_ADDR_DISP, gui_update_HHT_net_IP_Addr);

		APPW_SetText(ID_SCREEN_HHT_NET_SETTINGS, ID_TEXT_HHT_SNET_ADDR_DISP, "");
		APPW_SetText(ID_SCREEN_HHT_NET_SETTINGS, ID_TEXT_HHT_SNET_ADDR_DISP, gui_update_HHT_net_SubNet_Addr);

		APPW_SetText(ID_SCREEN_HHT_NET_SETTINGS, ID_TEXT_HHT_GW_ADDR_DISP, "");
		APPW_SetText(ID_SCREEN_HHT_NET_SETTINGS, ID_TEXT_HHT_GW_ADDR_DISP, gui_update_HHT_net_gateway_Addr);
	}
  GUI_USE_PARA(pAction);
  GUI_USE_PARA(hScreen);
  GUI_USE_PARA(pMsg);
  GUI_USE_PARA(pResult);
}

/*************************** End of file ****************************/
