com_config.h
Last updated: 25-Feb-2025
Go to the documentation of this file.
1Â #ifndef _COM_CONFIG_H_ 2Â #define _COM_CONFIG_H_ 3Â 4Â #include <vector> 5Â #include <string> 6Â #include <pthread.h> 7Â #include "ipc/jsobject.h" 8Â 10Â class ComConfig 11Â { 12Â private: 13Â // disable copy constructor and assign operator 14Â ComConfig(const ComConfig&); 15Â ComConfig& operator=(const ComConfig&); 16Â #if __cplusplus >= 201103L // since C++11 also forbid usage of move 17Â ComConfig(const ComConfig&&); 18Â ComConfig& operator=(ComConfig&&); 19Â #endif 20Â 21Â // mutex protecting members 22Â pthread_mutex_t m_mutex; 23Â 26Â std::string m_profile; 27Â std::vector<std::string> m_whitelist; 28Â std::string m_bt_address; 29Â std::string m_bt_device; 30Â std::string m_com1a_address; 31Â std::string m_com1a_device; 32Â bool m_com1a_btclient_reconnect_idle; 33Â unsigned m_com1a_mode; 34Â bool m_com1a_btserver_pairing_idle; 35Â std::string m_ble_address; 36Â std::string m_ble_device; 37Â std::string m_bt_own_device_name; 38Â unsigned m_bt_num_paired; 42Â int m_idx; 43Â std::vector<unsigned> m_idx_list; 45Â ComConfig(); 46Â virtual ~ComConfig(); 47Â 48Â public: 49Â // operation modes for COM1A profile 50Â enum Com1aMode 51Â { 52Â Com1a_Usb = 0, // COM1A USB (default) 53Â Com1a_BtClient = 1, // COM1A BT-client 54Â Com1a_BtServer = 2 // COM1A BT-server 55Â }; 56Â 59Â static ComConfig& getInstance(); 60Â 63Â inline void lock() 64Â { 65Â pthread_mutex_lock(&m_mutex); 66Â } 68Â inline void unlock() 69Â { 70Â pthread_mutex_unlock(&m_mutex); 71Â } 74Â inline pthread_mutex_t &getMutex() 75Â { 76Â return m_mutex; 77Â } 78Â 83Â inline std::string& profile() 84Â { 85Â return m_profile; // written/changed by select_com_profile() 86Â } 89Â inline const std::vector<std::string>& whitelist() 90Â { 91Â return m_whitelist; 92Â } 95Â inline std::string& bt_address() 96Â { 97Â return m_bt_address; // written/changes by bt_pan_menu() 98Â } 101Â inline std::string& bt_device() 102Â { 103Â return m_bt_device; // written/changes by bt_pan_menu() 104Â } 107Â inline std::string& com1a_address() 108Â { 109Â return m_com1a_address; // written/changes by com1a_menu() 110Â } 113Â inline std::string& com1a_device() 114Â { 115Â return m_com1a_device; // written/changes by com1a_menu() 116Â } 119Â inline bool& com1a_btclient_reconnect_idle() 120Â { 121Â return m_com1a_btclient_reconnect_idle; // written/changed by com1a_menu() 122Â } 125Â inline unsigned& com1a_mode() 126Â { 127Â return m_com1a_mode; // written/changed by com1a_menu() 128Â } 131Â inline bool& com1a_btserver_pairing_idle() 132Â { 133Â return m_com1a_btserver_pairing_idle; // written/changed by com1a_menu() 134Â } 137Â inline std::string& ble_address() 138Â { 139Â return m_ble_address; // written/changed by bt_pairing_submenu() 140Â } 143Â inline std::string& ble_device() 144Â { 145Â return m_ble_device; // written/changed by bt_pairing_submenu() 146Â } 149Â inline const std::string& bt_own_device_name() 150Â { 151Â return m_bt_own_device_name; // written/changed by activateConnectionProfile() 152Â } 155Â inline unsigned bt_num_paired() 156Â { 157Â return m_bt_num_paired; 158Â } 159Â 162Â inline int& idx() 163Â { 164Â return m_idx; // written/changed by select_com_profile() and displayCOMMenu() 165Â } 168Â inline std::vector<unsigned>& idx_list() 169Â { 170Â return m_idx_list; // written/changed by select_com_profile() 171Â } 172Â 174Â void clear(); 175Â 182Â void read(bool *storage_needed = 0); 183Â 185Â void store(); 186Â 190Â static std::string getCom1aModeName(unsigned mode); 191Â 200Â static bool load(const std::string &com_if_file, vfiipc::JSObject &res, bool *storage_needed = 0); 201Â 203Â enum MultiConnectMode 204Â { 205Â MCM_Default = 0, 206Â MCM_Enabled = 1, 207Â MCM_Disabled = 2 208Â }; 214Â static enum MultiConnectMode getMultiConnectMode(); 215Â }; 216Â 217Â #endif // _COM_CONFIG_H_ 218Â
Rate this article: