@@ -69,6 +69,24 @@ uint16_t chksum(const uint8_t data[], const uint16_t len) {
69
69
}
70
70
71
71
72
+ void JkRS485Sniffer::set_broadcast_changes_to_all_bms (bool state) {
73
+ this ->broadcast_changes_to_all_bms_ = state;
74
+ if (state) {
75
+ ESP_LOGD (TAG, " Broadcast to All BMSs ACTIVATED" );
76
+ // Aquí puedes añadir el código que se ejecuta cuando se activa
77
+ } else {
78
+ ESP_LOGD (TAG, " Broadcast to All BMSs DEACTIVATED" );
79
+ // Aquí puedes añadir el código que se ejecuta cuando se desactiva
80
+ }
81
+ }
82
+
83
+
84
+
85
+ bool JkRS485Sniffer::get_broadcast_changes_to_all_bms () const {
86
+ return this ->broadcast_changes_to_all_bms_ ;
87
+ }
88
+
89
+
72
90
void JkRS485Sniffer::handle_bms2sniffer_event (std::uint8_t slave_address, std::string event, std::uint8_t frame_type){
73
91
// Maneja el evento aquí. Por ejemplo, puedes imprimir el evento:
74
92
ESP_LOGD (TAG," Received Event from BMS.. [address:0x%02X] @ %d --> %s" , slave_address, frame_type, event.c_str ());
@@ -110,7 +128,7 @@ void JkRS485Sniffer::handle_bms2sniffer_switch_or_number_uint32_event(std::uint8
110
128
send_command_switch_or_number_to_slave_uint32 (slave_address,third_element_of_frame,register_address,value);
111
129
}
112
130
113
- if (this ->broadcast_to_all_bms_ ==true ){
131
+ if (this ->broadcast_changes_to_all_bms_ ==true ){
114
132
for (uint8_t j = 1 ; j < 16 ; ++j) {
115
133
if (rs485_network_node[j].available && slave_address!=j) {
116
134
delayMicroseconds (50000 );
@@ -137,7 +155,7 @@ void JkRS485Sniffer::handle_bms2sniffer_switch_or_number_int32_event(std::uint8_
137
155
send_command_switch_or_number_to_slave_int32 (slave_address,third_element_of_frame,register_address,value);
138
156
}
139
157
140
- if (this ->broadcast_to_all_bms_ ==true ){
158
+ if (this ->broadcast_changes_to_all_bms_ ==true ){
141
159
for (uint8_t j = 1 ; j < 16 ; ++j) {
142
160
if (rs485_network_node[j].available && slave_address!=j) {
143
161
delayMicroseconds (50000 );
@@ -159,7 +177,7 @@ void JkRS485Sniffer::handle_bms2sniffer_switch_or_number_uint16_event(std::uint8
159
177
rs485_network_node[slave_address].last_device_info_request_received_OK =0 ;
160
178
}
161
179
162
- if (this ->broadcast_to_all_bms_ ==true ){
180
+ if (this ->broadcast_changes_to_all_bms_ ==true ){
163
181
for (uint8_t j = 1 ; j < 16 ; ++j) {
164
182
if (rs485_network_node[j].available && slave_address!=j) {
165
183
delayMicroseconds (50000 );
0 commit comments