4 * Created on: 2014. 11. 13.
14 // Arduino WiFi Shield
19 // Arduino Ethernet Shield
20 #include <EthernetServer.h>
23 #include <EthernetClient.h>
25 #include <EthernetUdp.h>
30 PROGMEM const char TAG[] = "ReferenceSensor";
33 // Arduino WiFi Shield
34 // Note : Arduino WiFi Shield currently does NOT support multicast and therefore
35 // this server will NOT be listening on 224.0.1.187 multicast address.
37 /// WiFi Shield firmware with Intel patches
38 static const char INTEL_WIFI_SHIELD_FW_VER[] = "1.2.0";
40 /// WiFi network info and credentials
41 char ssid[] = "SoftSensor_AP";
42 char pass[] = "1234567890";
43 //char ssid[] = "SoftSensor_2.4G";
44 //char pass[] = "12344321";
46 int ConnectToNetwork()
49 int status = WL_IDLE_STATUS;
50 // check for the presence of the shield:
51 if (WiFi.status() == WL_NO_SHIELD)
53 OC_LOG(ERROR, TAG, PCF("WiFi shield not present"));
57 // Verify that WiFi Shield is running the firmware with all UDP fixes
58 fwVersion = WiFi.firmwareVersion();
59 OC_LOG_V(INFO, TAG, "WiFi Shield Firmware version %s", fwVersion);
60 if ( strncmp(fwVersion, INTEL_WIFI_SHIELD_FW_VER, sizeof(INTEL_WIFI_SHIELD_FW_VER)) !=0 )
62 OC_LOG(DEBUG, TAG, PCF("!!!!! Upgrade WiFi Shield Firmware version !!!!!!"));
66 // attempt to connect to Wifi network:
67 while (status != WL_CONNECTED)
69 OC_LOG_V(INFO, TAG, "Attempting to connect to SSID: %s", ssid);
70 status = WiFi.begin(ssid,pass);
72 // wait 10 seconds for connection:
75 OC_LOG(DEBUG, TAG, PCF("Connected to wifi"));
77 IPAddress ip = WiFi.localIP();
78 OC_LOG_V(INFO, TAG, "IP Address: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
82 // Arduino Ethernet Shield
83 int ConnectToNetwork()
85 // Note: ****Update the MAC address here with your shield's MAC address****
86 uint8_t ETHERNET_MAC[] = {0x90, 0xA2, 0xDA, 0x0E, 0xB8, 0xAC};
88 uint8_t error = Ethernet.begin(ETHERNET_MAC);
91 OC_LOG_V(ERROR, TAG, "error is: %d", error);
94 IPAddress ip = Ethernet.localIP();
95 OC_LOG_V(INFO, TAG, "IP Address: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);