tb.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. /* Copyright (C) 2016 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef __TB_H__
  13. #define __TB_H__
  14. #include "osi_api.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. //macro
  19. #define TB_SUCCESS 0
  20. #define TB_FAILURE 1
  21. #define TB_GSM_SIGNAL_BAR_5_VALUE 16
  22. #define TB_GSM_SIGNAL_BAR_4_VALUE 13
  23. #define TB_GSM_SIGNAL_BAR_3_VALUE 10
  24. #define TB_GSM_SIGNAL_BAR_2_VALUE 7
  25. #define TB_GSM_SIGNAL_BAR_1_VALUE 3
  26. #define TB_LTE_SIGNAL_BAR_5_VALUE 51
  27. #define TB_LTE_SIGNAL_BAR_4_VALUE 45
  28. #define TB_LTE_SIGNAL_BAR_3_VALUE 39
  29. #define TB_LTE_SIGNAL_BAR_2_VALUE 33
  30. #define TB_LTE_SIGNAL_BAR_1_VALUE 26
  31. #define TB_SIGNAL_BAR_5 "5"
  32. #define TB_SIGNAL_BAR_4 "4"
  33. #define TB_SIGNAL_BAR_3 "3"
  34. #define TB_SIGNAL_BAR_2 "2"
  35. #define TB_SIGNAL_BAR_1 "1"
  36. #define TB_SIGNAL_BAR_0 "0"
  37. #define TB_ROAMING_STATUS_HOME "Home"
  38. #define TB_ROAMING_STATUS_INTERNAL "Internal"
  39. #define TB_ROAMING_STATUS_INTERNATIONAL "International"
  40. #define TB_NET_TYPE_GSM "GSM"
  41. #define TB_NET_TYPE_LTE "LTE"
  42. #define TB_CS_PS_STAUS_CS_ONLY "CS_ONLY"
  43. #define TB_CS_PS_STAUS_PS_ONLY "PS_ONLY"
  44. #define TB_CS_PS_STAUS_CS_PS "CS_PS"
  45. #define TB_CS_PS_STAUS_CAMPED "CAMPED"
  46. #define TB_NETWORK_TYPE_4G "4G"
  47. #define TB_NETWORK_TYPE_2G "2G"
  48. #define TB_NETWORK_TYPE_LIMITED "Limited Service"
  49. #define TB_NETWORK_TYPE_NO_SERVICE "No Service"
  50. #define TB_PROVIDER_LONG_NAME_SIZE 64
  51. #define TB_PROVIDER_SHORT_NAME_SIZE 32
  52. #define TB_NETWORK_TYPE_SIZE 32
  53. #define TB_MCC_MNC_SIZE 3
  54. #define TB_LAC_CODE_SIZE 2
  55. #define TB_CELL_ID_SIZE 4
  56. #define TB_NETWORK_BAND_SIZE 2
  57. #define TB_PROFILE_PARA_LEN 128
  58. #define TB_IPV4_ADDR_LEN 16
  59. #define TB_IPV6_ADDR_LEN 40
  60. #define TB_DATA_STATISTICS_TIME_THRESHOLD 60
  61. #define TB_SMS_SEND_NUM_MAX 5
  62. #define TB_WMS_ADDRESS_LEN_MAX 21
  63. #define TB_SMS_MSG_CONTENT_LEN_MAX 140
  64. #define TB_SMS_CONCAT_SMS_COUNT_MAX 5
  65. #define TB_RESULT_FUPDATE_SUCCESS 200
  66. #define TB_RESULT_FUPDATE_NOPACK 402
  67. #define TB_RESULT_FUPDATE_VERIFY_FAIL 403
  68. #define TB_RESULT_FUPDATE_FAILURE 410
  69. //enum
  70. typedef enum tb_wan_notify_type_enum
  71. {
  72. TB_WAN_NOTIFY_TYPE_SIG_BAR = 0,
  73. TB_WAN_NOTIFY_TYPE_ROAMING_STATUS,
  74. TB_WAN_NOTIFY_TYPE_NET_PROVIDER,
  75. TB_WAN_NOTIFY_TYPE_NET_TYPE,
  76. TB_WAN_NOTIFY_TYPE_CS_PS_STATUS,
  77. TB_WAN_NOTIFY_TYPE_CELL_ID_INFO
  78. } tb_wan_notify_type_e;
  79. typedef enum tb_wan_domain_state_enum
  80. {
  81. TB_WAN_DOMIAN_STATE_UNKOWN = -1,
  82. TB_WAN_DOMAIN_STATE_CS_PS,
  83. TB_WAN_DOMAIN_STATE_CS_ONLY,
  84. TB_WAN_DOMAIN_STATE_PS_ONLY
  85. } tb_wan_domain_state_e;
  86. typedef enum lsdk_wan_roam_status_enum
  87. {
  88. TB_WAN_ROAM_STATUS_UNKOWN = 0,
  89. TB_WAN_ROAM_STATUS_HOME,
  90. TB_WAN_ROAM_STATUS_INTERNAL,
  91. TB_WAN_ROAM_STATUS_INTERNATIONAL
  92. } tb_wan_roam_status_e;
  93. typedef enum
  94. {
  95. TB_PROFILE_ID_MIN_ENUM_VAL = -2147483647,
  96. TB_PROFILE_ID_PUBLIC = 1,
  97. TB_PROFILE_ID_PRIVATE = 2,
  98. TB_PROFILE_ID_MAX_ENUM_VAL = 2147483647
  99. } tb_data_profile_id;
  100. typedef enum
  101. {
  102. TB_DIAL_STATUS_MIN_ENUM_VAL = -2147483647,
  103. TB_DIAL_STATUS_CONNECTING = 0,
  104. TB_DIAL_STATUS_CONNECTED = 1,
  105. TB_DIAL_STATUS_DISCONNECTING = 2,
  106. TB_DIAL_STATUS_DISCONNECTED = 3,
  107. TB_DIAL_STATUS_MAX_ENUM_VAL = 2147483647
  108. } tb_data_dial_status;
  109. typedef enum
  110. {
  111. TB_PDP_TYPE_MIN_ENUM_VAL = -2147483647,
  112. TB_PDP_TYPE_IPV4 = 0,
  113. TB_PDP_TYPE_IPV6 = 1,
  114. TB_PDP_TYPE_IPV4V6 = 2,
  115. TB_DATA_PDP_TYPE_UNUSED,
  116. TB_PDP_TYPE_MAX_ENUM_VAL = 2147483647,
  117. } tb_data_pdp_type;
  118. typedef enum
  119. {
  120. TB_DATA_AUTH_MODE_MIN_ENUM_VAL = -2147483647,
  121. TB_DATA_AUTH_MODE_NONE = 0,
  122. TB_DATA_AUTH_MODE_PAP = 1,
  123. TB_DATA_AUTH_MODE_CHAP = 2,
  124. TB_DATA_AUTH_MODE_MAX_ENUM_VAL = 2147483647,
  125. } tb_data_auth_mode;
  126. typedef enum
  127. {
  128. TB_SIM_STATUS_UNDETECTED,
  129. TB_SIM_STATUS_WAIT_PIN,
  130. TB_SIM_STATUS_WAIT_PUK,
  131. TB_SIM_STATUS_READY,
  132. } tb_sim_status;
  133. typedef enum
  134. {
  135. TB_SIM_NV_UNREAD_SMS,
  136. TB_SMS_RECEIVED,
  137. TB_SMS_FULL_FLAG,
  138. TB_SMS_NV_TOTAL_SMS,
  139. TB_SMS_RECEIVED_WITH_ID,
  140. TB_SMS_DELETE_RESULT,
  141. TB_SMS_SEND_RESULT,
  142. } tb_sms_status;
  143. typedef enum
  144. {
  145. TB_SMS_STORAGE_ME,
  146. TB_SMS_STORAGE_SM,
  147. TB_SMS_STORAGE_NS,
  148. } tb_wms_storage_type;
  149. typedef enum
  150. {
  151. TB_VOICE_REPORT_CALL_INFO = 0,
  152. TB_VOICE_REPORT_MSD_TRANSMISSION_STATUS = 1,
  153. } tb_voice_report_event_e;
  154. typedef enum
  155. {
  156. TB_VOICE_CALL_TYPE_VOICE,
  157. TB_VOICE_CALL_TYPE_VIDEO
  158. } tb_voice_call_type;
  159. typedef enum
  160. {
  161. TB_VOICE_NOTIFY_CALL_START = 0,
  162. TB_VOICE_NOTIFY_CALL_INCOMING,
  163. TB_VOICE_NOTIFY_CALL_FAILED,
  164. TB_VOICE_NOTIFY_CALL_CONNECTING,
  165. TB_VOICE_NOTIFY_CALL_CONNECTED,
  166. TB_VOICE_NOTIFY_CALL_ENDED,
  167. TB_VOICE_NOTIFY_CALL_STATUS_MAX
  168. } tb_voice_notify_call_status;
  169. typedef enum
  170. {
  171. TB_VOICE_PRESENTATION_NAME_PRESENTATION_ALLOWED = 0x00,
  172. TB_VOICE_PRESENTATION_NAME_PRESENTATION_RESTRICTED = 0x01,
  173. TB_VOICE_PRESENTATION_NAME_UNAVAILABLE = 0x02,
  174. TB_VOICE_PRESENTATION_NAME_NAME_PRESENTATION_RESTRICTED = 0x03,
  175. } tb_voice_pi_name_type;
  176. //struct
  177. typedef struct
  178. {
  179. char provider_long_name[TB_PROVIDER_LONG_NAME_SIZE];
  180. char provider_short_name[TB_PROVIDER_SHORT_NAME_SIZE];
  181. char net_type[TB_NETWORK_TYPE_SIZE];
  182. tb_wan_domain_state_e domain_state;
  183. tb_wan_roam_status_e roam_state;
  184. char mcc[TB_MCC_MNC_SIZE];
  185. char mnc[TB_MCC_MNC_SIZE];
  186. char lac_code[TB_LAC_CODE_SIZE];
  187. char cell_id[TB_CELL_ID_SIZE];
  188. char net_band[TB_NETWORK_BAND_SIZE];
  189. } tb_wan_network_info_s;
  190. typedef struct
  191. {
  192. int signal_bar;
  193. int rssi;
  194. int rsrp;
  195. int rsrq;
  196. int rscp;
  197. } tb_wan_signal_info_s;
  198. typedef struct
  199. {
  200. char config_name[TB_PROFILE_PARA_LEN];
  201. char apn[TB_PROFILE_PARA_LEN];
  202. char username[TB_PROFILE_PARA_LEN];
  203. char password[TB_PROFILE_PARA_LEN];
  204. tb_data_pdp_type pdp_type;
  205. tb_data_auth_mode auth_mode;
  206. } tb_data_connect_profile;
  207. typedef struct
  208. {
  209. unsigned long long realtime_rx_bytes;
  210. unsigned long long realtime_tx_bytes;
  211. unsigned long long realtime_rx_thrpt;
  212. unsigned long long realtime_tx_thrpt;
  213. unsigned long long realtime_time;
  214. unsigned long long monthly_rx_bytes;
  215. unsigned long long monthly_tx_bytes;
  216. unsigned long long monthly_time;
  217. unsigned long long total_rx_bytes;
  218. unsigned long long total_tx_bytes;
  219. unsigned long long total_time;
  220. } tb_data_statistics;
  221. typedef struct
  222. {
  223. char ip_addr[TB_IPV4_ADDR_LEN];
  224. char pref_dns_addr[TB_IPV4_ADDR_LEN];
  225. char standy_dns_addr[TB_IPV4_ADDR_LEN];
  226. } tb_data_ipv4_addr;
  227. typedef struct
  228. {
  229. tb_data_pdp_type nPdpType;
  230. char ip_addr[TB_IPV4_ADDR_LEN];
  231. char pref_dns_addr[TB_IPV4_ADDR_LEN];
  232. char standy_dns_addr[TB_IPV4_ADDR_LEN];
  233. char ipv6_addr[TB_IPV6_ADDR_LEN];
  234. char pref_v6_dns_addr[TB_IPV6_ADDR_LEN];
  235. char standy_v6_dns_addr[TB_IPV6_ADDR_LEN];
  236. } tb_data_ip_addr;
  237. typedef struct
  238. {
  239. uint16_t year;
  240. uint8_t month;
  241. uint8_t day;
  242. uint8_t hour;
  243. uint8_t minute;
  244. uint8_t second;
  245. uint8_t izone;
  246. } tb_sms_time_stamp;
  247. typedef struct
  248. {
  249. tb_wms_storage_type mem_store;
  250. unsigned char dest_num[TB_WMS_ADDRESS_LEN_MAX + 1];
  251. unsigned short msg_len;
  252. unsigned short msg_content[TB_SMS_MSG_CONTENT_LEN_MAX * TB_SMS_CONCAT_SMS_COUNT_MAX];
  253. long id;
  254. tb_sms_time_stamp date;
  255. unsigned char draft_group_id[32];
  256. unsigned char send_and_save_sms;
  257. int classtype;
  258. } tb_sms_msg_type;
  259. typedef struct
  260. {
  261. int index;
  262. int rpt_index;
  263. int submit_index;
  264. int tag;
  265. char *content;
  266. char phone[41];
  267. int isfull;
  268. int total;
  269. int current_index;
  270. int received;
  271. int callsType;
  272. tb_sms_time_stamp date;
  273. char mem_store[10];
  274. int content_len;
  275. struct tb_sms_message *next;
  276. } tb_sms_message;
  277. typedef struct
  278. {
  279. tb_voice_pi_name_type name_pi;
  280. unsigned char coding_scheme;
  281. unsigned int name_len;
  282. char name[182];
  283. } tb_voice_remote_party_name_type;
  284. typedef struct
  285. {
  286. tb_voice_notify_call_status call_state;
  287. tb_voice_call_type call_type;
  288. int is_call_of_callsession;
  289. char number[32];
  290. tb_voice_remote_party_name_type remote_party_name;
  291. unsigned char remote_party_name_valid;
  292. int dial_result;
  293. int connect_result;
  294. int hungup_result;
  295. } tb_voice_notify_call_state_number_info;
  296. //type
  297. typedef void (*tb_wan_network_info_cb)(tb_wan_notify_type_e type, const char *value);
  298. typedef void (*tb_data_callback_fun)(tb_data_profile_id cid, tb_data_dial_status status);
  299. typedef void (*tb_sim_callback_fun)(tb_sim_status type);
  300. typedef void (*tb_sms_callback_fun)(tb_sms_status type, int value);
  301. typedef void (*tb_sms_received_contents_cb)(tb_sms_message *received_sms_message);
  302. typedef void (*tb_voice_callback_fun)(tb_voice_report_event_e event, void *voice_report_info);
  303. typedef osiTimer_t *tb_timer_p;
  304. typedef void (*tb_timer_callbck)(void *ctx);
  305. //api
  306. //Nw module
  307. extern int tb_wan_reg_callback(tb_wan_network_info_cb wan_network_info_func);
  308. extern int tb_wan_get_network_type(char *type, int size);
  309. extern int tb_wan_get_network_info(tb_wan_network_info_s *network_info);
  310. extern int tb_wan_get_signal_info(tb_wan_signal_info_s *signal_info);
  311. extern int tb_data_reg_callback(tb_data_callback_fun fun);
  312. extern int tb_data_wan_disconnect(tb_data_profile_id cid);
  313. extern int tb_data_get_dial_status(tb_data_profile_id cid, tb_data_dial_status *istatus);
  314. extern int tb_data_set_connect_parameter(tb_data_profile_id cid, tb_data_connect_profile para);
  315. extern int tb_data_wan_connect(tb_data_profile_id cid);
  316. extern int tb_data_get_connect_parameter(tb_data_profile_id cid, tb_data_connect_profile *para);
  317. extern int tb_data_get_statistics(tb_data_profile_id cid, tb_data_statistics *statistics);
  318. extern int tb_data_get_ipv4_address(tb_data_profile_id cid, tb_data_ipv4_addr *address);
  319. extern int tb_data_get_ip_address(tb_data_profile_id cid, tb_data_ip_addr *address);
  320. // SIM module
  321. extern int tb_sim_reg_callback(tb_sim_callback_fun fun);
  322. extern int tb_sim_get_sim_state(tb_sim_status *istate);
  323. extern int tb_sim_get_imsi(char *imsi, int size);
  324. extern int tb_sim_get_imei(char *imei, int size);
  325. extern int tb_sim_get_phone_num(char *pBuf, int size);
  326. // SMS module
  327. extern int tb_sms_reg_callback(tb_sms_callback_fun fun);
  328. extern int tb_sms_get_contents_cb(tb_sms_received_contents_cb fun);
  329. extern int tb_sms_send_sms(tb_sms_msg_type *msg);
  330. extern int tb_sms_delete_sms(int MessageIndex);
  331. extern int tb_sms_get_sms_withid(int id);
  332. // Voice module
  333. extern int tb_voice_reg_callback(tb_voice_callback_fun fun);
  334. extern int tb_voice_dial_call(char *call_number);
  335. extern int tb_voice_answer_call();
  336. extern int tb_voice_hungup_call();
  337. extern int tb_voice_switch_audio_channel(int audio_channel);
  338. extern int tb_voice_control_loopback(int ctlType, bool on);
  339. //device info
  340. extern int tb_device_get_modemserialnumber(char *msn, int size);
  341. extern int tb_device_get_hwversion(char *hdver, int size);
  342. extern int tb_device_getversion(char *ver, int size);
  343. extern int tb_device_get_iccid(char *iccid, int size);
  344. extern int tb_device_set_rtc_timer(unsigned long seconds, tb_timer_callbck pCallback, tb_timer_p *pTimer);
  345. extern int tb_device_cancel_timer(tb_timer_p pTimer);
  346. extern int tb_device_shutdown_system(void);
  347. extern int tb_device_reboot_system(void);
  348. extern void tb_device_reset_update_result(void);
  349. extern int tb_device_get_update_result(unsigned int *errcode);
  350. extern int tb_device_start_update_firmware(void);
  351. extern int tb_device_query_hu_ipaddr(char *hu_ipaddr, int ipaddr_buf_len);
  352. extern int tb_device_modem_wakeup_mcu(uint32_t gpio_num);
  353. extern int tb_device_enable_sleep(bool enable);
  354. //cfw event handle
  355. extern int tb_handle_cfw_event(const osiEvent_t *event);
  356. #ifdef __cplusplus
  357. }
  358. #endif
  359. #endif