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
00058 #define P2P_XMPL_LED (0x30)
00060
00061 #define P2P_WUART_DATA (0x40)
00063
00064 #define P2P_CHSWEEP_SWEEP_REQ (0x50)
00066 #define P2P_CHSWEEP_RESULT_REQ (0x51)
00067 #define P2P_CHSWEEP_RESULT_CNF (0x52)
00068 #define P2P_CHSWEEP_EXEC_REQ (0x53)
00072
00073
00074 typedef enum {
00075 P2P_STATUS_IDLE = 0x00,
00076 P2P_STATUS_RECEIVINGDATA = 0x01,
00077 P2P_STATUS_ERROR = 0xFF
00078 } p2p_status_t;
00079
00080 typedef enum {
00081 P2P_ERROR_NONE = 0x00,
00082 P2P_ERROR_NONE_DATAMISS,
00083 P2P_ERROR_SUCCESS
00084 } p2p_error_t;
00085
00091 typedef struct
00092 {
00093 uint16_t fcf;
00094 uint8_t seq;
00095 uint16_t pan;
00096 uint16_t dst;
00097 uint16_t src;
00098 uint8_t cmd;
00100 } p2p_hdr_t;
00101
00102 #define __FILL_P2P_HEADER__(hdr, vfcf, vpan, vdst, vsrc, vcmd) \
00103 do{\
00104 hdr->fcf = (vfcf);\
00105 hdr->seq += 1;\
00106 hdr->pan = (vpan);\
00107 hdr->dst = (vdst);\
00108 hdr->src = (vsrc);\
00109 hdr->cmd = (vcmd);\
00110 }while(0)
00111
00113 #define FILL_P2P_HEADER_ACK(hdr, pan, dst, src, cmd) \
00114 __FILL_P2P_HEADER__(hdr, 0x8861, pan, dst, src, cmd)
00115
00117 #define FILL_P2P_HEADER_NOACK(hdr, pan, dst, src, cmd) \
00118 __FILL_P2P_HEADER__(hdr, 0x8841, pan, dst, src, cmd)
00119
00120 #define SET_P2P_HEADER_DESTADD(hdr, seq) \
00121 do {hdr->dst = dst;} while(0)
00122
00123 #define INC_P2P_HEADER_SEQNB(hdr, seq) \
00124 do {hdr->seq ++;} while(0)
00125
00126 #define SET_P2P_HEADER_SEQNB(hdr, seq) \
00127 do {hdr->seq = (seq);} while(0)
00128
00129
00131 typedef struct
00132 {
00133 p2p_hdr_t hdr;
00134 } p2p_ping_req_t;
00135
00136
00138 typedef struct
00139 {
00140 p2p_hdr_t hdr;
00141 p2p_status_t status;
00142 p2p_error_t errno;
00143 uint8_t version;
00144 uint16_t crc;
00145 uint16_t pagesize;
00146 char appname[8];
00147 char boardname[];
00148 } p2p_ping_cnf_t;
00149
00151 typedef struct
00152 {
00153 p2p_hdr_t hdr;
00154 } p2p_jump_bootl_t;
00155
00157 typedef struct {
00158 p2p_hdr_t hdr;
00159 uint8_t targmem;
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 } p2p_wibo_exit_t;
00182
00184 typedef struct {
00185 p2p_hdr_t hdr;
00186 uint8_t led;
00187 uint8_t state;
00188 } p2p_xmpl_led_t;
00189
00191 typedef struct
00192 {
00193 p2p_hdr_t hdr;
00194 uint8_t mode;
00195 } p2p_wuart_data_t;
00196
00198 typedef struct{
00199 p2p_hdr_t hdr;
00200 uint16_t rx_addr;
00201 } p2p_chsweep_sweep_req_t;
00202
00204 typedef struct {
00205 p2p_hdr_t hdr;
00206 uint8_t res_mode;
00207 } p2p_chsweep_result_req_t;
00208
00210 typedef struct
00211 {
00212 p2p_hdr_t hdr;
00213 uint8_t res_mode;
00214 uint8_t data[];
00215 } p2p_chsweep_result_cnf_t;
00216
00218 typedef struct
00219 {
00220 p2p_hdr_t hdr;
00221 uint8_t clear_stat;
00222 uint8_t next_channel;
00223 } p2p_chsweep_exec_req_t;
00224
00225
00226 #ifdef __cplusplus
00227 extern "C" {
00228 #endif
00229
00230 #ifdef __cplusplus
00231 }
00232 #endif
00233
00234
00235 #endif