Simple Thing for DJ
Dependencies: WIZnet_Library mbed
Fork of SimpleThing_DJ by
Diff: main.cpp
- Revision:
- 1:421fd0a7b5d7
- Parent:
- 0:412f9c1172b7
- Child:
- 2:1e8031dab116
--- a/main.cpp Mon Apr 27 00:23:46 2015 +0000 +++ b/main.cpp Sat Jun 06 14:31:33 2015 +0000 @@ -1,42 +1,51 @@ #include "mbed.h" #include "WIZnetInterface.h" -#define USE_DHCP 1 +#define USE_DHCP 0 #define LOOPBACKPORT 5000 -const char * IP_Addr = "192.168.11.194"; +const char * IP_Addr = "192.168.1.20"; const char * IP_Subnet = "255.255.255.0"; -const char * IP_Gateway = "192.168.11.1"; -unsigned char MAC_Addr[6] = {0x00,0x08,0xDC,0x12,0x34,0x56}; +const char * IP_Gateway = "192.168.1.1"; +unsigned char MAC_Addr[6] = {0x00,0x08,0xDC,0x12,0x07,0x07}; DigitalOut myled1(LED1); Serial pc(USBTX, USBRX); -#ifdef TARGET_LPC11U68 -SPI spi(P0_9,P0_8,P1_29); -WIZnetInterface ethernet(&spi,P0_2,P1_13); -#endif +//#ifdef TARGET_LPC11U68 +SPI spi(PTD2,PTD3,PTD1); +WIZnetInterface ethernet(&spi,PTD0,PTA20); +//#endif -int main() { +int main() +{ + + uint8_t mac[6]; - mbed_mac_address((char *)MAC_Addr); //Use mbed mac addres + // set these to match the mac address on the Arduino Ethernet Shield + mac[0] = 0x90; mac[1] = 0xa2; mac[2] = 0xda; + mac[3] = 0x0f; mac[4] = 0x0e; mac[5] = 0x63; // 90:a2:da:0f:0e:63 + + //Set serial port baudrate speed: 115200 pc.baud(115200); - + pc.printf("Started\r\n"); + + //mbed_mac_address((char *)MAC_Addr); //Use mbed mac addres + pc.printf("Start\r\n"); char buffer[256]; - - while(1) - { - #if USE_DHCP - int ret = ethernet.init(MAC_Addr); - #else + + while(1) { +#if USE_DHCP + int ret = ethernet.init(mac); +#else int ret = ethernet.init(MAC_Addr,IP_Addr,IP_Subnet,IP_Gateway); - #endif - +#endif + if (!ret) { pc.printf("Initialized, MAC: %s\r\n", ethernet.getMACAddress()); ret = ethernet.connect(); @@ -55,7 +64,7 @@ TCPSocketServer server; server.bind(LOOPBACKPORT); server.listen(); - + while (1) { pc.printf("\nWait for new connection...\r\n"); TCPSocketConnection client;