multiplayer pong game for LPC 1768
Dependencies: mbed MbedJSONValue mbed-rtos Adafruit_ST7735 Adafruit_GFX EthernetInterface DebouncedInterrupt
network.cpp
- Committer:
- vsoltan
- Date:
- 2020-11-28
- Revision:
- 34:b19f39ad74ac
- Parent:
- 19:58cc5465f647
File content as of revision 34:b19f39ad74ac:
#include "network.h" void initEthernet(EthernetInterface *eth, UDPSocket *sock, Endpoint *nist) { int rc; rc = eth->init(); //Use DHCP if (rc < 0) { printf("\n\rFatal Error: failed to initialize ethernet via DHCP\n\r"); return; } rc = eth->connect(); if (rc < 0) { printf("\n\rFatal Error: failed to connect\n\r"); return; } rc = sock->init(); if (rc < 0) { printf("\n\rFatal Error: failed to initialize socket\n\r"); return; } rc = nist->set_address(AWS_IP, PORT); if (rc < 0) { printf("\n\rFatal Error: failed to set address\n\r"); return; } sock->set_blocking(false, 0); printf("\n\rSuccess! Connected to %s, port: %i\n\r", AWS_IP, PORT); } void cleanupEthernet(EthernetInterface *eth, UDPSocket *sock) { sock->close(); eth->disconnect(); }