-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRadio.h
47 lines (38 loc) · 1.09 KB
/
Radio.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
//////////////////////////////////////////////////////////////////////
void DebugMode_Msg(String text);
void DebugMode_Msg(String text, char* valoare);
void Radio_Setup();
void Radio_Receiver();
//////////////////////////////////////////////////////////////////////
void Radio_Setup(){
vw_set_ptt_inverted(true);
vw_set_tx_pin(PIN_tx);
vw_setup(Radio_Speed);
vw_rx_start();
DebugMode_Msg("Radio > Activ.");
}
void Radio_Receiver(){
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)){
if(buf[0]=='C'){ digitalWrite(13,1); }
if(buf[0]=='M'){ digitalWrite(13,0); }
for (int i = 0; i < buflen; i++){
Serial.print(char(buf[i]));
Serial.print(", ");
}
Serial.println("S-a gasit");
}
}
void Radio_Send(char *Value){
vw_send((uint8_t *)Value, strlen(Value));
vw_send((uint8_t *)Value, strlen(Value));
vw_wait_tx();
DebugMode_Msg("Radio_Send()", Value);
}
void Radio_Send(String Value){
int iValue = Value.length() + 1;
char cValue[iValue];
Value.toCharArray(cValue, iValue);
Radio_Send(cValue);
}