summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeff Hatch <jhatch@multitech.com>2021-05-13 17:52:00 -0500
committerJeff Hatch <jhatch@multitech.com>2021-05-13 17:52:00 -0500
commit717cc0092c436aa6f8e5fca5c530da701ea8cf79 (patch)
treeadfa7759b7e11e4a3d675ae4b9c151d5159bad4e /src
parentdec4431752a10e0359ef83514658ba8c5340eb79 (diff)
parent31e7d30482ee2e6708c479183b57ce4c2e056d74 (diff)
downloadmts-id-eeprom-717cc0092c436aa6f8e5fca5c530da701ea8cf79.tar.gz
mts-id-eeprom-717cc0092c436aa6f8e5fca5c530da701ea8cf79.tar.bz2
mts-id-eeprom-717cc0092c436aa6f8e5fca5c530da701ea8cf79.zip
Merge branch 'mtre' into 'master'
Add MTRE support See merge request !3
Diffstat (limited to 'src')
-rw-r--r--src/eeprom_main.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/eeprom_main.c b/src/eeprom_main.c
index d8a81e8..26cfe70 100644
--- a/src/eeprom_main.c
+++ b/src/eeprom_main.c
@@ -211,6 +211,10 @@ static int id_yaml_out(const char *name, struct mts_id_eeprom_layout *id_eeprom)
fprintf(file, "lora-product-id: \"%.32s\"\n", id_eeprom->lora_product_id);
fprintf(file, "lora-hw-version: \"%.32s\"\n", id_eeprom->lora_hw_version);
+#ifdef MTRE
+ fprintf(file, "oem-string1: %.32s\n", id_eeprom->oem_string1);
+ fprintf(file, "oem-string2: %.32s\n", id_eeprom->oem_string2);
+#endif
fprintf(file, "...\n");
@@ -425,6 +429,10 @@ static void mts_id_eeprom_inspect(struct mts_id_eeprom_layout *id_eeprom)
log_info("lora-product-id: %.32s", id_eeprom->lora_product_id);
log_info("lora-hw-version: %.32s", id_eeprom->lora_hw_version);
+#ifdef MTRE
+ log_info("oem-string1: %.32s", id_eeprom->oem_string1);
+ log_info("oem-string2: %.32s", id_eeprom->oem_string2);
+#endif
}
static void mts_ap_eeprom_inspect(struct mts_ap_eeprom_layout *ap_eeprom)
@@ -532,6 +540,10 @@ static void usage(FILE *out) {
fprintf(out, " --lora-eui <EUI-64> |\n");
fprintf(out, " --lora-hw-version <hw-version> |\n");
fprintf(out, " --lora-product-id <product-id> |\n");
+#ifdef MTRE
+ fprintf(out, " --oem-string1 <string> |\n");
+ fprintf(out, " --oem-string2 <string> |\n");
+#endif
fprintf(out, " --imei <imei> |\n");
fprintf(out, " --capa-gps |\n");
fprintf(out, " --capa-din |\n");
@@ -588,6 +600,10 @@ enum {
CMD_OPT_OUT_FORMAT,
CMD_OPT_UPDATE,
CMD_OPT_ACCESSORY_CARD,
+#ifdef MTRE
+ CMD_OPT_OEM_STRING1,
+ CMD_OPT_OEM_STRING2,
+#endif
#ifdef MTCDT3B
CMD_OPT_BASE_BOARD,
CMD_OPT_SLOTS,
@@ -611,6 +627,10 @@ static struct option long_options[] = {
{"hw-version", 1, NULL, CMD_OPT_HW_VERSION},
{"lora-product-id", 1, NULL, CMD_OPT_LORA_PRODUCT_ID},
{"lora-hw-version", 1, NULL, CMD_OPT_LORA_HW_VERSION},
+#ifdef MTRE
+ {"oem-string1", 1, NULL, CMD_OPT_OEM_STRING1},
+ {"oem-string2", 1, NULL, CMD_OPT_OEM_STRING2},
+#endif
{"mac-addr", 1, NULL, CMD_OPT_MAC_ADDR},
{"mac-bluetooth", 1, NULL, CMD_OPT_MAC_BLUETOOTH},
{"mac-wifi", 1, NULL, CMD_OPT_MAC_WIFI},
@@ -679,6 +699,10 @@ int main(int argc, char *argv[]) {
char *lora_eui = NULL;
char *lora_product_id = NULL;
char *lora_hw_version = NULL;
+#ifdef MTRE
+ char *oem_string1 = NULL;
+ char *oem_string2 = NULL;
+#endif
struct mts_id_eeprom_layout id_eeprom;
struct mts_ap_eeprom_layout ap_eeprom;
@@ -837,6 +861,16 @@ int main(int argc, char *argv[]) {
lora_product_id = optarg;
break;
+#ifdef MTRE
+ case CMD_OPT_OEM_STRING1:
+ oem_string1 = optarg;
+ break;
+
+ case CMD_OPT_OEM_STRING2:
+ oem_string2 = optarg;
+ break;
+#endif
+
case CMD_OPT_DEVICE_ID:
device_id = optarg;
break;
@@ -1115,6 +1149,26 @@ int main(int argc, char *argv[]) {
else
EEPROM_SET(id_eeprom,lora_hw_version)
}
+#ifdef MTRE
+ if (oem_string1) {
+ if (! accessory_card) {
+ strncpy(id_eeprom.oem_string1, oem_string1, sizeof(id_eeprom.oem_string1) - 1);
+ } else {
+ log_error("--oem-string1 option is not supported on accessory card eeprom");
+ usage(stderr);
+ exit(1);
+ }
+ }
+ if (oem_string2) {
+ if (! accessory_card) {
+ strncpy(id_eeprom.oem_string2, oem_string2, sizeof(id_eeprom.oem_string2) - 1);
+ } else {
+ log_error("--oem-string2 option is not supported on accessory card eeprom");
+ usage(stderr);
+ exit(1);
+ }
+ }
+#endif
if (lora_eui) {
if (accessory_card)
tmp = hwaddr_aton(lora_eui, ap_eeprom.eui, sizeof(ap_eeprom.eui));