mirror of git://git.sysmocom.de/ofono
qmi: move rat_to_tech() into own module
We want to use this function from multiple atoms so this patch moves it out to its own module for NAS-related helper functions.
This commit is contained in:
parent
526b30b7ec
commit
d6704223d8
|
@ -210,6 +210,7 @@ qmi_sources = drivers/qmimodem/qmi.h drivers/qmimodem/qmi.c \
|
||||||
drivers/qmimodem/ctl.h \
|
drivers/qmimodem/ctl.h \
|
||||||
drivers/qmimodem/dms.h \
|
drivers/qmimodem/dms.h \
|
||||||
drivers/qmimodem/nas.h \
|
drivers/qmimodem/nas.h \
|
||||||
|
drivers/qmimodem/nas.c \
|
||||||
drivers/qmimodem/uim.h \
|
drivers/qmimodem/uim.h \
|
||||||
drivers/qmimodem/wms.h \
|
drivers/qmimodem/wms.h \
|
||||||
drivers/qmimodem/wds.h \
|
drivers/qmimodem/wds.h \
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* oFono - Open Source Telephony
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Jonas Bonn. All rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "nas.h"
|
||||||
|
|
||||||
|
#include "src/common.h"
|
||||||
|
|
||||||
|
int qmi_nas_rat_to_tech(uint8_t rat)
|
||||||
|
{
|
||||||
|
switch (rat) {
|
||||||
|
case QMI_NAS_NETWORK_RAT_GSM:
|
||||||
|
return ACCESS_TECHNOLOGY_GSM;
|
||||||
|
case QMI_NAS_NETWORK_RAT_UMTS:
|
||||||
|
return ACCESS_TECHNOLOGY_UTRAN;
|
||||||
|
case QMI_NAS_NETWORK_RAT_LTE:
|
||||||
|
return ACCESS_TECHNOLOGY_EUTRAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
|
@ -162,3 +162,5 @@ struct qmi_nas_home_network {
|
||||||
uint8_t desc_len;
|
uint8_t desc_len;
|
||||||
char desc[0];
|
char desc[0];
|
||||||
} __attribute__((__packed__));
|
} __attribute__((__packed__));
|
||||||
|
|
||||||
|
int qmi_nas_rat_to_tech(uint8_t rat);
|
||||||
|
|
|
@ -43,20 +43,6 @@ struct netreg_data {
|
||||||
uint8_t current_rat;
|
uint8_t current_rat;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int rat_to_tech(uint8_t rat)
|
|
||||||
{
|
|
||||||
switch (rat) {
|
|
||||||
case QMI_NAS_NETWORK_RAT_GSM:
|
|
||||||
return ACCESS_TECHNOLOGY_GSM;
|
|
||||||
case QMI_NAS_NETWORK_RAT_UMTS:
|
|
||||||
return ACCESS_TECHNOLOGY_UTRAN;
|
|
||||||
case QMI_NAS_NETWORK_RAT_LTE:
|
|
||||||
return ACCESS_TECHNOLOGY_EUTRAN;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool extract_ss_info(struct qmi_result *result, int *status,
|
static bool extract_ss_info(struct qmi_result *result, int *status,
|
||||||
int *lac, int *cellid, int *tech,
|
int *lac, int *cellid, int *tech,
|
||||||
struct ofono_network_operator *operator)
|
struct ofono_network_operator *operator)
|
||||||
|
@ -82,7 +68,7 @@ static bool extract_ss_info(struct qmi_result *result, int *status,
|
||||||
for (i = 0; i < ss->radio_if_count; i++) {
|
for (i = 0; i < ss->radio_if_count; i++) {
|
||||||
DBG("radio in use %d", ss->radio_if[i]);
|
DBG("radio in use %d", ss->radio_if[i]);
|
||||||
|
|
||||||
*tech = rat_to_tech(ss->radio_if[i]);
|
*tech = qmi_nas_rat_to_tech(ss->radio_if[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qmi_result_get_uint8(result, QMI_NAS_RESULT_ROAMING_STATUS,
|
if (qmi_result_get_uint8(result, QMI_NAS_RESULT_ROAMING_STATUS,
|
||||||
|
@ -278,7 +264,7 @@ static void scan_nets_cb(struct qmi_result *result, void *user_data)
|
||||||
DBG("%03d:%02d %d", netrat->info[i].mcc, netrat->info[i].mnc,
|
DBG("%03d:%02d %d", netrat->info[i].mcc, netrat->info[i].mnc,
|
||||||
netrat->info[i].rat);
|
netrat->info[i].rat);
|
||||||
|
|
||||||
list[i].tech = rat_to_tech(netrat->info[i].rat);
|
list[i].tech = qmi_nas_rat_to_tech(netrat->info[i].rat);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
Loading…
Reference in New Issue