summaryrefslogtreecommitdiff
path: root/src/packet_interface.h
blob: 05023250804dfdc99494752918639f0a97a4ea61 (plain)
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
#ifndef __PACKET_INTERFACE_H__
#define __PACKET_INTERFACE_H__

#include "usart_helpers.h"


extern struct dma_usart_file *usart2_out;

enum control_packet_types {
    _HOST_RESERVED = 0,
    HOST_INITIATE_HANDSHAKE = 1,
    HOST_HANDSHAKE = 2,
    HOST_DATA = 3,
    HOST_COMM_ERROR = 4,
    HOST_CRYPTO_ERROR = 5,
    HOST_TOO_MANY_FAILS = 6,
};

enum packet_types {
    _REPORT_RESERVED = 0,
    REPORT_KEYBOARD= 1,
    REPORT_MOUSE= 2,
    REPORT_PAIRING_INPUT = 3,
    REPORT_PAIRING_SUCCESS = 4,
    REPORT_PAIRING_ERROR = 5,
};

struct hid_report_packet {
    uint8_t type;
    union {
        struct {
            uint8_t len;
            uint8_t report[8];
        } report;
        struct {
            char c;
        } pairing_input;
    };
} __attribute__((__packed__));


struct control_packet {
    uint8_t type;
    uint8_t payload[0];
} __attribute__((__packed__));


void send_packet(struct dma_usart_file *f, const uint8_t *data, size_t len);

#endif