1 /*
2 * Copyright 2018 Oticon A/S
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6 #include "modem_if.h"
7 #include "bs_pc_base.h"
8 #include "bs_pc_base.h"
9 #include "bs_pc_2G4_utils.h"
10 #include <stdlib.h>
11 #include <stdio.h>
12
13 //compile as
14 /* gcc test_analog_rx.c ../modem_BLE_simple.c ../modem_BLE_simple_args.c \
15 -I../../../ext_2G4_libPhyComv1/src/ -I../../../libRandv2/src/ \
16 -I../../../libPhyComv1/src/ -I../../../ext_2G4_phy_v1/src/ \
17 -I../../../libUtilv1/src/ ../../../../lib/libUtilv1.a \
18 ../../../../lib/libPhyComv1.a ../../../../lib/libRandv2.a ../../../../lib/lib2G4PhyComv1.a \
19 ../../../../lib/libUtilv1.a ../../../../lib/libPhyComv1.a ../../../../lib/libRandv2.a \
20 -lm -o test_ana -std=c99 -Wall -pedantic -g
21 */
22 //run as ./test_ana
23 //the results can be compared against the MATLAB reference (test_ana.m)
24
main(int argc,char ** argv)25 int main(int argc, char**argv){
26
27 #define Ndevices 15
28 uint device_nbr = 0;
29 uint nbr_devices = Ndevices;
30 void* ModemObj;
31 double RxPowers[Ndevices];
32 tx_l_c_t Tx_List_container;
33 uint desired_tx_nbr;
34 p2G4_radioparams_t RxRadioParams;
35
36 Tx_List_container.tx_list = calloc(sizeof(tx_el_t), Ndevices);
37 Tx_List_container.used = calloc(sizeof(uint), Ndevices);
38
39 ModemObj = modem_init(argc-1, &argv[1], device_nbr, nbr_devices);
40
41 RxPowers[0] = 0;
42 RxPowers[1] = -70; //1
43 RxPowers[2] = -60; //desired
44 RxPowers[3] = -60; //2
45 RxPowers[4] = -50; //3
46 RxPowers[5] = -80; //4
47 RxPowers[6] = 0;
48 RxPowers[7] = -80; //5
49 RxPowers[9] = -70; //6
50 RxPowers[10] = -60; //7
51
52 desired_tx_nbr = 2;
53 Tx_List_container.used[2] = 1;
54 RxRadioParams.modulation = P2G4_MOD_BLE2M;
55 p2G4_freq_from_d( 2450, 0, &RxRadioParams.center_freq );
56
57
58 Tx_List_container.tx_list[1].tx_s.radio_params.modulation = P2G4_MOD_BLE;
59 p2G4_freq_from_d( 2448e6, 0, &Tx_List_container.tx_list[1].tx_s.radio_params.center_freq );
60 Tx_List_container.used[1] = 1;
61
62 Tx_List_container.tx_list[3].tx_s.radio_params.modulation = P2G4_MOD_WHITENOISE1MHz;
63 p2G4_freq_from_d( 2446e6, 0, &Tx_List_container.tx_list[3].tx_s.radio_params.center_freq );
64 Tx_List_container.used[3] = 1;
65
66 Tx_List_container.tx_list[4].tx_s.radio_params.modulation = P2G4_MOD_CWINTER;
67 p2G4_freq_from_d( 2446e6, 0, &Tx_List_container.tx_list[4].tx_s.radio_params.center_freq );
68 Tx_List_container.used[4] = 1;
69
70 Tx_List_container.tx_list[5].tx_s.radio_params.modulation = P2G4_MOD_WHITENOISE4MHz;
71 p2G4_freq_from_d( 2449e6, 0, &Tx_List_container.tx_list[5].tx_s.radio_params.center_freq );
72 Tx_List_container.used[5] = 1;
73
74 Tx_List_container.tx_list[7].tx_s.radio_params.modulation = P2G4_MOD_WHITENOISE2MHz;
75 p2G4_freq_from_d( 2451e6, 0, &Tx_List_container.tx_list[7].tx_s.radio_params.center_freq );
76 Tx_List_container.used[7] = 1;
77
78 Tx_List_container.tx_list[9].tx_s.radio_params.modulation = P2G4_MOD_PROP4M; //should not contribute at all
79 p2G4_freq_from_d( 2448e6, 0, &Tx_List_container.tx_list[9].tx_s.radio_params.center_freq );
80 Tx_List_container.used[9] = 1;
81
82
83 Tx_List_container.tx_list[10].tx_s.radio_params.modulation = P2G4_MOD_PROP2M; //should not contribute at all
84 p2G4_freq_from_d( 2448e6, 0, &Tx_List_container.tx_list[10].tx_s.radio_params.center_freq );
85 Tx_List_container.used[10] = 1;
86
87 double OutputSNR;
88 double Output_RSSI_power_level;
89
90 modem_analog_rx(ModemObj, &RxRadioParams, &OutputSNR, &Output_RSSI_power_level,
91 RxPowers, &Tx_List_container, desired_tx_nbr);
92
93 modem_delete(ModemObj);
94
95 free(Tx_List_container.tx_list);
96 free(Tx_List_container.used);
97
98 fprintf(stdout,"SNR: %f\tRSSI:%f\n", OutputSNR, Output_RSSI_power_level);
99 }
100