Skip to content

Commit

Permalink
add: 添加mobile.tac()函数, 并在获取cellinfo失败是提示先执行reqCellInfo()
Browse files Browse the repository at this point in the history
  • Loading branch information
wendal committed Jul 9, 2023
1 parent 20f43c4 commit d4d1e03
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
28 changes: 26 additions & 2 deletions components/mobile/luat_lib_mobile.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,24 @@ static int l_mobile_eci(lua_State* L) {
return 1;
}

/**
获取当前服务小区的TAC或者LAC
@api mobile.tac()
@return int 当前eci值,若失败返回-1. 如果尚未注册到网络,会返回0
@usage
-- 本API于 2023.7.9 新增
*/
static int l_mobile_tac(lua_State* L) {
uint32_t tac;
if (luat_mobile_get_service_tac_or_lac(&tac) == 0) {
lua_pushinteger(L, tac);
}
else {
lua_pushinteger(L, -1);
}
return 1;
}

/**
获取当前服务小区的eNBID(eNodeB Identifier)
@api mobile.enbid()
Expand Down Expand Up @@ -566,7 +584,7 @@ static inline uint16_t u162bcd(uint16_t src) {
]]
mobile.reqCellInfo(60)
-- 订阅式
-- 订阅
sys.subscribe("CELL_INFO_UPDATE", function()
log.info("cell", json.encode(mobile.getCellInfo()))
end)
Expand Down Expand Up @@ -598,7 +616,12 @@ static int l_mobile_get_cell_info(lua_State* L) {

// 当前仅返回lte信息
if (info->lte_info_valid == 0 || info->lte_service_info.cid == 0) {
LLOGI("lte cell info not found");
if (0 == luat_mobile_get_service_cell_identifier(&info->lte_service_info.cid) && info->lte_service_info.cid) {
LLOGW("pls call mobile.reqCellInfo() and wait for CELL_INFO_UPDATE");
}
else {
LLOGI("lte cell info not found");
}
goto exit;
}

Expand Down Expand Up @@ -877,6 +900,7 @@ static const rotable_Reg_t reg_mobile[] = {
{"rsrp", ROREG_FUNC(l_mobile_rsrp)},
{"snr", ROREG_FUNC(l_mobile_snr)},
{"eci", ROREG_FUNC(l_mobile_eci)},
{"tac", ROREG_FUNC(l_mobile_tac)},
{"enbid", ROREG_FUNC(l_mobile_enbid)},
{"flymode", ROREG_FUNC(l_mobile_flymode)},
{"simid", ROREG_FUNC(l_mobile_simid)},
Expand Down
8 changes: 8 additions & 0 deletions components/mobile/luat_mobile.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,14 @@ int luat_mobile_get_last_notify_signal_strength(uint8_t *csq);
* @return int =0成功,其他失败
*/
int luat_mobile_get_service_cell_identifier(uint32_t *eci);

/**
* @brief 获取当前服务小区的TAC或LAC
*
* @param tac
* @return int =0成功,其他失败
*/
int luat_mobile_get_service_tac_or_lac(uint16_t *tac);
/* --------------------------------------------------- cell info end --------------------------------------------------- */


Expand Down

0 comments on commit d4d1e03

Please sign in to comment.