⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 egi_swit.c

📁 世纪民生公司的带网络功能的单片机CS6209开发http服务器的演示源代码。
💻 C
字号:
/*
 * 
 * Egi_swit.c
 * 
 * Part of the Myson Century CS620X	demo program.
 *
 * Authors: LY Lin, WM Wang, IJ Chen, WH Lee
 *
 * Egi_swit.c contains HTTP ioset.cgi callback routine.
 *
 * This	program	was developed using the Keil 8051 C uVision 2 system.
 * The Keil compiler MUST be used if working with Myson Century supplied
 * firmware.
 *
 * 
 *
*/



#include <stdio.h>
#include <string.h>
#include <ctype.h>

#include "ether.h"
#include "netutil.h"
#include "ip.h"
#include "tcp.h"
#include "config.h"
#include "http.h"
#include "ioset.h"
sfr P1 = 0x90 ;
xdata char switch_str[]="switch";
extern webdebug;
/************************************************************************
/*	Function Name : ioset_resp											*
/*																		*
/*	Arguments : 														*
/*			TSOCK xdata *ts: Point to TSOCK.							*
/*			char xdata *str: Point to egi comment tag string(<!--#)		*
/*							 or	NULL if this function is first time be  *
/*							 called.							 		*
/*																		*
/*	Return :															*
/*			None														*
/*  Comment :															*
/*			This function is a callback function for ioset.cgi. First,	*
/*			this function be called on the start of ioset.cgi with 		*
/*			str=NULL. Then when webpage meet egi comment tag(<!--#) ,	*
/*			this function will be called , the 'str' is point to egi 	*
/*			comment tag.												*
/*																		*
/************************************************************************/
void ioset_resp(TSOCK xdata *ts, char xdata *str)
{
    APPDATA *adp;
    char *s;
	RAM_WEB_PAGE *ptr_web_page;
    int which_bit, mask;

    adp = (APPDATA *)ts->app;

    if (!str)/*The egi function is called the first time.*/
    {/*Init app for ioset.cgi. */
       	adp->egi = ioset_resp;
       	ptr_web_page = search_get_web_page ("ioset.cgi");
   	   	adp->in = ptr_web_page->RAM_WEB_PAGE_DATA;
	   	adp->file_length = ptr_web_page->RAM_WEB_PAGE_LEN;

		/*Find "switch" string in egi request string.*/
		s = find_connvar(ts, switch_str);
        if (*s!=0)/*egi request string have substring of "switch"*/
        {	/*Set P1*/
            which_bit = *(s+6) - '0';
            mask = 1 << which_bit;
            P1 ^= mask;
        }
    }
    else/*Egi comment tag.*/
    {
        if (webdebug)
           printf("EGI Tag '%s'\n", str);/*Egi comment tag.*/
        str += EGI_STARTLEN;/*Skip "<!--#" .*/

		/*Egi web page needs P1 led data.*/
        if (!strncmp(str, "$led", 4) && isdigit(*(str+4)))
        {
            which_bit = *(str+4) - '0';
            mask = 0x1 << which_bit;
            buff_instr(&ts->txb, (P1 & mask) ? "OFF" : "ON");
        }
    }
}

/* EOF */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -