-
Notifications
You must be signed in to change notification settings - Fork 2
/
global.h
173 lines (140 loc) · 4.7 KB
/
global.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#ifndef GLOBAL_H
#define GLOBAL_H
#include <sys/types.h> /* open() */
#include <sys/stat.h> /* open() */
#include <fcntl.h> /* open() */
#include <unistd.h> /* close() */
#include <string.h> /* bzero() */
#include <sys/signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <termios.h>
//#include"sys/types.h"
#include "sys/msg.h"
#include "util_by_wei.h"
//#include "unistd.h"
//#include"stdio.h"
typedef signed char int8;
typedef unsigned char uint8;
typedef unsigned char byte;
typedef signed short int16;
typedef unsigned short uint16;
typedef signed long int32;
typedef unsigned long uint32;
//@by @wei
//#define UPDBG printf
#define UPDBG(x...)
/*
#define USER_DBG_EN
#ifdef USER_DBG_EN
#define Udbg(x...) {printf("User# fun: ");printf(x);}while(0)
#define Udbgln(x...) {printf("User # ");printf(x);printf("\n");}while(0)
#define Udbgv(v) {printf("kernel # ");printf(#v);printf("\t:%08x %d \n",v , v);}while(0)
#define ULdbg() printf("line :%d fun:%s \n",__LINE__,__FUNCTION__)
#else
#define Udbg(x...)
#define Udbgv(x...)
#define ULdbg()
#endif
*/
#define ERROR_ID_NOT_EXIST 0x1001
#define ERROR_ID_REGISTERED 0x1002
#define BUFSIZE 256
#define SOP_VALUE 0x02
#define MAX_APP_PKT_SIZE 256
#define ENDMINITERM1 27 /* ESC to quit miniterm */
#define ENDMINITERM2 3 /*ctl +c to quit miniterm */
//#define FALSE 0
//#define TRUE 1
#define SPI_CMD_NWK_CONNECT_REQ 0x0050
#define SPI_CMD_NWK_CONNECT_RSP 0x1050
#define SPI_CMD_GET_NWK_DESP_REQ 0x0051
#define SPI_CMD_GET_NWK_DESP_RSP 0x1051
#define SPI_CMD_GET_NWK_TOPO_REQ 0x0052
#define SPI_CMD_GET_NWK_TOPO_RSP 0x1052
#define SPI_CMD_SET_SENSOR_MODE_REQ 0x0053
#define SPI_CMD_SET_SENSOR_MODE_RSP 0x1053
#define SPI_CMD_GET_SENSOR_STATUS_REQ 0x0054
#define SPI_CMD_GET_SENSOR_STATUS_RSP 0x1054
#define SPI_CMD_SET_SENSOR_STATUS_REQ 0x0055
#define SPI_CMD_SET_SENSOR_STATUS_RSP 0x1055
#define SPI_CMD_GET_DEVINFO_REQ 0x0056
#define SPI_CMD_GET_DEVINFO_RSP 0x1056
#define SPI_CMD_RPT_NODEOUT_REQ 0x0057
#define SPI_CMD_RPT_NODEOUT_RSP 0x1057
#define CMD_ALARM_ASYNC 0x1058
/* takes a byte out of a uint32 : var - uint32, ByteNum - byte to take out (0 - 3) */
#define BREAK_UINT32( var, ByteNum ) \
(byte)((uint32)(((var) >>((ByteNum) * 8)) & 0x00FF))
#define BUILD_UINT32(Byte0, Byte1, Byte2, Byte3) \
((uint32)((uint32)((Byte0) & 0x00FF) \
+ ((uint32)((Byte1) & 0x00FF) << 8) \
+ ((uint32)((Byte2) & 0x00FF) << 16) \
+ ((uint32)((Byte3) & 0x00FF) << 24)))
#define BUILD_UINT16(loByte, hiByte) \
((uint16)(((loByte) & 0x00FF) + (((hiByte) & 0x00FF) << 8)))
#define HI_UINT16(a) (((a) >> 8) & 0xFF)
#define LO_UINT16(a) ((a) & 0xFF)
#define BUILD_UINT8(hiByte, loByte) \
((uint8)(((loByte) & 0x0F) + (((hiByte) & 0x0F) << 4)))
#define HI_UINT8(a) (((a) >> 4) & 0x0F)
#define LO_UINT8(a) ((a) & 0x0F)
typedef struct{
unsigned char sop;
unsigned char cmdH;
unsigned char cmdL;
unsigned char len;
unsigned char data[MAX_APP_PKT_SIZE];
unsigned char fcs;
}AppCmdPack,*pAppCmdPack;
typedef struct NwkDesp{
unsigned int panid;// 16bits
unsigned long int channel;//32bits
unsigned char maxchild;
unsigned char maxdepth;
unsigned char maxrouter;
}NwkDesp,*pNwkDesp;
typedef struct{
unsigned int nwkaddr;
unsigned char sensortype;
unsigned long int sensorvalue;// 32bits
} SensorDesp,*pSensorDesp;
typedef struct DeviceInfo{
unsigned int nwkaddr;
unsigned char macaddr[8];
unsigned char depth;
unsigned char devtype;
unsigned int parentnwkaddr;
unsigned char sensortype;
unsigned long int sensorvalue;
unsigned char status;
}DeviceInfo,*pDeviceInfo;
typedef struct NodeInfo NodeInfo,*pNodeInfo;
struct NodeInfo{
DeviceInfo *devinfo;
NodeInfo *next;
unsigned char row;
unsigned char num;
};
typedef struct{
struct DeviceInfo *devinfo;
struct NodeNwkTopoInfo *next;
unsigned char row;
unsigned char num;
struct NodeNwkTopoInfo *parent;
unsigned int pos_x;
unsigned int pos_y;
}NodeNwkTopoInfo,*pNodeNwkTopoInfo;
#include "tty_ctrl.h"
//#define FALSE 0
//#define TRUE 1
typedef enum bool{FALSE, TRUE} bool;
struct msgbuf{
long mtype;
char phone[12];
};
int msgid;
struct msgbuf msg_sbuf;
struct msgbuf msg_rbuf;
#endif // GLOBAL_H