📄 remoteconfigcbk.c
字号:
/****************************************************************************
*
* Name: VLANCbk.c
*
* Description: Call Back Function
*
* Copyright: ASEC
* All rights reserved.
*
****************************************************************************/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "tfTypes.h"
#include "fs.h"
#include "httpd.h"
//#include "html.h"
#include "monitorConfig.h"
#include "ip113f.h"
extern struct httpd_state *hs;
extern variable_t var_list[];
static char rtconfbuf[50]=" ";
int rtconfData;
extern int sign;
extern int stNo;
extern int RtstData;
extern int remotesign;
u8_t ssiRemoteModuleConfig(u8_t varid, value_t *vp)
{
switch (varid)
{
case TGI_M_CONFIG_NO:
sprintf(rtconfbuf,"%d module",stNo);
vp->value.string = rtconfbuf;
vp->type = string;
break;
case TGI_REMOTE_SPEED_100M:
if((sign ==1)&&(remotesign==1))
{
if(rtconfData&0x0008)
vp->value.string = "CHECKED";
else
vp->value.string = "";
}
else
vp->value.string = "";
vp->type = string;
break;
case TGI_REMOTE_SPEED_10M:
if((sign ==1)&&(remotesign==1))
{
if(rtconfData&0x0008)
vp->value.string = "";
else
vp->value.string = "CHECKED";
}
else
vp->value.string = "";
vp->type = string;
break;
case TGI_REMOTE_DUPLEX_FULL:
if((sign ==1)&&(remotesign==1))
{
if(rtconfData&0x0010)
vp->value.string = "CHECKED";
else
vp->value.string = "";
}
else
vp->value.string = "";
vp->type = string;
break;
case TGI_REMOTE_DUPLEX_HALF:
if((sign ==1)&&(remotesign==1))
{
if(rtconfData&0x0010)
vp->value.string = "";
else
vp->value.string = "CHECKED";
}
else
vp->value.string = "";
vp->type = string;
break;
case TGI_REMOTE_AN_EN:
if((sign ==1)&&(remotesign==1))
{
if(rtconfData&0x0004)
vp->value.string = "CHECKED";
else
vp->value.string = "";
}
else
vp->value.string = "";
vp->type = string;
break;
case TGI_REMOTE_AN_DIS:
if((sign ==1)&&(remotesign==1))
{
if(rtconfData&0x0004)
vp->value.string = "";
else
vp->value.string = "CHECKED";
}
else
vp->value.string = "";
vp->type = string;
break;
case TGI_REMOTE_FC_EN:
if((sign ==1)&&(remotesign==1))
{
if(rtconfData&0x0020)
vp->value.string = "CHECKED";
else
vp->value.string = "";
}
else
vp->value.string = "";
vp->type = string;
break;
case TGI_REMOTE_FC_DIS:
if((sign ==1)&&(remotesign==1))
{
if(rtconfData&0x0020)
vp->value.string = "";
else
vp->value.string = "CHECKED";
}
else
vp->value.string = "";
vp->type = string;
break;
case TGI_RLFP_ENABLE:
if((sign==1)&&(remotesign==1))
{
if(DATA_GETBIT(rtconfData, 15)==1)
vp->value.string = "CHECKED";
else
vp->value.string = "";
vp->type = string;
}
else
{
vp->value.string = "";
vp->type = string;
}
break;
case TGI_RLFP_DISABLE:
if((sign==1)&&(remotesign==1))
{
if(DATA_GETBIT(rtconfData, 15)==1)
vp->value.string = "";
else
vp->value.string = "CHECKED";
vp->type = string;
}
else
{
vp->value.string = "";
vp->type = string;
}
break;
default:
vp->value.string = NULL;
vp->type = string;
break;
}
return OK;
}
u8_t tgiRemoteModuleConfig(u8_t cnt, value_t *vp1)
{
unsigned char sendbuf[9];
unsigned int c;
//debug end
/*for(i=0;i<=cnt; i++)
{
printf("var_list[%d].value = %s\r\n",i,var_list[i].value);
}*/
// if (strncmp(var_list[cnt-1].value, "Apply", 5)==0)
if ((strncmp(var_list[7].value, "Apply", 5)==0)||(strncmp(var_list[5].value, "Apply", 5)==0)||(strncmp(var_list[6].value, "Apply", 5)==0) )
{
if(remotesign==1)
{
rtconfData=RtstData;
if(stNo<10)
{
sendbuf[1]='0';
sendbuf[2]=stNo+'0';
}
else
{
sendbuf[1]='1';
sendbuf[2]=stNo-10+'0';
}
sendbuf[0]='t';//select func number
sendbuf[3]='2';
sendbuf[4]='2';
// Speed - bit3
if (strncmp(var_list[0].value, "100M", 4)==0)
{
rtconfData=DATA_SETBIT(rtconfData,3);
}
else if (strncmp(var_list[0].value, "10M", 4)==0)
{
rtconfData=DATA_CLRBIT(rtconfData,3);
}
// Duplex - bit4
if (strncmp(var_list[1].value, "Full", 4)==0)
{
rtconfData=DATA_SETBIT(rtconfData,4);
}
else if (strncmp(var_list[1].value, "Half", 3)==0)
{
rtconfData=DATA_CLRBIT(rtconfData,4);
}
// Auto-Negotitation - bit2
if (strncmp(var_list[2].value, "Enable", 6)==0)
{
rtconfData=DATA_SETBIT(rtconfData,2);
}
else if (strncmp(var_list[2].value, "Disable", 7)==0)
{
rtconfData=DATA_CLRBIT(rtconfData,2);
}
// Flow Control - bit5
if (strncmp(var_list[3].value, "Enable", 6)==0)
{
rtconfData=DATA_SETBIT(rtconfData,5);
}
else if (strncmp(var_list[3].value, "Disable", 7)==0)
{
rtconfData=DATA_CLRBIT(rtconfData,5);
}
if (strncmp(var_list[4].value, "Enable", 6)==0)
{
rtconfData=DATA_SETBIT(rtconfData,15);
}
else if (strncmp(var_list[4].value, "Disable", 7)==0)
{
rtconfData=DATA_CLRBIT(rtconfData,15);
}
c=(rtconfData>>12)&0x0f;
if((c>=0)&&(c<=9))
sendbuf[5]=c+'0';
else if((c>=0xa)&&(c<=0xf))
sendbuf[5]=c-10+'a';
c=(rtconfData>>8)&0x0f;
if((c>=0)&&(c<=9))
sendbuf[6]=c+'0';
else if((c>=0xa)&&(c<=0xf))
sendbuf[6]=c-10+'a';
c=(rtconfData>>4)&0x0f;
if((c>=0)&&(c<=9))
sendbuf[7]=c+'0';
else if((c>=0xa)&&(c<=0xf))
sendbuf[7]=c-10+'a';
c=rtconfData&0x0f;
if((c>=0)&&(c<=9))
sendbuf[8]=c+'0';
else if((c>=0xa)&&(c<=0xf))
sendbuf[8]=c-10+'a';
putstr(sendbuf);
Delay(50000);
}
httpd_send_file(fs_open3("monitorConfig.htm"));
}
// httpd_send_file(fs_open3("monitorConfig.htm"));
// <script language=javalanguage>parent.main.location.reload();</script>
return OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -