-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlwrx.cpp
More file actions
44 lines (36 loc) · 741 Bytes
/
lwrx.cpp
File metadata and controls
44 lines (36 loc) · 741 Bytes
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
#include <stdio.h>
#include <wiringPi.h>
#include "LightwaveRX.h"
void loop();
void printMsg(uint8_t *msg, uint8_t len);
int main(int argc, char const *argv[])
{
printf("lwrx starting\n");
wiringPiSetup();
lwrx_setup(2, 2);
while (1) {
loop();
}
return 0;
}
void loop() {
uint8_t msg[10];
uint8_t len = 10;
if (lwrx_gotMessage())
{
bool ok = lwrx_getMessageRaw(msg);
if (ok) {
printMsg(msg, len);
} else {
printf("failed to get message\n");
}
}
delay(20);
}
void printMsg(uint8_t *msg, uint8_t len) {
printf("msg recv'd: ");
for(int i=0; i<len; i++) {
printf("0x%02x ", msg[i]);
}
printf("\n");
}