friendev EtherDune TCP/IP library
EtherSocketTest.ino
Go to the documentation of this file.
1 // EtherDune scratchpad test .ino
2 // Author: Javier Peletier <jm@friendev.com>
3 // Summary: Won't contain anything clean. Look at the other examples instead.
4 //
5 // Copyright (c) 2015 All Rights Reserved, http://friendev.com
6 //
7 // This source is subject to the GPLv2 license.
8 // Please see the License.txt file for more information.
9 // All other rights reserved.
10 //
11 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
12 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
14 // PARTICULAR PURPOSE.
15 
16 #include <ACross.h>
17 #include <Checksum.h>
18 #include <TCPSocket.h>
19 #include <UDPSocket.h>
20 
21 #include <inet.h>
22 #include <ENC28J60.h>
23 #include <DNS.h>
24 #include <FlowScanner.h>
25 #include <HTTPClient.h>
26 #include <DHCP.h>
27 
28 
29 #define AC_LOGLEVEL 6
30 #include <ACLog.h>
31 ACROSS_MODULE("EtherSocketTest");
32 
33 
34 static const uint8_t CS_PIN = 10; //Put here what pin you are using for your ENC28J60's chip select
35 static MACAddress_P mymac = { 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64 };
36 static IPAddress_P gatewayIP = { 192, 168, 1, 1 };
37 static IPAddress_P myIP = { 192, 168, 1, 33 };
38 static IPAddress_P netmask = { 255, 255, 255, 0 };
39 
41 
42 
43 void setup()
44 {
45 
46  Serial.begin(115200);
47  ACross::init();
48 
49 
50  Serial.println(F("Press any key to start..."));
51 
52  while (!Serial.available());
53 
58 
59  if (!net::begin(CS_PIN))
60  ACERROR("failed to start EtherDune");
61 
62  ACINFO("waiting for link...");
63 
64  while (!net::isLinkUp());
65 
66  ACINFO("link is up");
67 
68 
69 
70  //if (!dhcp.dhcpSetup())
71  //{
72  // Serial.println(F("DHCP setup failed"));
73  // ACross::halt(1);
74  //}
75 
76  Serial.println(F("DHCP setup OK"));
77 
78 
79 }
80 
81 
82 void loop()
83 {
84  net::loop();
85 
86 }
87 
#define MACAddress_P
Definition: inet.h:242
#define IPAddress_P
helper macro to store an IP address in PROGMEM
Definition: inet.h:170
static IPAddress_P gatewayIP
EtherDune DHCP Service.
Definition: DHCP.h:122
static bool begin(uint8_t cspin)
Initializes EtherDune and the underlying hardware
ACROSS_MODULE("EtherSocketTest")
static IPAddress netmask
Subnet mask.
static IPAddress gatewayIP
IP address of the gateway in this network.
static const uint8_t CS_PIN
static MACAddress_P mymac
static bool isLinkUp()
Determines whether the network link is ready
Definition: ENC28J60.cpp:306
void setup()
DHCP dhcp
static MACAddress localMAC
Ethernet MAC address.
static IPAddress_P myIP
Base data structures for Internet communication.
static void loop()
Gives processing time to EtherDune so that it can check for incoming packets or send queued packets...
static IPAddress localIP
IP address of this application.
static IPAddress_P netmask
void loop()