Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00036 #ifndef P2P_PROTOCOL_H
00037 #define P2P_PROTOCOL_H
00038
00039 #include <stdint.h>
00040
00041
00042
00045
00046 #define P2P_PING_REQ (0x01)
00048 #define P2P_PING_CNF (0x02)
00049 #define P2P_JUMP_BOOTL (0x03)
00051
00052 #define P2P_WIBO_DATA (0x20)
00053 #define P2P_WIBO_FINISH (0x21)
00054 #define P2P_WIBO_RESET (0x22)
00055 #define P2P_WIBO_EXIT (0x23)
00057 #define P2P_WIBO_TARGET (0x24)
00059
00060 #define P2P_XMPL_LED (0x30)
00062
00063 #define P2P_WUART_DATA (0x40)
00065
00066 #define P2P_CHSWEEP_SWEEP_REQ (0x50)
00068 #define P2P_CHSWEEP_RESULT_REQ (0x51)
00069 #define P2P_CHSWEEP_RESULT_CNF (0x52)
00070 #define P2P_CHSWEEP_EXEC_REQ (0x53)
00074
00075
00076 typedef enum {
00077 P2P_STATUS_IDLE = 0x00,
00078 P2P_STATUS_RECEIVINGDATA = 0x01,
00079 P2P_STATUS_ERROR = 0xFF
00080 } p2p_status_t;
00081
00082 typedef enum {
00083 P2P_ERROR_NONE = 0x00,
00084 P2P_ERROR_NONE_DATAMISS,
00085 P2P_ERROR_SUCCESS
00086 } p2p_error_t;
00087
00093 typedef struct
00094 {
00095 uint16_t fcf;
00096 uint8_t seq;
00097 uint16_t pan;
00098 uint16_t dst;
00099 uint16_t src;
00100 uint8_t cmd;
00102 } p2p_hdr_t;
00103
00104 #define __FILL_P2P_HEADER__(hdr, vfcf, vpan, vdst, vsrc, vcmd) \
00105 do{\
00106 hdr->fcf = (vfcf);\
00107 hdr->seq += 1;\
00108 hdr->pan = (vpan);\
00109 hdr->dst = (vdst);\
00110 hdr->src = (vsrc);\
00111 hdr->cmd = (vcmd);\
00112 }while(0)
00113
00115 #define FILL_P2P_HEADER_ACK(hdr, pan, dst, src, cmd) \
00116 __FILL_P2P_HEADER__(hdr, 0x8861, pan, dst, src, cmd)
00117
00119 #define FILL_P2P_HEADER_NOACK(hdr, pan, dst, src, cmd) \
00120 __FILL_P2P_HEADER__(hdr, 0x8841, pan, dst, src, cmd)
00121
00122 #define SET_P2P_HEADER_DESTADD(hdr, seq) \
00123 do {hdr->dst = dst;} while(0)
00124
00125 #define INC_P2P_HEADER_SEQNB(hdr, seq) \
00126 do {hdr->seq ++;} while(0)
00127
00128 #define SET_P2P_HEADER_SEQNB(hdr, seq) \
00129 do {hdr->seq = (seq);} while(0)
00130
00131
00133 typedef struct
00134 {
00135 p2p_hdr_t hdr;
00136 } p2p_ping_req_t;
00137
00138
00140 typedef struct
00141 {
00142 p2p_hdr_t hdr;
00143 p2p_status_t status;
00144 p2p_error_t errno;
00145 uint8_t version;
00146 uint16_t crc;
00147 char appname[8];
00148 char boardname[];
00149 } p2p_ping_cnf_t;
00150
00152 typedef struct
00153 {
00154 p2p_hdr_t hdr;
00155 } p2p_jump_bootl_t;
00156
00158 typedef struct {
00159 p2p_hdr_t hdr;
00160 uint8_t dsize;
00161 uint8_t data[];
00162 } p2p_wibo_data_t;
00163
00165 typedef struct
00166 {
00167 p2p_hdr_t hdr;
00168 } p2p_wibo_finish_t;
00169
00170
00172 typedef struct
00173 {
00174 p2p_hdr_t hdr;
00175 } p2p_wibo_reset_t;
00176
00178 typedef struct
00179 {
00180 p2p_hdr_t hdr;
00181 uint8_t targmem;
00182 } p2p_wibo_target_t;
00183
00185 typedef struct
00186 {
00187 p2p_hdr_t hdr;
00188 } p2p_wibo_exit_t;
00189
00191 typedef struct {
00192 p2p_hdr_t hdr;
00193 uint8_t led;
00194 uint8_t state;
00195 } p2p_xmpl_led_t;
00196
00198 typedef struct
00199 {
00200 p2p_hdr_t hdr;
00201 uint8_t mode;
00202 } p2p_wuart_data_t;
00203
00205 typedef struct{
00206 p2p_hdr_t hdr;
00207 uint16_t rx_addr;
00208 } p2p_chsweep_sweep_req_t;
00209
00211 typedef struct {
00212 p2p_hdr_t hdr;
00213 uint8_t res_mode;
00214 } p2p_chsweep_result_req_t;
00215
00217 typedef struct
00218 {
00219 p2p_hdr_t hdr;
00220 uint8_t res_mode;
00221 uint8_t data[];
00222 } p2p_chsweep_result_cnf_t;
00223
00225 typedef struct
00226 {
00227 p2p_hdr_t hdr;
00228 uint8_t clear_stat;
00229 uint8_t next_channel;
00230 } p2p_chsweep_exec_req_t;
00231
00232
00233 #ifdef __cplusplus
00234 extern "C" {
00235 #endif
00236
00237 #ifdef __cplusplus
00238 }
00239 #endif
00240
00241
00242 #endif