ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
automation.h
Go to the documentation of this file.
1#pragma once
2
3#include <type_traits>
4
5#include "types.h"
6
7namespace esphome::canopen {
8
9// SDO reply callbacks for the generated actions; an automation that isn't configured is nullptr
10template<auto ON_SUCCESS, auto ON_ERROR> void sdo_write_reply(void * /*context*/, const SDOReply &reply) {
11 if (reply.ok()) {
12 if constexpr (!std::is_null_pointer_v<decltype(ON_SUCCESS)>)
13 ON_SUCCESS();
14 } else if constexpr (!std::is_null_pointer_v<decltype(ON_ERROR)>) {
15 ON_ERROR(reply.result, reply.abort_code);
16 }
17}
18
19template<auto ON_VALUE, auto ON_ERROR> void sdo_read_reply(void * /*context*/, const SDOReply &reply) {
20 if (reply.ok()) {
21 if constexpr (!std::is_null_pointer_v<decltype(ON_VALUE)>)
22 ON_VALUE(reply.value);
23 } else if constexpr (!std::is_null_pointer_v<decltype(ON_ERROR)>) {
24 ON_ERROR(reply.result, reply.abort_code);
25 }
26}
27
28} // namespace esphome::canopen
void sdo_read_reply(void *, const SDOReply &reply)
Definition automation.h:19
void sdo_write_reply(void *, const SDOReply &reply)
Definition automation.h:10