-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHC12.hpp
40 lines (37 loc) · 920 Bytes
/
HC12.hpp
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
/**
* @file HC12.hpp
* @author Alberto MN
*
* This is a library for long-distance wireless HC-12 modules.
*/
#ifndef HC12_HPP
#define HC12_HPP
#include <Arduino.h>
#include <SoftwareSerial.h>
class HC12
{
public:
HC12(uint8_t RX_Pin, uint8_t TX_Pin);
HC12(uint8_t RX_Pin, uint8_t TX_Pin, uint8_t SET_Pin);
enum Mode
{
FU1 = 49,
FU2 = 50,
FU3 = 51
};
void begin(int baudrate);
void sleep(void);
void wakeup(void);
void set_mode(Mode mode);
void set_power(short power);
void set_channel(String channel);
void set_baudrate(unsigned int baudrate);
void send(String message);
String receive(unsigned int timeout, char end);
private:
SoftwareSerial _serial;
uint8_t _SET_PIN;
Mode _MODE;
void send_AT(String command);
};
#endif