radio.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /******************************************************************************/
  2. /* */
  3. /* Copyright 2023 by AICXTEK TECHNOLOGIES CO.,LTD. All rights reserved. */
  4. /* */
  5. /******************************************************************************/
  6. /**
  7. * DESCRIPTION
  8. *
  9. * This file is enter of radio
  10. */
  11. /*********************
  12. * INCLUDES
  13. *********************/
  14. #include "aic_type.h"
  15. #include "aic_srv_tele.h"
  16. /**********************
  17. * STATIC VARIABLES
  18. **********************/
  19. /**
  20. * handleRadioCallback.
  21. * @arg1: p_param;size:p_param data length
  22. * Return: int,-1,error,0 success.
  23. */
  24. static int32_t handleRadioCallback(void *p_param, uint32_t size)
  25. {
  26. ts_event_radio_t *p_radio_event = NULL;
  27. if(NULL == p_param) {
  28. alog_error("%s,p_param is null",__func__);
  29. return -1;
  30. }
  31. p_radio_event = (ts_event_radio_t *)p_param;
  32. switch(p_radio_event->event_id) {
  33. case TS_EVENT_RADIO_SIGNAL_INFO_UPDATED: /* signal strenth&level reported per 10s */
  34. {
  35. ts_radio_signal_info_updated_t *p_signal_info = NULL;
  36. alog_info("[%s],TS_EVENT_RADIO_SIGNAL_INFO_UPDATED",__func__);
  37. p_signal_info = (ts_radio_signal_info_updated_t *)p_param;
  38. alog_info("[%s], signal_strength = %d, signal_level = %d.\r\n",
  39. __func__,
  40. p_signal_info->signal_strength,
  41. p_signal_info->signal_level);
  42. /* signal level0: signal strenth <=-120dBm */
  43. /* signal level1: signal strenth -111~-119dBm */
  44. /* signal level2: signal strenth -106~-110dBm */
  45. /* signal level3: signal strenth -91~-105dBm */
  46. /* signal level4: signal strenth >=-90dBm */
  47. /* update signal
  48. to ui task: update signal level */
  49. break;
  50. }
  51. case TS_EVENT_RADIO_REG_STATUS_UPDATED: /* register net status reported */
  52. {
  53. ts_radio_reg_status_updated_t *p_reg_status = NULL;
  54. alog_info("[%s],TS_EVENT_RADIO_REG_STATUS_UPDATED",__func__);
  55. p_reg_status = (ts_radio_reg_status_updated_t *)p_param;
  56. alog_info("[%s],reg status = %d.\r\n",__func__,p_reg_status->reg_status);
  57. if(TS_RADIO_REG_STATUS_IN_SERVICE == p_reg_status->reg_status) {
  58. /* register successfual
  59. to ui task: update reg status icon */
  60. } else {
  61. /* No register
  62. to ui task: update reg status icon */
  63. }
  64. break;
  65. }
  66. case TS_EVENT_RADIO_IMS_REG_STATUS_UPDATED: /* ims status reported */
  67. {
  68. ts_radio_ims_reg_status_updated_t *p_ims_status = NULL;
  69. alog_info("[%s],TS_EVENT_RADIO_IMS_REG_STATUS_UPDATED",__func__);
  70. p_ims_status = (ts_radio_ims_reg_status_updated_t *)p_param;
  71. alog_info("[%s],ims status = %d.\r\n",__func__,p_ims_status->is_ims_on);
  72. if(true == p_ims_status->is_ims_on) {
  73. /* ims open
  74. to ui task: update ims icon */
  75. } else {
  76. /* ims close
  77. to ui task: update ims icon */
  78. }
  79. break;
  80. }
  81. case TS_EVENT_RADIO_OPERATOR_INFO_UPDATED: /* openator name(eg,cmcc,cucc,ctcc) reported*/
  82. {
  83. ts_radio_operator_info_updated_t *p_operator_name = NULL;
  84. alog_info("[%s],TS_EVENT_RADIO_OPERATOR_INFO_UPDATED",__func__);
  85. p_operator_name = (ts_radio_operator_info_updated_t *)p_param;
  86. alog_info("[%s],operator short name = %s, long name = %s,",__func__,
  87. p_operator_name->operator_info.operator_short_name,/*cmcc/cucc/ctcc*/
  88. p_operator_name->operator_info.operator_long_name);/*China Mobile/China Unicom/china Telecom*/
  89. /* operator name
  90. to ui task: display operator name */
  91. break;
  92. }
  93. case TS_EVENT_RADIO_GET_CELL_INFO_RESP: {
  94. ts_radio_get_cell_info_resp_t *p_cell_info = NULL;
  95. alog_info("[%s],TS_EVENT_RADIO_GET_CELL_INFO_RESP",__func__);
  96. p_cell_info = (ts_radio_get_cell_info_resp_t *)p_param;
  97. alog_info("[%s]ret_value = %d, rat_type = %d, plmn_mcc = %s, plmn_mnc = %s, tac = %d, earfcn = %d, cellid = %d, rsrp = %d, rsrq = %d, pcid = %d, is_roaming = %d, band = %d, ul_bandwidth = %d, dl_bandwidth = %d, sinr = %d, srxlev = %d, rssi = %d.",
  98. __func__,
  99. p_cell_info->ret_value,
  100. p_cell_info->cell_info.rat_type,
  101. p_cell_info->cell_info.plmn_mcc,
  102. p_cell_info->cell_info.plmn_mnc,
  103. p_cell_info->cell_info.tac,
  104. p_cell_info->cell_info.earfcn,
  105. p_cell_info->cell_info.cellid,
  106. p_cell_info->cell_info.rsrp,
  107. p_cell_info->cell_info.rsrq,
  108. p_cell_info->cell_info.pcid,
  109. p_cell_info->cell_info.is_roaming,
  110. p_cell_info->cell_info.band,
  111. p_cell_info->cell_info.ul_bandwidth,
  112. p_cell_info->cell_info.dl_bandwidth,
  113. p_cell_info->cell_info.sinr,
  114. p_cell_info->cell_info.srxlev,
  115. p_cell_info->cell_info.rssi);
  116. break;
  117. }
  118. case TS_EVENT_RADIO_GET_NEIGHBOR_CELL_INFO_LIST_RESP: {
  119. ts_radio_get_neighbor_cell_info_list_resp_t *p_nb_cell_info_list = NULL;
  120. uint8_t num = 0;
  121. alog_info("[%s],TS_EVENT_RADIO_GET_NEIGHBOR_CELL_INFO_LIST_RESP",__func__);
  122. p_nb_cell_info_list = (ts_radio_get_neighbor_cell_info_list_resp_t *)p_param;
  123. alog_info("[%s]ret_value = %d.", __func__, p_nb_cell_info_list->ret_value);
  124. alog_info("[%s]ncell_num = %d.", __func__, p_nb_cell_info_list->ncell_info_list.ncell_num);
  125. for (num = 0; num < p_nb_cell_info_list->ncell_info_list.ncell_num; num++) {
  126. alog_info("[%s]index = %d, rat_type = %d, plmn_mcc = %s, plmn_mnc = %s, tac = %d, cellid = %d, earfcn = %d, rsrp = %d, rsrq = %d, pcid = %d, sinr = %d, srxlev = %d, rssi = %d.",
  127. __func__,
  128. num,
  129. p_nb_cell_info_list->ncell_info_list.ncell_info[num].rat_type,
  130. p_nb_cell_info_list->ncell_info_list.ncell_info[num].plmn_mcc,
  131. p_nb_cell_info_list->ncell_info_list.ncell_info[num].plmn_mnc,
  132. p_nb_cell_info_list->ncell_info_list.ncell_info[num].tac,
  133. p_nb_cell_info_list->ncell_info_list.ncell_info[num].cellid,
  134. p_nb_cell_info_list->ncell_info_list.ncell_info[num].earfcn,
  135. p_nb_cell_info_list->ncell_info_list.ncell_info[num].rsrp,
  136. p_nb_cell_info_list->ncell_info_list.ncell_info[num].rsrq,
  137. p_nb_cell_info_list->ncell_info_list.ncell_info[num].pcid,
  138. p_nb_cell_info_list->ncell_info_list.ncell_info[num].sinr,
  139. p_nb_cell_info_list->ncell_info_list.ncell_info[num].srxlev,
  140. p_nb_cell_info_list->ncell_info_list.ncell_info[num].rssi);
  141. }
  142. break;
  143. }
  144. case TS_EVENT_RADIO_SET_IMEI_RESP: {
  145. ts_radio_set_imei_resp_t *p_set_imei = NULL;
  146. p_set_imei = (ts_radio_set_imei_resp_t *)p_param;
  147. alog_info("[%s]ret_value = %d.", __func__, p_set_imei->ret_value);
  148. break;
  149. }
  150. case TS_EVENT_RADIO_START_SEARCH_RESP: {
  151. uint32_t index = 0;
  152. ts_radio_start_search_resp_t *p_resp = NULL;
  153. ts_radio_operator_info_t *p_operator_info = NULL;
  154. p_resp = (ts_radio_start_search_resp_t *)p_param;
  155. alog_info("[%s]Receive TS_EVENT_RADIO_START_SEARCH_RESP.", __func__);
  156. alog_info("[%s]event_id = 0x%x, ret_value = %d, operator_num = %d.",
  157. __func__,
  158. p_resp->event_id,
  159. p_resp->ret_value,
  160. p_resp->operator_num);
  161. for (index = 0; index < p_resp->operator_num; index++) {
  162. p_operator_info = (ts_radio_operator_info_t *)(&(p_resp->data_header)) + index;
  163. alog_info("[%s][%d]operator_short_name = %s, operator_long_name = %s, plmn_mcc = %s, plmn_mnc = %s, operator_id = %d, network_type = %d, status = %d.",
  164. __func__,
  165. index,
  166. p_operator_info->operator_short_name,
  167. p_operator_info->operator_long_name,
  168. p_operator_info->plmn_mcc,
  169. p_operator_info->plmn_mnc,
  170. p_operator_info->operator_id,
  171. p_operator_info->network_type,
  172. p_operator_info->status);
  173. }
  174. break;
  175. }
  176. default:
  177. break;
  178. }
  179. return 0;
  180. }
  181. /**********************
  182. * GLOBAL FUNCTIONS
  183. **********************/
  184. /* when power on, open radio,then start network */
  185. void radio_init( void )
  186. {
  187. int32_t radio_handle = 0;
  188. /* open network */
  189. aic_srv_tele_radio_on(0, true, NULL);
  190. /* 1.register radio callback,this callback receive global msg(eg.signal quality,operator name,ims status)*/
  191. radio_handle = aic_srv_tele_radio_register(NULL, handleRadioCallback);
  192. }