diff options
author | Jesse Gilles <jgilles@multitech.com> | 2012-08-22 11:47:47 -0500 |
---|---|---|
committer | Jesse Gilles <jgilles@multitech.com> | 2012-08-22 11:47:47 -0500 |
commit | 89af83db85810eb2e3e41f50b4e48b4350c9e0fd (patch) | |
tree | 2a1a489422acfdeae83279087bc4a571d02b1c8a | |
parent | d143de5b6fbf012cfb0fbca1d8b61cf08e16b110 (diff) | |
download | mts-id-eeprom-89af83db85810eb2e3e41f50b4e48b4350c9e0fd.tar.gz mts-id-eeprom-89af83db85810eb2e3e41f50b4e48b4350c9e0fd.tar.bz2 mts-id-eeprom-89af83db85810eb2e3e41f50b4e48b4350c9e0fd.zip |
add bluetooth, wifi flags and mac addresses, ability to update eeprom in place
-rw-r--r-- | src/eeprom_main.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/eeprom_main.c b/src/eeprom_main.c index 6fe49cc..1eeca17 100644 --- a/src/eeprom_main.c +++ b/src/eeprom_main.c @@ -19,6 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * 2012-07-30 JSR - Added wifi and bluetooth capa flags */ #include <stdio.h> @@ -117,6 +118,8 @@ static int yaml_out(const char *name, struct mts_id_eeprom_layout *id_eeprom) fprintf(file, "capa-din: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_DIN) ? "true" : "false"); fprintf(file, "capa-dout: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_DOUT) ? "true" : "false"); fprintf(file, "capa-adc: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_ADC) ? "true" : "false"); + fprintf(file, "capa-wifi: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_WIFI) ? "true" : "false"); + fprintf(file, "capa-bluetooth: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_BLUETOOTH) ? "true" : "false"); fprintf(file, "capa: \""); int i; @@ -125,6 +128,20 @@ static int yaml_out(const char *name, struct mts_id_eeprom_layout *id_eeprom) } fprintf(file, "\"\n"); + fprintf(file, "mac-bluetooth: \"%02X:%02X:%02X:%02X:%02X:%02X\"\n", + id_eeprom->mac_bluetooth[0], + id_eeprom->mac_bluetooth[1], + id_eeprom->mac_bluetooth[2], + id_eeprom->mac_bluetooth[3], + id_eeprom->mac_bluetooth[4], + id_eeprom->mac_bluetooth[5]); + fprintf(file, "mac-wifi: \"%02X:%02X:%02X:%02X:%02X:%02X\"\n", + id_eeprom->mac_wifi[0], + id_eeprom->mac_wifi[1], + id_eeprom->mac_wifi[2], + id_eeprom->mac_wifi[3], + id_eeprom->mac_wifi[4], + id_eeprom->mac_wifi[5]); fprintf(file, "...\n"); fclose(file); @@ -180,6 +197,23 @@ static void mts_id_eeprom_inspect(struct mts_id_eeprom_layout *id_eeprom) log_info("capa-din: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_DIN) ? "yes" : "no"); log_info("capa-dout: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_DOUT) ? "yes" : "no"); log_info("capa-adc: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_ADC) ? "yes" : "no"); + log_info("capa-wifi: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_WIFI) ? "yes" : "no"); + log_info("capa-bluetooth: %s\n", DEVICE_CAPA(id_eeprom->capa, CAPA_BLUETOOTH) ? "yes" : "no"); + + log_info("mac-bluetooth: %02X:%02X:%02X:%02X:%02X:%02X", + id_eeprom->mac_bluetooth[0], + id_eeprom->mac_bluetooth[1], + id_eeprom->mac_bluetooth[2], + id_eeprom->mac_bluetooth[3], + id_eeprom->mac_bluetooth[4], + id_eeprom->mac_bluetooth[5]); + log_info("mac-wifi: %02X:%02X:%02X:%02X:%02X:%02X", + id_eeprom->mac_wifi[0], + id_eeprom->mac_wifi[1], + id_eeprom->mac_wifi[2], + id_eeprom->mac_wifi[3], + id_eeprom->mac_wifi[4], + id_eeprom->mac_wifi[5]); } static void print_version(const char *name) { @@ -201,13 +235,18 @@ static void usage(FILE *out) { fprintf(out, " --device-id <device-id> |\n"); fprintf(out, " --hw-version <hw-version> |\n"); fprintf(out, " --mac-addr <mac-addr> |\n"); + fprintf(out, " --mac-bluetooth <mac-addr> |\n"); + fprintf(out, " --mac-wifi <mac-addr> |\n"); fprintf(out, " --imei <imei> |\n"); fprintf(out, " --capa-gps |\n"); fprintf(out, " --capa-din |\n"); fprintf(out, " --capa-dout |\n"); fprintf(out, " --capa-adc |\n"); + fprintf(out, " --capa-wifi |\n"); + fprintf(out, " --capa-bluetooth |\n"); fprintf(out, " --capa <capa> |\n"); fprintf(out, " --out-format { bin | yaml (default) } |\n"); + fprintf(out, " --update\n"); fprintf(out, " }\n"); fprintf(out, "\n"); } @@ -220,13 +259,18 @@ enum { CMD_OPT_DEVICE_ID, CMD_OPT_HW_VERSION, CMD_OPT_MAC_ADDR, + CMD_OPT_MAC_BLUETOOTH, + CMD_OPT_MAC_WIFI, CMD_OPT_IMEI, CMD_OPT_CAPA_GPS, CMD_OPT_CAPA_DIN, CMD_OPT_CAPA_DOUT, CMD_OPT_CAPA_ADC, + CMD_OPT_CAPA_WIFI, + CMD_OPT_CAPA_BLUETOOTH, CMD_OPT_CAPA, CMD_OPT_OUT_FORMAT, + CMD_OPT_UPDATE, CMD_OPT_VERSION, CMD_OPT_HELP, }; @@ -240,13 +284,18 @@ static struct option long_options[] = { {"device-id", 1, NULL, CMD_OPT_DEVICE_ID}, {"hw-version", 1, NULL, CMD_OPT_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}, {"imei", 1, NULL, CMD_OPT_IMEI}, {"capa-gps", 0, NULL, CMD_OPT_CAPA_GPS}, {"capa-din", 0, NULL, CMD_OPT_CAPA_DIN}, {"capa-dout", 0, NULL, CMD_OPT_CAPA_DOUT}, {"capa-adc", 0, NULL, CMD_OPT_CAPA_ADC}, + {"capa-wifi", 0, NULL, CMD_OPT_CAPA_WIFI}, + {"capa-bluetooth", 0, NULL, CMD_OPT_CAPA_BLUETOOTH}, {"capa", 1, NULL, CMD_OPT_CAPA}, {"out-format", 1, NULL, CMD_OPT_OUT_FORMAT}, + {"update", 0, NULL, CMD_OPT_UPDATE}, {"version", 0, NULL, CMD_OPT_VERSION}, {"help", 0, NULL, CMD_OPT_HELP}, {0, 0, 0, 0}, @@ -279,6 +328,11 @@ int main(int argc, char *argv[]) { DEVICE_CAPA_SET(id_eeprom.capa, CAPA_DIN); DEVICE_CAPA_SET(id_eeprom.capa, CAPA_DOUT); DEVICE_CAPA_SET(id_eeprom.capa, CAPA_ADC); + DEVICE_CAPA_SET(id_eeprom.capa, CAPA_WIFI); + DEVICE_CAPA_SET(id_eeprom.capa, CAPA_BLUETOOTH); + + hwaddr_aton("00:d0:a0:02:0d:e2", id_eeprom.mac_bluetooth, sizeof(id_eeprom.mac_bluetooth)); + hwaddr_aton("00:d0:a0:02:0d:e3", id_eeprom.mac_wifi, sizeof(id_eeprom.mac_wifi)); #endif while((i = getopt_long(argc, argv, short_options, long_options, &option_index)) >= 0) { @@ -310,6 +364,9 @@ int main(int argc, char *argv[]) { break; + case CMD_OPT_UPDATE: + out_file = in_file; + break; case CMD_OPT_OUT_FILE: out_file = optarg; break; @@ -339,6 +396,24 @@ int main(int argc, char *argv[]) { } break; + case CMD_OPT_MAC_BLUETOOTH: + tmp = hwaddr_aton(optarg, id_eeprom.mac_bluetooth, sizeof(id_eeprom.mac_bluetooth)); + if (!tmp) { + log_error("invalid mac-bluetooth %s", optarg); + usage(stderr); + exit(1); + } + break; + + case CMD_OPT_MAC_WIFI: + tmp = hwaddr_aton(optarg, id_eeprom.mac_wifi, sizeof(id_eeprom.mac_wifi)); + if (!tmp) { + log_error("invalid mac-wifi %s", optarg); + usage(stderr); + exit(1); + } + break; + case CMD_OPT_IMEI: strncpy(id_eeprom.imei, optarg, sizeof(id_eeprom.imei) - 1); break; @@ -359,6 +434,14 @@ int main(int argc, char *argv[]) { DEVICE_CAPA_SET(id_eeprom.capa, CAPA_ADC); break; + case CMD_OPT_CAPA_WIFI: + DEVICE_CAPA_SET(id_eeprom.capa, CAPA_WIFI); + break; + + case CMD_OPT_CAPA_BLUETOOTH: + DEVICE_CAPA_SET(id_eeprom.capa, CAPA_BLUETOOTH); + break; + case CMD_OPT_CAPA: log_error("capa option not implemented"); exit(1); |