#include "coppino.h" #include "ipv6.h" #include "slip.h" #include "udp.h" const char MY_ADDRESS[] = "\x20\x01\x04\x70\xc8\x44\x00\x31\x00\x00\x00\x00\x00\x00\xca\xfe"; void setup() { /* Customize coppino library configuration settings by editing settings.h */ /* setup serial for Internet connectivity * attach a SLIP daemon on the other endpoint; a good one is `tunslip6` by Contiki * $ tunslip6 -s /dev/ttyUSB0 -L -v5 -B 19200 2001:db8:1324::1/64 * Note: the address given is the one on the host it is running on */ Serial.begin(19200); /* set unique identifier of network hardware. It MUST be unique! * For example, this could be your microcontroller serial number * Note: pay attention to enter exactly 64 bits / 8 bytes */ ipv6::setEUI("\xde\xad\xbe\xef\x12\x34\x56\x78"); /* set global address -- will be overwritten if SLAAC is enabled and a Router Advertisement is received */ ipv6::setGlobalAddress(MY_ADDRESS); } void loop() { char message[16]; ipv6::IPv6Addr srcaddr = ipv6::IPv6Addr(MY_ADDRESS); ipv6::IPv6Addr dstaddr = ipv6::IPv6Addr("\x20\x01\x04\x70\xc8\x44\x00\x31\x00\x00\x00\x00\x00\x00\x00\x01"); uint16_t srcport = 1337; uint16_t dstport = 1234; udp::UDPClient udpclient = udp::UDPClient(srcaddr, dstaddr, srcport, dstport); while (true) { for (int i = 0; i < 32; ++i) { sprintf(message, "iteration #%d\r\n", i); udpclient.send_datagram((const uint8_t *)message, strlen(message)); delay(1000); } } }