forked from neutrinus/everblu-meters
-
Notifications
You must be signed in to change notification settings - Fork 17
/
everblu_meters.h
63 lines (50 loc) · 1.43 KB
/
everblu_meters.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
48
49
50
51
52
53
54
55
56
57
58
59
60
/* the radian_trx SW shall not be distributed nor used for commercial product*/
/* it is exposed just to demonstrate CC1101 capability to reader water meter indexes */
/* there is no Warranty on radian_trx SW */
#include "time.h"
#include "stdio.h"
#include "stdarg.h"
#include "stdlib.h"
//#include "pthread.h"
#include "stdint.h"
#include "string.h"
#ifdef __unix__
# include <time.h>
# include <unistd.h> // pour sleep
# include <termios.h>
//# include <ncurses.h> // pour getch mais fonctionne bizarement
char getch(){
/*#include <unistd.h> //_getch*/
/*#include <termios.h> //_getch*/
char buf=0;
struct termios old={0};
fflush(stdout);
if(tcgetattr(0, &old)<0)
perror("tcsetattr()");
old.c_lflag&=~ICANON;
old.c_lflag&=~ECHO;
old.c_cc[VMIN]=1;
old.c_cc[VTIME]=0;
if(tcsetattr(0, TCSANOW, &old)<0)
perror("tcsetattr ICANON");
if(read(0,&buf,1)<0)
perror("read()");
old.c_lflag|=ICANON;
old.c_lflag|=ECHO;
if(tcsetattr(0, TCSADRAIN, &old)<0)
perror ("tcsetattr ~ICANON");
printf("%c",buf);
return buf;
}
#elif defined _WIN32
# include <windows.h>
# include <conio.h> // pour getch
#define sleep(x) Sleep(1000 * x)
#endif
#include "cc1101.h"
typedef unsigned char T_BOOL; //1 octets
// Change these define according to your hardware
#define FREQUENCY 433.8683f
#define GDO0 5 //header 11
#define METER_YEAR 15
#define METER_SERIAL 886451