µracoli Manual
Version foo
µracoli
User Guide
Reference Guide
p2p_protocol.h
1
/* Copyright (c) 2007 - 2012 Axel Wachtler
2
All rights reserved.
3
4
Redistribution and use in source and binary forms, with or without
5
modification, are permitted provided that the following conditions
6
are met:
7
8
* Redistributions of source code must retain the above copyright
9
notice, this list of conditions and the following disclaimer.
10
* Redistributions in binary form must reproduce the above copyright
11
notice, this list of conditions and the following disclaimer in the
12
documentation and/or other materials provided with the distribution.
13
* Neither the name of the authors nor the names of its contributors
14
may be used to endorse or promote products derived from this software
15
without specific prior written permission.
16
17
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
POSSIBILITY OF SUCH DAMAGE. */
28
29
/* $Id$ */
36
#ifndef P2P_PROTOCOL_H
37
#define P2P_PROTOCOL_H
38
39
#include <stdint.h>
40
41
/* === Macros =============================================================== */
42
45
/* === generic commands ===================================================== */
46
#define P2P_PING_REQ (0x01)
48
#define P2P_PING_CNF (0x02)
49
#define P2P_JUMP_BOOTL (0x03)
51
/* === wibo ================================================================= */
52
#define P2P_WIBO_DATA (0x20)
53
#define P2P_WIBO_FINISH (0x21)
54
#define P2P_WIBO_RESET (0x22)
55
#define P2P_WIBO_EXIT (0x23)
57
#define P2P_WIBO_TARGET (0x24)
58
#define P2P_WIBO_DEAF (0x25)
59
#define P2P_WIBO_ADDR (0x26)
60
#define P2P_WIBO_BOOTLUP (0x27)
62
/* === wibo example application ============================================= */
63
#define P2P_XMPL_LED (0x30)
65
/* === wuart ================================================================ */
66
#define P2P_WUART_DATA (0x40)
68
/* === Sensor Apps ========================================================== */
69
#define P2P_SENSOR_DATA (0x60)
70
#define P2P_SENSOR_CAPTION (0x61)
71
72
/* === Types ================================================================ */
73
74
typedef
enum
{
75
P2P_STATUS_IDLE = 0x00,
76
P2P_STATUS_RECEIVINGDATA = 0x01,
77
P2P_STATUS_ERROR = 0xFF
78
} p2p_status_t;
79
80
typedef
enum
{
81
P2P_ERROR_NONE = 0x00,
82
P2P_ERROR_NONE_DATAMISS,
83
P2P_ERROR_SUCCESS
84
} p2p_error_t;
85
91
typedef
struct
92
{
93
uint16_t fcf;
94
uint8_t seq;
95
uint16_t pan;
96
uint16_t dst;
97
uint16_t src;
98
uint8_t cmd;
100
#ifdef P2P_PROTOCOL_VERION_2
101
uint16_t nwk_dst;
102
uint16_t nwk_src;
103
uint16_t nwk_reserverd;
104
#endif
105
}
p2p_hdr_t
;
106
107
#define __FILL_P2P_HEADER__(hdr, vfcf, vpan, vdst, vsrc, vcmd) \
108
do{\
109
hdr->fcf = (vfcf);\
110
hdr->seq += 1;\
111
hdr->pan = (vpan);\
112
hdr->dst = (vdst);\
113
hdr->src = (vsrc);\
114
hdr->cmd = (vcmd);\
115
}while(0)
116
118
#define FILL_P2P_HEADER_ACK(hdr, pan, dst, src, cmd) \
119
__FILL_P2P_HEADER__(hdr, 0x8861, pan, dst, src, cmd)
120
122
#define FILL_P2P_HEADER_NOACK(hdr, pan, dst, src, cmd) \
123
__FILL_P2P_HEADER__(hdr, 0x8841, pan, dst, src, cmd)
124
125
#define SET_P2P_HEADER_DESTADD(hdr, seq) \
126
do {hdr->dst = dst;} while(0)
127
128
#define INC_P2P_HEADER_SEQNB(hdr, seq) \
129
do {hdr->seq ++;} while(0)
130
131
#define SET_P2P_HEADER_SEQNB(hdr, seq) \
132
do {hdr->seq = (seq);} while(0)
133
134
136
typedef
struct
137
{
138
p2p_hdr_t
hdr;
139
}
p2p_ping_req_t
;
140
141
143
typedef
struct
144
{
145
p2p_hdr_t
hdr;
146
p2p_status_t status;
147
p2p_error_t errno;
148
uint8_t version;
149
uint16_t crc;
150
uint8_t appname[8];
151
uint8_t boardname[16];
152
}
p2p_ping_cnf_t
;
153
155
typedef
struct
156
{
157
p2p_hdr_t
hdr;
158
}
p2p_jump_bootl_t
;
159
161
typedef
struct
{
162
p2p_hdr_t
hdr;
163
uint8_t dsize;
164
uint8_t data[];
165
}
p2p_wibo_data_t
;
166
168
typedef
struct
169
{
170
p2p_hdr_t
hdr;
171
}
p2p_wibo_finish_t
;
172
173
175
typedef
struct
176
{
177
p2p_hdr_t
hdr;
178
}
p2p_wibo_reset_t
;
179
181
typedef
struct
182
{
183
p2p_hdr_t
hdr;
184
uint8_t targmem;
185
}
p2p_wibo_target_t
;
186
188
typedef
struct
189
{
190
p2p_hdr_t
hdr;
191
uint32_t address;
192
}
p2p_wibo_addr_t
;
193
195
typedef
struct
196
{
197
p2p_hdr_t
hdr;
198
}
p2p_wibo_exit_t
;
199
201
typedef
struct
202
{
203
p2p_hdr_t
hdr;
204
}
p2p_wibo_bootlup_t
;
205
207
typedef
struct
{
208
p2p_hdr_t
hdr;
209
uint8_t led;
210
uint8_t state;
211
}
p2p_xmpl_led_t
;
212
214
typedef
struct
215
{
216
p2p_hdr_t
hdr;
217
uint8_t mode;
218
}
p2p_wuart_data_t
;
219
221
typedef
struct
222
{
223
p2p_hdr_t
hdr;
224
uint8_t data[];
225
}
p2p_sensor_data_t
;
226
228
typedef
struct
229
{
230
p2p_hdr_t
hdr;
231
uint8_t caption[];
232
}
p2p_sensor_caption_t
;
233
234
/* === prototypes ========================================================== */
235
#ifdef __cplusplus
236
extern
"C"
{
237
#endif
238
239
#ifdef __cplusplus
240
}
/* extern "C" */
241
#endif
242
243
244
#endif
/* ifndef P2P_PROTOCOL_H */
p2p_wuart_data_t
Definition:
p2p_protocol.h:217
p2p_ping_cnf_t
Definition:
p2p_protocol.h:146
p2p_wibo_bootlup_t
Definition:
p2p_protocol.h:204
p2p_sensor_caption_t
Definition:
p2p_protocol.h:231
p2p_wibo_addr_t
Definition:
p2p_protocol.h:191
p2p_hdr_t
Definition:
p2p_protocol.h:94
p2p_wibo_finish_t
Definition:
p2p_protocol.h:171
p2p_wibo_data_t
Definition:
p2p_protocol.h:164
p2p_wibo_target_t
Definition:
p2p_protocol.h:184
p2p_xmpl_led_t
Definition:
p2p_protocol.h:210
p2p_ping_req_t
Definition:
p2p_protocol.h:139
p2p_wibo_exit_t
Definition:
p2p_protocol.h:198
p2p_wibo_reset_t
Definition:
p2p_protocol.h:178
p2p_jump_bootl_t
Definition:
p2p_protocol.h:158
p2p_sensor_data_t
Definition:
p2p_protocol.h:224
Lib
Inc
p2p_protocol.h
Generated on Sat Aug 29 2015 08:07:13 for µracoli Manual by
1.8.10