-
Notifications
You must be signed in to change notification settings - Fork 1
/
*Transmitter Module
207 lines (167 loc) · 5.18 KB
/
*Transmitter Module
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
//TO DO
//Convert all String to char[] (done? needs testing)
//dtmf audio out
//SSerial conversion?
//RX activity pin to prevent transmitting on a busy channel (DIP switch for field setting?)
// BOARD CHANGES
//Include AF filter/uModem hardware
//Include RF filter
//
#define TX_RXact 42 //Module Pin 1 Low = Squelch open, High = squelch closed
#define TX_AFout 43 //Module pin 3 Receive audio
#define TX_ptt 45 //Module pin 5 Low for TX
#define TX_sleep 46 //Module pin 6 0=sleep
#define TX_pwr 47 //Module pin 7 ***DO NOT SET TO HIGH, MUST FLOAT FOR HIGH POWER***
#define TX_AFin 49 //Module pin 18 Audio out from arduino
#define RADIO_SERIAL Serial
//#define error_pin 13 //Onboard LED pin
char TX_shake[] = "AT+DMOCONNECT"; //handshake
char TX_sgHead[] = "AT+DMOSETGROUP="; //group set preamble
char TX_volHead[] = "AT+DMOSETVOLUME="; //volume preamble
char TX_filHead[] = "AT+DMOSETFILTER="; //audio filter preamble
char TX_bw[] = "0"; //0 = 12.5khz 1 = 25khz
char TX_txf[] = "144.3900"; //TX frequency: Must use 4 digits after dot
char TX_rxf[] = "144.3900"; //rx freq: " "
char TX_txpl[] = "0000"; //TX CTCSS 0000 = none See programming manual for codes
char TX_sq[] = "6"; //Squelch level 0-8: 0 = open
//------------------------------------------------------------//
char TX_rxpl[] = "0000"; //RX CTCSS
char TX_vol[] = "4"; //RX audio volume level 1-8
char TX_fil[] = "1,1,1"; //RX audio filter. Emphasis,Highpass,Lowpass 1 = bypass 0 = normal
char groupString[47];
//char groupString[] = TX_sgHead + TX_bw + TX_txf + TX_rxf + TX_txpl + TX_sq + TX_rxpl;
char volumeString[18];
//char volumeString[] = TX_volHead + TX_vol;
char filterString[22];
//char filterString[] = TX_filHead + TX_fil;
char shakeReply[32];
char groupReply[32];
char volumeReply[32];
char filterReply[32];
int serialCount = 0;
byte errorFlag;
//-------------------DEBUG------------------------//
//Prints all set commands and replies, turns on onboard LED. Last character should be 0. 1 = error
void txDebug() {
//digitalWrite(error_pin, HIGH);
Serial.println("TRANSCEIVER ERROR");
Serial.print("Handshake: ");
Serial.println(TX_shake);
Serial.print("Reply: ");
Serial.println(shakeReply);
Serial.print("SetGroup: ");
Serial.println(groupString);
Serial.print("Reply: ");
Serial.println(groupReply);
Serial.print("SetVolume: ");
Serial.println(volumeString);
Serial.print("Reply: ");
Serial.println(volumeReply);
Serial.print("SetFilter: ");
Serial.println(filterString);
Serial.print("Reply: ");
Serial.println(filterReply);
}
//-----------------Handshake-----------------//
void handShake() {
serialCount = 0;
RADIO_SERIAL.println("AT+DMOCONNECT");
delay(100);
RADIO_SERIAL.println("AT+DMOCONNECT");
while (RADIO_SERIAL.available() > 0) {
char incomingChar;
incomingChar = RADIO_SERIAL.read();
shakeReply[serialCount] = incomingChar;
serialCount++;
}
if (serialCount == 0 || shakeReply[serialCount] == 1) {
errorFlag = true;
}
}
//----------------SetGroup---------------//
void setGroup() {
serialCount = 0;
sprintf(groupString, "AT+DMOSETGROUP=%s,%s,%s,%s,%s,%s", TX_bw, TX_rxf, TX_txpl, TX_sq, TX_rxpl);
RADIO_SERIAL.println(groupString);
delay(100);
RADIO_SERIAL.println(groupString);
while (RADIO_SERIAL.available() > 0) {
char incomingChar;
incomingChar = RADIO_SERIAL.read();
groupReply[serialCount] = incomingChar;
serialCount++;
}
if (serialCount == 0 || shakeReply[serialCount] == 1) {
errorFlag = true;
}
}
//------------------SetVolume---------------//
void setVolume() {
serialCount = 0;
sprintf(volumeString, "AT+DMOSETVOLUME=%s", TX_vol);
RADIO_SERIAL.println(volumeString);
delay(100);
RADIO_SERIAL.println(volumeString);
while (RADIO_SERIAL.available() > 0) {
char incomingChar;
incomingChar = RADIO_SERIAL.read();
volumeReply[serialCount] = incomingChar;
serialCount++;
}
if (serialCount == 0 || volumeReply[serialCount] == 1) {
errorFlag = true;
}
}
//---------------SetFilter----------------//
void setFilter() {
serialCount = 0;
sprintf(filterString, "AT+DMOSETFILTER=%s", TX_fil);
RADIO_SERIAL.println(filterString);
delay(100);
RADIO_SERIAL.println(filterString);
while (RADIO_SERIAL.available() > 0) {
char incomingChar;
incomingChar = RADIO_SERIAL.read();
filterReply[serialCount] = incomingChar;
serialCount++;
}
if (serialCount == 0 || filterReply[serialCount] == 1) {
errorFlag = true;
}
}
//--------------TRANSMIT & stopTransmit-----------//
void transmit() {
pinMode(TX_ptt, LOW);
}
void stopTransmit() {
pinMode(TX_ptt, HIGH);
}
//---------------------txSetup----------------------//
void txSetup() {
pinMode(TX_pwr, OUTPUT);
digitalWrite(TX_pwr, LOW);
pinMode(TX_RXact, INPUT);
pinMode(TX_ptt, OUTPUT);
digitalWrite(TX_ptt, HIGH);
pinMode(TX_sleep, OUTPUT);
digitalWrite(TX_sleep, HIGH);
//pinMode(error_pin, OUTPUT);
//digitalWrite(error_pin, LOW);
Serial.begin(115200);
RADIO_SERIAL.begin(9600);
delay(1000);
handShake();
delay(500);
setGroup();
delay(500);
setVolume();
delay(500);
setFilter();
if (errorFlag == true) {
txDebug();
}
}
void setup(){
}
void loop() {
}