-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBluetoothRN42.h
84 lines (69 loc) · 1.75 KB
/
BluetoothRN42.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
73
74
75
76
77
78
79
80
81
82
83
84
/**
* @file BluetoothRN42.h
* @brief
* @author Travis Lane
* @version
* @date 2015-03-04
*/
#ifndef BLUETOOTHRN42_H
#define BLUETOOTHRN42_H
#include "Bluetooth.h"
#define RN42_POWER_16_STR "0010"
#define RN42_POWER_12_STR "000C"
#define RN42_POWER_8_STR "0008"
#define RN42_POWER_4_STR "0004"
#define RN42_POWER_0_STR "0000"
#define RN42_POWER_N4_STR "FFFC"
#define RN42_POWER_N8_STR "FFF8"
#define RN42_POWER_N12_STR "FFF4"
enum rn42_power_e {
RN42_POWER_16 = 7,
RN42_POWER_12 = 6,
RN42_POWER_8 = 5,
RN42_POWER_4 = 4,
RN42_POWER_0 = 3,
RN42_POWER_N4 = 2,
RN42_POWER_N8 = 1,
RN42_POWER_N12 = 0
};
enum rn42_mode_e {
RN42_MODE_SLAVE = 0,
RN42_MODE_MASTER = 1,
RN42_MODE_TRIGGER = 2,
RN42_MODE_AC_MASTER = 3,
RN42_MODE_AC_DTR = 4,
RN42_MODE_AC_ANY = 5,
RN42_MODE_PAIR = 6
};
#define RN42_POWER_MAX RN42_POWER_16
#define RN42_POWER_MIN RN42_POWER_N12
class BluetoothRN42 : public Bluetooth
{
protected:
int status_pin;
bool inCommand;
static const char * const power_level_strs[];
public:
BluetoothRN42(int new_status_pin, int new_mode = 0,
const char *new_name = NULL,
const char *new_pin = NULL) :
Bluetooth(new_mode, new_name, new_pin) {
status_pin = new_status_pin;
inCommand = false;
}
int setMode(int new_mode);
int setPin(const char *new_pin);
int setName(const char *new_name);
int setCod(const char *new_cod);
// Device Specific
void enterCommand();
void exitCommand();
int setInquryScanWindow(const char *scan_window);
int setPageScanWindow(const char *scan_window);
int setBonding(bool bonding_enabled);
int setPower(enum rn42_power_e power_level);
// Gotta implement
virtual bool connected();
virtual void setup();
};
#endif /* BLUETOOTHRN42_H */