@@ -12,15 +12,13 @@ using json = nlohmann::json;
1212
1313constexpr int KnightBase::start_byte;
1414constexpr int KnightBase::end_byte;
15- const std::set<int > KnightBase::allowed_gains = {1 , 2 , 3 , 4 , 6 , 8 , 12 };
1615
1716KnightBase::KnightBase (int board_id, struct BrainFlowInputParams params) : Board (board_id, params)
1817{
1918 serial = NULL ;
2019 is_streaming = false ;
2120 keep_alive = false ;
2221 initialized = false ;
23- gain = 12 ; // default gain value
2422}
2523
2624KnightBase::~KnightBase ()
@@ -42,46 +40,6 @@ int KnightBase::prepare_session ()
4240 return (int )BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
4341 }
4442
45- // Parse gain from other_info if provided
46- if (!params.other_info .empty ())
47- {
48- try
49- {
50- json j = json::parse (params.other_info );
51- if (j.contains (" gain" ))
52- {
53- int parsed_gain = j[" gain" ];
54- // Validate gain is one of allowed values
55- if (allowed_gains.count (parsed_gain))
56- {
57- gain = parsed_gain;
58- safe_logger (spdlog::level::info, " Knight board gain set to {}" , gain);
59- }
60- else
61- {
62- safe_logger (
63- spdlog::level::err, " Invalid gain value {} in other_info" , parsed_gain);
64- return (int )BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
65- }
66- }
67- else
68- {
69- safe_logger (spdlog::level::info, " No gain field in other_info, using default 12" );
70- }
71- }
72- catch (json::parse_error &e)
73- {
74- safe_logger (spdlog::level::err, " Failed to parse JSON from other_info: {}" , e.what ());
75- return (int )BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
76- }
77- catch (json::exception &e)
78- {
79- safe_logger (
80- spdlog::level::err, " JSON exception while parsing other_info: {}" , e.what ());
81- return (int )BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
82- }
83- }
84-
8543 serial = Serial::create (params.serial_port .c_str (), this );
8644 int port_open = open_port ();
8745 if (port_open != (int )BrainFlowExitCodes::STATUS_OK)
0 commit comments