tangibleInterface.c 1.18 KB
#include <avr/io.h>
#include <util/delay.h>
#include <stdio.h>

#include "serial.h"
#include "ethernet.h"
#include "w5100.h"
#include "socket.h"

#define MAC_SIZE	6
#define IPV4_SIZE	4

int main(void)
{
  uint8_t little_mac[MAC_SIZE] = {0xA0,0xBD,0xCD,0xDD,0xED,0xFD};
  uint8_t ip[IPV4_SIZE] = {172,26,145,205};
  uint8_t gateway[IPV4_SIZE] = {172,26,145,254};
  uint8_t mask[IPV4_SIZE] = {255,255,255,0};
  uint16 size;
  const char answer [15]= "I'M OK";
  uint8 buf[16]; // Message à stocker.
  uint8_t addr[IPV4_SIZE]; // Adresse source du message reçu.
  uint8_t addr2[IPV4_SIZE]={172,26,145,35};
  uint16_t port; // Port source du message reçu.
  SOCKET sUDP=0;
  SOCKET sTCP=1;
  int test = 0;
  init_printf();
  ethernet_init(little_mac,ip,gateway,mask); 
  test = socket(sUDP,Sn_MR_UDP,2020,0);
  while(test)
    {
      //sendto(sUDP,answer,sizeof(answer),addr2,2020);
      recvfrom(sUDP,buf,sizeof(buf),addr,&port);
    }
  printf("Sortie boucle\n");
  return 0;
}



/* if(listen(sTCP)) //Repondre je vais bien à un client */
/* 	{ */
/* 	  send(sTCP,(uint8 *)answer,sizeof(answer)); */
/* 	} */
  /* if (!socket(sTCP,Sn_MR_TCP,2020,0)) */
  /*   { */
  /*     return -1; */
  /*   } */