Skip to content

Instantly share code, notes, and snippets.

View mfiumara's full-sized avatar

Mattia mfiumara

View GitHub Profile
@mfiumara
mfiumara / output SW2 @ NRF91
Created November 27, 2022 22:21
Output BMP
./src/blackmagic -tv 1
Black Magic Debug App v1.8.0-1139-g97b5c115-dirty
for Black Magic Probe, ST-Link v2 and v3, CMSIS-DAP, JLink and libftdi/MPSSE
Using 1d50:6018 98B72495 Black Magic Debug
Black Magic Probe v1.8.0-1139-g97b5c115-dirty
Running in Test Mode
Target voltage: 1.8V Volt
Speed set to 3.2727 MHz for SWD
scan_multidrop: true
DP DPIDR 0x6ba02477 (v2 rev0) designer 0x43b partno 0xba
@mfiumara
mfiumara / mqtt_pub_sub.rs
Last active October 8, 2022 15:36
MQTT publish and subscribe
// Spawn thread to listen to incoming events on the mqtt connection
thread::spawn(move || {
println!("MQTT Listening for messages");
while let Some(msg) = connection.next() {
match msg {
Err(e) => println!("MQTT Message ERROR: {}", e),
Ok(event) => {
println!("MQTT Event: {:?}", event);
// Wait for a received event
@mfiumara
mfiumara / mqtt_setup.rs
Created October 2, 2022 20:05
MQTT set-up
let mqtt_conf = MqttClientConfiguration {
client_id: Some("my-esp32"),
..Default::default()
};
let (mut mqtt_client, mut connection) = EspMqttClient::new_with_conn(
"mqtt://broker.emqx.io",
&mqtt_conf
).unwrap();
@mfiumara
mfiumara / wifi_setup.rs
Last active October 2, 2022 20:05
WiFi set-up
// Initialize wifi configuration as a client configuration
let mut wifi = EspWifi::new(
Arc::new(EspNetifStack::new().unwrap()),
Arc::new(EspSysLoopStack::new().unwrap()),
Arc::new(EspDefaultNvs::new().unwrap()),
).unwrap();
wifi.set_configuration(
&Configuration::Client(ClientConfiguration {
ssid: "<SSID>".into(),
@mfiumara
mfiumara / rust_on_esp_setup.sh
Last active September 28, 2022 20:55
Rust set-up for ESP32-C3 development
# Install the required nightly toolchain
rustup install nightly
rustup component add rust-src --toolchain nightly
rustup target add riscv32imc-unknown-none-elf
# Install tooling to check the size of our binary
rustup component add llvm-tools-preview
# Install helper packages for a smooth development workflow
cargo install cargo-generate
==30037== Memcheck, a memory error detector
==30037== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==30037== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==30037== Command: ./build/zephyr/zephyr.exe --bt-dev=hci0
==30037==
WARNING: Using a test - not safe - entropy source
[00:00:00.000,000] <inf> flash_native_posix: Device flash_ctrl initialized
***** Booting Zephyr OS build zephyr-v2.0.0-1-gca3eb0eb31d1 *****
Initializing...
[00:00:00.870,000] <inf> bt_hci_core: Identity: 60:57:18:3e:41:61 (public)