wmp_misc.c
Go to the documentation of this file.
00001 /*------------------------------------------------------------------------
00002  *---------------------           RT-WMP              --------------------
00003  *------------------------------------------------------------------------
00004  *                                                         V7.0B  11/05/10
00005  *
00006  *
00007  *  File: ./src/core/wmp_misc.c
00008  *  Authors: Danilo Tardioli
00009  *  ----------------------------------------------------------------------
00010  *  Copyright (C) 2000-2010, Universidad de Zaragoza, SPAIN
00011  *
00012  *  Contact Addresses: Danilo Tardioli                   dantard@unizar.es
00013  *
00014  *  RT-WMP is free software; you can  redistribute it and/or  modify it
00015  *  under the terms of the GNU General Public License  as published by the
00016  *  Free Software Foundation;  either  version 2, or (at  your option) any
00017  *  later version.
00018  *
00019  *  RT-WMP  is distributed  in the  hope  that  it will be   useful, but
00020  *  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
00021  *  MERCHANTABILITY  or  FITNESS FOR A  PARTICULAR PURPOSE.    See the GNU
00022  *  General Public License for more details.
00023  *
00024  *  You should have received  a  copy of  the  GNU General Public  License
00025  *  distributed with RT-WMP;  see file COPYING.   If not,  write to the
00026  *  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
00027  *  02111-1307, USA.
00028  *
00029  *  As a  special exception, if you  link this  unit  with other  files to
00030  *  produce an   executable,   this unit  does  not  by  itself cause  the
00031  *  resulting executable to be covered by the  GNU General Public License.
00032  *  This exception does  not however invalidate  any other reasons why the
00033  *  executable file might be covered by the GNU Public License.
00034  *
00035  *----------------------------------------------------------------------*/
00036 
00037 #include "config/compiler.h"
00038 #include "include/definitions.h"
00039 #include "include/global.h"
00040 #include "include/wmp_misc.h"
00041 void state_to_string(char state, char* string){
00042         switch (state){
00043                 case EVALUATE_TOKEN:
00044                                 sprintf(string,"EVALUATE_TOKEN");
00045                                 break;
00046                 case EVALUATE_AUTHORIZATION:
00047                                 sprintf(string,"EVALUATE_AUTHORIZATION");
00048                                 break;
00049                 case EVALUATE_MESSAGE:
00050                                 sprintf(string,"EVALUATE_MESSAGE");
00051                                 break;
00052                 case EVALUATE_DROP_TOKEN:
00053                                 sprintf(string,"EVALUATE_DROP_TOKEN");
00054                                 break;
00055                 case EVALUATE_FOREIGN:
00056                                 sprintf(string,"EVALUATE_FOREIGN");
00057                                 break;
00058                 case NEW_TOKEN:
00059                                 sprintf(string,"NEW_TOKEN");
00060                                 break;
00061                 case WAIT_ACK:
00062                                 sprintf(string,"WAIT_ACK");
00063                                 break;
00064                 case SEND_TOKEN:
00065                                 sprintf(string,"SEND_TOKEN");
00066                                 break;
00067                 case RETRY:
00068                                 sprintf(string,"RETRY");
00069                                 break;
00070                 case RECEIVE:
00071                                 sprintf(string,"RECEIVE");
00072                                 break;
00073                 case INTERPRET_RECEIVED:
00074                                 sprintf(string,"INTERPRET_RECEIVED");
00075                                 break;
00076                 case INTERPRET_ACK:
00077                                 sprintf(string,"INTERPRET_ACK");
00078                                 break;
00079                 case SEND_MESSAGE:
00080                                 sprintf(string,"SEND_MESSAGE");
00081                                 break;
00082                 case DECODE_ROUTING_INFO_ON_RECEIVE:
00083                                 sprintf(string,"DECODE_ROUTING_INFO_ON_RECEIVE");
00084                                 break;
00085                 case DECODE_ROUTING_INFO_ON_WACK:
00086                                 sprintf(string,"DECODE_ROUTING_INFO_ON_WACK");
00087                                 break;
00088                 case SEND_AUTHORIZATION:
00089                                 sprintf(string,"SEND_AUTHORIZATION");
00090                                 break;
00091                 case TO_TOKEN_EXPIRED:
00092                                 sprintf(string,"TO_TOKEN_EXPIRED");
00093                                 break;
00094                 case TO_AUTHORIZATION_EXPIRED:
00095                                 sprintf(string,"TO_AUTHORIZATION_EXPIRED");
00096                                 break;
00097                 case TO_MESSAGE_EXPIRED:
00098                                 sprintf(string,"TO_MESSAGE_EXPIRED");
00099                                 break;
00100                 case DUPLICATE_TOKEN:
00101                                 sprintf(string,"DUPLICATE_TOKEN");
00102                                 break;
00103                 case CREATE_AUTHORIZATION:
00104                                 sprintf(string,"CREATE_AUTHORIZATION");
00105                                 break;
00106                 case CREATE_MESSAGE:
00107                                 sprintf(string,"CREATE_MESSAGE");
00108                                 break;
00109                 case ENQUEUE_MESSAGE:
00110                                 sprintf(string,"ENQUEUE_MESSAGE");
00111                                 break;
00112                 case UPDATE_RSSI_ON_RECEIVE:
00113                                 sprintf(string,"UPDATE_RSSI_ON_RECEIVE");
00114                                 break;
00115                 case UPDATE_RSSI_ON_ACK:
00116                                 sprintf(string,"UPDATE_RSSI_ON_ACK");
00117                                 break;
00118                 default:
00119                                 sprintf(string,"UKNOWN STATE");
00120         }
00121 }
00122 
00123 unsigned char get_net_id(void){
00124         return status.net_id;
00125 }
00126 
00127 unsigned int wmpGetMTU(void){
00128         return status.MAXIMUM_DATA_SIZE;
00129 }
00130 
00131 void wmp_set_pose(double x, double y, int pow_mw){
00132         status.x = x;
00133         status.y = y;
00134         status.pow = pow_mw;
00135 }
00136 void wmp_get_pose(double * x, double * y, int * pow){
00137         *x = status.x;
00138         *y = status.y;
00139         *pow = status.pow;
00140 }
00141 void wmpSetActiveSearch(int val){
00142         status.active_search = val;
00143 }
00144 
00145 int wmpGetActiveSearch(void){
00146         return status.active_search;
00147 }
00148 
00149 void wmpSetPrimBasedRouting(int val){
00150         WMP_MSG(stderr,"Prim Based routing: %d\n",val);
00151         status.use_prim = val;
00152 }
00153 
00154 int wmpGetPrimBasedRouting(int val){
00155    return status.use_prim;
00156 }
00157 
00158 void wmpSetPruneBasedRouting(int val){
00159         WMP_MSG(stderr,"Prune Based routing: %d\n",val);
00160         status.use_prune = val;
00161 
00162 }
00163 
00164 int apply_config(Status * status, char * param, char * val) {
00165         if (strcmp(param, "NODE_ID") == 0) {
00166                 status->id = atoi(val);
00167                 return 1;
00168         } else if (strcmp(param, "NUM_NODES") == 0) {
00169                 status->N_NODES = atoi(val);
00170                 return 1;
00171         } else if (strcmp(param, "TIMEOUT") == 0) {
00172                 return 1;
00173                 status->TIMEOUT = atoi(val);
00174         } else if (strcmp(param, "HOLD_TIME") == 0) {
00175                 status->hold_time = atoi(val);
00176                 return 1;
00177         } else if (strcmp(param, "MAX_PER_NODE_RETRIES") == 0) {
00178                 status->maxPerNodeRetries = atoi(val);
00179                 return 1;
00180         } else if (strcmp(param, "MAX_TOTAL_RETRIES") == 0) {
00181                 status->maxTotalRetries = atoi(val);
00182                 return 1;
00183         } else if (strcmp(param, "MOBILE_AVERAGE_ELEMENTS") == 0) {
00184                 status->mobile_average_elements = atoi(val);
00185                 return 1;
00186         } else if (strcmp(param, "RX_QUEUE_ELEMENTS") == 0) {
00187                 status->rx_queue_elements = atoi(val);
00188                 return 1;
00189         } else if (strcmp(param, "TX_QUEUE_ELEMENTS") == 0) {
00190                 status->tx_queue_elements = atoi(val);
00191                 return 1;
00192         } else if (strcmp(param, "NET_ID") == 0) {
00193                 status->net_id = atoi(val);
00194                 return 1;
00195         } else if (strcmp(param, "USE_POWER_SAVE") == 0) {
00196                 status->power_save = atoi(val);
00197                 return 1;
00198         } else if (strcmp(param, "SECURE") == 0) {
00199                 status->secure = atoi(val);
00200                 return 1;
00201         }else if (strcmp(param, "USE_PRUNE") == 0) {
00202                 status->use_prune = atoi(val);
00203                 return 1;
00204         }else if (strcmp(param, "USE_PRIM") == 0) {
00205                 status->use_prim = atoi(val);
00206                 return 1;
00207         }else if (strcmp(param, "RATE") == 0) {
00208                 status->rate = atoi(val);
00209                 return 1;
00210         }else if (strcmp(param, "MAX_MSG_SIZE") == 0) {
00211                 status->max_msg_size = atoi(val);
00212                 return 1;
00213         }else if (strcmp(param, "CPU_DELAY_US") == 0) {
00214                 status->cpu_delay = atoi(val);
00215                 return 1;
00216         }
00217         return 0;
00218 
00219 }
00220 
00221 void wmpSetDefaultConfiguration(Status * s){
00222         s->cpu_delay=10;
00223         s->perHopDelay=10;
00224         s->id=0;
00225         s->maxPerNodeRetries=1;
00226         s->maxTotalRetries=2000;
00227         s->max_rssi=100;
00228         s->hold_time=1500;
00229         s->quiet=0;
00230         s->mobile_average_elements=50;
00231         s->acknow=-1;
00232         s->TIMEOUT=100;
00233         s->rx_queue_elements=50;
00234         s->tx_queue_elements=50;
00235         s->rssi_rising_factor=3;
00236         s->rate=60;
00237         s->multiplier=1;
00238         s->wait_ack_from=0;
00239         s->enable_flow_control = 0;
00240         s->enable_message_reschedule = 1;
00241         s->net_id=0;
00242         s->use_prim = 0;
00243         s->use_prune = 1;
00244         s->use_prob = 0;
00245         s->highestSerial = 0;
00246         s->wait_implicit_ack_from = -1;
00247         s->pow = -1;
00248         s->x = 0;
00249         s->y = 0;
00250         s->active_search = 1;
00251         s->lastRecvdType = -1;
00252         s->w100 = 25;
00253         s->w3 = 30;
00254         s->w2 = 40;
00255         s->w1 = 80;
00256         s->power_save = 1;
00257         s->secure = 1;
00258         s->max_msg_size = 65535;
00259         s->num_ports = 32;
00260 }
00261 
00262 


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Mon Oct 6 2014 08:27:11