Skip to content

Commit

Permalink
Allow CANIds to be defined in yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
kr0ner committed Dec 10, 2024
1 parent 50039a6 commit 72286a2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/communication.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ struct CanMember {
std::uint16_t getResponseId() const { return getWriteId() | 0x200; }
};

static const CanMember ESPClient{0x6a2, "ESPClient"};
static const CanMember Anfrage{0x6a1, "Anfrage"};
static const CanMember Kessel{0x180, "Kessel"};
static const CanMember HK1{0x301, "HK1"};
static const CanMember HK2{0x302, "HK2"};
static const CanMember ESPClient{ESPCLIENT_ID, "ESPClient"};
static const CanMember Manager{MANAGER_ID, "Manager"};
static const CanMember Kessel{KESSEL_ID, "Kessel"};
static const CanMember HK1{HK1_ID, "HK1"};
static const CanMember HK2{HK2_ID, "HK2"};

static const std::vector<std::reference_wrapper<const CanMember>> canMembers{Anfrage, Kessel, HK1, HK2};
static const std::vector<std::reference_wrapper<const CanMember>> canMembers{Kessel, HK1, HK2, Manager, ESPClient};

using Request = std::pair<const CanMember, const Property>;
static std::queue<Request> request_queue;
Expand Down
16 changes: 15 additions & 1 deletion yaml/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ esphome:
- OneESP32ToRuleThemAll/src/simple_variant.h
- OneESP32ToRuleThemAll/src/type.h
- OneESP32ToRuleThemAll/src/type.cpp
platformio_options:
build_flags:
- "-DESPCLIENT_ID=$espclient_can_id"
- "-DMANAGER_ID=$manager_can_id"
- "-DKESSEL_ID=$kessel_can_id"
- "-DHK1_ID=$hk1_can_id"
- "-DHK2_ID=$hk2_can_id"

substitutions:
kessel_can_id: "0x180"
hk1_can_id: "0x301"
hk2_can_id: "0x302"
manager_can_id: "0x6a1"
espclient_can_id: "0x6a2"

#########################################
# #
Expand Down Expand Up @@ -152,7 +166,7 @@ sensor:
#########################################
canbus:
- id: wp_can
can_id: 680
can_id: $espclient_can_id
use_extended_id: false
bit_rate: 20kbps
on_frame:
Expand Down

0 comments on commit 72286a2

Please sign in to comment.