-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDevice.h
More file actions
81 lines (53 loc) · 1.63 KB
/
Device.h
File metadata and controls
81 lines (53 loc) · 1.63 KB
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
/*
Device.h - Handle the controlled device
Saul bertuccio 4 feb 2017
Released into the public domain.
*/
#ifndef Device_h
#define Device_h
#include "Arduino.h"
#include "WString.h"
#include "RfKey.h"
#include "IrKey.h"
// GPIO16 -> D0 ->
// GPIO05 -> D1 -> Pin Ricevitore RF433
// GPIO04 -> D2 -> Pin Trasmettitore RF433
// GPIO -> D5 -> RXD Riceve da IR-TXD
// GPIO -> D6 -> TXD Trasmette su IR-RXD
class Device {
public:
static const int MAX_NAME_LENGTH = 16;
static String TYPES[];
static String TYPES_DESCRIPTION[];
static const int TYPE_NUM=2;
static const int RF_RX_PIN = D2;
static const int RF_TX_PIN = D1;
static const int IR_RX_PIN = D5;
static const int IR_TX_PIN = D6;
Device(const String &dev_name, const String &dev_type);
~Device();
void setName(const String &new_name);
void setType(const String &new_type);
String getName();
String getType();
Key * getKeys();
String * getKeysPropertyNames();
int getKeysPropertyNum();
boolean isValidPropertyById(int id, const String &val);
boolean addKey(String * key_data);
boolean removeKey(const String &key_name );
Key * acquireKeyData();
boolean sendKeyData(const String & key_name);
private:
String dev_name;
String dev_type;
Key * first_key = NULL;
Key * last_key = NULL;
Key * findPreviousKeyByName(const String &key_name );
String * getProperties(const String names[], int len);
static Key * acquireRfKeyData();
static Key * acquireIrKeyData();
static void sendRfKeyData(Key *key);
static void sendIrKeyData(Key *key);
};
#endif