Skip to content

Commit fa12996

Browse files
committed
Added BLE MAC read command
Added command for reading BLE MAC address from the RS9116. Signed-off-by: Jared Baumann <jared.baumann8@t-mobile.com>
1 parent 65f2077 commit fa12996

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

samples/tmo_shell/src/tmo_ble_demo.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,3 +1191,24 @@ int cmd_ble_conn_rssi(const struct shell *shell, size_t argc, char** argv)
11911191
}
11921192
return 0;
11931193
}
1194+
1195+
int cmd_ble_mac(const struct shell *shell, size_t argc, char** argv)
1196+
{
1197+
char mac_addr_buf[sizeof("xx:xx:xx:xx:xx:xx")];
1198+
uint8_t mac_addr[6];
1199+
int ret;
1200+
1201+
ret = bt_get_mac(mac_addr);
1202+
1203+
if (ret) {
1204+
shell_error(shell, "Failed to read mac address (%d)", ret);
1205+
return -EIO;
1206+
}
1207+
1208+
sprintf(mac_addr_buf, "%02x:%02x:%02x:%02x:%02x:%02x", mac_addr[0], mac_addr[1],
1209+
mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
1210+
1211+
shell_print(shell, "BLE Mac Address: %s", mac_addr_buf);
1212+
1213+
return 0;
1214+
}

samples/tmo_shell/src/tmo_ble_demo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ int cmd_ble_adv_ebeacon(const struct shell *shell, size_t argc, char **argv);
2020
int cmd_ble_adv_ibeacon(const struct shell *shell, size_t argc, char **argv);
2121
int cmd_ble_adv_conn(const struct shell *shell, size_t argc, char **argv);
2222
int cmd_ble_conn_rssi(const struct shell *shell, size_t argc, char **argv);
23+
int cmd_ble_mac(const struct shell *shell, size_t argc, char **argv);
2324

2425
#endif

samples/tmo_shell/src/tmo_shell.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,6 +2713,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(tmo_ble_sub,
27132713
#if IS_ENABLED(CONFIG_BT_PERIPHERAL)
27142714
SHELL_CMD(adv, &ble_adv_sub, "BLE advertisement test controls",
27152715
NULL),
2716+
SHELL_CMD(mac, NULL, "BLE MAC read", cmd_ble_mac),
27162717
SHELL_CMD(rssi, NULL, "BLE peripheral RSSI read", cmd_ble_conn_rssi),
27172718
#endif
27182719
SHELL_SUBCMD_SET_END);

0 commit comments

Comments
 (0)