Skip to content

Commit

Permalink
Follow the basic Memfault SDK integration steps
Browse files Browse the repository at this point in the history
  • Loading branch information
fnune committed Feb 15, 2021
1 parent 6671fbf commit edbfc2c
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/components/memfault_port/memfault-firmware-sdk"]
path = src/components/memfault_port/memfault-firmware-sdk
url = https://github.com/memfault/memfault-firmware-sdk.git
4 changes: 4 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ PROJECT_NAME := toastboard

EXTRA_COMPONENT_DIRS = $(IDF_PATH)/examples/common_components/protocol_examples_common

EXTRA_COMPONENT_DIRS += \
components/memfault_port/memfault-firmware-sdk/ports/esp8266_sdk/memfault \
components/memfault_port/memfault-firmware-sdk/ports/esp8266_sdk/memfault_freertos

include $(IDF_PATH)/make/project.mk

5 changes: 5 additions & 0 deletions src/components/memfault_port/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
config MEMFAULT_API_KEY
string "Your Memfault project API key"
default "YOUR_PROJECT_API_KEY"
help
Get it from https://app.memfault.com/organizations/memfault/projects/toastboard/settings
2 changes: 2 additions & 0 deletions src/components/memfault_port/component.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
COMPONENT_ADD_INCLUDEDIRS := config

Empty file.
Empty file.
1 change: 1 addition & 0 deletions src/components/memfault_port/memfault-firmware-sdk
Submodule memfault-firmware-sdk added at 1afdc3
37 changes: 37 additions & 0 deletions src/components/memfault_port/memfault_port.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//! @file components/memfault_port/memfault_port.c

#include "memfault/components.h"

#include <stdio.h>

#include "memfault/esp8266_port/core.h"

sMfltHttpClientConfig g_mflt_http_client_config = {
.api_key = "YOUR_PROJECT_API_KEY",
};

static char s_fw_version[32];

void memfault_platform_get_device_info(sMemfaultDeviceInfo *info) {
if (s_fw_version[0] == 0) {
// initialize version
char build_id[7];
memfault_build_id_get_string(build_id, sizeof(build_id));
snprintf(s_fw_version, sizeof(s_fw_version), "1.0.0+%s", build_id);
}

// platform specific version information. For more details
// see https://mflt.io/version-nomenclature
*info = (sMemfaultDeviceInfo) {
.device_serial = "DEMOSERIAL",
.software_type = "app-fw",
.software_version = s_fw_version,
.hardware_version = "dvt",
};
}

int memfault_platform_boot(void) {
memfault_esp_port_boot();
return 0;
}

0 comments on commit edbfc2c

Please sign in to comment.