\doxysection{include/osmocom/gsm/gsm48\+\_\+arfcn\+\_\+range\+\_\+encode.h File Reference}
\label{gsm48__arfcn__range__encode_8h}\index{include/osmocom/gsm/gsm48\_arfcn\_range\_encode.h@{include/osmocom/gsm/gsm48\_arfcn\_range\_encode.h}}
{\ttfamily \#include $<$stdint.\+h$>$}\newline
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ OSMO\+\_\+\+GSM48\+\_\+\+RANGE\+\_\+\+ENC\+\_\+\+MAX\+\_\+\+ARFCNS}~29
\end{DoxyCompactItemize}
\doxysubsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \textbf{ osmo\+\_\+gsm48\+\_\+range} \{ \newline
\textbf{ OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+\+INVALID} = -\/1
, \newline
\textbf{ OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+128} = 127
, \newline
\textbf{ OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+256} = 255
, \newline
\textbf{ OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+512} = 511
, \newline
\textbf{ OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+1024} = 1023
 \}
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+determine\+\_\+range} (const int $\ast$arfcns, int size, int $\ast$f0\+\_\+out)
\begin{DoxyCompactList}\small\item\em This implements the range determination as described in GSM 04.\+08 J4. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+arfcns} (enum \textbf{ osmo\+\_\+gsm48\+\_\+range} rng, const int $\ast$arfcns, int sze, int $\ast$out, int idx)
\begin{DoxyCompactList}\small\item\em Range encode the ARFCN list. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+find\+\_\+index} (enum \textbf{ osmo\+\_\+gsm48\+\_\+range} rng, const int $\ast$arfcns, int size)
\begin{DoxyCompactList}\small\item\em Determine at which index to split the ARFCNs to create an equally size partition for the given range. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+filter\+\_\+arfcns} (int $\ast$arfcns, const int sze, const int f0, int $\ast$f0\+\_\+included)
\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+128} (uint8\+\_\+t $\ast$chan\+\_\+list, int f0, int $\ast$w)
\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+256} (uint8\+\_\+t $\ast$chan\+\_\+list, int f0, int $\ast$w)
\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+512} (uint8\+\_\+t $\ast$chan\+\_\+list, int f0, int $\ast$w)
\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+1024} (uint8\+\_\+t $\ast$chan\+\_\+list, int f0, int f0\+\_\+incl, int $\ast$w)
\end{DoxyCompactItemize}


\doxysubsection{Macro Definition Documentation}
\mbox{\label{gsm48__arfcn__range__encode_8h_a3bfd46424e2704131defc952272301d7}} 
\index{gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}!OSMO\_GSM48\_RANGE\_ENC\_MAX\_ARFCNS@{OSMO\_GSM48\_RANGE\_ENC\_MAX\_ARFCNS}}
\index{OSMO\_GSM48\_RANGE\_ENC\_MAX\_ARFCNS@{OSMO\_GSM48\_RANGE\_ENC\_MAX\_ARFCNS}!gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}}
\doxysubsubsection{OSMO\_GSM48\_RANGE\_ENC\_MAX\_ARFCNS}
{\footnotesize\ttfamily \#define OSMO\+\_\+\+GSM48\+\_\+\+RANGE\+\_\+\+ENC\+\_\+\+MAX\+\_\+\+ARFCNS~29}



\doxysubsection{Enumeration Type Documentation}
\mbox{\label{gsm48__arfcn__range__encode_8h_a1bf10bb9d7e8ba79767bf141ca420777}} 
\index{gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}!osmo\_gsm48\_range@{osmo\_gsm48\_range}}
\index{osmo\_gsm48\_range@{osmo\_gsm48\_range}!gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}}
\doxysubsubsection{osmo\_gsm48\_range}
{\footnotesize\ttfamily enum \textbf{ osmo\+\_\+gsm48\+\_\+range}}

\begin{DoxyEnumFields}{Enumerator}
\raisebox{\heightof{T}}[0pt][0pt]{\index{OSMO\_GSM48\_ARFCN\_RANGE\_INVALID@{OSMO\_GSM48\_ARFCN\_RANGE\_INVALID}!gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}}\index{gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}!OSMO\_GSM48\_ARFCN\_RANGE\_INVALID@{OSMO\_GSM48\_ARFCN\_RANGE\_INVALID}}}\mbox{\label{gsm48__arfcn__range__encode_8h_a1bf10bb9d7e8ba79767bf141ca420777a107d57aa19c69ac977be705043baf33e}} 
OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+\+INVALID&\\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{OSMO\_GSM48\_ARFCN\_RANGE\_128@{OSMO\_GSM48\_ARFCN\_RANGE\_128}!gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}}\index{gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}!OSMO\_GSM48\_ARFCN\_RANGE\_128@{OSMO\_GSM48\_ARFCN\_RANGE\_128}}}\mbox{\label{gsm48__arfcn__range__encode_8h_a1bf10bb9d7e8ba79767bf141ca420777a3f7fcda0f3a4248b06087a5a571a9d15}} 
OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+128&\\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{OSMO\_GSM48\_ARFCN\_RANGE\_256@{OSMO\_GSM48\_ARFCN\_RANGE\_256}!gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}}\index{gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}!OSMO\_GSM48\_ARFCN\_RANGE\_256@{OSMO\_GSM48\_ARFCN\_RANGE\_256}}}\mbox{\label{gsm48__arfcn__range__encode_8h_a1bf10bb9d7e8ba79767bf141ca420777a5c24e4741c92bd79b858ded98e9d43f4}} 
OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+256&\\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{OSMO\_GSM48\_ARFCN\_RANGE\_512@{OSMO\_GSM48\_ARFCN\_RANGE\_512}!gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}}\index{gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}!OSMO\_GSM48\_ARFCN\_RANGE\_512@{OSMO\_GSM48\_ARFCN\_RANGE\_512}}}\mbox{\label{gsm48__arfcn__range__encode_8h_a1bf10bb9d7e8ba79767bf141ca420777ac94ac2253cd3b058daf3d32c8b99bd09}} 
OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+512&\\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{OSMO\_GSM48\_ARFCN\_RANGE\_1024@{OSMO\_GSM48\_ARFCN\_RANGE\_1024}!gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}}\index{gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}!OSMO\_GSM48\_ARFCN\_RANGE\_1024@{OSMO\_GSM48\_ARFCN\_RANGE\_1024}}}\mbox{\label{gsm48__arfcn__range__encode_8h_a1bf10bb9d7e8ba79767bf141ca420777a092688ac8ee914a2a312417195b9eb16}} 
OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+1024&\\
\hline

\end{DoxyEnumFields}


\doxysubsection{Function Documentation}
\mbox{\label{gsm48__arfcn__range__encode_8h_a2673dcfead831fd420d5bbc5f0b3b3b8}} 
\index{gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}!osmo\_gsm48\_range\_enc\_1024@{osmo\_gsm48\_range\_enc\_1024}}
\index{osmo\_gsm48\_range\_enc\_1024@{osmo\_gsm48\_range\_enc\_1024}!gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_1024()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+1024 (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{chan\+\_\+list,  }\item[{int}]{f0,  }\item[{int}]{f0\+\_\+incl,  }\item[{int $\ast$}]{w }\end{DoxyParamCaption})}



References \textbf{ write\+\_\+all\+\_\+wn()}.



Referenced by \textbf{ range\+\_\+encode()}.

\mbox{\label{gsm48__arfcn__range__encode_8h_a6d9a7c982386b4ee5c6d35a7024f190c}} 
\index{gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}!osmo\_gsm48\_range\_enc\_128@{osmo\_gsm48\_range\_enc\_128}}
\index{osmo\_gsm48\_range\_enc\_128@{osmo\_gsm48\_range\_enc\_128}!gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_128()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+128 (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{chan\+\_\+list,  }\item[{int}]{f0,  }\item[{int $\ast$}]{w }\end{DoxyParamCaption})}



References \textbf{ write\+\_\+all\+\_\+wn()}, and \textbf{ write\+\_\+orig\+\_\+arfcn()}.



Referenced by \textbf{ range\+\_\+encode()}.

\mbox{\label{gsm48__arfcn__range__encode_8h_aed2cdbc388075b6ccb28a621d18b9a3c}} 
\index{gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}!osmo\_gsm48\_range\_enc\_256@{osmo\_gsm48\_range\_enc\_256}}
\index{osmo\_gsm48\_range\_enc\_256@{osmo\_gsm48\_range\_enc\_256}!gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_256()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+256 (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{chan\+\_\+list,  }\item[{int}]{f0,  }\item[{int $\ast$}]{w }\end{DoxyParamCaption})}



References \textbf{ write\+\_\+all\+\_\+wn()}, and \textbf{ write\+\_\+orig\+\_\+arfcn()}.



Referenced by \textbf{ range\+\_\+encode()}.

\mbox{\label{gsm48__arfcn__range__encode_8h_a4f830c03682612b8245be84fb1e11832}} 
\index{gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}!osmo\_gsm48\_range\_enc\_512@{osmo\_gsm48\_range\_enc\_512}}
\index{osmo\_gsm48\_range\_enc\_512@{osmo\_gsm48\_range\_enc\_512}!gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_512()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+512 (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{chan\+\_\+list,  }\item[{int}]{f0,  }\item[{int $\ast$}]{w }\end{DoxyParamCaption})}



References \textbf{ write\+\_\+all\+\_\+wn()}, and \textbf{ write\+\_\+orig\+\_\+arfcn()}.



Referenced by \textbf{ range\+\_\+encode()}.

\mbox{\label{gsm48__arfcn__range__encode_8h_a55063b8daa287ef3d93e7ed674028d20}} 
\index{gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}!osmo\_gsm48\_range\_enc\_arfcns@{osmo\_gsm48\_range\_enc\_arfcns}}
\index{osmo\_gsm48\_range\_enc\_arfcns@{osmo\_gsm48\_range\_enc\_arfcns}!gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_arfcns()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+arfcns (\begin{DoxyParamCaption}\item[{enum \textbf{ osmo\+\_\+gsm48\+\_\+range}}]{range,  }\item[{const int $\ast$}]{arfcns,  }\item[{int}]{size,  }\item[{int $\ast$}]{out,  }\item[{const int}]{index }\end{DoxyParamCaption})}



Range encode the ARFCN list. 


\begin{DoxyParams}{Parameters}
{\em range} & The range to use. \\
\hline
{\em arfcns} & The list of ARFCNs \\
\hline
{\em size} & The size of the list of ARFCNs \\
\hline
{\em out} & Place to store the W(i) output. \\
\hline
\end{DoxyParams}


References \textbf{ \+\_\+range\+\_\+enc\+\_\+arfcns()}.



Referenced by \textbf{ \+\_\+range\+\_\+enc\+\_\+arfcns()}, and \textbf{ range\+\_\+encode()}.

\mbox{\label{gsm48__arfcn__range__encode_8h_ae599d5450ead96df515efce6ade5dda2}} 
\index{gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}!osmo\_gsm48\_range\_enc\_determine\_range@{osmo\_gsm48\_range\_enc\_determine\_range}}
\index{osmo\_gsm48\_range\_enc\_determine\_range@{osmo\_gsm48\_range\_enc\_determine\_range}!gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_determine\_range()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+determine\+\_\+range (\begin{DoxyParamCaption}\item[{const int $\ast$}]{arfcns,  }\item[{const int}]{size,  }\item[{int $\ast$}]{f0 }\end{DoxyParamCaption})}



This implements the range determination as described in GSM 04.\+08 J4. 

The result will be a base frequency f0 and the range to use. Note that for range 1024 encoding f0 always refers to ARFCN 0 even if it is not an element of the arfcns list.


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em arfcns} & The input frequencies, they must be sorted, lowest number first \\
\hline
\mbox{\texttt{ in}}  & {\em size} & The length of the array \\
\hline
\mbox{\texttt{ out}}  & {\em f0} & The selected F0 base frequency. It might not be inside the list \\
\hline
\end{DoxyParams}


References \textbf{ OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+1024}, \textbf{ OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+128}, \textbf{ OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+256}, \textbf{ OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+512}, and \textbf{ OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+\+INVALID}.

\mbox{\label{gsm48__arfcn__range__encode_8h_ae3d9290d7db3d20151d6ab751089fd3e}} 
\index{gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}!osmo\_gsm48\_range\_enc\_filter\_arfcns@{osmo\_gsm48\_range\_enc\_filter\_arfcns}}
\index{osmo\_gsm48\_range\_enc\_filter\_arfcns@{osmo\_gsm48\_range\_enc\_filter\_arfcns}!gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_filter\_arfcns()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+filter\+\_\+arfcns (\begin{DoxyParamCaption}\item[{int $\ast$}]{arfcns,  }\item[{const int}]{sze,  }\item[{const int}]{f0,  }\item[{int $\ast$}]{f0\+\_\+included }\end{DoxyParamCaption})}



References \textbf{ mod()}.



Referenced by \textbf{ range\+\_\+encode()}.

\mbox{\label{gsm48__arfcn__range__encode_8h_ad05f36203e4c9891781263fec923e8c3}} 
\index{gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}!osmo\_gsm48\_range\_enc\_find\_index@{osmo\_gsm48\_range\_enc\_find\_index}}
\index{osmo\_gsm48\_range\_enc\_find\_index@{osmo\_gsm48\_range\_enc\_find\_index}!gsm48\_arfcn\_range\_encode.h@{gsm48\_arfcn\_range\_encode.h}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_find\_index()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+find\+\_\+index (\begin{DoxyParamCaption}\item[{enum \textbf{ osmo\+\_\+gsm48\+\_\+range}}]{range,  }\item[{const int $\ast$}]{freqs,  }\item[{const int}]{size }\end{DoxyParamCaption})}



Determine at which index to split the ARFCNs to create an equally size partition for the given range. 

Return -\/1 if no such partition exists. 

References \textbf{ mod()}, and \textbf{ n}.



Referenced by \textbf{ \+\_\+range\+\_\+enc\+\_\+arfcns()}.

