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

Method prepare_session

src/board_controller/neuromd/brainbit.cpp:63–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63int BrainBit::prepare_session ()
64{
65 if (initialized)
66 {
67 safe_logger (spdlog::level::info, "Session is already prepared");
68 return (int)BrainFlowExitCodes::STATUS_OK;
69 }
70 // init all function pointers
71 int res = NeuromdBoard::prepare_session ();
72 if (res != (int)BrainFlowExitCodes::STATUS_OK)
73 {
74 return res;
75 }
76
77 // try to find device
78 res = find_device ();
79 if (res != (int)BrainFlowExitCodes::STATUS_OK)
80 {
81 free_device ();
82 return res;
83 }
84 // try to connect to device
85 res = connect_device ();
86 if (res != (int)BrainFlowExitCodes::STATUS_OK)
87 {
88 free_device ();
89 return res;
90 }
91
92 // need to set callbacks for battery charge and resistance data
93 // get info about channels
94 ChannelInfoArray device_channels;
95 int brainbit_code = device_available_channels (device, &device_channels);
96 if (brainbit_code != SDK_NO_ERROR)
97 {
98 char error_msg[1024];
99 sdk_last_error_msg (error_msg, 1024);
100 safe_logger (spdlog::level::err, "get channels error {}", error_msg);
101 free_device ();
102 return (int)BrainFlowExitCodes::GENERAL_ERROR;
103 }
104
105 // set correct callbacks for channels
106 for (size_t i = 0; i < device_channels.info_count; ++i)
107 {
108 //////////////////////////
109 //////// Battery /////////
110 //////////////////////////
111 if (device_channels.info_array[i].type == ChannelTypeBattery)
112 {
113 if (brainbit_code == SDK_NO_ERROR)
114 {
115 brainbit_code = device_subscribe_int_channel_data_received (device,
116 device_channels.info_array[i], &BrainBitCallbacks::on_battery_charge_received,
117 &battery_listener, (void *)this);
118 }
119 }
120 ////////////////////

Callers

nothing calls this directly

Calls 1

prepare_sessionFunction · 0.85

Tested by

no test coverage detected