cfw_utility.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* Copyright (C) 2018 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. /**
  13. *@file cfw_utility.h
  14. *@author UNISOC
  15. *@email
  16. *@version
  17. *@data
  18. */
  19. #ifndef _CFW_UTILITY_H_
  20. #define _CFW_UTILITY_H_
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. typedef enum
  25. {
  26. CFW_SIM_0 = 0x00,
  27. CFW_SIM_1 = 0x01,
  28. CFW_SIM_END = 0xFF,
  29. CFW_SIM_ENUM_FILL = 0x7FFFFFFF
  30. } CFW_SIM_ID;
  31. #define MAX_NUM_EVENT_LIST 11 ///< 11 type of events
  32. #define CFW_SAT_MAX_ALPHA_STR_LEN 255
  33. #define CFW_SAT_MAX_ADDR_LEN 20
  34. #define CFW_MAX_SMS_PDU_LEN 176
  35. #define CFW_MAX_SMS_DATA_LEN 160
  36. #define CFW_SAT_MAX_TEXT_STR_LEN 255
  37. #define CFW_SAT_MAX_SS_STR_LEN 255
  38. #define CFW_SAT_MAX_USSD_STR_LEN 255
  39. #define CFW_SAT_MAX_FILE_LIST_LEN 252
  40. #define CFW_SAT_MAX_DTMF_LEN 252
  41. #define CFW_SAT_MAX_BEARER_DESC_LEN 255
  42. #define CFW_SAT_MAX_NW_ACCESS_NAME_LEN 255
  43. #define CFW_SAT_MAX_CHANNEL_DATA_STR_LEN 255
  44. #define CFW_SAT_MAX_URL_LEN 255
  45. #define CFW_SAT_MAX_LIST_BEARER_LEN 255
  46. #define CFW_SAT_MAX_PROVISIONING_FILE_LEN 255
  47. #define CFW_SAT_MAX_DTMF_STR_LEN 255
  48. #define CFW_SIM_COUNT CONFIG_NUMBER_OF_SIM
  49. #define CFW_TIME_ZONE_SECOND (15 * 60)
  50. #define CFW_CC_IND_UTI 0x01
  51. #define CFW_SS_IND_UTI 0x02
  52. #define CFW_NW_IND_UTI 0x03
  53. #define CFW_SIM_IND_UTI 0x04
  54. #define CFW_PBK_IND_UTI 0x05
  55. #define CFW_SMS_PATH_GSM 0
  56. #define CFW_SMS_PATH_GPRS 1
  57. #define CFW_NW_SRV_ID 0 ///< Indicate the network management Service
  58. #define CFW_SIM_SRV_ID 1 ///< Indicate the SIM management Service
  59. #define CFW_CC_SRV_ID 2 ///< Indicate the Call management Service
  60. #define CFW_SS_SRV_ID 3 ///< Indicate the SS Service
  61. #define CFW_SMS_MO_SRV_ID 4 ///< Indicate the SMS MO management Service
  62. #define CFW_SMS_MT_SRV_ID 5 ///< Indicate the SMS MT management Service
  63. #define CFW_SMS_CB_ID 6 ///< Indicate the SMS CB management Service
  64. #define CFW_GPRS_SRV_ID 7
  65. #define CFW_PDP_SRV_ID 7
  66. #define CFW_PSD_SRV_ID 7
  67. #define CFW_CSD_SRV_ID 8
  68. #define CFW_EMOD_SRV_ID 9 ///< Engineering Mode
  69. #define CFW_APP_SRV_ID 10
  70. #define CFW_TIMER_SRV_ID 11
  71. #define CFW_MAX_SRV_ID (11 * CFW_SIM_COUNT)
  72. #define CFW_PBK_SRV_ID CFW_APP_SRV_ID
  73. #define CFW_SRV_NW_EV_RSP (0)
  74. #define CFW_SRV_CC_EV_RSP (1)
  75. #define CFW_SRV_SS_EV_RSP (2)
  76. #define CFW_SRV_SIM_EV_RSP (3)
  77. #define CFW_SRV_SMS_EV_RSP (4)
  78. #define CFW_SRV_PBK_EV_RSP (5)
  79. #define CFW_SRV_GPRS_EV_RSP (6)
  80. #define CFW_SRV_FAX_EV_RSP (7)
  81. #define CFW_SRV_EV_IND (8)
  82. #define CFW_SRV_EV_MAX (8)
  83. #define CFW_SRV_EV_UNKNOW (0xFF)
  84. #define CFW_TELNUMBER_TYPE_INTERNATIONAL 145 ///< International number
  85. #define CFW_TELNUMBER_TYPE_NATIONAL 161 ///< National number.
  86. #define CFW_TELNUMBER_TYPE_UNKNOWN 129 ///< Unknown number type (default)
  87. //
  88. // Basic Utility Macros
  89. //
  90. #define CFW_SET_BIT(val, n) ((val) |= (1 << n))
  91. #define CFW_CLR_BIT(val, n) ((val) &= ~(1 << n))
  92. #define CFW_IS_BIT_SET(val, n) ((val) & (1 << n))
  93. #define CFW_IS_BIT_CLR(val, n) (~((val) & (1 << n)))
  94. #define CFW_SWITCH_BIT(val, n) ((val) ^= (1 << n))
  95. #define CFW_GET_BIT(val, n) (((val) >> n) & 1)
  96. #define CFW_CFG_RECEIVE_STORAGE(sms, bm, sr) ((sms) | (bm) | (sr))
  97. #define CFW_CFG_SET_ALARM_RECUR(mon, tue, wed, thu, fri, sta, sun) ((1 << mon | 1 << tue | 1 << wed | 1 << thu | 1 << fri | 1 << sta | 1 << sun) & 0xFE)
  98. #define CFW_CFG_CMER(mode, keyp, disp, ind, bfr) ((mode) | ((keyp) << 2) | ((disp) << 4) | ((ind) << 6) | ((bfr) << 8))
  99. #define CFW_CFG_CMER_MODE(cmer) (cmer & 0x03)
  100. #define CFW_CFG_CMER_KEYP(cmer) (cmer >> 2 & 0x03)
  101. #define CFW_CFG_CMER_DISP(cmer) (cmer >> 4 & 0x03)
  102. #define CFW_CFG_CMER_IND(cmer) (cmer >> 6 & 0x03)
  103. #define CFW_CFG_CMER_BFR(cmer) (cmer >> 8 & 0x03)
  104. #define AT_DEFAULT_APN_MAX_NUM 60
  105. #ifdef AT_EXT_CONF_SUPPORT
  106. #define CFW_CALL_MAX_EXT_CONF_NUM 5
  107. #endif
  108. #define CFW_CFG_IND_BC_EVENT (1 << 0)
  109. #define CFW_CFG_IND_SQ_EVENT (1 << 1)
  110. #define CFW_CFG_IND_NW_EVENT (1 << 2)
  111. #define CFW_CFG_IND_SOUNDER_EVENT (1 << 3)
  112. #define CFW_CFG_IND_SMS_RECEIVE_EVENT (1 << 4)
  113. #define CFW_CFG_IND_CALL_EVENT (1 << 5)
  114. #define CFW_CFG_IND_VOX_EVENT (1 << 6)
  115. #define CFW_CFG_IND_ROAM_EVENT (1 << 7)
  116. #define CFW_CFG_IND_SMS_FULL_EVENT (1 << 8)
  117. #define CFW_CFG_IND_BIT_ERR_EVENT (1 << 9)
  118. #define CFW_CFG_IND_USER_SQ_EVENT (1 << 10)
  119. #define CFW_CFG_IND_EVENT(bc, sq, nw, sounder, sms_receive, call, vox, roam, sms_full, biterr) \
  120. ((bc)|((sq)<<1)|((nw)<<2)|((sounder)<<3)|((sms_receive)<<4)|((call)<<5)|((vox)<<6)|((roam)<<7)|((sms_full)<<8|biterr<<9)
  121. #define IS_CFG_IND_BC_EVENT(ind) (ind >> 0 & 1)
  122. #define IS_CFG_IND_SQ_EVENT(ind) (ind >> 1 & 1)
  123. #define IS_CFG_IND_NW_EVENT(ind) (ind >> 2 & 1)
  124. #define IS_CFG_IND_SOUNDER_EVENT(ind) (ind >> 3 & 1)
  125. #define IS_CFG_IND_SMS_RECEIVE_EVENT(ind) (ind >> 4 & 1)
  126. #define IS_CFG_IND_CALL_EVENT(ind) (ind >> 5 & 1)
  127. #define IS_CFG_IND_VOX_EVENT(ind) (ind >> 6 & 1)
  128. #define IS_CFG_IND_ROAM_EVENT(ind) (ind >> 7 & 1)
  129. #define IS_CFG_IND_SMS_FULL_EVENT(ind) (ind >> 8 & 1)
  130. #define IS_CFG_IND_BIT_ERR_EVENT(ind) (ind >> 9 & 1)
  131. #endif