hw_device_mnt.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /***********************************//**
  2. * @file hw_device_mnt.h
  3. * @author Gifur
  4. * @email guifaliao@gmail.com
  5. * @version 1.1.0.0
  6. * @date 2020-07-23
  7. * @copyright China Merchants Bank Co.,Ltd All rights reserved
  8. *
  9. * @brief
  10. * @details
  11. **************************************/
  12. #pragma once
  13. #include <cstdio>
  14. #include <string>
  15. #include <vector>
  16. #ifdef HWMOBILEDLL_EXPORTS
  17. #define HWMOBILE_API _declspec(dllexport)
  18. #else
  19. #define HWMOBILE_API _declspec(dllimport)
  20. #pragma comment(lib, "HWMobileDll.lib")
  21. #endif
  22. namespace hw
  23. {
  24. enum auth_mode_em
  25. {
  26. auth_auto = 0,
  27. auth_pap,
  28. auth_chap,
  29. auth_none
  30. };
  31. enum ip_type_em
  32. {
  33. //0:ipv4; 1:ipv6; 2:ipv4&v6
  34. ipv4 = 0,
  35. ipv6,
  36. ipv46
  37. };
  38. enum connect_status_em
  39. {
  40. invalid = 0,
  41. connecting,
  42. connected,
  43. disconnected,
  44. disconnecting,
  45. connect_failed,
  46. connect_failed_with_poor,
  47. other,
  48. no_service,
  49. connect_dial_up_param_failed
  50. };
  51. enum sim_status_em
  52. {
  53. invalid_sim,
  54. valid_sim,
  55. sim_not_found
  56. };
  57. #define MBB_STR_BUF_LEN 256
  58. struct apn_config_t
  59. {
  60. wchar_t profile_name[MBB_STR_BUF_LEN];
  61. wchar_t apn_name[MBB_STR_BUF_LEN];
  62. wchar_t username[MBB_STR_BUF_LEN];
  63. wchar_t password[MBB_STR_BUF_LEN];
  64. auth_mode_em auth_mode;
  65. ip_type_em ip_type;
  66. };
  67. struct wlan_config_t
  68. {
  69. wchar_t ssid[MBB_STR_BUF_LEN];
  70. wchar_t password[MBB_STR_BUF_LEN];
  71. bool hidden;
  72. };
  73. struct connect_profile_t
  74. {
  75. uint32_t index;
  76. apn_config_t apn_config;
  77. bool is_default;
  78. };
  79. struct wlan_status_t
  80. {
  81. bool started;
  82. wlan_config_t wlan_config;
  83. };
  84. struct network_info_t
  85. {
  86. connect_status_em connect_status;
  87. uint8_t signal_strength;
  88. uint8_t network_type;
  89. uint8_t battery_percent;
  90. bool roaming;
  91. bool sim_locked;
  92. sim_status_em sim_status;
  93. bool wifi_status;
  94. int32_t wifi_current_user_count;
  95. bool usb_plug_in_status;
  96. wchar_t dev_name[MBB_STR_BUF_LEN];
  97. };
  98. struct dev_info_t
  99. {
  100. wchar_t dev_name[MBB_STR_BUF_LEN];
  101. wchar_t provider_name[MBB_STR_BUF_LEN];
  102. wchar_t sn[MBB_STR_BUF_LEN];
  103. wchar_t work_mode[MBB_STR_BUF_LEN];
  104. wchar_t hardware_version[MBB_STR_BUF_LEN];
  105. wchar_t iccid[MBB_STR_BUF_LEN];
  106. wchar_t imsi[MBB_STR_BUF_LEN];
  107. wchar_t extend_msg[MBB_STR_BUF_LEN];
  108. network_info_t network_status;
  109. };
  110. struct mac_filter_t
  111. {
  112. int mac_filter_mode;
  113. wchar_t mac_filter[MBB_STR_BUF_LEN];
  114. };
  115. #define CURRENT_NETWORK_NO_SERVICE 0
  116. #define SERVICE_DOMAIN_NO_SERVICE 0
  117. #define SERVICE_STATUS_AVAILABLE 2
  118. class HWMOBILE_API hw_device_mnt
  119. {
  120. public:
  121. hw_device_mnt();
  122. ~hw_device_mnt();
  123. /*检测MIFI设备是否存在*/
  124. bool detect_devices();
  125. /*登录到MIFI设备*/
  126. int login(std::wstring const& username, std::wstring const& password);
  127. /*更改MIFI的登录密码*/
  128. int change_password(std::wstring const& username, std::wstring const& current_password, std::wstring const& new_password);
  129. /*获取APN配置文件列表*/
  130. int get_connect_profiles(std::vector<connect_profile_t>& profiles);
  131. /*获取APN配置文件列表*/
  132. int get_profiles(connect_profile_t* profile, const int profile_capacity);
  133. /*设置当前的APN配置文件*/
  134. int set_default_profile_by(const uint32_t profile_idx);
  135. /*添加APN配置文件,set_as_default 指定是否将新添加的配置文件设备默认的*/
  136. int add_profile(const apn_config_t& config, bool set_as_default);
  137. /*更新APN配置文件*/
  138. int update_profile(const connect_profile_t& profile);
  139. /*根据APN配置文件的序号,删除指定的配置文件*/
  140. int delete_profile_by(const uint32_t profile_idx);
  141. /*根据APN配置文件的名称,删除指定的配置文件*/
  142. int delete_profile(std::wstring profile_name);
  143. /*切换是否自动连接(拨号)*/
  144. int switch_auto_dial(bool enable = true);
  145. /*断开网络拨号连接*/
  146. int disconnect();
  147. /*拨号连接*/
  148. int connect();
  149. /*判断用户是否已经登录*/
  150. bool has_login(bool& first_login);
  151. /*注销*/
  152. int logout();
  153. /*设置WIFI的SSID,密码等相关信息*/
  154. int set_wlan_config(const wlan_config_t& config, bool restart);
  155. /*获取WIFI的SSID,密码等相关信息*/
  156. int get_wlan_config(wlan_config_t& config);
  157. /*查询WIFI状态是否打开*/
  158. bool is_wlan_open();
  159. /*获取SIM卡和设备的一些信息*/
  160. int get_dev_info(dev_info_t& info);
  161. /*获取网络的一些信息*/
  162. int get_network_info(network_info_t& info);
  163. /*激活并将新条目加入白名单*/
  164. int insert_mac_filter(const mac_filter_t& info);
  165. private:
  166. int connect_pending(bool to_connect);
  167. };
  168. }