ESPHome  2022.11.3
Data Structures | Typedefs | Functions | Variables
esphome::shelly_dimmer Namespace Reference

Data Structures

class  ShellyDimmer
 
struct  VarlenCmd
 

Typedefs

using stm32_err_t = enum Stm32Err { STM32_ERR_OK=0, STM32_ERR_UNKNOWN, STM32_ERR_NACK, STM32_ERR_NO_CMD, }
 
using flags_t = enum Flags { F_NO_ME=1<< 0, F_OBLL=1<< 1, }
 
using stm32_cmd_t = struct Stm32Cmd { uint8_t get
 
using stm32_dev_t = struct Stm32Dev { const uint16_t id
 
using stm32_t = struct Stm32 { uart::UARTDevice *stream
 
using stm32_unique_ptr = std::unique_ptr< stm32_t, void(*)(stm32_t *)>
 

Functions

uint16_t shelly_dimmer_checksum (const uint8_t *buf, int len)
 Computes a crappy checksum as defined by the Shelly Dimmer protocol. More...
 
stm32_unique_ptr stm32_init (uart::UARTDevice *stream, const uint8_t flags, const char init)
 
stm32_err_t stm32_read_memory (const stm32_unique_ptr &stm, const uint32_t address, uint8_t *data, const unsigned int len)
 
stm32_err_t stm32_write_memory (const stm32_unique_ptr &stm, uint32_t address, const uint8_t *data, const unsigned int len)
 
stm32_err_t stm32_wunprot_memory (const stm32_unique_ptr &stm)
 
stm32_err_t stm32_wprot_memory (const stm32_unique_ptr &stm)
 
stm32_err_t stm32_runprot_memory (const stm32_unique_ptr &stm)
 
stm32_err_t stm32_readprot_memory (const stm32_unique_ptr &stm)
 
stm32_err_t stm32_erase_memory (const stm32_unique_ptr &stm, uint32_t spage, uint32_t pages)
 
stm32_err_t stm32_go (const stm32_unique_ptr &stm, const uint32_t address)
 
stm32_err_t stm32_reset_device (const stm32_unique_ptr &stm)
 
stm32_err_t stm32_crc_memory (const stm32_unique_ptr &stm, const uint32_t address, const uint32_t length, uint32_t *const crc)
 
uint32_t stm32_sw_crc (uint32_t crc, uint8_t *buf, unsigned int len)
 
stm32_err_t stm32_crc_wrapper (const stm32_unique_ptr &stm, uint32_t address, uint32_t length, uint32_t *crc)
 

Variables

constexpr uint32_t SZ_128 = 0x00000080
 
constexpr uint32_t SZ_256 = 0x00000100
 
constexpr uint32_t SZ_1K = 0x00000400
 
constexpr uint32_t SZ_2K = 0x00000800
 
constexpr uint32_t SZ_16K = 0x00004000
 
constexpr uint32_t SZ_32K = 0x00008000
 
constexpr uint32_t SZ_64K = 0x00010000
 
constexpr uint32_t SZ_128K = 0x00020000
 
constexpr uint32_t SZ_256K = 0x00040000
 
constexpr uint32_t p_128 [] = {SZ_128, 0}
 
constexpr uint32_t p_256 [] = {SZ_256, 0}
 
constexpr uint32_t p_1k [] = {SZ_1K, 0}
 
constexpr uint32_t p_2k [] = {SZ_2K, 0}
 
constexpr uint32_t f2f4 [] = {SZ_16K, SZ_16K, SZ_16K, SZ_16K, SZ_64K, SZ_128K, 0}
 
constexpr uint32_t f4db []
 
constexpr uint32_t f7 [] = {SZ_32K, SZ_32K, SZ_32K, SZ_32K, SZ_128K, SZ_256K, 0}
 
constexpr stm32_dev_t DEVICES []
 
constexpr auto STREAM_OPT_BYTE = (1 << 0)
 
constexpr auto STREAM_OPT_GVR_ETX = (1 << 1)
 
constexpr auto STREAM_OPT_CMD_INIT = (1 << 2)
 
constexpr auto STREAM_OPT_RETRY = (1 << 3)
 
constexpr auto STREAM_OPT_I2C = (1 << 4)
 
constexpr auto STREAM_OPT_STRETCH_W = (1 << 5)
 
constexpr auto STREAM_SERIAL = (STREAM_OPT_BYTE | STREAM_OPT_GVR_ETX | STREAM_OPT_CMD_INIT | STREAM_OPT_RETRY)
 
constexpr auto STREAM_I2C = (STREAM_OPT_I2C | STREAM_OPT_STRETCH_W)
 
constexpr auto STM32_MAX_RX_FRAME = 256
 
constexpr auto STM32_MAX_TX_FRAME = (1 + 256 + 1)
 
constexpr auto STM32_MAX_PAGES = 0x0000ffff
 
constexpr auto STM32_MASS_ERASE = 0x00100000
 
uint8_t gvr
 
uint8_t gid
 
uint8_t rm
 
uint8_t go
 
uint8_t wm
 
uint8_t er
 
uint8_t wp
 
uint8_t uw
 
uint8_t rp
 
uint8_t ur
 
uint8_t crc
 
const char * name
 
const uint32_t ram_start
 
const uint32_t ram_end
 
const uint32_t fl_start
 
const uint32_t fl_end
 
const uint16_t fl_pps
 
const uint32_t * fl_ps
 
const uint32_t opt_start
 
const uint32_t opt_end
 
const uint32_t mem_start
 
const uint32_t mem_end
 
const uint32_t flags
 
struct VarlenCmdcmd_get_reply
 
uint8_t bl_version
 
uint8_t version
 
uint8_t option1
 
uint8_t option2
 
uint16_t pid
 
stm32_cmd_tcmd
 
const stm32_dev_tdev
 

Typedef Documentation

◆ flags_t

using esphome::shelly_dimmer::flags_t = typedef enum Flags { F_NO_ME = 1 << 0, F_OBLL = 1 << 1, }

Definition at line 59 of file stm32flash.h.

◆ stm32_cmd_t

using esphome::shelly_dimmer::stm32_cmd_t = typedef struct Stm32Cmd { uint8_t get

Definition at line 62 of file stm32flash.h.

◆ stm32_dev_t

using esphome::shelly_dimmer::stm32_dev_t = typedef struct Stm32Dev { const uint16_t id

Definition at line 77 of file stm32flash.h.

◆ stm32_err_t

using esphome::shelly_dimmer::stm32_err_t = typedef enum Stm32Err { STM32_ERR_OK = 0, STM32_ERR_UNKNOWN, STM32_ERR_NACK, STM32_ERR_NO_CMD, }

Definition at line 54 of file stm32flash.h.

◆ stm32_t

using esphome::shelly_dimmer::stm32_t = typedef struct Stm32 { uart::UARTDevice *stream

Definition at line 89 of file stm32flash.h.

◆ stm32_unique_ptr

using esphome::shelly_dimmer::stm32_unique_ptr = typedef std::unique_ptr<stm32_t, void (*)(stm32_t *)>

Definition at line 112 of file stm32flash.h.

Function Documentation

◆ shelly_dimmer_checksum()

uint16_t esphome::shelly_dimmer::shelly_dimmer_checksum ( const uint8_t *  buf,
int  len 
)

Computes a crappy checksum as defined by the Shelly Dimmer protocol.

Definition at line 61 of file shelly_dimmer.cpp.

◆ stm32_crc_memory()

stm32_err_t esphome::shelly_dimmer::stm32_crc_memory ( const stm32_unique_ptr stm,
const uint32_t  address,
const uint32_t  length,
uint32_t *const  crc 
)

Definition at line 932 of file stm32flash.cpp.

◆ stm32_crc_wrapper()

stm32_err_t esphome::shelly_dimmer::stm32_crc_wrapper ( const stm32_unique_ptr stm,
uint32_t  address,
uint32_t  length,
uint32_t *  crc 
)

Definition at line 1028 of file stm32flash.cpp.

◆ stm32_erase_memory()

stm32_err_t esphome::shelly_dimmer::stm32_erase_memory ( const stm32_unique_ptr stm,
uint32_t  spage,
uint32_t  pages 
)

Definition at line 810 of file stm32flash.cpp.

◆ stm32_go()

stm32_err_t esphome::shelly_dimmer::stm32_go ( const stm32_unique_ptr stm,
const uint32_t  address 
)

Definition at line 898 of file stm32flash.cpp.

◆ stm32_init()

stm32_unique_ptr esphome::shelly_dimmer::stm32_init ( uart::UARTDevice stream,
const uint8_t  flags,
const char  init 
)

Definition at line 500 of file stm32flash.cpp.

◆ stm32_read_memory()

stm32_err_t esphome::shelly_dimmer::stm32_read_memory ( const stm32_unique_ptr stm,
const uint32_t  address,
uint8_t *  data,
const unsigned int  len 
)

Definition at line 658 of file stm32flash.cpp.

◆ stm32_readprot_memory()

stm32_err_t esphome::shelly_dimmer::stm32_readprot_memory ( const stm32_unique_ptr stm)

Definition at line 797 of file stm32flash.cpp.

◆ stm32_reset_device()

stm32_err_t esphome::shelly_dimmer::stm32_reset_device ( const stm32_unique_ptr stm)

Definition at line 921 of file stm32flash.cpp.

◆ stm32_runprot_memory()

stm32_err_t esphome::shelly_dimmer::stm32_runprot_memory ( const stm32_unique_ptr stm)

Definition at line 784 of file stm32flash.cpp.

◆ stm32_sw_crc()

uint32_t esphome::shelly_dimmer::stm32_sw_crc ( uint32_t  crc,
uint8_t *  buf,
unsigned int  len 
)

Definition at line 999 of file stm32flash.cpp.

◆ stm32_wprot_memory()

stm32_err_t esphome::shelly_dimmer::stm32_wprot_memory ( const stm32_unique_ptr stm)

Definition at line 771 of file stm32flash.cpp.

◆ stm32_write_memory()

stm32_err_t esphome::shelly_dimmer::stm32_write_memory ( const stm32_unique_ptr stm,
uint32_t  address,
const uint8_t *  data,
const unsigned int  len 
)

Definition at line 697 of file stm32flash.cpp.

◆ stm32_wunprot_memory()

stm32_err_t esphome::shelly_dimmer::stm32_wunprot_memory ( const stm32_unique_ptr stm)

Definition at line 758 of file stm32flash.cpp.

Variable Documentation

◆ bl_version

uint8_t esphome::shelly_dimmer::bl_version

Definition at line 92 of file stm32flash.h.

◆ cmd

stm32_cmd_t* esphome::shelly_dimmer::cmd

Definition at line 96 of file stm32flash.h.

◆ cmd_get_reply

struct VarlenCmd* esphome::shelly_dimmer::cmd_get_reply

Definition at line 91 of file stm32flash.h.

◆ crc

uint8_t esphome::shelly_dimmer::crc

Definition at line 73 of file stm32flash.h.

◆ dev

const stm32_dev_t* esphome::shelly_dimmer::dev

Definition at line 97 of file stm32flash.h.

◆ DEVICES

constexpr stm32_dev_t esphome::shelly_dimmer::DEVICES[]

Definition at line 62 of file dev_table.h.

◆ er

uint8_t esphome::shelly_dimmer::er

Definition at line 68 of file stm32flash.h.

◆ f2f4

constexpr uint32_t esphome::shelly_dimmer::f2f4[] = {SZ_16K, SZ_16K, SZ_16K, SZ_16K, SZ_64K, SZ_128K, 0}

Definition at line 50 of file dev_table.h.

◆ f4db

constexpr uint32_t esphome::shelly_dimmer::f4db[]
Initial value:
constexpr uint32_t SZ_64K
Definition: dev_table.h:35
constexpr uint32_t SZ_128K
Definition: dev_table.h:36
constexpr uint32_t SZ_16K
Definition: dev_table.h:33

Definition at line 52 of file dev_table.h.

◆ f7

constexpr uint32_t esphome::shelly_dimmer::f7[] = {SZ_32K, SZ_32K, SZ_32K, SZ_32K, SZ_128K, SZ_256K, 0}

Definition at line 55 of file dev_table.h.

◆ fl_end

const uint32_t esphome::shelly_dimmer::fl_end

Definition at line 80 of file stm32flash.h.

◆ fl_pps

const uint16_t esphome::shelly_dimmer::fl_pps

Definition at line 81 of file stm32flash.h.

◆ fl_ps

const uint32_t* esphome::shelly_dimmer::fl_ps

Definition at line 82 of file stm32flash.h.

◆ fl_start

const uint32_t esphome::shelly_dimmer::fl_start

Definition at line 80 of file stm32flash.h.

◆ flags

uint8_t esphome::shelly_dimmer::flags

Definition at line 85 of file stm32flash.h.

◆ gid

uint8_t esphome::shelly_dimmer::gid

Definition at line 64 of file stm32flash.h.

◆ go

uint8_t esphome::shelly_dimmer::go

Definition at line 66 of file stm32flash.h.

◆ gvr

uint8_t esphome::shelly_dimmer::gvr

Definition at line 63 of file stm32flash.h.

◆ mem_end

const uint32_t esphome::shelly_dimmer::mem_end

Definition at line 84 of file stm32flash.h.

◆ mem_start

const uint32_t esphome::shelly_dimmer::mem_start

Definition at line 84 of file stm32flash.h.

◆ name

const char* esphome::shelly_dimmer::name

Definition at line 78 of file stm32flash.h.

◆ opt_end

const uint32_t esphome::shelly_dimmer::opt_end

Definition at line 83 of file stm32flash.h.

◆ opt_start

const uint32_t esphome::shelly_dimmer::opt_start

Definition at line 83 of file stm32flash.h.

◆ option1

uint8_t esphome::shelly_dimmer::option1

Definition at line 94 of file stm32flash.h.

◆ option2

uint8_t esphome::shelly_dimmer::option2

Definition at line 94 of file stm32flash.h.

◆ p_128

constexpr uint32_t esphome::shelly_dimmer::p_128[] = {SZ_128, 0}

Definition at line 45 of file dev_table.h.

◆ p_1k

constexpr uint32_t esphome::shelly_dimmer::p_1k[] = {SZ_1K, 0}

Definition at line 47 of file dev_table.h.

◆ p_256

constexpr uint32_t esphome::shelly_dimmer::p_256[] = {SZ_256, 0}

Definition at line 46 of file dev_table.h.

◆ p_2k

constexpr uint32_t esphome::shelly_dimmer::p_2k[] = {SZ_2K, 0}

Definition at line 48 of file dev_table.h.

◆ pid

uint16_t esphome::shelly_dimmer::pid

Definition at line 95 of file stm32flash.h.

◆ ram_end

const uint32_t esphome::shelly_dimmer::ram_end

Definition at line 79 of file stm32flash.h.

◆ ram_start

const uint32_t esphome::shelly_dimmer::ram_start

Definition at line 79 of file stm32flash.h.

◆ rm

uint8_t esphome::shelly_dimmer::rm

Definition at line 65 of file stm32flash.h.

◆ rp

uint8_t esphome::shelly_dimmer::rp

Definition at line 71 of file stm32flash.h.

◆ STM32_MASS_ERASE

constexpr auto esphome::shelly_dimmer::STM32_MASS_ERASE = 0x00100000

Definition at line 47 of file stm32flash.h.

◆ STM32_MAX_PAGES

constexpr auto esphome::shelly_dimmer::STM32_MAX_PAGES = 0x0000ffff

Definition at line 46 of file stm32flash.h.

◆ STM32_MAX_RX_FRAME

constexpr auto esphome::shelly_dimmer::STM32_MAX_RX_FRAME = 256

Definition at line 43 of file stm32flash.h.

◆ STM32_MAX_TX_FRAME

constexpr auto esphome::shelly_dimmer::STM32_MAX_TX_FRAME = (1 + 256 + 1)

Definition at line 44 of file stm32flash.h.

◆ STREAM_I2C

constexpr auto esphome::shelly_dimmer::STREAM_I2C = (STREAM_OPT_I2C | STREAM_OPT_STRETCH_W)

Definition at line 41 of file stm32flash.h.

◆ STREAM_OPT_BYTE

constexpr auto esphome::shelly_dimmer::STREAM_OPT_BYTE = (1 << 0)

Definition at line 33 of file stm32flash.h.

◆ STREAM_OPT_CMD_INIT

constexpr auto esphome::shelly_dimmer::STREAM_OPT_CMD_INIT = (1 << 2)

Definition at line 35 of file stm32flash.h.

◆ STREAM_OPT_GVR_ETX

constexpr auto esphome::shelly_dimmer::STREAM_OPT_GVR_ETX = (1 << 1)

Definition at line 34 of file stm32flash.h.

◆ STREAM_OPT_I2C

constexpr auto esphome::shelly_dimmer::STREAM_OPT_I2C = (1 << 4)

Definition at line 37 of file stm32flash.h.

◆ STREAM_OPT_RETRY

constexpr auto esphome::shelly_dimmer::STREAM_OPT_RETRY = (1 << 3)

Definition at line 36 of file stm32flash.h.

◆ STREAM_OPT_STRETCH_W

constexpr auto esphome::shelly_dimmer::STREAM_OPT_STRETCH_W = (1 << 5)

Definition at line 38 of file stm32flash.h.

◆ STREAM_SERIAL

constexpr auto esphome::shelly_dimmer::STREAM_SERIAL = (STREAM_OPT_BYTE | STREAM_OPT_GVR_ETX | STREAM_OPT_CMD_INIT | STREAM_OPT_RETRY)

Definition at line 40 of file stm32flash.h.

◆ SZ_128

constexpr uint32_t esphome::shelly_dimmer::SZ_128 = 0x00000080

Definition at line 29 of file dev_table.h.

◆ SZ_128K

constexpr uint32_t esphome::shelly_dimmer::SZ_128K = 0x00020000

Definition at line 36 of file dev_table.h.

◆ SZ_16K

constexpr uint32_t esphome::shelly_dimmer::SZ_16K = 0x00004000

Definition at line 33 of file dev_table.h.

◆ SZ_1K

constexpr uint32_t esphome::shelly_dimmer::SZ_1K = 0x00000400

Definition at line 31 of file dev_table.h.

◆ SZ_256

constexpr uint32_t esphome::shelly_dimmer::SZ_256 = 0x00000100

Definition at line 30 of file dev_table.h.

◆ SZ_256K

constexpr uint32_t esphome::shelly_dimmer::SZ_256K = 0x00040000

Definition at line 37 of file dev_table.h.

◆ SZ_2K

constexpr uint32_t esphome::shelly_dimmer::SZ_2K = 0x00000800

Definition at line 32 of file dev_table.h.

◆ SZ_32K

constexpr uint32_t esphome::shelly_dimmer::SZ_32K = 0x00008000

Definition at line 34 of file dev_table.h.

◆ SZ_64K

constexpr uint32_t esphome::shelly_dimmer::SZ_64K = 0x00010000

Definition at line 35 of file dev_table.h.

◆ ur

uint8_t esphome::shelly_dimmer::ur

Definition at line 72 of file stm32flash.h.

◆ uw

uint8_t esphome::shelly_dimmer::uw

Definition at line 70 of file stm32flash.h.

◆ version

uint8_t esphome::shelly_dimmer::version

Definition at line 93 of file stm32flash.h.

◆ wm

uint8_t esphome::shelly_dimmer::wm

Definition at line 67 of file stm32flash.h.

◆ wp

uint8_t esphome::shelly_dimmer::wp

Definition at line 69 of file stm32flash.h.