1 /* 2 * Copyright 2018 Oticon A/S 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #ifndef P2G4_MODEM_IF 7 #define P2G4_MODEM_IF 8 9 #include "bs_types.h" 10 #include "bs_pc_2G4_types.h" 11 #include "p2G4_pending_tx_rx_list.h" 12 #include "modem_if_types.h" 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 /** 19 * Initialize the modem internal status 20 * 21 * The input parameters are: 22 * dev_nbr : the device number this modem library corresponds to 23 * (note that this library may be reused in between several devices) 24 * nbr_devices : the total number of devices in the simulation (gives the length of vectors later) 25 * char *argv[] : a set of arguments passed to the modem library (same convention as POSIX main() command line arguments) 26 * int argc : the number of arguments passed to the modem library 27 * 28 * It is up to the modem to define which arguments it can or shall receive to configure it 29 * The only argument all modems shall understand is : 30 * [-h] [--h] [--help] [-?] 31 * The modem shall print a list of arguments it supports with a descriptive message for each 32 * 33 * This function shall return a pointer to this modems status structure 34 * This same pointer will be passed back to consecutive function calls of the library (void *this) 35 * 36 * If the library does not require to keep any status it can just return NULL 37 */ 38 void* modem_init(int argc, char *argv[], uint dev_nbr, uint nbr_devices); 39 40 /** 41 * Calculate the SNR of the desired input signal at the digital modem input/analog output 42 * including all modem analog impairments 43 * 44 * inputs: 45 * this : Pointer to this modem object 46 * rx_radioparams : Radio parameters/configuration of this receiver for this Rx/RSSI measurement 47 * rx_powers : For each possible transmitter ([0..n_devices-1]) what is their power level at this device antenna connector in dBm 48 * txl_c : For each possible transmitter what are their Tx parameters 49 * desired_tx_nbr : which of the transmitters is the one we are trying to receive 50 * 51 * outputs: 52 * OutputSNR : SNR in the analog output / digital input of this modem (dB) 53 * Output_RSSI_power_level : RSSI level (analog, dBm) sent to the modem digital 54 */ 55 void modem_analog_rx(void *this, p2G4_radioparams_t *rx_radioparams, double *OutputSNR,double *Output_RSSI_power_level, 56 double *rx_powers, tx_l_c_t *txl_c, uint desired_tx_nbr); 57 58 /** 59 * Return the bit error probability ([0.. RAND_PROB_1]) for a given SNR 60 * 61 * inputs: 62 * this : Pointer to this modem object 63 * rx_modemparams : Modem parameters/configuration of this receiver for this Rx/RSSI measurement 64 * SNR : SNR level at the analog output as calculated by modem_analog_rx() 65 */ 66 uint32_t modem_digital_perf_ber(void *this, p2G4_modemdigparams_t *rx_modemparams, double SNR); 67 68 /** 69 * Return the probability of the packet sync'ing ([0.. RAND_PROB_1]) for a given SNR and 70 * transmission parameters 71 * 72 * (note that this should ONLY include excess packet error probability, 73 * as over the sync word and address normal bit errors will also be calculated) 74 * 75 * inputs: 76 * this : Pointer to this modem object 77 * rx_modemparams : Modem parameters/configuration of this receiver for this Rx/RSSI measurement 78 * SNR : SNR level at the analog output as calculated by modem_analog_rx() 79 * tx_s : Parameters of the transmission we are receiving (in case the sync. probability depends on any of them) 80 */ 81 uint32_t modem_digital_perf_sync(void *this, p2G4_modemdigparams_t *rx_modemparams, double SNR, p2G4_txv2_t* tx_s); 82 83 /** 84 * Return the digital RSSI value the modem would have produced for this given 85 * RSSI_power_level in the digital input 86 * 87 * inputs: 88 * this : Pointer to this modem object 89 * rx_radioparams : Radio parameters/configuration of this receiver for this Rx/RSSI measurement 90 * RSSI_power_level : Analog power level as measured by modem_analog_rx() 91 * 92 * outputs: 93 * RSSI : RSSI "digital" value returned by this modem, following the p2G4_rssi_power_t format (16.16 signed value) * 94 */ 95 void modem_digital_RSSI(void *this, p2G4_radioparams_t *rx_radioparams, double RSSI_power_level, p2G4_rssi_power_t *RSSI); 96 97 /** 98 * Clean up: Free the memory the modem may have allocated 99 * close any file descriptors etc. 100 * (the simulation has ended) 101 */ 102 void modem_delete(void *this); 103 104 #ifdef __cplusplus 105 } 106 #endif 107 108 #endif 109