| 692 | } |
| 693 | |
| 694 | int Ganglion::call_open () |
| 695 | { |
| 696 | if (dll_loader == NULL) |
| 697 | { |
| 698 | return (int)BrainFlowExitCodes::BOARD_NOT_READY_ERROR; |
| 699 | } |
| 700 | int res = GanglionLib::CustomExitCodes::GENERAL_ERROR; |
| 701 | if (use_mac_addr) |
| 702 | { |
| 703 | int (*func) (void *) = (int (*) (void *))dll_loader->get_address ("open_ganglion_mac_addr"); |
| 704 | if (func == NULL) |
| 705 | { |
| 706 | safe_logger ( |
| 707 | spdlog::level::err, "failed to get function address for open_ganglion_mac_addr"); |
| 708 | return (int)BrainFlowExitCodes::GENERAL_ERROR; |
| 709 | } |
| 710 | |
| 711 | safe_logger (spdlog::level::info, "search for {}", params.mac_address.c_str ()); |
| 712 | |
| 713 | GanglionLib::ConnectionParameters connection_params; |
| 714 | connection_params.mac_address = const_cast<char *> (params.mac_address.c_str ()); |
| 715 | connection_params.firmware = 2; |
| 716 | |
| 717 | res = func ((void *)&connection_params); |
| 718 | |
| 719 | if (firmware == 0) |
| 720 | { |
| 721 | safe_logger ( |
| 722 | spdlog::level::info, "detected firmware version {}", connection_params.firmware); |
| 723 | firmware = connection_params.firmware; |
| 724 | } |
| 725 | } |
| 726 | else |
| 727 | { |
| 728 | int (*func) (void *) = (int (*) (void *))dll_loader->get_address ("open_ganglion"); |
| 729 | if (func == NULL) |
| 730 | { |
| 731 | safe_logger (spdlog::level::err, "failed to get function address for open_ganglion"); |
| 732 | return (int)BrainFlowExitCodes::GENERAL_ERROR; |
| 733 | } |
| 734 | |
| 735 | safe_logger ( |
| 736 | spdlog::level::info, "mac address is not specified, try to find ganglion without it"); |
| 737 | |
| 738 | |
| 739 | if (firmware == 0) |
| 740 | { |
| 741 | res = func ((void *)&firmware); |
| 742 | safe_logger (spdlog::level::info, "detected firmware version {}", firmware); |
| 743 | } |
| 744 | } |
| 745 | if (res != GanglionLib::CustomExitCodes::STATUS_OK) |
| 746 | { |
| 747 | if (res == GanglionLib::CustomExitCodes::PORT_OPEN_ERROR) |
| 748 | { |
| 749 | safe_logger (spdlog::level::err, |
| 750 | "Make sure you provided correct port name and have permissions to open it(run with " |
| 751 | "sudo/admin). And close all other apps using this port."); |
nothing calls this directly
no test coverage detected