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