Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / resource / csdk / stack / test / arduino / ocserver.cpp
1 #include <Time.h>
2 #include <SPI.h>
3 #include <Ethernet.h>
4 #include <ocstack.h>
5 #include <logger.h>
6
7 static uint8_t ETHERNET_MAC[] = {0x90, 0xA2, 0xDA, 0x0F, 0x2B, 0x72 };
8
9 #define TAG PCF("ocserver")
10
11 void ocInitialize () {
12     OC_LOG(DEBUG, TAG, PCF("IP addr is:"));
13     OC_LOG_BUFFER(INFO, TAG, (uint8_t*)ipAddr, sizeof(ipAddr));
14     delay(2000);
15     OCInit (NULL, 0, OC_SERVER);
16 }
17
18 void setup() {
19     Serial.begin(115200);
20
21     Serial.println ("Trying to get an IP addr using DHCP");
22     if (Ethernet.begin(ETHERNET_MAC) == 0) {
23         Serial.println("DHCP failed");
24     }
25         ocInitialize ();
26 }
27
28 void loop() {
29     Serial.println ("Processing CoAP messages!\n");
30     OCProcess ();
31     delay(1000);
32 }
33