-
Notifications
You must be signed in to change notification settings - Fork 0
/
rcGW.ino
64 lines (50 loc) · 1.19 KB
/
rcGW.ino
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
#include <SPI.h>
#include <Ethernet.h>
#include <stdlib.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
char c;
char command[16];
boolean incoming = 0;
RF24 radio(8,9);
const uint64_t pipes = 0xE8E8F0F0E1LL;
byte mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDA, 0x02}; /* 0x15, 0x9B, 0x87, 0x2B, 0x0E, 0x98 the other Arduino0 */
IPAddress ip(192,168,1,177);
EthernetServer server(80);
void setup(){
// Serial.begin(9600);
Ethernet.begin(mac, ip);
server.begin();
radio.begin();
radio.setPALevel(RF24_PA_HIGH);
radio.setDataRate(RF24_250KBPS);
radio.setPayloadSize(sizeof(unsigned long));
radio.openWritingPipe(pipes);
}
void loop(){
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
c = client.read();
if (c == '$') incoming = 1;
if (incoming == 1){
for (int x=0 ; x<16 ; x++){
c = client.read();
command[x] = c;
radio.write(command, 16);
// Serial.print(command);
}
incoming = 0;
}
}
}
}
Serial.print(command);
delay(1);
client.stop();
radio.powerDown();
//delay(1000);
radio.powerUp();
}