-
Notifications
You must be signed in to change notification settings - Fork 9
/
art-net.c
66 lines (52 loc) · 1.6 KB
/
art-net.c
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
#include "lwip/debug.h"
#include "lwip/stats.h"
#include "lwip/udp.h"
#include "art-net.h"
#include "art-net_packets.h"
#include <string.h>
#ifndef ARTNET_DEBUG
#define ARTNET_DEBUG LWIP_DBG_OFF
#endif
void artnet_send_poll_reply(struct udp_pcb * upcb)
{
//p = pbuf_alloc(PBUF_TRANSPORT,sizeof(msg),PBUF_RAM);
}
void artnet_recv(void * arg, struct udp_pcb * upcb,
struct pbuf * p,
struct ip_addr * addr,
u16_t port)
{
artnet_packet_t * artnet_packet = (artnet_packet_t*) p->payload;
printf("Datagramm received!\r\n");
if (p->len >= 3)
{
if (strncmp("Art-Net", (char*) artnet_packet->id, 8) == 0);
{
printf("%s\n", artnet_packet->id);
printf("OpCode: %x \r\n", artnet_packet->op_code);
switch (artnet_packet->op_code)
{
case ARTNET_OP_POLL:
printf("Art-Net Poll\r\n");
uint16_t proto_version = ((artnet_packet->data.poll.version_hi << 8) | artnet_packet->data.poll.version_lo);
if (proto_version > 14)
{
//artnet_send_poll_reply();
}
break;
case ARTNET_OP_POLL_REPLY:
printf("Art-Net PollReply\r\n");
break;
}
}
}
pbuf_free(p);
}
void artnet_init(void)
{
struct udp_pcb *pcb;
LWIP_DEBUGF(ARTNET_DEBUG, ("art-net_init\r\n"));
pcb = udp_new();
udp_bind(pcb, IP_ADDR_ANY, 0x1936);
udp_recv(pcb, artnet_recv, NULL);
}