40 lines
966 B
Arduino
40 lines
966 B
Arduino
|
|
#include <Arduino.h>
|
||
|
|
#include <Ethernet.h>
|
||
|
|
#include <wakaama-client.h>
|
||
|
|
|
||
|
|
// network config
|
||
|
|
byte mac[] = {
|
||
|
|
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
|
||
|
|
};
|
||
|
|
IPAddress ip(192,168,14,21);
|
||
|
|
IPAddress dnsIp(8,8,8,8);
|
||
|
|
//IPAddress gatewayIp(192,168,14,1);
|
||
|
|
|
||
|
|
// constructor only sets uri, init() called later so we can debug print
|
||
|
|
//ArduinoClient wakaamaClient("coap://192.168.14.14:5683");
|
||
|
|
//ArduinoClient wakaamaClient("coap://leshan.eclipse.org:5683");
|
||
|
|
ArduinoClient wakaamaClient("coap://ethinnoday-lwm2m-server.westeurope.cloudapp.azure.com:5683");
|
||
|
|
|
||
|
|
void setup() {
|
||
|
|
delay(5000);
|
||
|
|
Ethernet.begin(mac, ip, dnsIp);
|
||
|
|
// Ethernet.begin(mac, ip, dnsIp, gatewayIp);
|
||
|
|
SerialOut.begin(9600);
|
||
|
|
while (!SerialOut) {
|
||
|
|
; // wait for serial port to connect.
|
||
|
|
}
|
||
|
|
SerialOut.println(F("Serial init done"));
|
||
|
|
|
||
|
|
// initialize the client
|
||
|
|
wakaamaClient.init();
|
||
|
|
}
|
||
|
|
|
||
|
|
void loop() {
|
||
|
|
// our worker loop
|
||
|
|
wakaamaClient.doWorkStep();
|
||
|
|
|
||
|
|
// sleep a bit while we are in debug mode
|
||
|
|
delay(1000);
|
||
|
|
}
|
||
|
|
|