STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
Ethernet.h
Go to the documentation of this file.
1// Stub: Ethernet.h — for native tests
2// Provides EthernetServer/Client/UDP stubs, plus enough of EthernetClass for
3// board_net.h: DHCP can be made to succeed or fail, and every address write is
4// recorded so a test can assert what the board pushed into the W5500.
5#pragma once
6#include <Arduino.h> // IPAddress
7
8#include <cstdint>
9#include <cstring>
10
12public:
13 operator bool() {
14 return false;
15 }
16 int available() {
17 return 0;
18 }
19 int read() {
20 return -1;
21 }
22 int read(uint8_t*, int) {
23 return 0;
24 }
25 void stop() {
26 }
27 void flush() {
28 }
29 void println(const char*) {
30 }
31};
32
34public:
35 EthernetServer(uint16_t) {
36 }
37 virtual void begin() {
38 }
42};
43
44// Records what board_net.h writes into the chip, so tests can inspect it.
46public:
51
52 // --- DHCP, scripted by the test ---
53 bool dhcp_should_succeed = false;
56 // --- static configuration, recorded so a test can prove it did or did
57 // not happen ---
61
63
64 /** DHCP form: returns 1 on success, 0 on failure, like Ethernet 2.x —
65 * which zeroes the address before asking, so a failure leaves 0.0.0.0. */
66 int begin(uint8_t*, unsigned long, unsigned long) {
68 local_ip = IPAddress(0, 0, 0, 0);
70 return 0;
72 return 1;
73 }
74 /** Static form. */
75 void begin(uint8_t*, IPAddress ip, IPAddress, IPAddress, IPAddress mask) {
77 static_ip = ip;
78 static_subnet = mask;
79 local_ip = ip;
80 subnet_mask = mask;
81 }
82
83 void setLocalIP(const IPAddress ip) {
84 local_ip = ip;
86 }
87 void setSubnetMask(const IPAddress mask) {
88 subnet_mask = mask;
90 }
92 return local_ip;
93 }
95 return subnet_mask;
96 }
97 int maintain() {
99 return 0;
100 }
114};
115
static EthernetClass Ethernet
Definition Ethernet.h:116
const int IPAddress
void setSubnetMask(const IPAddress mask)
Definition Ethernet.h:87
IPAddress dhcp_assigned
Definition Ethernet.h:54
IPAddress static_ip
Definition Ethernet.h:59
IPAddress subnetMask() const
Definition Ethernet.h:94
IPAddress local_ip
Definition Ethernet.h:47
int set_local_ip_calls
Definition Ethernet.h:49
IPAddress static_subnet
Definition Ethernet.h:60
int maintain()
Definition Ethernet.h:97
IPAddress localIP() const
Definition Ethernet.h:91
int set_subnet_calls
Definition Ethernet.h:50
IPAddress subnet_mask
Definition Ethernet.h:48
int dhcp_begin_calls
Definition Ethernet.h:62
int maintain_calls
Definition Ethernet.h:55
void reset()
Definition Ethernet.h:101
bool dhcp_should_succeed
Definition Ethernet.h:53
int begin(uint8_t *, unsigned long, unsigned long)
DHCP form: returns 1 on success, 0 on failure, like Ethernet 2.x — which zeroes the address before as...
Definition Ethernet.h:66
void begin(uint8_t *, IPAddress ip, IPAddress, IPAddress, IPAddress mask)
Static form.
Definition Ethernet.h:75
void setLocalIP(const IPAddress ip)
Definition Ethernet.h:83
int static_begin_calls
Definition Ethernet.h:58
void flush()
Definition Ethernet.h:27
int read(uint8_t *, int)
Definition Ethernet.h:22
void stop()
Definition Ethernet.h:25
int available()
Definition Ethernet.h:16
void println(const char *)
Definition Ethernet.h:29
EthernetClient available()
Definition Ethernet.h:39
EthernetServer(uint16_t)
Definition Ethernet.h:35
virtual void begin()
Definition Ethernet.h:37