Esempio n. 1
0
static void on_up_button (void)
{
    if (_mode == NORMAL)
    {
        _mode = TIME_CONFIG;
        _config_pos = POS_HOURS_1;
        print_time_config ();
        return;
    }

    else if (_mode == TIME_CONFIG)
    {
        increment_digit (&_time, _config_pos);
        print_time_config ();
    }

    else if (_mode == ALARM_SET_CONFIG)
    {
        _alarm_set ^= 1;
        print_alarm_config ();
    }

    else if (_mode == ALARM_TIME_CONFIG)
    {
        increment_digit (&_alarm, _config_pos);
        print_alarm_config ();
    }
}
Esempio n. 2
0
static void on_down_button (void)
{
    if (_mode == NORMAL)
    {
        _mode = ALARM_SET_CONFIG;
        print_alarm_config ();
        return;
    }

    if (_mode == ALARM_SET_CONFIG)
    {
        if (_alarm_set)
        {
            _mode = ALARM_TIME_CONFIG;
            _config_pos = POS_HOURS_1;
            print_alarm_config ();
        }
        else
        {
            _mode = NORMAL;
            print_normal_mode ();
        }

        return;
    }

    // Last position of the time config
    if (_config_pos == POS_SEC_2)
    {
        _mode = NORMAL;
        print_normal_mode ();
        return;
    }

    // Increment the position of the cursor
    _config_pos = next_config_pos (_config_pos);

    if (_mode == TIME_CONFIG)
        print_time_config ();
    else
        print_alarm_config ();
}
// analyse the url given
//                The string passed to this function will look like this:
//                ?s=1 HTTP/1.....
//                We start after the first slash ("/" already removed)
int8_t analyse_get_url(char *str)
{
	// the first slash:
	if (*str == 'c'){
		// alarm configpage:
		gPlen=print_alarm_config();
		return(10);
	}
	if (*str == 'n'){
		// network configpage:
		gPlen=print_net_config();
		return(10);
	}	
	if (*str == 'u'){
		if (find_key_val(str,gStrbuf,STR_BUFFER_SIZE,"pw")){
			urldecode(gStrbuf);
			if (verify_password(gStrbuf)){
				if (find_key_val(str,gStrbuf,STR_BUFFER_SIZE,"n")){
					urldecode(gStrbuf);
					gStrbuf[MYNAME_LEN]='\0';
					strcpy(myname,gStrbuf);
				}
				if (find_key_val(str,gStrbuf,STR_BUFFER_SIZE,"di")){
					urldecode(gStrbuf);
					if (parse_ip(udpsrvip,gStrbuf)!=0){
						return(-2);
					}					
					
					// we've found destip, which means this is update from the
					// alarm conf page (this is a mandatory field)
					// Check alarm check box here
					if (find_key_val(str,gStrbuf,STR_BUFFER_SIZE,"ae")){
						alarmOn=1;
					}else{
						alarmOn=0;
					}
				}
				if (find_key_val(str,gStrbuf,STR_BUFFER_SIZE,"dp")){
					gStrbuf[4]='\0';
					udpsrvport=atoi(gStrbuf);
				}
				if (find_key_val(str,gStrbuf,STR_BUFFER_SIZE,"hb")){
					gStrbuf[4]='\0';
					heartbeat_timeout_sec=atoi(gStrbuf);
					
					// we've found heartbeat, which means this is update from the
					// network conf page
					// Check dhcp check box here
					if (find_key_val(str,gStrbuf,STR_BUFFER_SIZE,"dh")){
						dhcpOn=1;
					}else{
						dhcpOn=0;
					}		
				}
				if (find_key_val(str,gStrbuf,STR_BUFFER_SIZE,"gi")){
					urldecode(gStrbuf);
					if (parse_ip(gwip,gStrbuf)!=0){
						return(-2);
					}
				}
				if (find_key_val(str,gStrbuf,STR_BUFFER_SIZE,"ip")){
					urldecode(gStrbuf);
					if (parse_ip(myip,gStrbuf)!=0){
						return(-2);
					}
				}
				data2eeprom();
				gPlen=http200ok();
				gPlen=fill_tcp_data_p(buf,gPlen,PSTR("<a href=/>[home]</a>"));
				gPlen=fill_tcp_data_p(buf,gPlen,PSTR("<h2>OK</h2>"));
				return(10);
			}
		}
		return(-1);
	}
	return(0);
}