diff options
author | John Klug <john.klug@multitech.com> | 2019-11-04 18:32:15 -0600 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2019-11-04 18:32:15 -0600 |
commit | ae139bfe0a2983a6c71f0a79e316555ab707b088 (patch) | |
tree | 40fdc04ee28aef46b1e7d52acb5eb50d3827d070 | |
parent | 10f75df27ed6051c7673c98d0b1ecc3ff93fb778 (diff) | |
download | mts-id-eeprom-ae139bfe0a2983a6c71f0a79e316555ab707b088.tar.gz mts-id-eeprom-ae139bfe0a2983a6c71f0a79e316555ab707b088.tar.bz2 mts-id-eeprom-ae139bfe0a2983a6c71f0a79e316555ab707b088.zip |
Add the LoRa device IDs for MTCDT3
-rw-r--r-- | src/eeprom_main.c | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/src/eeprom_main.c b/src/eeprom_main.c index 1a68199..93812f6 100644 --- a/src/eeprom_main.c +++ b/src/eeprom_main.c @@ -281,7 +281,15 @@ static int mtcdt3b_yaml_out(const char *name, struct mtcdt3b_eeprom_layout *mtcd fprintf(file, "product-id: \"%.32s\"\n", mtcdt3b_eeprom->product_id); fprintf(file, "device-id: \"%.32s\"\n", mtcdt3b_eeprom->device_id); fprintf(file, "hw-version: \"%.32s\"\n", mtcdt3b_eeprom->hw_version); + fprintf(file, "mac-addr: \"%02X:%02X:%02X:%02X:%02X:%02X\"\n", + mtcdt3b_eeprom->mac_addr[0], + mtcdt3b_eeprom->mac_addr[1], + mtcdt3b_eeprom->mac_addr[2], + mtcdt3b_eeprom->mac_addr[3], + mtcdt3b_eeprom->mac_addr[4], + mtcdt3b_eeprom->mac_addr[5]); fprintf(file, "capa-lora: %s\n", DEVICE_CAPA(mtcdt3b_eeprom->capa, MTCDT3B_CAPA_LORA) ? "true" : "false"); + fprintf(file, "lora-device-id: \"%.32s\"\n", mtcdt3b_eeprom->lora_device_id); fprintf(file, "lora-eui: \"%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\"\n", mtcdt3b_eeprom->lora_eui[0], mtcdt3b_eeprom->lora_eui[1], @@ -291,6 +299,7 @@ static int mtcdt3b_yaml_out(const char *name, struct mtcdt3b_eeprom_layout *mtcd mtcdt3b_eeprom->lora_eui[5], mtcdt3b_eeprom->lora_eui[6], mtcdt3b_eeprom->lora_eui[7]); + fprintf(file, "lora-device-id2: \"%.32s\"\n", mtcdt3b_eeprom->lora_device_id2); fprintf(file, "lora-eui2: \"%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\"\n", mtcdt3b_eeprom->lora_eui2[0], mtcdt3b_eeprom->lora_eui2[1], @@ -436,7 +445,15 @@ static void mtcdt3b_eeprom_inspect(struct mtcdt3b_eeprom_layout *mtcdt3b_eeprom) log_info("product-id: %.32s", mtcdt3b_eeprom->product_id); log_info("device-id: %.32s", mtcdt3b_eeprom->device_id); log_info("hw-version: %.32s", mtcdt3b_eeprom->hw_version); + log_info("mac-addr: \"%02X:%02X:%02X:%02X:%02X:%02X\"\n", + mtcdt3b_eeprom->mac_addr[0], + mtcdt3b_eeprom->mac_addr[1], + mtcdt3b_eeprom->mac_addr[2], + mtcdt3b_eeprom->mac_addr[3], + mtcdt3b_eeprom->mac_addr[4], + mtcdt3b_eeprom->mac_addr[5]); log_info("mtcdt3b-capa-lora: %s", DEVICE_CAPA(mtcdt3b_eeprom->capa, MTCDT3B_CAPA_LORA) ? "yes" : "no"); + log_info("lora-device-id: %.32s", mtcdt3b_eeprom->lora_device_id); log_info("lora-eui: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", mtcdt3b_eeprom->lora_eui[0], mtcdt3b_eeprom->lora_eui[1], @@ -446,6 +463,7 @@ static void mtcdt3b_eeprom_inspect(struct mtcdt3b_eeprom_layout *mtcdt3b_eeprom) mtcdt3b_eeprom->lora_eui[5], mtcdt3b_eeprom->lora_eui[6], mtcdt3b_eeprom->lora_eui[7]); + log_info("lora-device-id-2: %.32s", mtcdt3b_eeprom->lora_device_id2); log_info("lora-eui2: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", mtcdt3b_eeprom->lora_eui2[0], mtcdt3b_eeprom->lora_eui2[1], @@ -483,7 +501,12 @@ 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"); +#ifdef MTCDT3B + fprintf(out, " --lora-eui2 <EUI-64> |\n"); + fprintf(out, " --lora-device-id <lora-device-id> |\n"); + fprintf(out, " --lora-device-id2 <lora-device-id2> |\n"); +#endif + 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"); @@ -535,6 +558,8 @@ enum { CMD_OPT_ACCESSORY_CARD, #ifdef MTCDT3B CMD_OPT_BASE_BOARD, + CMD_OPT_LORA_DEVICE_ID, + CMD_OPT_LORA_DEVICE_ID2, CMD_OPT_LORA_EUI2, #endif CMD_OPT_VERSION, @@ -573,6 +598,9 @@ static struct option long_options[] = { {"accessory-card", 0, NULL, CMD_OPT_ACCESSORY_CARD}, #ifdef MTCDT3B {"base-board", 0, NULL, CMD_OPT_BASE_BOARD}, + {"device-id", 1, NULL, CMD_OPT_DEVICE_ID}, + {"lora-device-id", 1, NULL, CMD_OPT_LORA_DEVICE_ID}, + {"lora-device-id2", 1, NULL, CMD_OPT_LORA_DEVICE_ID2}, {"lora-eui2", 1, NULL, CMD_OPT_LORA_EUI2}, #endif {"version", 0, NULL, CMD_OPT_VERSION}, @@ -594,6 +622,8 @@ int main(int argc, char *argv[]) { #ifdef MTCDT3B int base_board = 0; char *lora_eui2 = NULL; + char *lora_device_id = NULL; + char *lora_device_id2 = NULL; #endif char *vendor_id = NULL; char *product_id = NULL; @@ -609,6 +639,11 @@ int main(int argc, char *argv[]) { #ifdef MTCDT3B struct mtcdt3b_eeprom_layout mtcdt3b_eeprom; memset (&mtcdt3b_eeprom, 0, eeprom_size); + if (sizeof mtcdt3b_eeprom != eeprom_size) { + fprintf(stderr,"Internal error:\n mtcdt3b_eeprom is not the correct size: expected %d, but %d is defined for the part\n", + eeprom_size,sizeof mtcdt3b_eeprom); + exit(1); + } #endif memset(&id_eeprom, 0, eeprom_size); @@ -716,6 +751,12 @@ int main(int argc, char *argv[]) { case CMD_OPT_LORA_EUI2: lora_eui2 = optarg; break; + case CMD_OPT_LORA_DEVICE_ID: + lora_device_id = optarg; + break; + case CMD_OPT_LORA_DEVICE_ID2: + lora_device_id2 = optarg; + break; #endif case CMD_OPT_OUT_FILE: @@ -910,11 +951,8 @@ int main(int argc, char *argv[]) { if (accessory_card) tmp = hwaddr_aton(mac_addr, ap_eeprom.mac_addr, sizeof(ap_eeprom.mac_addr)); #ifdef MTCDT3B - else if(base_board) { - log_error("--mac-addr option is not supported on MTCDT3 base board eeprom"); - usage(stderr); - exit(1); - } + else if(base_board) + tmp = hwaddr_aton(mac_addr, mtcdt3b_eeprom.mac_addr, sizeof(mtcdt3b_eeprom.mac_addr)); #endif else tmp = hwaddr_aton(mac_addr, id_eeprom.mac_addr, sizeof(id_eeprom.mac_addr)); @@ -975,6 +1013,12 @@ int main(int argc, char *argv[]) { if (lora_eui2) if (base_board) tmp = hwaddr_aton(lora_eui2, mtcdt3b_eeprom.lora_eui2, sizeof(mtcdt3b_eeprom.lora_eui2)); + if (lora_device_id) + if (base_board) + EEPROM_SET(mtcdt3b_eeprom,lora_device_id); + if (lora_device_id2) + if (base_board) + EEPROM_SET(mtcdt3b_eeprom,lora_device_id2); #endif // updating eeprom in place, force bin format |