-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnifferSM.h
57 lines (42 loc) · 1.08 KB
/
SnifferSM.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
/*
* File: SnifferSM.h
* Author: nikos
*
* Created on January 9, 2019, 11:52 AM
*/
#include <stdbool.h>
#ifndef SNIFFERSM_H
#define SNIFFERSM_H
// This eventually translates into a 0.5ms timer interval. Don't ask
#define MDB_WAIT_FOR_TICKS 1000
// The magic address that will trigger the sniffing
#define MDB_WATCH_ADDR 0x13 //0x12
// 50 8-bit bytes max. (Throw away address bit - not sending over adserial)
#define MDB_BUF_MAX 50
#ifdef __cplusplus
extern "C" {
#endif
enum State {
WAIT,
NEXT_BYTE,
OVERFLOW,
TIMEOUT,
SEND_AD,
BAD_CKSUM
};
// Volatile: value of state may change between consecutive statements
// Force compiler to emit instructions that fetch state from memory every time it's read
// (instead of using a value of state that might be in the registers)
volatile extern enum State state;
/**
* Advance the sniffer SM.
*/
void step(void);
/**
* Run when the timer expires.
*/
inline void timer_expire(void);
#ifdef __cplusplus
}
#endif
#endif /* SNIFFERSM_H */