MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / prepare_session

Method prepare_session

src/board_controller/streaming_board.cpp:29–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29int StreamingBoard::prepare_session ()
30{
31 if (initialized)
32 {
33 safe_logger (spdlog::level::info, "Session is already prepared");
34 return (int)BrainFlowExitCodes::STATUS_OK;
35 }
36 if (params.master_board == (int)BoardIds::NO_BOARD)
37 {
38 safe_logger (spdlog::level::err, "Master board id is not provided");
39 return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
40 }
41 try
42 {
43 board_id = params.master_board;
44 board_descr = boards_struct.brainflow_boards_json["boards"][std::to_string (board_id)];
45 }
46 catch (json::exception &e)
47 {
48 safe_logger (spdlog::level::err, "Invalid json for master board");
49 safe_logger (spdlog::level::err, e.what ());
50 return (int)BrainFlowExitCodes::GENERAL_ERROR;
51 }
52 catch (const std::exception &e)
53 {
54 safe_logger (spdlog::level::err,
55 "Write board id for the board which streams data to other_info field");
56 safe_logger (spdlog::level::err, e.what ());
57 return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
58 }
59
60 // default preset
61 if ((!params.ip_address.empty ()) && (params.ip_port != 0))
62 {
63 MultiCastClient *client = new MultiCastClient (params.ip_address.c_str (), params.ip_port);
64 clients.push_back (client);
65 presets.push_back ((int)BrainFlowPresets::DEFAULT_PRESET);
66 }
67 if ((!params.ip_address.empty ()) != (params.ip_port != 0))
68 {
69 safe_logger (spdlog::level::warn, "ip_address or ip_port is not specified");
70 }
71 // aux preset
72 if ((!params.ip_address_aux.empty ()) && (params.ip_port_aux != 0))
73 {
74 MultiCastClient *client =
75 new MultiCastClient (params.ip_address_aux.c_str (), params.ip_port_aux);
76 clients.push_back (client);
77 presets.push_back ((int)BrainFlowPresets::AUXILIARY_PRESET);
78 }
79 if ((!params.ip_address_aux.empty ()) != (params.ip_port_aux != 0))
80 {
81 safe_logger (spdlog::level::warn, "ip_address_aux or ip_port_aux is not specified");
82 }
83 // anc preset
84 if ((!params.ip_address_anc.empty ()) && (params.ip_port_anc != 0))
85 {
86 MultiCastClient *client =

Callers

nothing calls this directly

Calls 3

whatMethod · 0.80
emptyMethod · 0.80
initMethod · 0.45

Tested by

no test coverage detected