summaryrefslogtreecommitdiff
path: root/io-module/mts-io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io-module/mts-io.c')
-rw-r--r--io-module/mts-io.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/io-module/mts-io.c b/io-module/mts-io.c
index 7c33ea4..df52a12 100644
--- a/io-module/mts-io.c
+++ b/io-module/mts-io.c
@@ -201,6 +201,8 @@ static time64_t time_now_secs(void);
bool sent_extra_long = false;
+int is_mtr(void);
+
/*
* For EEPROM layout after version 0, we use the
* CAPA_CELLULAR flag to determine if we have a cellular
@@ -222,6 +224,11 @@ bool sent_extra_long = false;
* If the B is the last character we have a modem.
* If the modem field starts with IN, we have an
* India LoRa channel plan with no cellular modem.
+ *
+ * If the device is an MTR it always has a Cellular radio.
+ * It is indended to fix wrongly written EEPROM values.
+ * mts_has_radio has to have its own check, because it is exported.
+ *
* All other cases, we have a modem.
*
* TRUE: 1 for return result
@@ -231,7 +238,10 @@ int
mts_has_radio(const char *product_id, size_t len)
{
char *p;
- int found_i = 0;
+ int found_i = 0;
+ if (is_mtr()) {
+ return 1;
+ }
if (!product_id || ! *product_id)
return 1; /* No Product ID? */
p = memchr(product_id,'-',len);
@@ -282,6 +292,14 @@ mts_has_radio(const char *product_id, size_t len)
}
EXPORT_SYMBOL(mts_has_radio);
+int is_mtr(void) {
+ if ((strncmp(id_eeprom.hw_version, HW_VERSION_MTR_DASH, strlen(HW_VERSION_MTR_DASH)) == 0)||
+ (strncmp(id_eeprom.hw_version, HW_VERSION_MTRV1_DASH, strlen(HW_VERSION_MTRV1_DASH)) == 0)) {
+ return 1;
+ }
+ return 0;
+}
+
/* active-low socket modem reset */
static ssize_t mts_attr_store_radio_reset(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
@@ -632,12 +650,16 @@ static ssize_t mts_attr_show_product_info(struct device *dev,
} else if (strcmp(attr->attr.name, "product-id") == 0) {
value = sprintf(buf, "%.32s\n", id_eeprom.product_id);
} else if (strcmp(attr->attr.name, "has-radio") == 0) {
- if(id_eeprom.eeprom_layout_version == 0)
- value = sprintf(buf, "%d\n",
- mts_has_radio(id_eeprom.product_id,sizeof id_eeprom.product_id));
- else
- /* Newer EEPROM version with CAPA_CELLULAR */
- value = sprintf(buf, "%1d\n",DEVICE_CAPA(id_eeprom.capa, CAPA_CELLULAR) ? 1 : 0);
+ if (is_mtr()) {
+ value = sprintf(buf, "1\n"); // MTRs always have cellular
+ } else {
+ if(id_eeprom.eeprom_layout_version == 0)
+ value = sprintf(buf, "%d\n",
+ mts_has_radio(id_eeprom.product_id,sizeof id_eeprom.product_id));
+ else
+ /* Newer EEPROM version with CAPA_CELLULAR */
+ value = sprintf(buf, "%1d\n",DEVICE_CAPA(id_eeprom.capa, CAPA_CELLULAR) ? 1 : 0);
+ }
} else if (strcmp(attr->attr.name, "device-id") == 0) {
value = sprintf(buf, "%.32s\n", id_eeprom.device_id);
} else if (strcmp(attr->attr.name, "uuid") == 0) {
@@ -828,6 +850,11 @@ mts_id_eeprom_load(void)
has_cellular_capaflag = 1;
noradio = ! DEVICE_CAPA(id_eeprom.capa, CAPA_CELLULAR);
}
+
+ if (is_mtr()) {
+ noradio = 0;
+ }
+
log_debug("mts_id_eeprom_load: noradio=%d",noradio);
if (found_board(HW_VERSION_MTCAP_0_0,MTCAP_0_0,&hw_version_str,&mts_hw_version) ||