1 /* Rx Level statistics */
3 /* (C) 2010 by Harald Welte <laforge@gnumonks.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <osmocom/core/bitvec.h>
31 #include <osmocom/gsm/rxlev_stat.h>
33 void rxlev_stat_input(struct rxlev_stats *st, uint16_t arfcn, uint8_t rxlev)
37 if (rxlev >= NUM_RXLEVS)
40 bv.data_len = NUM_ARFCNS/8;
41 bv.data = st->rxlev_buckets[rxlev];
43 bitvec_set_bit_pos(&bv, arfcn, ONE);
46 /* get the next ARFCN that has the specified Rxlev */
47 int16_t rxlev_stat_get_next(const struct rxlev_stats *st, uint8_t rxlev, int16_t arfcn)
51 if (rxlev >= NUM_RXLEVS)
54 bv.data_len = NUM_ARFCNS/8;
59 bv.data = (uint8_t *) st->rxlev_buckets[rxlev];
61 return bitvec_find_bit_pos(&bv, arfcn+1, ONE);
64 void rxlev_stat_reset(struct rxlev_stats *st)
66 memset(st, 0, sizeof(*st));
69 void rxlev_stat_dump(const struct rxlev_stats *st)
73 for (i = NUM_RXLEVS-1; i >= 0; i--) {
76 printf("ARFCN with RxLev %u: ", i);
77 while ((arfcn = rxlev_stat_get_next(st, i, arfcn)) >= 0) {