diff --git a/drivers/hwinfo/hwinfo_shell.c b/drivers/hwinfo/hwinfo_shell.c index c827b05119..39104425d5 100644 --- a/drivers/hwinfo/hwinfo_shell.c +++ b/drivers/hwinfo/hwinfo_shell.c @@ -38,6 +38,33 @@ static int cmd_get_device_id(const struct shell *sh, size_t argc, char **argv) return 0; } +static int cmd_get_device_eui64(const struct shell *sh, size_t argc, char **argv) +{ + uint8_t dev_eui64[8]; + int ret; + int i; + + ret = hwinfo_get_device_eui64(dev_eui64); + + if (ret == -ENOSYS) { + shell_error(sh, "Not supported by hardware"); + return -ENOSYS; + } else if (ret < 0) { + shell_error(sh, "Error: %d", ret); + return ret; + } + + shell_fprintf(sh, SHELL_NORMAL, "EUI64: 0x"); + + for (i = 0 ; i < 8 ; i++) { + shell_fprintf(sh, SHELL_NORMAL, "%02x", dev_eui64[i]); + } + + shell_fprintf(sh, SHELL_NORMAL, "\n"); + + return 0; +} + static inline const char *cause_to_string(uint32_t cause) { switch (cause) { @@ -188,6 +215,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_reset_cause, SHELL_STATIC_SUBCMD_SET_CREATE(sub_hwinfo, SHELL_CMD_ARG(devid, NULL, "Show device id", cmd_get_device_id, 1, 0), + SHELL_CMD_ARG(deveui64, NULL, "Show device eui64", cmd_get_device_eui64, 1, 0), SHELL_CMD_ARG(reset_cause, &sub_reset_cause, "Reset cause commands", cmd_show_reset_cause, 1, 0), SHELL_SUBCMD_SET_END /* Array terminated. */