Skip to content

Instantly share code, notes, and snippets.

View MathiasKoch's full-sized avatar

Mathias Koch MathiasKoch

View GitHub Profile
@MathiasKoch
MathiasKoch / Example.md
Last active June 20, 2023 07:19
AWS IoT Protobuf decoding

Creating descriptor file

protoc --descriptor_set_out=issue.desc --proto_path=src/sensor --include_imports issue.proto

Running the decode locally using protoc:

@MathiasKoch
MathiasKoch / version_migration.sh
Last active April 25, 2023 05:45
Migrate `Device` DynamoDB table in mgmt account to support new Duo v2
#!/usr/bin/env bash
declare -gA CRED_MAP=()
assume_role() {
CREDENTIALS=`aws sts assume-role --role-arn arn:aws:iam::$1:role/ExternalAccessProvisionIoT --role-session-name "VERSION-MIGRATION" --duration-seconds 3600 --output=json`
AWS_ACCESS_KEY_ID=`echo ${CREDENTIALS} | jq -r '.Credentials.AccessKeyId'`
AWS_SECRET_ACCESS_KEY=`echo ${CREDENTIALS} | jq -r '.Credentials.SecretAccessKey'`
AWS_SESSION_TOKEN=`echo ${CREDENTIALS} | jq -r '.Credentials.SessionToken'`
@MathiasKoch
MathiasKoch / main.rs
Created February 5, 2022 16:15
ublox_mqtt_example
#![no_main]
#![no_std]
#[rtic::app(device = stm32l4xx_hal::pac, peripherals = true, dispatchers = [UART5, SPI1, SPI2])]
mod app {
#[monotonic(binds = SysTick, default = true)]
type MyMono = DwtSystick<80_000_000>; // 80 MHz
const MQTT_QUEUE_LEN: usize = 6144;
type MqttClient = Client<'static, 'static, MQTT_QUEUE_LEN>;
@MathiasKoch
MathiasKoch / bringup.md
Created October 18, 2021 10:28
Duo bringup
  1. Insert debug probe into Device
  2. Run ./bbctl device fbduo bootstrap --bootloader bootloader --firmware bootstrap --hardware v1_1. Note the first line (UUID: "ba79a2bd874d2301") this is the "Full UUID" for later.
  3. Wait for label to be printed, and then terminate process (ctrl-c)
  4. Go to cloud.blackbird.online, Administration page -> Devices, and claim the device using the 7 digit ID
  5. Run ./bbctl device fbduo inject-credentials <Full UUID> eg. ./bbctl device fbduo inject-credentials ba79a2bd874d2301
  6. Run probe-run --chip STM32L475VGT firmware-v1_1 and wait for (HOST) INFO success! print
  7. Remove debugger & power, and apply label
//
// Decompiled by Procyon v0.5.32
//
package com.st.microxplorer.plugins.ip.i2c.gui;
import java.util.ArrayList;
import org.apache.log4j.Logger;
public class I2cTimingTraitement implements I2cConstants
use embedded_hal::timer::CountDown;
use stm32l4xx_hal::time::Hertz;
use void::Void;
pub struct Millis(pub u32);
impl From<u32> for Millis {
fn from(ms: u32) -> Self {
Millis(ms)
}
use embedded_hal::{digital::v2::OutputPin, PwmPin};
#[derive(PartialEq)]
pub enum Polarity {
ActiveLow,
ActiveHigh,
}
#[allow(unused)]
#[derive(PartialEq)]
#![feature(prelude_import)]
#![no_main]
#![no_std]
#[prelude_import]
use core::prelude::v1::*;
#[macro_use]
extern crate core;
#[macro_use]
extern crate compiler_builtins;
use atat::{self, ClientBuilder, ComQueue, Queues, ResQueue, UrcQueue};
use hal::{
delay::Delay,
dma::{dma1, dma2, Event as DmaEvent},
gpio::{
gpioa::{PA0, PA1, PA15, PA6},
gpiob::{PB1, PB14, PB4, PB6, PB7},
gpioc::{PC13, PC4, PC5},
gpiod::{PD14, PD15, PD3, PD5, PD6, PD8, PD9},
gpioe::{PE0, PE1, PE2, PE4, PE5},
Alternate, Edge, Floating, Input, OpenDrain, Output, PushPull, AF7, AF8,