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

Method prepare_session

src/board_controller/emotibit/emotibit.cpp:37–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37int Emotibit::prepare_session ()
38{
39 if (initialized)
40 {
41 safe_logger (spdlog::level::info, "Session is already prepared");
42 return (int)BrainFlowExitCodes::STATUS_OK;
43 }
44
45 if (params.timeout < 2)
46 {
47 params.timeout = 4;
48 }
49
50 int res = create_adv_connection ();
51 if (res == (int)BrainFlowExitCodes::STATUS_OK)
52 {
53 res = create_data_connection ();
54 }
55 if (res == (int)BrainFlowExitCodes::STATUS_OK)
56 {
57 res = create_control_connection ();
58 }
59 if (res == (int)BrainFlowExitCodes::STATUS_OK)
60 {
61 res = send_connect_msg ();
62 }
63 if (res == (int)BrainFlowExitCodes::STATUS_OK)
64 {
65 res = wait_for_connection ();
66 }
67 if (res == (int)BrainFlowExitCodes::STATUS_OK)
68 {
69 res = send_control_msg (MODE_LOW_POWER);
70 }
71
72 if (res != (int)BrainFlowExitCodes::STATUS_OK)
73 {
74 if (adv_socket != NULL)
75 {
76 delete adv_socket;
77 adv_socket = NULL;
78 }
79 if (data_socket != NULL)
80 {
81 delete data_socket;
82 data_socket = NULL;
83 }
84 if (control_socket != NULL)
85 {
86 delete control_socket;
87 control_socket = NULL;
88 }
89 }
90 else
91 {
92 initialized = true;
93 connection_thread = std::thread ([this] { this->ping_thread (); });
94 }

Callers

nothing calls this directly

Calls 1

ping_threadMethod · 0.95

Tested by

no test coverage detected