summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.in2
-rw-r--r--src/eeprom_main.c78
2 files changed, 66 insertions, 14 deletions
diff --git a/configure.in b/configure.in
index 1b58026..f80ac3c 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
AC_INIT([src/eeprom_main.c])
-AM_INIT_AUTOMAKE([mts-id-eeprom], [0.2.8])
+AM_INIT_AUTOMAKE([mts-id-eeprom], [0.2.9])
AM_CONFIG_HEADER([config.h])
AC_PROG_CC
diff --git a/src/eeprom_main.c b/src/eeprom_main.c
index ad81734..bea72e7 100644
--- a/src/eeprom_main.c
+++ b/src/eeprom_main.c
@@ -162,6 +162,7 @@ static int id_yaml_out(const char *name, struct mts_id_eeprom_layout *id_eeprom)
fprintf(file, "capa-bluetooth: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_BLUETOOTH) ? "true" : "false");
fprintf(file, "capa-wifi-bluetooth: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_WIFI_BT) ? "true" : "false");
fprintf(file, "capa-gnss: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_GNSS) ? "true" : "false");
+ fprintf(file, "capa-lora: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_LORA) ? "true" : "false");
fprintf(file, "capa: \"");
@@ -200,6 +201,9 @@ static int id_yaml_out(const char *name, struct mts_id_eeprom_layout *id_eeprom)
id_eeprom->lora_eui[6],
id_eeprom->lora_eui[7]);
+ fprintf(file, "lora-product-id: \"%.32s\"\n", id_eeprom->lora_product_id);
+ fprintf(file, "lora-hw-version: \"%.32s\"\n", id_eeprom->lora_hw_version);
+
fprintf(file, "...\n");
fclose(file);
@@ -305,8 +309,9 @@ static void mts_id_eeprom_inspect(struct mts_id_eeprom_layout *id_eeprom)
log_info("capa-adc: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_ADC) ? "yes" : "no");
log_info("capa-wifi: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_WIFI) ? "yes" : "no");
log_info("capa-bluetooth: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_BLUETOOTH) ? "yes" : "no");
- log_info("capa-wifi-bluetooth: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_WIFI_BT) ? "yes" : "no");
- log_info("capa-gnss: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_GNSS) ? "yes" : "no");
+ log_info("capa-wifi-bluetooth: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_WIFI_BT) ? "yes" : "no");
+ log_info("capa-gnss: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_GNSS) ? "yes" : "no");
+ log_info("capa-lora: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_LORA) ? "yes" : "no");
log_info("mac-bluetooth: %02X:%02X:%02X:%02X:%02X:%02X",
id_eeprom->mac_bluetooth[0],
@@ -329,7 +334,7 @@ static void mts_id_eeprom_inspect(struct mts_id_eeprom_layout *id_eeprom)
}
log_info("uuid: %s", (char*)buf);
- log_info("lora-eui: \"%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\"\n",
+ log_info("lora-eui: \"%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\"",
id_eeprom->lora_eui[0],
id_eeprom->lora_eui[1],
id_eeprom->lora_eui[2],
@@ -338,6 +343,9 @@ static void mts_id_eeprom_inspect(struct mts_id_eeprom_layout *id_eeprom)
id_eeprom->lora_eui[5],
id_eeprom->lora_eui[6],
id_eeprom->lora_eui[7]);
+
+ log_info("lora-product-id: %.32s", id_eeprom->lora_product_id);
+ log_info("lora-hw-version: %.32s", id_eeprom->lora_hw_version);
}
static void mts_ap_eeprom_inspect(struct mts_ap_eeprom_layout *ap_eeprom)
@@ -387,7 +395,9 @@ static void usage(FILE *out) {
fprintf(out, " --mac-addr <mac-addr> |\n");
fprintf(out, " --mac-bluetooth <mac-addr> |\n");
fprintf(out, " --mac-wifi <mac-addr> |\n");
- fprintf(out, " --eui <EUI-64> |\n");
+ fprintf(out, " --lora-eui <EUI-64> |\n");
+ fprintf(out, " --lora-hw-version <hw-version> |\n");
+ fprintf(out, " --lora-product-id <product-id> |\n");
fprintf(out, " --imei <imei> |\n");
fprintf(out, " --capa-gps |\n");
fprintf(out, " --capa-din |\n");
@@ -397,6 +407,7 @@ static void usage(FILE *out) {
fprintf(out, " --capa-bluetooth |\n");
fprintf(out, " --capa-wifi-bluetooth |\n");
fprintf(out, " --capa-gnss |\n");
+ fprintf(out, " --capa-lora |\n");
fprintf(out, " --capa-clear (clears all flags) |\n");
fprintf(out, " --out-format { bin | yaml (default) } |\n");
fprintf(out, " --update |\n");
@@ -416,7 +427,9 @@ enum {
CMD_OPT_MAC_ADDR,
CMD_OPT_MAC_BLUETOOTH,
CMD_OPT_MAC_WIFI,
- CMD_OPT_EUI,
+ CMD_OPT_LORA_EUI,
+ CMD_OPT_LORA_HW_VERSION,
+ CMD_OPT_LORA_PRODUCT_ID,
CMD_OPT_IMEI,
CMD_OPT_CAPA_GPS,
CMD_OPT_CAPA_DIN,
@@ -426,10 +439,12 @@ enum {
CMD_OPT_CAPA_BLUETOOTH,
CMD_OPT_CAPA_WIFI_BT,
CMD_OPT_CAPA_GNSS,
+ CMD_OPT_CAPA_LORA,
CMD_OPT_CAPA_CLEAR,
CMD_OPT_OUT_FORMAT,
CMD_OPT_UPDATE,
CMD_OPT_ACCESSORY_CARD,
+
CMD_OPT_VERSION,
CMD_OPT_HELP,
};
@@ -443,10 +458,12 @@ static struct option long_options[] = {
{"device-id", 1, NULL, CMD_OPT_DEVICE_ID},
{"uuid", 1, NULL, CMD_OPT_UUID},
{"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},
{"mac-addr", 1, NULL, CMD_OPT_MAC_ADDR},
{"mac-bluetooth", 1, NULL, CMD_OPT_MAC_BLUETOOTH},
{"mac-wifi", 1, NULL, CMD_OPT_MAC_WIFI},
- {"eui", 1, NULL, CMD_OPT_EUI},
+ {"lora-eui", 1, NULL, CMD_OPT_LORA_EUI},
{"imei", 1, NULL, CMD_OPT_IMEI},
{"capa-gps", 0, NULL, CMD_OPT_CAPA_GPS},
{"capa-din", 0, NULL, CMD_OPT_CAPA_DIN},
@@ -456,6 +473,7 @@ static struct option long_options[] = {
{"capa-bluetooth", 0, NULL, CMD_OPT_CAPA_BLUETOOTH},
{"capa-wifi-bluetooth", 0, NULL, CMD_OPT_CAPA_WIFI_BT},
{"capa-gnss", 0, NULL, CMD_OPT_CAPA_GNSS},
+ {"capa-lora", 0, NULL, CMD_OPT_CAPA_LORA},
{"capa-clear", 0, NULL, CMD_OPT_CAPA_CLEAR},
{"out-format", 1, NULL, CMD_OPT_OUT_FORMAT},
{"update", 0, NULL, CMD_OPT_UPDATE},
@@ -483,7 +501,9 @@ int main(int argc, char *argv[]) {
char *uuid = NULL;
char *hw_version = NULL;
char *mac_addr = NULL;
- char *eui = NULL;
+ char *lora_eui = NULL;
+ char *lora_product_id = NULL;
+ char *lora_hw_version = NULL;
struct mts_id_eeprom_layout id_eeprom;
struct mts_ap_eeprom_layout ap_eeprom;
@@ -603,6 +623,10 @@ int main(int argc, char *argv[]) {
product_id = optarg;
break;
+ case CMD_OPT_LORA_PRODUCT_ID:
+ lora_product_id = optarg;
+ break;
+
case CMD_OPT_DEVICE_ID:
device_id = optarg;
break;
@@ -624,6 +648,10 @@ int main(int argc, char *argv[]) {
hw_version = optarg;
break;
+ case CMD_OPT_LORA_HW_VERSION:
+ lora_hw_version = optarg;
+ break;
+
case CMD_OPT_MAC_ADDR:
mac_addr = optarg;
break;
@@ -646,8 +674,8 @@ int main(int argc, char *argv[]) {
}
break;
- case CMD_OPT_EUI:
- eui = optarg;
+ case CMD_OPT_LORA_EUI:
+ lora_eui = optarg;
break;
case CMD_OPT_IMEI:
@@ -685,6 +713,10 @@ int main(int argc, char *argv[]) {
case CMD_OPT_CAPA_GNSS:
DEVICE_CAPA_SET(id_eeprom.capa, CAPA_GNSS);
break;
+
+ case CMD_OPT_CAPA_LORA:
+ DEVICE_CAPA_SET(id_eeprom.capa, CAPA_LORA);
+ break;
case CMD_OPT_CAPA_CLEAR:
memset(id_eeprom.capa, 0, sizeof(id_eeprom.capa));
@@ -747,15 +779,35 @@ int main(int argc, char *argv[]) {
exit(1);
}
}
- if (eui) {
+ // on-board lora product id
+ if (lora_product_id) {
+ if (! accessory_card) {
+ strncpy(id_eeprom.lora_product_id, lora_product_id, sizeof(id_eeprom.lora_product_id) - 1);
+ } else {
+ log_error("--lora-product-id option is not supported on accessory card eeprom");
+ usage(stderr);
+ exit(1);
+ }
+ }
+ // on-board lora hw version
+ if (lora_hw_version) {
+ if (! accessory_card) {
+ strncpy(id_eeprom.lora_hw_version, lora_hw_version, sizeof(id_eeprom.lora_hw_version) - 1);
+ } else {
+ log_error("--lora-hw-version option is not supported on accessory card eeprom");
+ usage(stderr);
+ exit(1);
+ }
+ }
+ if (lora_eui) {
if (!accessory_card) {
- tmp = hwaddr_aton(eui, id_eeprom.lora_eui, sizeof(id_eeprom.lora_eui));
+ tmp = hwaddr_aton(lora_eui, id_eeprom.lora_eui, sizeof(id_eeprom.lora_eui));
}
else {
- tmp = hwaddr_aton(eui, ap_eeprom.eui, sizeof(ap_eeprom.eui));
+ tmp = hwaddr_aton(lora_eui, ap_eeprom.eui, sizeof(ap_eeprom.eui));
}
if (!tmp) {
- log_error("invalid EUI %s", eui);
+ log_error("invalid EUI %s", lora_eui);
usage(stderr);
exit(1);
}