Webserver atmega88

Zdravím
Na serveru tuxgraphics.org/electronics/2006 … rver.shtml je projekt který se snažím realizovat ale místo webstránky se zobrazují tyhle fragmenty [code]
http://192.168.0.25/secret do prohlížeče
HT/. 0 oe emnnl
Lcto:secret/
otn-ye ethm
Pam:n-ah

<131MvdPraety/1
/
otn-ye ethm
Pam:n-ah

adataln ls oteul

http://192.168.0.25/ do prohlížeče
HT/. 0 K
otn-ye ethm

<>sg:ht:/oto_ppswr<p
HT/. 0 K
otn-ye ethm

http://192.168.0.25/secret/1 do prohlížeče
HT/. 0 K
otn-ye ethm
Pam:n-ah

<etr<>upti:<otclr"0F0" N/ot sal< rf""[ers tts<a<sal<p
p< rf"/“Sic f<a<> sal< rf”"[ers tts<a<sal<p
p< rf"h>b>eso .7 ugahc.r
/"Sic n/>p

http://192.168.0.25/secret/0 do prohlížeče
HT/. 0 K
otn-ye ethm
Pam:n-ah

<etr<>upti:OF<otclr"0F0" N/ot sal< rf""[ers tts<a<sal<p
p< rf"/"Sic n/>ph>b>eso .7 ugahc.r
/"Sic n/>p
[/code]
Relé funguje vypínání 192.168.0.25/secret/1
v příloze je můj upravený projekt atmega88 jede na interním oscilátoru 8MHz
při překladu mám tam 20 warmingů PROGMEN
to asi bude ten problém že se nezobrazí webstránka jak má Warning 1 type defaults to 'int' in declaration of 'progmem_s' [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.c 384 68 atmega88webserver Warning 2 '__progmem__' attribute ignored -Wattributes] E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.c 384 1 atmega88webserver Warning 3 type defaults to 'int' in declaration of 'progmem_s' [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 75 atmega88webserver Warning 4 '__progmem__' attribute ignored -Wattributes] E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 1 atmega88webserver Warning 5 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 96 9 atmega88webserver Message 6 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver Warning 7 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 98 9 atmega88webserver Message 8 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver Warning 9 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 99 9 atmega88webserver Message 10 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver Warning 11 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 100 9 atmega88webserver Message 12 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver Warning 13 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 109 9 atmega88webserver Message 14 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver Warning 15 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 110 9 atmega88webserver Message 16 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver Warning 17 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 112 17 atmega88webserver Message 18 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver Warning 19 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 114 17 atmega88webserver Message 20 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver Warning 21 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 116 9 atmega88webserver Message 22 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver Warning 23 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 118 17 atmega88webserver Message 24 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver Warning 25 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 120 17 atmega88webserver Message 26 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver Warning 27 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 122 9 atmega88webserver Message 28 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver Warning 29 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 243 41 atmega88webserver Message 30 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver Warning 31 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 247 41 atmega88webserver Message 32 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver Warning 33 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 248 41 atmega88webserver Message 34 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver Warning 35 passing argument 3 of 'fill_tcp_data_p' from incompatible pointer type [enabled by default] E:\atmel\atmega88webserver\atmega88webserver\main.c 255 41 atmega88webserver Message 36 expected 'const int *' but argument is of type 'const char *' E:\atmel\atmega88webserver\atmega88webserver\ip_arp_udp_tcp.h 28 17 atmega88webserver
ten projekt je dřívějšího data a pro definici ukládání do flash paměti se používalo místo PROGMEN něco jiného a v tom asi bude zakopaný pes
potřeboval bych pomoc při opravě?
díky
atmega88webserver.rar (96 KB)

Tak už jsem se dobral úspěšného konce úprava v souboru ip_arp_udp_tcp.c
je taková místo uint16_t fill_tcp_data_p(uint8_t *buf,uint16_t pos, const prog_char *progmem_s)
tak uint16_t fill_tcp_data_p(uint8_t *buf,uint16_t pos, const char *progmem_s) díky
webserver4.jpg

Parada. Co s tym planujes robit dalej ? ak sa smiem spytat ?

Tak chtěl bych se pokusit doprogramovat obsluhu těch ostatních 8 I/O linek ale má to jeden háček nedostatek Flash paměti Atmega88 to ovládání tranzistoru čili jedna I/O linka zabírá 63% místa ,chci doufat že další I/O linky už toho moc neseřerou díky

V tom pripade sa budes musiet pozriet aj na html.
Uz z obrazka vidim priestor na usetrenie trochu pamäte: ten text na stranke “version 2.17, tuxgraphics.org” je zbytocny.
Myslim ze by sa to tam mohlo vojst, ak mas teraz zaplnenych “len” 63%

ups

Další věc jak přidat aby se ovládalo více I/O linek teď ovládám jen jednu I/O linku a to PORTD7 například PORTD0,PORTD1,PORTD3,PORTD4,PORTD5,PORTD6 to se nějak vypreparuje ale jelikož moc C jazyk neumím ta nevím jak na to? níže ve zdojáku je jak se ovládá ta jedna I/O linka
do prohlízeče pro nahození linky dávám
http://192.168.0.25/secret/1

[code]/*********************************************

// please modify the following two lines. mac and ip have to be unique
// in your local area network. You can not have the same numbers in
// two devices:
static uint8_t mymac[6] = {0x54,0x55,0x58,0x10,0x00,0x24};
// how did I get the mac addr? Translate the first 3 numbers into ascii is: TUX
static uint8_t myip[4] = {192,168,0,25}; //puvodni{10,0,0,24};
//static uint8_t myip[4] = {192,168,255,100};
// listen port for tcp/www (max range 1-254)
#define MYWWWPORT 80
//
// listen port for udp
#define MYUDPPORT 1200

#define BUFFER_SIZE 550
static uint8_t buf[BUFFER_SIZE+1];

// the password string (only the first 5 char checked), (only a-z,0-9,_ characters):
static char password]=“secret”; // must not be longer than 9 char

//
uint8_t verify_password(char *str)
{
// the first characters of the received string are
// a simple password/cookie:
if (strncmp(password,str,5)==0){
return(1);
}
return(0);
}

// takes a string of the form password/commandNumber and analyse it
// return values: -1 invalid password, otherwise command number
// -2 no command given but password valid
// -3 valid password, no command and no trailing “/”
int8_t analyse_get_url(char str)
{
uint8_t loop=1;
uint8_t i=0;
while(loop){
if(password
){
if(str==password){
str++;
i++;
}else{
return(-1);
}
}else{
// end of password
loop=0;
}
}
// is is now one char after the password
if (*str == ‘/’){
str++;
}else{
return(-3);
}
// check the first char, garbage after this is ignored (including a slash)
if (*str < 0x3a && *str > 0x2f){
// is a ASCII number, return it
return(*str-0x30);
}
return(-2);
}

// answer HTTP/1.0 301 Moved Permanently\r\nLocation: password/\r\n\r\n
// to redirect to the url ending in a slash
uint16_t moved_perm(uint8_t *buf)
{
uint16_t plen;

    plen=fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 301 Moved Permanently\r\nLocation: "));
    plen=fill_tcp_data(buf,plen,password);
    plen=fill_tcp_data_p(buf,plen,PSTR("/\r\nContent-Type: text/html\r\nPragma: no-cache\r\n\r\n"));
    plen=fill_tcp_data_p(buf,plen,PSTR("<h1>301 Moved Permanently</h1>\n"));
    plen=fill_tcp_data_p(buf,plen,PSTR("add a trailing slash to the url\n"));
    return(plen);

}

// prepare the webpage by writing the data to the tcp send buffer
uint16_t print_webpage(uint8_t *buf,uint8_t on_off)
{
uint16_t plen;
plen=fill_tcp_data_p(buf,0,PSTR(“HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nPragma: no-cache\r\n\r\n”));
plen=fill_tcp_data_p(buf,plen,PSTR(“

Output is: “));
if (on_off){
plen=fill_tcp_data_p(buf,plen,PSTR(”<font color=”#00FF00"> ON"));
}else{
plen=fill_tcp_data_p(buf,plen,PSTR(“OFF”));
}
plen=fill_tcp_data_p(buf,plen,PSTR(" <a href=".">[refresh status]

\n

<a href="."));
if (on_off){
plen=fill_tcp_data_p(buf,plen,PSTR("/0">Switch off

"));
}else{
plen=fill_tcp_data_p(buf,plen,PSTR("/1">Switch on

"));
}
plen=fill_tcp_data_p(buf,plen,PSTR(“



version 2.17, tuxgraphics.org\n”));
// Moje priprogramovane *************
plen =fill_tcp_data_p(buf,plen,PSTR("
"));

	/*plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox1\" name=\"Linka 1\" value=\"on\" checked style=\"position:absolute;left:147px;top:368px;z-index:0;\">"));
	plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox2\" name=\"Linka 2\" value=\"on\" checked style=\"position:absolute;left:147px;top:332px;z-index:1;\">"));
	plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox3\" name=\"Linka 3\" value=\"on\" checked style=\"position:absolute;left:147px;top:299px;z-index:2;\">"));
	plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox4\" name=\"Linka 4\"value=\"on\" checked style=\"position:absolute;left:148px;top:254px;z-index:3;\">"));
	plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox5\" name=\"Linka 5\" value=\"on\" checked style=\"position:absolute;left:258px;top:370px;z-index:4;\">"));
	plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox6\" name=\"Linka 6\" value=\"on\" checked style=\"position:absolute;left:257px;top:332px;z-index:5;\">"));
	plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox7\" name=\"Linka 7\" value=\"on\" checked style=\"position:absolute;left:257px;top:297px;z-index:6;\">"));
	plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox8\" name=\"Linka 8\" value=\"on\" checked style=\"position:absolute;left:258px;top:256px;z-index:7;\">"));
	*/
	plen = fill_tcp_data_p(buf,plen,PSTR("</pre></body></html>"));
	// --------------------------------------
	
    // Konec 
	return(plen);

}

int main(void){

    uint16_t plen;
    uint16_t dat_p;
    uint8_t i=0;
    uint8_t cmd_pos=0;
    int8_t cmd;
    uint8_t payloadlen=0;
    char str[30];
    char cmdval;
    
    // set the clock speed to "no pre-scaler" (8MHz with internal osc or 
    // full external speed)
    // set the clock prescaler. First write CLKPCE to enable setting of clock the
    // next four instructions.
    CLKPR=(1<<CLKPCE); // change enable
    CLKPR=0; // "no pre-scaler"
    _delay_loop_1(50); // 12ms

    /* enable PD2/INT0, as input */
    DDRD&= ~(1<<DDD2);

    /*initialize enc28j60*/
    enc28j60Init(mymac);
    enc28j60clkout(2); // change clkout from 6.25MHz to 12.5MHz
    _delay_loop_1(50); // 12ms
    
    // LED
    /* enable PB1, LED as output */
    DDRB|= (1<<DDB1);

    /* set output to Vcc, LED off */
    PORTB|= (1<<PORTB1);

    // the transistor on PD7
    DDRD|= (1<<DDD7);
    PORTD &= ~(1<<PORTD7);// transistor off
    
    /* Magjack leds configuration, see enc28j60 datasheet, page 11 */
    // LEDB=yellow LEDA=green
    //
    // 0x476 is PHLCON LEDA=links status, LEDB=receive/transmit
    // enc28j60PhyWrite(PHLCON,0b0000 0100 0111 01 10);
    enc28j60PhyWrite(PHLCON,0x476);
    _delay_loop_1(50); // 12ms
    
    /* set output to GND, red LED on */
    PORTB &= ~(1<<PORTB1);
    i=1;

    //init the ethernet/ip layer:
    init_ip_arp_udp_tcp(mymac,myip,MYWWWPORT);

    while(1){
            // get the next new packet:
            plen = enc28j60PacketReceive(BUFFER_SIZE, buf);

            /*plen will ne unequal to zero if there is a valid 
             * packet (without crc error) */
            if(plen==0){
                    continue;
            }
                    
            // arp is broadcast if unknown but a host may also
            // verify the mac address by sending it to 
            // a unicast address.
            if(eth_type_is_arp_and_my_ip(buf,plen)){
                    make_arp_answer_from_request(buf);
                    continue;
            }

            // check if ip packets are for us:
            if(eth_type_is_ip_and_my_ip(buf,plen)==0){
                    continue;
            }
            // led----------
            if (i){
                    /* set output to Vcc, LED off */
                    PORTB|= (1<<PORTB1);
                    i=0;
            }else{
                    /* set output to GND, LED on */
                    PORTB &= ~(1<<PORTB1);
                    i=1;
            }
            
            if(buf[IP_PROTO_P]==IP_PROTO_ICMP_V && buf[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V){
                    // a ping packet, let's send pong
                    make_echo_reply_from_request(buf,plen);
                    continue;
            }
            // tcp port www start, compare only the lower byte
            if (buf[IP_PROTO_P]==IP_PROTO_TCP_V&&buf[TCP_DST_PORT_H_P]==0&&buf[TCP_DST_PORT_L_P]==MYWWWPORT){
                    if (buf[TCP_FLAGS_P] & TCP_FLAGS_SYN_V){
                            make_tcp_synack_from_syn(buf);
                            // make_tcp_synack_from_syn does already send the syn,ack
                            continue;
                    }
                    if (buf[TCP_FLAGS_P] & TCP_FLAGS_ACK_V){
                            init_len_info(buf); // init some data structures
                            // we can possibly have no data, just ack:
                            dat_p=get_tcp_data_pointer();
                            if (dat_p==0){
                                    if (buf[TCP_FLAGS_P] & TCP_FLAGS_FIN_V){
                                            // finack, answer with ack
                                            make_tcp_ack_from_any(buf);
                                    }
                                    // just an ack with no data, wait for next packet
                                    continue;
                            }
                            if (strncmp("GET ",(char *)&(buf[dat_p]),4)!=0){
                                    // head, post and other methods:
                                    //
                                    // for possible status codes see:
                                    // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
                                    plen=fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n<h1>200 OK</h1>"));
                                    goto SENDTCP;
                            }
                            if (strncmp("/ ",(char *)&(buf[dat_p+4]),2)==0){
                                    plen=fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"));
                                    plen=fill_tcp_data_p(buf,plen,PSTR("<p>Usage: http://host_or_ip/password</p>\n"));
                                    goto SENDTCP;
                            }
                            cmd=analyse_get_url((char *)&(buf[dat_p+5]));
                            // for possible status codes see:
                            // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
                            if (cmd==-1){
                                    plen=fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 401 Unauthorized\r\nContent-Type: text/html\r\n\r\n<h1>401 Unauthorized</h1>"));
                                    goto SENDTCP;
                            }
                            if (cmd==1){
                                    PORTD|= (1<<PORTD7);// transistor on
                            }
                            if (cmd==0){
                                    PORTD &= ~(1<<PORTD7);// transistor off
                            }
                            if (cmd==-3){
                                    // redirect to add a trailing slash
                                    plen=moved_perm(buf);
                                    goto SENDTCP;
                            }
                            // if (cmd==-2) or any other value
                            // just display the status:
                            plen=print_webpage(buf,(PORTD & (1<<PORTD7)));
                            //

SENDTCP:
make_tcp_ack_from_any(buf); // send ack for http get
make_tcp_ack_with_data(buf,plen); // send data
continue;
}

            }
            // tcp port www end
            //
            // udp start, we listen on udp port 1200=0x4B0
            if (buf[IP_PROTO_P]==IP_PROTO_UDP_V&&buf[UDP_DST_PORT_H_P]==4&&buf[UDP_DST_PORT_L_P]==0xb0){
                    payloadlen=buf[UDP_LEN_L_P]-UDP_HEADER_LEN;
                    // you must sent a string starting with v
                    // e.g udpcom version 10.0.0.24
                    if (verify_password((char *)&(buf[UDP_DATA_P]))){
                            // find the first comma which indicates 
                            // the start of a command:
                            cmd_pos=0;
                            while(cmd_pos<payloadlen){
                                    cmd_pos++;
                                    if (buf[UDP_DATA_P+cmd_pos]==','){
                                            cmd_pos++; // put on start of cmd
                                            break;
                                    }
                            }
                            // a command is one char and a value. At
                            // least 3 characters long. It has an '=' on
                            // position 2:
                            if (cmd_pos<2 || cmd_pos>payloadlen-3 || buf[UDP_DATA_P+cmd_pos+1]!='='){
                                    strcpy(str,"e=no_cmd");
                                    goto ANSWER;
                            }
                            // supported commands are
                            // t=1 t=0 t=?
                            if (buf[UDP_DATA_P+cmd_pos]=='t'){
                                    cmdval=buf[UDP_DATA_P+cmd_pos+2];
                                    if(cmdval=='1'){
                                            PORTD|= (1<<PORTD7);// transistor on
                                            strcpy(str,"t=1");
                                            goto ANSWER;
                                    }else if(cmdval=='0'){
                                            PORTD &= ~(1<<PORTD7);// transistor off
                                            strcpy(str,"t=0");
                                            goto ANSWER;
                                    }else if(cmdval=='?'){
                                            if (PORTD & (1<<PORTD7)){
                                                    strcpy(str,"t=1");
                                                    goto ANSWER;
                                            }
                                            strcpy(str,"t=0");
                                            goto ANSWER;
                                    }
                            }
                            strcpy(str,"e=no_such_cmd");
                            goto ANSWER;
                    }
                    strcpy(str,"e=invalid_pw");

ANSWER:
make_udp_reply_from_request(buf,str,strlen(str),MYUDPPORT);
}
}
return (0);
}
[/code]
já bych potřeboval
http://192.168.0.25/secret/1/1 a tak dál až po tu poslední
díky**

a nechces vediet aj co sa tam deje a ako to funguje ?? :smiley:
Preto som ti pisal ze by si si mal pozriet aj html, a keby si si pozrel len uplne zaklady, vedel by si co vsetko musis spravit.
neskumal som komplet cely kod, ale vsimol som si ze tam mas nieco uz nachystane pre prehliadac:

/*plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox1\" name=\"Linka 1\" value=\"on\" checked style=\"position:absolute;left:147px;top:368px;z-index:0;\">")); plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox2\" name=\"Linka 2\" value=\"on\" checked style=\"position:absolute;left:147px;top:332px;z-index:1;\">")); plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox3\" name=\"Linka 3\" value=\"on\" checked style=\"position:absolute;left:147px;top:299px;z-index:2;\">")); plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox4\" name=\"Linka 4\"value=\"on\" checked style=\"position:absolute;left:148px;top:254px;z-index:3;\">")); plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox5\" name=\"Linka 5\" value=\"on\" checked style=\"position:absolute;left:258px;top:370px;z-index:4;\">")); plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox6\" name=\"Linka 6\" value=\"on\" checked style=\"position:absolute;left:257px;top:332px;z-index:5;\">")); plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox7\" name=\"Linka 7\" value=\"on\" checked style=\"position:absolute;left:257px;top:297px;z-index:6;\">")); plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox8\" name=\"Linka 8\" value=\"on\" checked style=\"position:absolute;left:258px;top:256px;z-index:7;\">")); */
To by ti malo na stranku pridat nejake checkboxy, a pomocou nich vyberies s ktorym pinom (linkou) chces pracovat. Ja by som to ale spravil cez tlacitka.
Dalej ak chces ovladat dalsie linky, musis ich nastavit ako vystupy.
A v kode si pohladaj, kde sa pracuje s PORTD7, a podla toho si napis kod pre ostatne “linky”. Je to spravene cez if-i. To co porovnavas v if-e ti musi sediet s tym, co ti posiela stranka naspät, ked kliknes na tlacitko na stranke (pomozu nejake zaklady z html)

Tento kód který uvádíš jsem tam přidal já /*plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox1\" name=\"Linka 1\" value=\"on\" checked style=\"position:absolute;left:147px;top:368px;z-index:0;\">")); plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox2\" name=\"Linka 2\" value=\"on\" checked style=\"position:absolute;left:147px;top:332px;z-index:1;\">")); plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox3\" name=\"Linka 3\" value=\"on\" checked style=\"position:absolute;left:147px;top:299px;z-index:2;\">")); plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox4\" name=\"Linka 4\"value=\"on\" checked style=\"position:absolute;left:148px;top:254px;z-index:3;\">")); plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox5\" name=\"Linka 5\" value=\"on\" checked style=\"position:absolute;left:258px;top:370px;z-index:4;\">")); plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox6\" name=\"Linka 6\" value=\"on\" checked style=\"position:absolute;left:257px;top:332px;z-index:5;\">")); plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox7\" name=\"Linka 7\" value=\"on\" checked style=\"position:absolute;left:257px;top:297px;z-index:6;\">")); plen = fill_tcp_data_p(buf,plen,PSTR("<input type=\"checkbox\" id=\"Checkbox8\" name=\"Linka 8\" value=\"on\" checked style=\"position:absolute;left:258px;top:256px;z-index:7;\">")); */
to jen takový nástřel jak by to mohlo vypadat ale já neumím vytáhnout s toho řetězce který tam je poslán ty znaky které dám do if a podle ovládat I/O linky když je to 1 tak nahodit a když je to 0 tak ji zhodit konkrétní linku kdyby tady fungoval debuging přímo v atmege88 tak by to šlo krokovat a v proměnné která obsahuje výběr znaků by jsem zjistil znaky které potřebuji na porovnání do IF náhodou neexistuje taková možnost debugingu na atmega88? díky

aha, to ma nenapadlo :smiley: mohol som sa pozriet do originalu :smiley:

Aby sme sa lepsie chapali, dohodnime sa ze chces zapinat a vypinat ledky.
Na zaciatok to sprav podla originalu, teda nepouzivaj chceckbox, ale sprav tam pre kazdu ledku jeden link. Pre kazdu ledku budes mat dve ciselka (na zapnutie a vypnutie ledky). Na zaciatok pouzi cisla 0-9, to mas 5 lediek.

//EDIT: tak som si to rozmyslel :smiley: stav ledky uz vypisujes, takze uz nemusis vytvarat odkaz podla toho ci chces on, alebo off. Staci ked tam bude odkaz, ktory bude posielat vzdy len jednu hodnotu a podla toho budes vediet, ze chces togglovat ledku (doteraz sa tam stiedali dva odkazy podla toho, aky bol stav ledky. A spät sa posielala 0 alebo 1). Teraz budes posielat pre jednu ledku vzdy len jednu hodnotu, bez ohladu na to ci chces on alebo off. Cize pre led 1 budes posielat spät vzdy len nulu, pre led 2 vzdy len 1.

V po dmienke IF budes potom kontrolovat cislo ktore ti pride zo stranky, a podla toho ake ti pride, togglujes ledku. Teda pride ti 0, togglujes led 1, pride ti 2 => toglujes led 3…

Nastrel strankz (neskusal som funkcnost):

[code]uint16_t print_webpage(uint8_t *buf,uint8_t led_1_status ,uint8_t led_2_status ,uint8_t led_3_status ,uint8_t led_4_status ,uint8_t led_5_status)
{
uint16_t plen;
plen=fill_tcp_data_p(buf,0,PSTR(“HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nPragma: no-cache\r\n\r\n”));

	plen=fill_tcp_data_p(buf,plen,PSTR("<center><p>Led 1 is: "));
    if (led_1_status){
            plen=fill_tcp_data_p(buf,plen,PSTR("ON"));
    }else{
            plen=fill_tcp_data_p(buf,plen,PSTR("OFF"));
    }
    plen=fill_tcp_data_p(buf,plen,PSTR(" <a href=\"./0\">Toggle Led</a>\n<center><p>Led 2 is: "));
    
	if (led_2_status){
		plen=fill_tcp_data_p(buf,plen,PSTR("ON"));
		}else{
		plen=fill_tcp_data_p(buf,plen,PSTR("OFF"));
	}
	plen=fill_tcp_data_p(buf,plen,PSTR(" <a href=\"./1\">Toggle Led</a>\n<center><p>Led 3 is: "));
	
	if (led_3_status){
		plen=fill_tcp_data_p(buf,plen,PSTR("ON"));
		}else{
		plen=fill_tcp_data_p(buf,plen,PSTR("OFF"));
	}
	plen=fill_tcp_data_p(buf,plen,PSTR(" <a href=\"./2\">Toggle Led</a>\n<center><p>Led 4 is: "));
	
	if (led_4_status){
		plen=fill_tcp_data_p(buf,plen,PSTR("ON"));
		}else{
		plen=fill_tcp_data_p(buf,plen,PSTR("OFF"));
	}
	plen=fill_tcp_data_p(buf,plen,PSTR(" <a href=\"./3\">Toggle Led</a>\n<center><p>Led 5 is: "));
	
	if (led_5_status){
		plen=fill_tcp_data_p(buf,plen,PSTR("ON"));
		}else{
		plen=fill_tcp_data_p(buf,plen,PSTR("OFF"));
	}
	plen=fill_tcp_data_p(buf,plen,PSTR(" <a href=\"./4\">Toggle Led</a><p>"));
    return(plen);

}[/code]

Tak mám tam jednu chybu příčina asi bude v rozdílném počtu parametrů funkce print_webpage jak to spravit ?díky
webserver6.jpg

Budeš muset doplnit parametry tak, jak je to deklarované ve funkci :slight_smile:

jo, pozri sa na tu moju funkciu z predchadzajuceho prispevku.
Tiez budes musiet nastavit piny pre dalsie 4 ledky (alebo aj nemusis, je to na teba), a zmenit funkciu ktora sa stara o spracovanie odpovede zo stranky, lebo uz nebudes robit “zapnut led / vypnut led”, ale “zmenit stav led”.
Tak nech sa dari :slight_smile:

To mi je jasné že tu obsluhu dalších I/O linek musím doplnit ale to až pak ale jak upravit tento řádek

 plen=print_webpage(buf,(PORTD & (1<<PORTD7)));

nějak takto ?

 plen=print_webpage(buf,(PORTD & (1<<PORTD7)),buf,(PORTD & (1<<PORTD7)),buf,(PORTD & (1<<PORTD7)),buf,(PORTD & (1<<PORTD7)),buf,(PORTD & (1<<PORTD7)));

nebo jak ? díky

Prošlo to takto

plen=print_webpage(buf,(PORTD & (1<<PORTD7)),(PORTD & (1<<PORTD7)),(PORTD & (1<<PORTD7)),(PORTD & (1<<PORTD7)),(PORTD & (1<<PORTD7)));
Compiler neměl žádné námitky díky

a tak je to spravne :slight_smile:
toto ti zistuje stav na pine7 portu D:

(PORTD & (1<<PORTD7))

Ty to tam mas teraz 5x, takze ti zobrazi 5x stav toho isteho pinu. Takze aby to davalo zmysel, tak tam das ine piny, a mozes aj iny port, napr:

(PORTB & (1<<PB1))

Já s tím počítám já jsem jenom chtěl aby to vzal compiler to si potom upravím jenže co mě dělá hlavu že si to funguje když to chce samo a ne kdy já chci, dneska jsem to například vůbec nenačetl do prohlížeče rozuměj ještě neupraveno podle tebe nevím kde je chyba? :blush: díky

nenapada.
Hrajkal som sa s tym len chvilku, ale vzdy mi to fungovalo tak ako malo.

Tady je příloha síťové komunikace že by tady byla chyba? díky
sít.jpg

můžeš mi poskytnout tvoje zapojení popřípadě fotku kde a jak to máš zapojeno nepájivém poli? možná dělám nějakou chybu díky