ESPHome
2026.12.0-dev
Loading...
Searching...
No Matches
esphome
components
canopen
automation.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <type_traits>
4
5
#include "
types.h
"
6
7
namespace
esphome::canopen
{
8
9
// SDO reply callbacks for the generated actions; an automation that isn't configured is nullptr
10
template
<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
19
template
<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
esphome::canopen
Definition
automation.h:7
esphome::canopen::sdo_read_reply
void sdo_read_reply(void *, const SDOReply &reply)
Definition
automation.h:19
esphome::canopen::sdo_write_reply
void sdo_write_reply(void *, const SDOReply &reply)
Definition
automation.h:10
esphome::canopen::SDOReply
Definition
types.h:34
esphome::canopen::SDOReply::ok
bool ok() const
Definition
types.h:42
esphome::canopen::SDOReply::result
SDOResult result
Definition
types.h:35
esphome::canopen::SDOReply::value
uint32_t value
Definition
types.h:37
esphome::canopen::SDOReply::abort_code
uint32_t abort_code
Definition
types.h:36
types.h
Generated by
1.12.0