Loading...
Searching...
No Matches
BindOverWifi.h
1#ifndef BINDOVERUDP_H
2#define BINDOVERUDP_H
3#ifdef ARDUINO_ARCH_ESP32
4#ifndef BL_ONLY_BIND
5#include "Bind.h"
6#include <Arduino.h>
7#include <Stream.h>
8#include <AsyncUDP.h>
9
10#define UDP_DEBUG_MSG 0 // Set to 1 to enable debug messages
11
12/*
13 * This class is used to send and receive data over UDP to be used
14 * with the Bind class.
15*/
16 class UDPStream : public Stream
17{
18 private:
19 bool sendPackets = false;
20 static uint8_t discoveryMsg[];
21 static uint8_t connectMsg[];
22 static uint8_t stopMsg[];
23 static uint8_t bindHeartbeat[];
24 static uint16_t bindPort;
25 IPAddress canvasIP = IPAddress(0, 0, 0, 0);
26 void handleUDP(UDPStream& udpStream, AsyncUDPPacket& packet);
27 Bind *_bind;
28 AsyncUDP udp;
29 uint32_t lastHeartbeat = 0;
30 const char* bindname;
31 public:
32 bool begin(const char* bindname, Bind &bind);
33 bool begin(Bind &bind, const char* bindname);
34 size_t write(const uint8_t *buffer, size_t size) override;
35 int available() override { return 0; }
36 int read() override { return 0; }
37 int peek() override { return 0; }
38 void flush() override {}
39 size_t write(uint8_t) override { return 0; }
40};
41#endif // BL_ONLY_BIND
42#endif // ARDUINO_ARCH_ESP32
43#endif // BINDOVERUDP_H
Bind
The Bind class provides a framework for creating interactive applications with BindCanvas.
Definition Bind.h:62