-
Notifications
You must be signed in to change notification settings - Fork 1
/
livolo.cpp
59 lines (50 loc) · 1022 Bytes
/
livolo.cpp
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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <wiringPi.h>
#include "LivoloTx.h"
/* defaults */
#define LIVOLO_REMOTE_ID 6400
#define LIVOLO_BTN 0
/* WiritngPi pin */
#define TX_PIN 0
void usage()
{
printf("Arguments:\n");
printf(" -p <PIN> - GPIO pin\n");
printf(" -g <REMOTE> - Livolo remote id\n");
printf(" -n <BUTTON> - Livolo button id\n");
}
int main(int argc, char **argv)
{
int c;
int pin = TX_PIN;
int remote = LIVOLO_REMOTE_ID;
int btn = LIVOLO_BTN;
while ((c = getopt(argc, argv, "p:g:n:h")) != -1) {
switch (c) {
case 'p':
pin = atoi(optarg);
break;
case 'g':
remote = atoi(optarg);
break;
case 'n':
btn = atoi(optarg);
break;
case 'h':
usage();
return 1;
}
}
if (wiringPiSetup() == -1) {
perror("wiringPiSetup failed");
return 1;
}
pinMode(pin, OUTPUT);
LivoloTx gLivolo(pin);
printf("remote %d button %d\n", remote, btn);
gLivolo.sendButton(remote, btn);
return 0;
}