55 return "BOARD_HEARTBEAT";
57 return "SERVER_HEARTBEAT";
61 return "ACTUATOR_COMMAND";
63 return "SENSOR_CONFIG";
65 return "ACTUATOR_CONFIG";
79 if (!buf || len <
sizeof(daq::PacketHeader)) {
80 Serial.print(
"RECV: (invalid, too short) ");
82 Serial.print(
" bytes from ");
89 memcpy(&h, buf,
sizeof(daq::PacketHeader));
94 Serial.print(
" bytes from ");
99 Serial.print((
int)h.packet_type);
100 Serial.print(
" version=");
101 Serial.print((
int)h.version);
103 Serial.println(h.timestamp);
110 unsigned long ts =
millis();
112 float v0 = (float)(ts % 10000) / 1000.0f;
113 float v1 = (float)((ts / 17) % 1000) / 100.0f;
115 memcpy(&b0, &v0,
sizeof(
float));
116 memcpy(&b1, &v1,
sizeof(
float));
117 chunk.add_datapoint(0, b0);
118 chunk.add_datapoint(1, b1);
120 std::vector<daq::SensorDataChunkCollection>
chunks;
126 Serial.println(
"SENT: (create_sensor_data_packet failed)");
134 Serial.print(
"SENT: [SENSOR_DATA] ");
136 Serial.print(
" bytes, 1 chunk, ");
138 Serial.print(
" sensors | ts=");
150 Serial.println(
"Multi-Board Comms Testing – PRIMARY");
151 Serial.println(
" Sends SENSOR_DATA -> 192.168.2.101:5006");
152 Serial.println(
" Listens on :5005 for reply");
153 Serial.println(
"----------------------------------------");
155 ESP_ERROR_CHECK(esp_read_mac(
mac, ESP_MAC_ETH));
157 for (
int i = 0; i < 6; i++) {
185 int n =
udp.parsePacket();
194 unsigned long now =
millis();
static EthernetClass Ethernet
std::vector< daq::SensorDataChunkCollection > chunks
IPAddress dns(192, 168, 2, 1)
IPAddress subnet(255, 255, 255, 0)
IPAddress staticIP(192, 168, 2, BOARD_ID_DEFAULT)
IPAddress gateway(0, 0, 0, 0)
static IPAddress subnet(255, 255, 255, 0)
static IPAddress gateway(192, 168, 2, 1)
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]
IPAddress dns(192, 168, 2, 1)
IPAddress staticIP(192, 168, 2, 101)
static constexpr int ETH_CS
Ball Valve Hotfire — motorized ball valve prototype board.
static constexpr int ETH_SCLK
static constexpr int ETH_MISO
static constexpr int ETH_MOSI
const unsigned long SEND_INTERVAL_MS
void printReceivedPacket(const uint8_t *buf, size_t len, IPAddress fromIP, uint16_t fromPort)
IPAddress secondaryIP(192, 168, 2, 101)
static const char * packetTypeName(uint8_t t)
constexpr Layout Actuator_Board
size_t create_sensor_data_packet(const std::vector< SensorDataChunkCollection > &chunks, const uint8_t num_sensors, uint32_t timestamp_ms, uint8_t *buffer, size_t buffer_size)
Creates a complete Sensor Data packet in the provided buffer.
*brief user defined string literal for JSON values *sa std::size_t n
Represents a single data chunk with timestamp and sensor datapoints.