1 /*
2  * Copyright 2018 Oticon A/S
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #include <stdlib.h>
7 #include "bs_playback_args.h"
8 #include "bs_tracing.h"
9 #include "bs_oswrap.h"
10 
11 char executable_name[] = "bs_device_2G4_playback";
component_print_post_help()12 void component_print_post_help(){
13   fprintf(stdout,"This devices plays back the activity of another device as it was recorded by the\n"
14           "phy in a previous simulation\n\n");
15 }
16 
17 playback_args_t *args_g;
18 
cmd_trace_lvl_found(char * argv,int offset)19 static void cmd_trace_lvl_found(char * argv, int offset){
20   bs_trace_set_level(args_g->verb);
21 }
22 
cmd_gdev_nbr_found(char * argv,int offset)23 static void cmd_gdev_nbr_found(char * argv, int offset){
24   bs_trace_set_prefix_dev(args_g->global_device_nbr);
25 }
26 
27 /**
28  * Check the arguments provided in the command line: set args based on it or defaults,
29  * and check they are correct
30  */
bs_playback_argsparse(int argc,char * argv[],playback_args_t * args)31 void bs_playback_argsparse(int argc, char *argv[], playback_args_t *args)
32 {
33   args_g = args;
34   bs_args_struct_t args_struct[] = {
35       BS_BASIC_DEVICE_2G4_FAKE_OPTIONS_ARG_STRUCT,
36       { false, true  , false,"inputf",  "inputfile", 's', (void*)&args->inputf,    NULL, "Path and begining of the dump files names to be played back: <inputfile>.Tx.csv <inputfile>.Rx.csv  <inputfile>.RSSI.csv"},\
37       { false, false , true, "txoff",   "txoff",     'b', (void*)&(args->txoff),   NULL, "Dont send Tx requests"},
38       { false, false , true, "rxoff",   "rxoff",     'b', (void*)&(args->rxoff),   NULL, "Dont send Rx requests"},
39       { false, false , true, "rssioff", "rssioff",   'b', (void*)&(args->rssioff), NULL, "Dont send RSSI requests"},
40       ARG_TABLE_ENDMARKER
41   };
42 
43   bs_args_typical_dev_set_defaults((bs_basic_dev_args_t *)args, args_struct);
44   static char default_phy[] ="2G4";
45 
46   bs_args_parse_cmd_line(argc, argv, args_struct);
47 
48   bs_args_typical_dev_post_check((bs_basic_dev_args_t *)args, args_struct, default_phy);
49   if ( args->inputf == NULL ) {
50     bs_args_print_switches_help(args_struct);
51     bs_trace_error_line("The input file needs to be specified\n");
52   }
53 }
54