Permalink
Browse files

SVN move

Revision: 4
Author: ulrich
Date: 02:45:38, Samstag, 27. August 2011
Message:
Enocean hinzugefügt
Letzter Zustand wird aus eeprom ausgelesen
  • Loading branch information...
1 parent 3d0f1aa commit 82a82377d8290d8f9593091093c594cad2d9f542 @uescher uescher committed Sep 26, 2011
@@ -1 +1 @@
-<Project name="ETH_M32_EX"><Folder name="camera"><File path="camera\cam.h"></File><File path="camera\cam.c"></File><File path="camera\servo.c"></File><File path="camera\servo.h"></File></Folder><Folder name="Netzwerktreiber"><File path="networkcard\enc28j60.c"></File><File path="networkcard\enc28j60.h"></File><File path="networkcard\rtl8019.c"></File><File path="networkcard\rtl8019.h"></File></Folder><File path="main.c"></File><File path="makefile"></File><File path="stack.c"></File><File path="stack.h"></File><File path="usart.c"></File><File path="usart.h"></File><File path="timer.c"></File><File path="cmd.h"></File><File path="cmd.c"></File><File path="httpd.h"></File><File path="httpd.c"></File><File path="telnetd.h"></File><File path="telnetd.c"></File><File path="config.h"></File><File path="base64.c"></File><File path="base64.h"></File><File path="webpage.h"></File><File path="ntp.h"></File><File path="ntp.c"></File><File path="timer.h"></File><File path="http_get.c"></File><File path="http_get.h"></File><File path="lcd.c"></File><File path="lcd.h"></File><File path="udp_lcd.h"></File><File path="udp_lcd.c"></File><File path="analog.h"></File><File path="analog.c"></File><File path="wol.h"></File><File path="wol.c"></File><File path="sendmail.c"></File><File path="sendmail.h"></File><File path="dnsc.c"></File><File path="dnsc.h"></File><File path="dhcpc.c"></File><File path="dhcpc.h"></File></Project>
+<Project name="ETH_M32_EX"><Folder name="camera"><File path="camera\cam.h"></File><File path="camera\cam.c"></File><File path="camera\servo.c"></File><File path="camera\servo.h"></File></Folder><Folder name="Netzwerktreiber"><File path="networkcard\enc28j60.c"></File><File path="networkcard\enc28j60.h"></File><File path="networkcard\rtl8019.c"></File><File path="networkcard\rtl8019.h"></File></Folder><File path="main.c"></File><File path="makefile"></File><File path="stack.c"></File><File path="stack.h"></File><File path="usart.c"></File><File path="usart.h"></File><File path="timer.c"></File><File path="cmd.h"></File><File path="cmd.c"></File><File path="httpd.h"></File><File path="httpd.c"></File><File path="telnetd.h"></File><File path="telnetd.c"></File><File path="config.h"></File><File path="base64.c"></File><File path="base64.h"></File><File path="webpage.h"></File><File path="ntp.h"></File><File path="ntp.c"></File><File path="timer.h"></File><File path="http_get.c"></File><File path="http_get.h"></File><File path="lcd.c"></File><File path="lcd.h"></File><File path="udp_lcd.h"></File><File path="udp_lcd.c"></File><File path="analog.h"></File><File path="analog.c"></File><File path="wol.h"></File><File path="wol.c"></File><File path="sendmail.c"></File><File path="sendmail.h"></File><File path="dnsc.c"></File><File path="dnsc.h"></File><File path="dhcpc.c"></File><File path="dhcpc.h"></File><File path="enocean.c"></File><File path="enocean.h"></File></Project>

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -136,6 +136,8 @@ void command_ip (void)
{
write_eeprom_ip(IP_EEPROM_STORE);
(*((unsigned long*)&myip[0])) = get_eeprom_value(IP_EEPROM_STORE,MYIP);
+ //Broadcast-Adresse berechnen
+ (*((unsigned long*)&broadcast_ip[0])) = (((*((unsigned long*)&myip[0])) & (*((unsigned long*)&netmask[0]))) | (~(*((unsigned long*)&netmask[0]))));
usart_write("My IP: %1i.%1i.%1i.%1i\r\n",myip[0],myip[1],myip[2],myip[3]);
}
@@ -171,6 +173,8 @@ void command_net (void)
{
write_eeprom_ip(NETMASK_EEPROM_STORE);
(*((unsigned long*)&netmask[0])) = get_eeprom_value(NETMASK_EEPROM_STORE,NETMASK);
+ //Broadcast-Adresse berechnen
+ (*((unsigned long*)&broadcast_ip[0])) = (((*((unsigned long*)&myip[0])) & (*((unsigned long*)&netmask[0]))) | (~(*((unsigned long*)&netmask[0]))));
usart_write("NETMASK: %1i.%1i.%1i.%1i\r\n",netmask[0],netmask[1],netmask[2],netmask[3]);
}
@@ -245,18 +249,18 @@ void command_tcp (void)
//ändern einer Variable
void command_setvar (void)
{
- var_array[variable[0]] = variable[1];
- usart_write("Inhalt der Variable[%2i] = %2i\r\n",variable[0],var_array[variable[0]]);
+// var_array[variable[0]] = variable[1];
+// usart_write("Inhalt der Variable[%2i] = %2i\r\n",variable[0],var_array[variable[0]]);
}
//------------------------------------------------------------------------------
//print Time
void command_time (void)
{
- unsigned char hh = (time/3600)%24;
- unsigned char mm = (time/60)%60;
- unsigned char ss = time %60;
- usart_write ("\n\rTIME: %2i:%2i:%2i\r\n",hh,mm,ss);
+// unsigned char hh = (time/3600)%24;
+// unsigned char mm = (time/60)%60;
+// unsigned char ss = time %60;
+// usart_write ("\n\rTIME: %2i:%2i:%2i\r\n",hh,mm,ss);
}
//------------------------------------------------------------------------------
@@ -373,6 +377,7 @@ void read_ip_addresses (void)
(*((unsigned long*)&myip[0])) = get_eeprom_value(IP_EEPROM_STORE,MYIP);
(*((unsigned long*)&netmask[0])) = get_eeprom_value(NETMASK_EEPROM_STORE,NETMASK);
(*((unsigned long*)&router_ip[0])) = get_eeprom_value(ROUTER_IP_EEPROM_STORE,ROUTER_IP);
+ (*((unsigned long*)&broadcast_ip[0])) = (((*((unsigned long*)&myip[0])) & (*((unsigned long*)&netmask[0]))) | (~(*((unsigned long*)&netmask[0]))));
#if USE_DNS
//DNS-Server IP aus EEPROM auslesen
@@ -33,7 +33,7 @@
//Konfiguration der PORTS (HEX)
//1=OUTPUT / 0=INPUT
#define OUTA 0x07
- #define OUTC 0x06
+ #define OUTC 0x00
#define OUTD 0x00
//Achtung!!!! an PORTB ist der ENC
//nur ändern wenn man weiß was man macht!
@@ -56,7 +56,10 @@
#define NETMASK IP(255,255,255,0)
//DHCP-Server
- #define USE_DHCP 1 //1 = DHCP Client on
+ #define USE_DHCP 0 //1 = DHCP Client on
+
+ //ENOCEAN
+ #define USE_ENOCEAN 1
//DNS-Server
#define USE_DNS 0 //1 = DNS Client on
@@ -86,13 +86,17 @@ unsigned char dhcp_state;
struct dhcp_cache cache;
volatile unsigned long dhcp_lease;
+unsigned char dhcp_offer_ip[4];
+
//----------------------------------------------------------------------------
//Init of DHCP client port
void dhcp_init (void)
{
//Port in Anwendungstabelle eintragen für eingehende DHCP Daten!
add_udp_app (DHCP_CLIENT_PORT, (void(*)(unsigned char))dhcp_get);
dhcp_state = DHCP_STATE_IDLE;
+ (*((unsigned long*)&myip[0])) = IP(0,0,0,0);
+ (*((unsigned long*)&dhcp_offer_ip[0])) = IP(10,42,3,100);
return;
}
//----------------------------------------------------------------------------
@@ -147,10 +151,11 @@ unsigned char dhcp (void)
break;
case DHCP_STATE_ACK_RCVD:
DHCP_DEBUG("LEASE %2x%2x%2x%2x\r\n", cache.lease[0],cache.lease[1],cache.lease[2],cache.lease[3]);
-
- dhcp_lease = (unsigned long)cache.lease[0] << 24 | (unsigned long)cache.lease[1] << 16 | (unsigned long)cache.lease[2] << 8 |(unsigned long)cache.lease[3];
-
- (*((unsigned long*)&netmask[0])) = (*((unsigned long*)&cache.netmask[0]));
+ dhcp_lease = *((unsigned long*)&cache.lease[0]);
+ (*((unsigned long*)&myip[0])) = (*((unsigned long*)&dhcp_offer_ip[0]));
+ (*((unsigned long*)&netmask[0])) = (*((unsigned long*)&cache.netmask[0]));
+ //Broadcast-Adresse berechnen
+ (*((unsigned long*)&broadcast_ip[0])) = (((*((unsigned long*)&myip[0])) & (*((unsigned long*)&netmask[0]))) | (~(*((unsigned long*)&netmask[0]))));
(*((unsigned long*)&router_ip[0])) = (*((unsigned long*)&cache.router_ip[0]));
#if USE_DNS
(*((unsigned long*)&dns_server_ip[0])) = (*((unsigned long*)&cache.dns1_ip[0]));
@@ -213,10 +218,10 @@ void dhcp_message (unsigned char type)
*options++ = 50; // Option 54: requested IP
*options++ = 4; // len = 4
- *options++ = myip[0];
- *options++ = myip[1];
- *options++ = myip[2];
- *options++ = myip[3];
+ *options++ = dhcp_offer_ip[0];
+ *options++ = dhcp_offer_ip[1];
+ *options++ = dhcp_offer_ip[2];
+ *options++ = dhcp_offer_ip[3];
switch (type)
{
@@ -240,15 +245,19 @@ void dhcp_message (unsigned char type)
}
*options++ = 12; // Option 12: host name
- *options++ = 8; // len = 8
- *options++ = 'M';
- *options++ = 'i';
- *options++ = 'n';
- *options++ = 'i';
- *options++ = '-';
+ *options++ = 12; // len = 8
*options++ = 'A';
*options++ = 'V';
*options++ = 'R';
+ *options++ = '-';
+ *options++ = 'L';
+ *options++ = 'I';
+ *options++ = 'G';
+ *options++ = 'H';
+ *options++ = 'T';
+ *options++ = 'C';
+ *options++ = 'T';
+ *options++ = 'R';
*options = 0xff; //end option
@@ -458,12 +467,16 @@ void dhcp_get (void)
{
case DHCPOFFER:
// this will be our IP address
- (*((unsigned long*)&myip[0])) = (*((unsigned long*)&msg->yiaddr[0]));
+ (*((unsigned long*)&dhcp_offer_ip[0])) = (*((unsigned long*)&msg->yiaddr[0]));
+ //Broadcast-Adresse berechnen
+ //(*((unsigned long*)&broadcast_ip[0])) = (((*((unsigned long*)&myip[0])) & (*((unsigned long*)&netmask[0]))) | (~(*((unsigned long*)&netmask[0]))));
DHCP_DEBUG("** DHCP OFFER RECVD! **\r\n");
dhcp_state = DHCP_STATE_OFFER_RCVD;
break;
case DHCPACK:
- DHCP_DEBUG("** DHCP ACK RECVD! **\r\n");
+ // this will be our IP address
+ (*((unsigned long*)&dhcp_offer_ip[0])) = (*((unsigned long*)&msg->yiaddr[0]));
+ DHCP_DEBUG("** DHCP ACK RECVD! **\r\n");
dhcp_state = DHCP_STATE_ACK_RCVD;
break;
case DHCPNAK:
Oops, something went wrong.

0 comments on commit 82a8237

Please sign in to comment.