@@ -18,6 +18,7 @@ const NotificationSequence sequence_hit = {
18
18
struct InfraredController {
19
19
LaserTagTeam team ;
20
20
InfraredWorker * worker ;
21
+ bool worker_rx_active ;
21
22
InfraredSignal * signal ;
22
23
NotificationApp * notification ;
23
24
bool hit_received ;
@@ -104,6 +105,11 @@ void infrared_controller_free(InfraredController* controller) {
104
105
FURI_LOG_I (TAG , "Freeing InfraredController" );
105
106
106
107
if (controller ) {
108
+ if (controller -> worker_rx_active ) {
109
+ FURI_LOG_I (TAG , "Stopping RX worker" );
110
+ infrared_worker_rx_stop (controller -> worker );
111
+ }
112
+
107
113
FURI_LOG_I (TAG , "Freeing InfraredWorker and InfraredSignal" );
108
114
infrared_worker_free (controller -> worker );
109
115
infrared_signal_free (controller -> signal );
@@ -139,12 +145,23 @@ void infrared_controller_send(InfraredController* controller) {
139
145
(unsigned long )message .address ,
140
146
(unsigned long )message .command );
141
147
148
+ if (controller -> worker_rx_active ) {
149
+ FURI_LOG_I (TAG , "Stopping RX worker" );
150
+ infrared_worker_rx_stop (controller -> worker );
151
+ controller -> worker_rx_active = false;
152
+ }
153
+
142
154
FURI_LOG_I (TAG , "Setting message for infrared signal" );
143
155
infrared_signal_set_message (controller -> signal , & message );
144
156
145
157
FURI_LOG_I (TAG , "Starting infrared signal transmission" );
146
158
infrared_signal_transmit (controller -> signal );
147
159
160
+ if (!controller -> worker_rx_active ) {
161
+ infrared_worker_rx_start (controller -> worker );
162
+ controller -> worker_rx_active = true;
163
+ }
164
+
148
165
FURI_LOG_I (TAG , "Infrared signal transmission completed" );
149
166
}
150
167
@@ -156,11 +173,11 @@ bool infrared_controller_receive(InfraredController* controller) {
156
173
return false;
157
174
}
158
175
159
- infrared_worker_rx_start ( controller -> worker );
160
-
161
- furi_delay_ms ( 250 ) ;
162
-
163
- infrared_worker_rx_stop ( controller -> worker );
176
+ if (! controller -> worker_rx_active ) {
177
+ infrared_worker_rx_start ( controller -> worker );
178
+ controller -> worker_rx_active = true ;
179
+ furi_delay_ms ( 250 );
180
+ }
164
181
165
182
bool hit = controller -> hit_received ;
166
183
0 commit comments