-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSNIPE.h
More file actions
176 lines (144 loc) · 3.28 KB
/
SNIPE.h
File metadata and controls
176 lines (144 loc) · 3.28 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
* A library for controlling SNIPE LoRa radio.
*
* @Author Rooney.Jang
* @Date 08/28/2018
*
*/
#ifndef SNIPE_h
#define SNIPE_h
#define LORA_AES_OFF 0
#define LORA_AES_ON 1
#define LORA_CH_1 1 //921.9 Mhz
#define LORA_CH_2 2 //922.1 Mhz
#define LORA_CH_3 3 //922.3 Mhz
#define LORA_CH_4 4 //922.5 Mhz
#define LORA_CH_5 5 //922.7 Mhz
#define LORA_CH_6 6 //922.9 Mhz
#define LORA_CH_7 7 //923.1 Mhz
#define LORA_CH_8 8 //923.3 Mhz
#define LORA_SF_7 7
#define LORA_SF_8 8
#define LORA_SF_9 9
#define LORA_SF_10 10
#define LORA_SF_11 11
#define LORA_SF_12 12
#include "Arduino.h"
class SNIPE
{
public:
/*
* A simplified constructor taking only a Stream ({Software/Hardware}Serial) object.
* The serial port should already be initialised when initialising this library.
*/
SNIPE(Stream& serial);
/*
* Initialization the module.
*/
bool lora_init(void);
/*
* Reset the module.
*/
void lora_reset(void);
/*
* Get the frequency of the module.
*/
String lora_getFreq(void);
/*
* Set the frequency of the module.
*/
bool lora_setFreq(int freq);
/*
* Get the Tx Power of the module.
*/
String lora_getTxp(void);
/*
* Set the Tx Power of the module.
*/
bool lora_setTxp(int txp);
/*
* Get the Spreading Factor of the module.
*/
String lora_getSf(void);
/*
* Set the Spreading Factor of the module.
*/
bool lora_setSf(int sf);
/*
* Get the Rx Timeout of the module.
*/
String lora_getRxtout(void);
/*
* Set the Rx Timeout of the module.
*/
bool lora_setRxtout(int rxtout);
/*
* Get the Tx Timeout of the module.
*/
String lora_getTxtout(void);
/*
* Set the Tx Timeout of the module.
*/
bool lora_setTxtout(int txtout);
/*
* Set the module AES mode, the module defaults to AES mode.
* mode = 0: Set the module to AES Disable mode.
* mode = 1: Set the module to AES Enable mode.
*/
bool lora_setAESMode(int mode);
/*
* Get the module AES Key.
*/
String lora_getAppKey(void);
/*
* Set the module AES Key.
* appKEY : Application key as a HEX string. Example "a5 84 99 8d 0d bd b1 54 51 a3 40 8f 92 9d 38 f5"
*/
bool lora_setAppKey(String appKEY);
/*
* Get the module RSSI.
*/
String lora_getRssi(void);
/*
* Get the module SNR.
*/
String lora_getSnr(void);
/*
* Gets the firmware version number of the module.
* Only applies to the firmware that the module programmed for the SNIPE AT command.
*/
String lora_getVersion(void);
/*
* Apply the Configuration value to the module.
* Configuration value : Frequency, TX Power, Spreading Factor, RX Timeout, TX Timeout
*/
bool lora_setConf(void);
/*
* Send Text Data to the module
*/
bool lora_send(String Text);
/*
* Send Binary Data to the module
*/
bool lora_sendBinary(String Hex);
/*
* Returns the data received by the module.
*
*/
String lora_recv(void);
/*
* Returns the binary data received by the module.
*
*/
String lora_recvBinary(void);
/*
* Send a raw command to the SNIPE module.
* Returns the raw string as received back from the SNIPE.
* If the SNIPE replies with multiple line, only the first line will be returned.
*/
String sendRawCommand(String command);
private:
Stream& _serial;
int _timeOut = 0;
};
#endif