forked from forkineye/ESPixelStick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FPPDiscovery.h
72 lines (61 loc) · 1.72 KB
/
FPPDiscovery.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* FPPDiscovery.h
*
* Project: ESPixelStick - An ESP8266 and E1.31 based pixel driver
* Copyright (c) 2018 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
* subject to the laws and regulations where you are using it. Due diligence
* is strongly suggested before using this code. Please give credit where due.
*
* The Author makes no warranty of any kind, express or implied, with regard
* to this program or the documentation contained in this document. The
* Author shall not be liable in any event for incidental or consequential
* damages in connection with, or arising out of, the furnishing, performance
* or use of these programs.
*
*/
#ifndef FPPDISCOVERY
#define FPPDISCOVERY
#ifdef ESP32
#include <WiFi.h>
#include <AsyncUDP.h>
#elif defined (ESP8266)
#include <ESPAsyncUDP.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#else
#error Platform not supported
#endif
#define FPP_DISCOVERY_PORT 32320
typedef union {
struct {
uint8_t header[4]; //FPPD
uint8_t packet_type;
uint16_t data_len;
uint8_t ping_version;
uint8_t ping_subtype;
uint8_t ping_hardware;
uint16_t versionMajor;
uint16_t versionMinor;
uint8_t operatingMode;
uint8_t ipAddress[4];
char hostName[65];
char version[41];
char hardwareType[41];
char ranges[41];
} __attribute__((packed));
uint8_t raw[256];
} FPPPingPacket;
class FPPDiscovery {
private:
const char *version;
AsyncUDP udp;
void parsePacket(AsyncUDPPacket _packet);
public:
FPPDiscovery(const char *ver);
bool begin();
void sendPingPacket();
};
#endif