rssi_average.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/rssi_average.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 "include/rssi_average.h"
00038 
00039 MobileAverage ** rssi;
00040 
00041 void initMobileAverage(int RSSI_AVERAGE_ELEMENTS){
00042         int i;
00043         rssi=(MobileAverage**) MALLOC(status.N_NODES*sizeof(MobileAverage*));
00044         for (i=0;i<status.N_NODES;i++){
00045                 rssi[i]=(MobileAverage *) MALLOC(sizeof(MobileAverage));
00046                 mobile_avg_init(rssi[i],RSSI_AVERAGE_ELEMENTS);
00047         }
00048 }
00049 
00050 void freeMobileAverage(){
00051         int i;
00052         for (i=0;i<status.N_NODES;i++){
00053                 mobile_avg_free(rssi[i]);
00054                 FREE(rssi[i]);
00055         }
00056         FREE(rssi);
00057 }
00058 
00059 void rssi_new_frame(unsigned char id, char val){
00060         mobile_avg_new_value(rssi[id],val);
00061 }
00062 
00063 void rssi_reset(unsigned char id){
00064         if (id >= 0 && id < status.N_NODES){
00065                 mobile_avg_reset(rssi[id]);
00066         }
00067 }
00068 
00069 char rssi_get_averaged_rssi(unsigned char id){
00070         return mobile_avg_get_averaged_value(rssi[id]);
00071 }
00072 unsigned long rssi_get_age(unsigned char id){
00073         return mobile_avg_get_age(rssi[id]);
00074 }
00075 
00076 
00077 
00078 
00079 


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Fri Jan 3 2014 12:07:55