summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVolodymyr Vorobiov <volodymyr.vorobiov@globallogic.com>2020-11-19 14:38:24 +0200
committerJohn Klug <john.klug@multitech.com>2020-11-23 09:52:02 -0600
commit10f8b9c9ce6e4d06341bed6b694fa4d2cb82e224 (patch)
treec195e2ea318b23fb83bb77fd8970e9cc13d4e0ea /src
parent55d3f2e066aed056605ac8448d51a067f963932c (diff)
downloadmts-id-eeprom-10f8b9c9ce6e4d06341bed6b694fa4d2cb82e224.tar.gz
mts-id-eeprom-10f8b9c9ce6e4d06341bed6b694fa4d2cb82e224.tar.bz2
mts-id-eeprom-10f8b9c9ce6e4d06341bed6b694fa4d2cb82e224.zip
[MTX-3702] Conduit 300: Add support ethernet switch to base board eeprom
Diffstat (limited to 'src')
-rw-r--r--src/eeprom_main.c81
1 files changed, 72 insertions, 9 deletions
diff --git a/src/eeprom_main.c b/src/eeprom_main.c
index 8b805b3..a51aaa9 100644
--- a/src/eeprom_main.c
+++ b/src/eeprom_main.c
@@ -173,7 +173,7 @@ static int id_yaml_out(const char *name, struct mts_id_eeprom_layout *id_eeprom)
fprintf(file, "capa-supercap: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_SUPERCAP) ? "true" : "false");
fprintf(file, "capa-cellular: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_CELLULAR) ? "true" : "false");
fprintf(file, "capa: \"");
-
+
for (i = 0; i < sizeof(id_eeprom->capa); i++) {
fprintf(file, "\\x%02X", id_eeprom->capa[i]);
}
@@ -316,7 +316,16 @@ static int mtcdt3b_yaml_out(const char *name, struct mtcdt3b_eeprom_layout *mtcd
mtcdt3b_eeprom->slot[i].lora_eui[6],
mtcdt3b_eeprom->slot[i].lora_eui[7]);
}
- fprintf(file, "...\n");
+ fprintf(file, "capa-eth-switch: %s\n", DEVICE_CAPA(mtcdt3b_eeprom->capa, MTCDT3B_CAPA_ETH_SWITCH) ? "true" : "false");
+ fprintf(file, "hw-version-eth-switch: %hu\n", mtcdt3b_eeprom->hw_version_eth_switch);
+ fprintf(file, "mac-eth-switch: \"%02X:%02X:%02X:%02X:%02X:%02X\"\n",
+ mtcdt3b_eeprom->mac_eth_switch[0],
+ mtcdt3b_eeprom->mac_eth_switch[1],
+ mtcdt3b_eeprom->mac_eth_switch[2],
+ mtcdt3b_eeprom->mac_eth_switch[3],
+ mtcdt3b_eeprom->mac_eth_switch[4],
+ mtcdt3b_eeprom->mac_eth_switch[5]);
+ fprintf(file, "...\n");
fclose(file);
@@ -485,6 +494,15 @@ static void mtcdt3b_eeprom_inspect(struct mtcdt3b_eeprom_layout *mtcdt3b_eeprom)
mtcdt3b_eeprom->slot[i].lora_eui[6],
mtcdt3b_eeprom->slot[i].lora_eui[7]);
}
+ log_info("capa-eth-switch: %s", DEVICE_CAPA(mtcdt3b_eeprom->capa, MTCDT3B_CAPA_ETH_SWITCH) ? "yes" : "no");
+ log_info("hw-version-eth-switch: %hu", mtcdt3b_eeprom->hw_version_eth_switch);
+ log_info("mac-eth-switch: \"%02X:%02X:%02X:%02X:%02X:%02X\"",
+ mtcdt3b_eeprom->mac_eth_switch[0],
+ mtcdt3b_eeprom->mac_eth_switch[1],
+ mtcdt3b_eeprom->mac_eth_switch[2],
+ mtcdt3b_eeprom->mac_eth_switch[3],
+ mtcdt3b_eeprom->mac_eth_switch[4],
+ mtcdt3b_eeprom->mac_eth_switch[5]);
}
#endif
@@ -512,7 +530,7 @@ static void usage(FILE *out) {
fprintf(out, " --mac-bluetooth <mac-addr> |\n");
fprintf(out, " --mac-wifi <mac-addr> |\n");
fprintf(out, " --lora-eui <EUI-64> |\n");
- fprintf(out, " --lora-hw-version <hw-version> |\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");
@@ -533,6 +551,9 @@ static void usage(FILE *out) {
#ifdef MTCDT3B
fprintf(out, " --base-board\n");
fprintf(out, " --slot i=0,device-id=<device-id>,lora-eui=<EUI-64>,i=1,...\n");
+ fprintf(out, " --capa-eth-switch \n");
+ fprintf(out, " --eth-switch-version <switch-version> \n");
+ fprintf(out, " --eth-switch-mac-addr <switch-mac-addr> \n");
#endif
fprintf(out, " }\n");
fprintf(out, "\n");
@@ -562,14 +583,17 @@ enum {
CMD_OPT_CAPA_LORA,
CMD_OPT_CAPA_BATTERY,
CMD_OPT_CAPA_SUPERCAP,
- CMD_OPT_CAPA_CELLULAR,
+ CMD_OPT_CAPA_CELLULAR,
CMD_OPT_CAPA_CLEAR,
CMD_OPT_OUT_FORMAT,
CMD_OPT_UPDATE,
CMD_OPT_ACCESSORY_CARD,
#ifdef MTCDT3B
- CMD_OPT_BASE_BOARD,
- CMD_OPT_SLOTS,
+ CMD_OPT_BASE_BOARD,
+ CMD_OPT_SLOTS,
+ CMD_OPT_CAPA_ETH_SWITCH,
+ CMD_OPT_ETH_SWITCH_VERSION,
+ CMD_OPT_ETH_SWITCH_MAC_ADDR,
#endif
CMD_OPT_VERSION,
CMD_OPT_HELP,
@@ -609,7 +633,10 @@ static struct option long_options[] = {
{"accessory-card", 0, NULL, CMD_OPT_ACCESSORY_CARD},
#ifdef MTCDT3B
{"base-board", 0, NULL, CMD_OPT_BASE_BOARD},
- {"slots", 1, NULL, CMD_OPT_SLOTS},
+ {"slots", 1, NULL, CMD_OPT_SLOTS},
+ {"capa-eth-switch", 0, NULL, CMD_OPT_CAPA_ETH_SWITCH},
+ {"eth-switch-version", 1, NULL, CMD_OPT_ETH_SWITCH_VERSION},
+ {"eth-switch-mac-addr", 1, NULL, CMD_OPT_ETH_SWITCH_MAC_ADDR},
#endif
{"version", 0, NULL, CMD_OPT_VERSION},
{"help", 0, NULL, CMD_OPT_HELP},
@@ -642,7 +669,7 @@ int main(int argc, char *argv[]) {
int accessory_card = 0;
#ifdef MTCDT3B
int base_board = 0;
- char *slots = NULL;
+ char *slots = NULL;
#endif
char *vendor_id = NULL;
char *product_id = NULL;
@@ -909,7 +936,7 @@ int main(int argc, char *argv[]) {
case CMD_OPT_CAPA_BATTERY:
DEVICE_CAPA_SET(id_eeprom.capa, CAPA_BATTERY);
break;
-
+
case CMD_OPT_CAPA_SUPERCAP:
DEVICE_CAPA_SET(id_eeprom.capa, CAPA_SUPERCAP);
break;
@@ -947,6 +974,42 @@ int main(int argc, char *argv[]) {
}
exit(0);
}
+#ifdef MTCDT3B
+ case CMD_OPT_CAPA_ETH_SWITCH:
+ if (base_board) {
+ DEVICE_CAPA_SET(mtcdt3b_eeprom.capa, MTCDT3B_CAPA_ETH_SWITCH);
+ break;
+ }
+ break;
+ case CMD_OPT_ETH_SWITCH_VERSION:
+ if (base_board) {
+ uint16_t u16;
+ if (sscanf(optarg, "%hu", &u16) != 1) {
+ log_error("invalid eth-switch-version %s", optarg);
+ usage(stderr);
+ exit(1);
+ }
+ if (u16 < ETH_SWITCH_MIN || u16 >= ETH_SWITCH_MAX) {
+ log_error("invalid eth-switch-version %s", optarg);
+ usage(stderr);
+ exit(1);
+ }
+ mtcdt3b_eeprom.hw_version_eth_switch = u16;
+ break;
+ }
+ break;
+ case CMD_OPT_ETH_SWITCH_MAC_ADDR:
+ if (base_board) {
+ tmp = hwaddr_aton(optarg, mtcdt3b_eeprom.mac_eth_switch, sizeof(mtcdt3b_eeprom.mac_eth_switch));
+ if (!tmp) {
+ log_error("invalid eth-switch-mac-addr %s", optarg);
+ usage(stderr);
+ exit(1);
+ }
+ break;
+ }
+ break;
+#endif
default:
usage(stderr);
exit(1);