1 /*
2  * Copyright 2018 Oticon A/S
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #include "bs_types.h"
7 #include "p2G4_pending_tx_rx_list.h"
8 #include "channel_NtNcable_args.h"
9 #include "channel_if.h"
10 
11 static uint n_devices;
12 static ch_NtN_args_t args;
13 
14 /**
15  * Initialize the channel
16  */
channel_init(int argc,char * argv[],uint n_devs)17 int channel_init(int argc, char *argv[], uint n_devs){
18   n_devices = n_devs;
19 
20   channel_NtNcable_argparse(argc, argv, &args);
21   return 0;
22 }
23 
24 /**
25  * Recalculate the fading and path loss of the channel in this current moment (<now>)
26  * in between the N used paths and the receive path (<rxnbr>)
27  *
28  * inputs:
29  *  tx_used    : array with n_devs elements, 0: that tx is not transmitting,
30  *                                           1: that tx is transmitting,
31  *               e.g. {0,1,1,0}: devices 1 and 2 are transmitting, device 0 and 3 are not.
32  *  tx_list    : array with all transmissions status (the channel can check here the modulation type of the transmitter if necessary)
33  *               (ignored in this channel)
34  *  txnbr      : desired transmitter number (the channel will calculate the ISI only for the desired transmitter)
35  *               (ignored in this channel)
36  *  rxnbr      : device number which is receiving
37  *               (ignored in this channel)
38  *  now        : current time
39  *               (ignored in this channel)
40  *  att        : array with n_devs elements. The channel will overwrite the element i
41  *               with the average attenuation from path i to rxnbr (in dBs)
42  *               The caller allocates this array
43  *  ISI_SNR    : The channel will return here an estimate of the SNR limit due to multipath
44  *               caused ISI for the desired transmitter (in dBs)
45  *               (This channel sets this value always to 100.0)
46  *
47  * Returns < 0 on error.
48  * 0 otherwise
49  */
channel_calc(const uint * tx_used,tx_el_t * tx_list,uint txnbr,uint rxnbr,bs_time_t now,double * att,double * ISI_SNR)50 int channel_calc(const uint *tx_used, tx_el_t *tx_list, uint txnbr, uint rxnbr, bs_time_t now, double *att, double *ISI_SNR){
51   uint i;
52   for ( i = 0 ; i < n_devices; i++ ){
53       att[i] = args.attenuation;
54   }
55   *ISI_SNR = 100;
56 
57   return 0;
58 }
59 
60 /**
61  * Clean up: Free the memory the channel may have allocate
62  * close any file descriptors etc.
63  * (the simulation has ended)
64  */
channel_delete()65 void channel_delete(){
66 
67 }
68