p2p_protocol.h

Go to the documentation of this file.
00001 /* Copyright (c) 2007 - 2012 Axel Wachtler
00002    All rights reserved.
00003 
00004    Redistribution and use in source and binary forms, with or without
00005    modification, are permitted provided that the following conditions
00006    are met:
00007 
00008    * Redistributions of source code must retain the above copyright
00009      notice, this list of conditions and the following disclaimer.
00010    * Redistributions in binary form must reproduce the above copyright
00011      notice, this list of conditions and the following disclaimer in the
00012      documentation and/or other materials provided with the distribution.
00013    * Neither the name of the authors nor the names of its contributors
00014      may be used to endorse or promote products derived from this software
00015      without specific prior written permission.
00016 
00017    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027    POSSIBILITY OF SUCH DAMAGE. */
00028 
00029 /* $Id: p2p__protocol_8h_source.html,v 1.1.1.3 2013/04/09 21:11:54 awachtler Exp $ */
00036 #ifndef P2P_PROTOCOL_H
00037 #define P2P_PROTOCOL_H
00038 
00039 #include <stdint.h>
00040 
00041 /* === Macros =============================================================== */
00042 
00045 /* === generic commands ===================================================== */
00046 #define P2P_PING_REQ (0x01)          
00048 #define P2P_PING_CNF (0x02)          
00049 #define P2P_JUMP_BOOTL (0x03)        
00051 /* === wibo ================================================================= */
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 /* === wibo example application ============================================= */
00060 #define P2P_XMPL_LED (0x30)           
00062 /* === wuart ================================================================ */
00063 #define P2P_WUART_DATA (0x40)         
00065 /* === chsweep ============================================================== */
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 /* === Types ================================================================ */
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 /* === prototypes ========================================================== */
00233 #ifdef __cplusplus
00234 extern "C" {
00235 #endif
00236 
00237 #ifdef __cplusplus
00238 } /* extern "C" */
00239 #endif
00240 
00241 
00242 #endif /* ifndef P2P_PROTOCOL_H */

This documentation for µracoli was generated on Tue Apr 9 2013 by  doxygen 1.7.1