| 257 | } |
| 258 | |
| 259 | int AAVAAv3::release_session () |
| 260 | { |
| 261 | if (initialized) |
| 262 | { |
| 263 | // repeat it multiple times, failure here may lead to a crash |
| 264 | for (int i = 0; i < 2; i++) |
| 265 | { |
| 266 | stop_stream (); |
| 267 | // need to wait for notifications to stop triggered before unsubscribing, otherwise |
| 268 | // macos fails inside simpleble with timeout |
| 269 | #ifdef _WIN32 |
| 270 | Sleep (1000); |
| 271 | #else |
| 272 | sleep (1); |
| 273 | #endif |
| 274 | if (simpleble_peripheral_unsubscribe (aavaa_peripheral, notified_characteristics.first, |
| 275 | notified_characteristics.second) != SIMPLEBLE_SUCCESS) |
| 276 | { |
| 277 | safe_logger (spdlog::level::err, "failed to unsubscribe for {} {}", |
| 278 | notified_characteristics.first.value, notified_characteristics.second.value); |
| 279 | } |
| 280 | else |
| 281 | { |
| 282 | safe_logger (spdlog::level::trace, "unsubscribed successfully."); |
| 283 | break; |
| 284 | } |
| 285 | } |
| 286 | safe_logger (spdlog::level::trace, "freeing packages."); |
| 287 | free_packages (); |
| 288 | initialized = false; |
| 289 | } |
| 290 | if (aavaa_peripheral != NULL) |
| 291 | { |
| 292 | safe_logger (spdlog::level::info, "peripheral is not NULL."); |
| 293 | bool is_connected = false; |
| 294 | if (simpleble_peripheral_is_connected (aavaa_peripheral, &is_connected) == |
| 295 | SIMPLEBLE_SUCCESS) |
| 296 | { |
| 297 | if (is_connected) |
| 298 | { |
| 299 | simpleble_peripheral_disconnect (aavaa_peripheral); |
| 300 | } |
| 301 | } |
| 302 | simpleble_peripheral_release_handle (aavaa_peripheral); |
| 303 | aavaa_peripheral = NULL; |
| 304 | } |
| 305 | if (aavaa_adapter != NULL) |
| 306 | { |
| 307 | safe_logger (spdlog::level::info, "adapter is not NULL."); |
| 308 | simpleble_adapter_release_handle (aavaa_adapter); |
| 309 | aavaa_adapter = NULL; |
| 310 | } |
| 311 | safe_logger (spdlog::level::trace, "released successfully."); |
| 312 | return (int)BrainFlowExitCodes::STATUS_OK; |
| 313 | } |
| 314 | |
| 315 | int AAVAAv3::config_board (std::string config, std::string &response) |
| 316 | { |
nothing calls this directly
no test coverage detected