Skip to content

Instantly share code, notes, and snippets.

View ejohnso49's full-sized avatar
🌭

Eric Johnson ejohnso49

🌭
  • Memfault
  • Chicago, IL
View GitHub Profile
@ejohnso49
ejohnso49 / flags.mk
Created January 4, 2024 06:49
Target built when flags change
.PHONY: force
$(TEST_TARGET).flags: force Makefile
$(SILENCE)mkdir -p $(dir $@)
$(SILENCE)echo '$(RAW_FLAGS)' | cmp -s - $@ || echo '$(RAW_FLAGS)' > $@
@ejohnso49
ejohnso49 / memfault_demo_cli.c
Last active August 11, 2023 16:03
Memfault + Gecko SDK CLI (copy into memfault-firmware-sdk/ports/emlib)
//! @file
//!
//! @brief
//! Adds a basic set of commands for interacting with Memfault SDK
#include <stdlib.h>
#include "memfault/components.h"
#ifdef SL_COMPONENT_CATALOG_PRESENT
#include "sl_component_catalog.h"
@ejohnso49
ejohnso49 / mqtt.py
Created June 23, 2023 15:48
Simple MQTT -> Memfault Forwarder
import paho.mqtt.client as mqtt
import requests
# MQTT broker configuration
broker_address = "localhost"
broker_port = 1883
broker_username = "test"
broker_password = "test1234"
# Memfault HTTP endpoint configuration
@ejohnso49
ejohnso49 / events_example.py
Created April 24, 2023 13:52
Events Endpoint Example
import json
import requests
url = "https://ingress.memfault.com/api/v0/events"
payload = json.dumps(
[
{
"type": "heartbeat",
@ejohnso49
ejohnso49 / exporter.py
Last active April 19, 2023 13:26
Continuously export Memfault chunks from serial port
import pathlib
import subprocess
import click
import serial
def run_cli_post_chunks(output, project_key, device_serial):
args = [
"memfault",
@ejohnso49
ejohnso49 / flake.nix
Last active July 30, 2023 23:26
Zephyr Nix Flake
{
description = "Flake used to setup development environment for Zephyr";
# Nixpkgs / NixOS version to use.
inputs.nixpkgs.url = "nixpkgs/nixos-21.11";
# mach-nix used to create derivation for Python dependencies in the requirements.txt files
inputs.mach-nix.url = "mach-nix/3.5.0";
outputs = { self, nixpkgs, mach-nix }: