Commit fed98e682f874999761024f9b59341e78efff20a

Authored by Speedclocker
2 parents b159f2fa 99a83ce4

Merge branch 'master' of https://archives.plil.fr/amoreau/skam_projet

Tangible/ethernet.o 0 → 100644
No preview for this file type
Tangible/iic.o 0 → 100644
No preview for this file type
Tangible/serial.h
1 1 /** Definitions for serial port **/
2 2  
  3 +void init_printf(void); // Met le BD à 9600
  4 +
3 5 void init_serial(int speed);
4   -void send_serial(char c);
5   -char get_serial(void);
6   -void init_printf(void);
  6 +
  7 +void send_serial(char c); //Envoi via UDR0
  8 +char get_serial(void); // Recupère UDR0
  9 +
... ...
Tangible/serial.o 0 → 100644
No preview for this file type
Tangible/socket.h
... ... @@ -10,11 +10,16 @@
10 10  
11 11 extern uint8 socket(SOCKET s, uint8 protocol, uint16 port, uint8 flag); // Opens a socket(TCP or UDP or IP_RAW mode)
12 12 extern void close(SOCKET s); // Close socket
  13 +
  14 +
13 15 extern uint8 connect(SOCKET s, uint8 * addr, uint16 port); // Establish TCP connection (Active connection)
14   -extern void disconnect(SOCKET s); // disconnect the connection
  16 +extern void disconnect(SOCKET s); // Disconnect the connection
  17 +
15 18 extern uint8 listen(SOCKET s); // Establish TCP connection (Passive connection)
16 19 extern uint16 send(SOCKET s, const uint8 * buf, uint16 len); // Send data (TCP)
17 20 extern uint16 recv(SOCKET s, uint8 * buf, uint16 len); // Receive data (TCP)
  21 +
  22 +
18 23 extern uint16 sendto(SOCKET s, const uint8 * buf, uint16 len, uint8 * addr, uint16 port); // Send data (UDP/IP RAW)
19 24 extern uint16 recvfrom(SOCKET s, uint8 * buf, uint16 len, uint8 * addr, uint16 *port); // Receive data (UDP/IP RAW)
20 25  
... ...
Tangible/socket.o 0 → 100644
No preview for this file type
Tangible/tangibleInterface.c
... ... @@ -12,7 +12,43 @@
12 12  
13 13 int main(void)
14 14 {
15   -init_printf();
16   -// Your code here !!
17   -return 0;
  15 + uint8_t mac[MAC_SIZE] = {0xAD,0xBD,0xCD,0xDD,0xED,0xFD};
  16 + uint8_t ip[IPV4_SIZE] = {172,26,145,205};
  17 + uint8_t gateway[4] = {172,26,145,35};
  18 + uint8_t mask[4] = {255,255,255,0};
  19 +
  20 + const char * answer = "I'm ok";
  21 +
  22 + char buf[16]; // Message à stocker.
  23 + uint8_t addr[IPV4_SIZE]; // Adresse source du message reçu.
  24 + uint16_t port; // Port source du message reçu.
  25 +
  26 + SOCKET sUDP;
  27 + SOCKET sTCP;
  28 +
  29 + init_printf(); // On active la liaison série (9600 BD).
  30 + ethernet_init(mac,ip,gateway,mask); // On assimile une adresse MAC et IP au shield + Indication de la passerelle et du masque de sous-réseau.
  31 + if (!socket(sUDP,Sn_MR_UDP,2020,0))
  32 + {
  33 + return -1;
  34 + }
  35 + if (!socket(sTCP,Sn_MR_TCP,2020,0))
  36 + {
  37 + return -1;
  38 + }
  39 + while(1)
  40 + {
  41 + if(listen(sTCP)) //Repondre je vais bien à un client
  42 + {
  43 + send(sTCP,(uint8 *)answer,sizeof(answer));
  44 + }
  45 +
  46 + if (recvfrom(sUDP,buf,sizeof(buf),addr,&port) != -1) //Reception via UDP (infos de la sonde)
  47 + {
  48 +
  49 + }
  50 + }
  51 + close(sTCP);
  52 + close(sUDP);
  53 + return 0;
18 54 }
... ...
Tangible/tangibleInterface.o 0 → 100644
No preview for this file type
Tangible/w5100.o 0 → 100644
No preview for this file type