Skip to content

Instantly share code, notes, and snippets.

View Staars's full-sized avatar

Christian Baars Staars

View GitHub Profile
@Staars
Staars / microspeech.be
Created January 12, 2023 18:12
snippet for TFL
class MICROSPEECH : Driver
var o # output tensor
var model # this var really holds the model data for the entire session
def init()
import TFL
self.o = bytes(-5) # size must match the model
var descriptor = bytes(-8)
descriptor[0] = 8 # amplification
descriptor[1] = 5 # noisefloor
@Staars
Staars / ld2410.be
Last active January 8, 2023 17:05
LD2410 BLE driver
#-
LF2410.be - HLK-LD2410 24GHz smart wave motion sensor support for Tasmota via BLE and Berry
port of xsns_102_ld2410.ino from Theo Arends
SPDX-FileCopyrightText: 2022 Christian Baars
SPDX-License-Identifier: GPL-3.0-only
-#
class LD2410 : Driver
var buf
var current_func, next_func
@Staars
Staars / mi32_disco.be
Last active November 18, 2022 17:14
WIP script to annonce MI32 BLE sensors to Homeassitant
#######################################################################
# Disco
#
# Homeassitant MQTT Discovery for Tasmota BLE Sensors
#######################################################################
import string
import json
class DISCO
@Staars
Staars / main.c
Created October 18, 2022 14:36
Non-usable RISCV ULP driver, because ULP and main cores can not share one I2C bus
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
/* ULP-RISC-V example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
@Staars
Staars / shining_mask.md
Created October 11, 2022 07:00
Shining Masks infos from various places

It sends commands over Bluetooth Low Energy. Commands are sent to the handle with UUID d44bc439-abfd-45a2-b575-925416129600, with a format of a single byte containing the length of the rest of the packet, some bytes of ASCII containing the command, and then any arguments to the command. This is padded out to 16 bytes and then AES encrypted in ECB mode with a key of: '\x32\x67\x2f\x79\x74\xad\x43\x45\x1d\x9c\x6c\x89\x4a\x0e\x87\x64'
Commands are:
LIGHT - one byte argument controls the brightness
IMAG - one byte controls which static image is displayed
DELE - one byte gives the number of uploaded images to be deleted, and the following bytes give the set of images to be deleted
SPEED - one byte that I think sets the transition speed between DIY images in playback mode
ANIM - one byte that chooses which animation is displayed
PLAY - one byte that contains the number of DIY images to play, and then the images to play in the order that they'll be played with one byte per image
CHEC - triggers a not

@Staars
Staars / send.cpp
Created September 13, 2022 19:55
Support for REV type d sockets
/*
Usage: ./send <systemCode> <unitCode> <command>
Command is 0 for OFF and 1 for ON
*/
#include "../rc-switch/RCSwitch.h"
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
/*
xlgt_10_berry.ino - virtual Berry led support for Tasmota
Copyright (C) 2021 Theo Arends & Christian Baars
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@Staars
Staars / ilc.be
Last active September 11, 2022 18:22
BLE ILC LED
# control ILC LED lamp
class ILC : Driver
var buf, light_state
def init(MAC)
import BLE
import light
self.buf = bytes(-32) # create a byte buffer for BLE
var cbp = tasmota.gen_cb(/e,o,u->self.cb(e,o,u)) # create BLE callback function pointer
BLE.conn_cb(cbp,self.buf)
@Staars
Staars / ulp_template.py
Last active June 29, 2022 18:34
Micropython template to generate ULP code for Berry in Tasmota
"""
Template for exporting ULP code to Tasmotas Berry implementation
"""
from esp32_ulp import src_to_binary
source = """
# replace this multiline string with the content of an .S file
# included header files will not work, but you will find missing defines there and can insert the missing lines here manually
# look for the console output of `micropython thisfile.py` to see, where you find the vars from Berry, i.e. 0001 my_var -> ULP.get_mem(1)
@Staars
Staars / crypto.js
Created May 28, 2022 18:14
stripped down version of this lib - enough for pairing of Xiaomi sensors
/** @fileOverview Javascript cryptography implementation.
*
* Crush to remove comments, shorten variable names and
* generally reduce transmission size.
*
* @author Emily Stark
* @author Mike Hamburg
* @author Dan Boneh
*/