Skip to content

Commit

Permalink
print device info within the filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
brentru committed Apr 11, 2022
1 parent c37a574 commit 4f041be
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
30 changes: 20 additions & 10 deletions src/Wippersnapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1065,16 +1065,16 @@ bool Wippersnapper::buildWSTopics() {
if (WS._username == NULL || WS._key == NULL || WS._network_ssid == NULL ||
WS._network_pass == NULL)
return false;

// TODO: Validate that we've filled the MAC address

// UID Manipulation, TODO refactor?
// Move the top 3 bytes from the UID
for (int i = 5; i > 2; i--) {
WS._macAddr[6 - 1 - i] = WS._macAddr[i];
}
snprintf(WS.sUID, sizeof(WS.sUID), "%02d%02d%02d", WS._macAddr[0], WS._macAddr[1],
WS._macAddr[2]);
snprintf(WS.sUID, sizeof(WS.sUID), "%02d%02d%02d", WS._macAddr[0],
WS._macAddr[1], WS._macAddr[2]);

// Get board ID from _Boards.h
WS._boardId = BOARD_ID;
Expand Down Expand Up @@ -1523,17 +1523,27 @@ bool validateAppCreds() {
/**************************************************************************/
void Wippersnapper::connect() {
WS_DEBUG_PRINTLN("Adafruit.io WipperSnapper");

// Print all identifiers to the debug log
WS_DEBUG_PRINTLN("-------Device Information-------");
WS_DEBUG_PRINT("Firmware Version: "); WS_DEBUG_PRINTLN(WS_VERSION);
WS_DEBUG_PRINT("Board ID: "); WS_DEBUG_PRINTLN(BOARD_ID);
WS_DEBUG_PRINT("Adafruit IO User: "); WS_DEBUG_PRINTLN(WS._username);
WS_DEBUG_PRINT("WiFi Network: "); WS_DEBUG_PRINTLN(WS._network_ssid);

WS_DEBUG_PRINT("Firmware Version: ");
WS_DEBUG_PRINTLN(WS_VERSION);

WS_DEBUG_PRINT("Board ID: ");
WS_DEBUG_PRINTLN(BOARD_ID);

WS_DEBUG_PRINT("Adafruit IO User: ");
WS_DEBUG_PRINTLN(WS._username);

WS_DEBUG_PRINT("WiFi Network: ");
WS_DEBUG_PRINTLN(WS._network_ssid);

char sMAC[18] = {0};
sprintf(sMAC, "%02X:%02X:%02X:%02X:%02X:%02X", WS._macAddr[0], WS._macAddr[1], WS._macAddr[2], WS._macAddr[3], WS._macAddr[4], WS._macAddr[5]);
WS_DEBUG_PRINT("MAC Address: "); WS_DEBUG_PRINTLN(sMAC);
sprintf(sMAC, "%02X:%02X:%02X:%02X:%02X:%02X", WS._macAddr[0], WS._macAddr[1],
WS._macAddr[2], WS._macAddr[3], WS._macAddr[4], WS._macAddr[5]);
WS_DEBUG_PRINT("MAC Address: ");
WS_DEBUG_PRINTLN(sMAC);
WS_DEBUG_PRINTLN("-------------------------------");

// enable WDT
Expand Down
2 changes: 1 addition & 1 deletion src/Wippersnapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class Wippersnapper {
WipperSnapper_LittleFS
*_littleFS; ///< Instance of LittleFS Filesystem (non-native USB)

uint8_t _macAddr[6]; /*!< Unique network iface identifier */
uint8_t _macAddr[6]; /*!< Unique network iface identifier */
char sUID[13]; /*!< Unique network iface identifier */
const char *_boardId; /*!< Adafruit IO+ board string */
Adafruit_MQTT *_mqtt; /*!< Reference to Adafruit_MQTT, _mqtt. */
Expand Down
15 changes: 15 additions & 0 deletions src/provisioning/tinyusb/Wippersnapper_FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,24 @@ void Wippersnapper_FS::eraseBootFile() {
/**************************************************************************/
bool Wippersnapper_FS::createBootFile() {
bool is_success = false;
char sMAC[18] = {0};

File bootFile = wipperFatFs.open("/wipper_boot_out.txt", FILE_WRITE);
if (bootFile) {
bootFile.println("Adafruit.io WipperSnapper");

bootFile.print("Firmware Version: ");
bootFile.println(WS_VERSION);

bootFile.print("Board ID: ");
bootFile.println(BOARD_ID);

bootFile.print("Firmware Version: ");
bootFile.println(WS_VERSION);

sprintf(sMAC, "%02X:%02X:%02X:%02X:%02X:%02X", WS._macAddr[0], WS._macAddr[1], WS._macAddr[2], WS._macAddr[3], WS._macAddr[4], WS._macAddr[5]);
bootFile.print("MAC Address: "); bootFile.println(sMAC);

bootFile.flush();
bootFile.close();
is_success = true;
Expand Down

0 comments on commit 4f041be

Please sign in to comment.