Skip to content

Conversation

@tonhuisman
Copy link
Contributor

@tonhuisman tonhuisman commented Oct 6, 2023

Feature:

  • Make IRremoteESP8266 compatible with C++20
    • Fix use of deprecated volatile operators like ++ and volatile method arguments
    • Add build environment for using ESP32 IDF 5.x and fix compilation for 'regular' ESP32 environment, still using IDF 4.x
    • Fix differences for IDF 5.x build using code by Tasmota team (by @s-hadinger )

Resolves #2039

@tonhuisman
Copy link
Contributor Author

tonhuisman commented Oct 6, 2023

Looks like the linter and doxygen need some fix to support conditional compilation 👎

@NiKiZe
Copy link
Collaborator

NiKiZe commented Oct 6, 2023

Have you considered defining internal types separately, all the #if s are becoming quite messy?

@tonhuisman
Copy link
Contributor Author

Have you considered defining internal types separately, all the #if s are becoming quite messy?

I'll think about that, but IMHO it'll be about as messy... 😞

@tonhuisman
Copy link
Contributor Author

Have you considered defining internal types separately, all the #if s are becoming quite messy?

Now using typedefs for everything that was defined volatile (though most still using volatile).

Copy link
Collaborator

@NiKiZe NiKiZe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm for the atomic_ changes, not sure about the rest which is more relevant to platformio than c++?

@Jason2866
Copy link
Contributor

Jason2866 commented Oct 7, 2023

@tonhuisman Why going back to core 2.0.x? Makes no sense. The platform 2023.10.03 is NOT based on IDF5.1
The left compile error is just a missing include of gpio.h

EDIT: Comment race condition ;-)

@Jason2866
Copy link
Contributor

@tonhuisman Adding this fixes the compile error and no code change regarding interrupts are needed

#if defined(ESP32)
#if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 3) )
#include <driver/gpio.h>
#endif  // ESP_ARDUINO_VERSION_MAJOR >= 3
#endif
#endif  // UNIT_TEST

@tonhuisman
Copy link
Contributor Author

Adding this fixes the compile error

Thanks! 🦸
That was what I didn't know I was searching for, but had to find...

@crankyoldgit
Copy link
Owner

FYI. I've seen this PR and been thinking about how to do this "better" in a way.
My plan is to create a new branch/PR etc and try to get rid of as much of the existing volatile stuff and replace it with atomic where appropriate. I think I can wittle it down to only a few variables/memory pointers etc. As this will be a major change that could introduce race-conditions and concurrency issues, I want to make sure this is tested on real hardware & in real situations as much as practical before I release it.

Btw .. thanks ever so much for all the work you've all put into this PR, it's awesome. You've done a great job. I just want to clean up something we inherited from the original IRremote library and the early days of this library. That stuff was left pretty much unchanged because it was magic code & worked, and assumed people know exactly what they were doing. My research in to volatile and what it does makes it sort of clear the use of it was more a kuldge than the right way to fix it. You're work has forced me to look at it and research it, and realise it only kind of does what we wanted.

In short, I want to enlist you guys (@tonhuisman & @Jason2866, tasmota etal) in helping to better fix it, and I don't want to just copy a lot of your work and pretend it was my work.

@crankyoldgit crankyoldgit self-assigned this Oct 11, 2023
@crankyoldgit crankyoldgit added enhancement ESP32 ESP32 only issue labels Oct 11, 2023
@Jason2866
Copy link
Contributor

Looking forward to do testing on all ESP32x MCUS. Considering to do a RMT driver?
It looks like all newer ESP32 MCUs have timing issues with the current driver.

@crankyoldgit
Copy link
Owner

I've changed my mind on the approach.
I'll look at approving/merging this as is and do the other changes later. I'm quite time-poor now-a-days so best I not hold this up.

@crankyoldgit crankyoldgit self-requested a review October 18, 2023 23:11
Copy link
Owner

@crankyoldgit crankyoldgit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What tests on actual hardware have been done? i.e. Does it still capture okay on ESP32s & 8266s?


#if defined(ESP32)
#if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 3) )
#include <driver/gpio.h>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this hurt or cause an issue if it is always included?
i.e. Can we just include this header all the time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm more inclined to only add includes when really needed, trying to avoid unneeded code being pulled in the build or having unexpected interactions.

@sagariotminds
Copy link

sagariotminds commented May 31, 2024 via email

@mboehmerm
Copy link

mboehmerm commented Aug 16, 2024

Works for me without errors, if add "bool timerStarted(hw_timer_t *timer);" to "esp32-hal-timer.h" and "esp32-hal-timer.c" and use this function in "IRrecv.cpp".

Base were the commits 9cfcebc and db98aa0

Test and files can be found here : https://github.com/mboehmerm/Three-IPS-Displays-with-ST7789-170x320-240x280-240x320/tree/main/IRremoteESP8266

Added in esp32-hal-timer.h

bool timerStarted(hw_timer_t *timer);

Added in esp32-hal-timer.c

bool timerStarted(hw_timer_t *timer) {
  return timer->timer_started;
}

In the file IRrecv.cpp i replaced

  timerWrite(timer, 0);
  timerStart(timer);

with

  timerWrite(timer, 0);
  if (timerStarted(timer))
    timerRestart(timer);
  else
    timerStart(timer);

and

  timerStop(timer);

with

  if (timerStarted(timer))
    timerStop(timer);

I hope there is a better solution without modifying the esp32-hal-timer files.

@Jason2866
Copy link
Contributor

Jason2866 commented Aug 16, 2024

@mboehmerm Dont know what's causing the need that you have to modify files.
The PR is working well in EspEasy and Tasmota without any further changes with Arduino Core 3.0.x

@mboehmerm
Copy link

@mboehmerm Dont know what's causing the need that you have to modify files. The PR is working well in EspEasy and Tasmota without any further changes with Arduino Core 3.0.x

This is the first solution i found, that works with Arduino IDE without any errors. Is there a better solution? Where can i find it?

@tonhuisman
Copy link
Contributor Author

the first solution i found, that works with Arduino IDE without any errors. Is there a better solution?

🤔 (... sorry, too obvious...)

@almirus
Copy link
Contributor

almirus commented Aug 29, 2024

I get an error

16:49:14.291 -> E (1146905) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.322 -> Timestamp : 001146.959
16:49:14.322 -> Library   : v2.8.6
16:49:14.322 -> 
16:49:14.322 -> Protocol  : UNKNOWN
16:49:14.322 -> Code      : 0xEBA17F (11 Bits)
16:49:14.322 -> uint16_t rawData[22] = {3060, 1620,  468, 4140,  5816, 5818,  5814, 5816,  5816, 5816,  5814, 5818,  5816, 5816,  5816, 5814,  5818, 5816,  5814, 5816,  5814, 5818 }E (1146978) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.354 -> E (1146979) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.354 -> E (1146980) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.354 -> E (1146985) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.354 -> E (1146991) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.450 -> E (1147072) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.450 -> E (1147078) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.450 -> E (1147084) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.450 -> E (1147090) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.450 -> E (1147096) gptimer: gptimer_start(348): timer is not enabled yet
16:49:14.489 -> ;  // UNKNOWN EBA17F
16:49:14.489 -> 
16:49:14.489 -> 
16:49:14.489 -> Timestamp : 001147.149
16:49:14.523 -> Library   : v2.8.6
16:49:14.523 -> 
16:49:14.523 -> Protocol  : UNKNOWN
16:49:14.523 -> Code      : 0x5B39BFD5 (12 Bits)
16:49:14.523 -> uint16_t rawData[23] = {3058, 1622,  470, 5494,  5818, 5816,  5814, 5818,  5816, 5816,  5816, 5816,  5812, 5818,  5816, 5816,  5816, 5814,  5818, 5816,  5816, 5816,  5816};  // UNKNOWN 5B39BFD5
16:49:14.523 -> 
16:49:14.523 -> 
16:59:14.509 -> E (1747136) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.541 -> E (1747138) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.541 -> E (1747138) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.541 -> E (1747142) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.541 -> E (1747148) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.541 -> E (1747154) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.573 -> E (1747160) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.573 -> E (1747166) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.573 -> E (1747172) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.573 -> E (1747177) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.573 -> E (1747183) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.573 -> E (1747189) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.605 -> E (1747195) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.605 -> E (1747201) gptimer: gptimer_start(348): timer is not enabled yet
16:59:14.605 -> E (1747206) gptimer: gptimer_start(348): timer is not enabled yet

@Buddy-Matt
Copy link

Buddy-Matt commented Sep 16, 2024

I'm also seeing the same error as @almirus regarding gptimer when using Arduino IDE targeting a M5Stack NanoC6.

The library also fails to receive the NEC codes that were previously working under ESP32 2.0.17 - so I don't believe they're spurious either.

@NiKiZe
Copy link
Collaborator

NiKiZe commented Sep 23, 2024

I'm considering merging #2144 which only has changes for ESP32 CoreV3, that way we don't risk breaking anything for earlier versions?

After that we could look into merging any other changes? How does that sound?
Or any reasons for not doing that?

@tonhuisman
Copy link
Contributor Author

We have been using these adjustments on the Arduino 3.x/IDF 5.x builds of ESPEasy since I started this PR, so I see no reason not to merge this, and other relevant changes.
I still don't fully understand why PR 2144 was created, though, since this PR has been open for quite some time...

@NiKiZe
Copy link
Collaborator

NiKiZe commented Sep 23, 2024

We have been using these adjustments on the Arduino 3.x/IDF 5.x builds of ESPEasy since I started this PR, so I see no reason not to merge this, and other relevant changes. I still don't fully understand why PR 2144 was created, though, since this PR has been open for quite some time...

In principle I agree, #2144 is a duplicate, but there is also about the cleanest solution. (read: easiest to review)
#2040 (this PR) has 3? different fixes mixed in one PR. I'm not able to verify these changes.
The reason for me starting to look into merging #2144 was #2144 (comment)

In it's current state it essentially only has added lines and no changes, which I can validate does not create any new issues for <V3
Another part, which currently is over my head, is the mentions about IDF, for example #1575, this library is for Arduino, even if that pulls in something else.

My hope is that this PR can be rebased on #2144 and then review the remaining parts.

@tonhuisman
Copy link
Contributor Author

In principle I agree, #2144 is a duplicate, but there is also about the cleanest solution. (read: easiest to review)
#2040 (this PR) has 3? different fixes mixed in one PR. I'm not able to verify these changes.

The scope of this PR is to instate compatibility with C++20, not 'just' Arduino 3.x.
To have compatibility with C++20 the 3 mentioned changes are required to avoid compiler warnings in the build log.

zehnm added a commit to zehnm/IRremoteESP8266 that referenced this pull request Feb 5, 2025
A small fix to remove "volatile ++" build warning.
Source: crankyoldgit#2040
zehnm added a commit to zehnm/IRremoteESP8266 that referenced this pull request Feb 5, 2025
Include open upstream PR crankyoldgit#2144
to make IR learning compatible with IDF 5.x.

Enhance with:
* update esp32-hal* to IDF v5.4
* C++20 compatibility
  A small fix to remove "volatile ++" build warning.
  Source: crankyoldgit#2040

---------

Co-authored-by: BorisKofman <Borisk@salt.security>
Co-authored-by: Christian I. Nilsson <nikize@gmail.com>
@swoboda1337
Copy link

Is this ever going to get merged?

@crankyoldgit
Copy link
Owner

This appears to be failing the unit tests. Perhaps it needs to be re-based on the recent PRs that address the automated build tests?

@tonhuisman
Copy link
Contributor Author

This appears to be failing the unit tests. Perhaps it needs to be re-based on the recent PRs that address the automated build tests?

It just needed an update of the platform package, as the old one was over 2 years old... 🤔 Now, all is fine again.

Copy link
Owner

@crankyoldgit crankyoldgit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for fixing.

@crankyoldgit crankyoldgit merged commit 95b87cc into crankyoldgit:master Dec 16, 2025
42 checks passed
crankyoldgit added a commit that referenced this pull request Jan 2, 2026
**[Bug Fixes]**
- Bosch: Fixed the bug where the wind speed was always set to auto. (#2237)
- Update IRsend sendHaierAC to include SEND_HAIER_AC160 (#2172)
- Gree: Fix reporting vertical swing (#2125)
- Fix `decodeYork()` parameter names & defaults. (#2121)
- Fix the Coolix fan-only mode in IRac class. (#2104)
- Fix missing quiet parameter of haier176 (#2102)
- ESP32-C3: Fix compilation error when USB CDC on Boot is enabled (#2080)

**[Features]**
- Add Fahrenheit support for the BOSCH144 protocol (#2224)
- Build: Add compatibility with C++20 (#2040)
- Add initial detailed support for Kelon168 (Kelon/Hisense) (#1949)
- Add support for the Eurom A/C protocol (#2208)
- Add Fahrenheit support for Coolix (#2214)
- ESP32: Esp32 Core version 3 support (#2144)
- auto_analyse_raw_data: Add kXxMsbFirst to easy change MSBFirst for the full protocol (#2143)
- change kAirtonMaxTemp from 25C to 31C (#2124)
- Added support for Bluestar Heavy AC (#2120)
- Add support of Toshiba Remote Control B (#2094)
- Update haier160 & HaierYRWO2 to use quiet in the common class. (#2115)
- Internationalisation: Solvakian translation (#2091)
- Daikin: Support setting temperature in 0.5 C unit (#2036)
- Quiet/Silent Mode for Electra_AC (#1990)

**[Misc]**
- Document Fischer R51L1/BGE remote support (#2231)
- CI: pin python v3.13
- CI: Attempt to fix intelhex failures
- IRMQTTServer: Fixes for ArduinoJson v7 to remove depreicated calls
- docs: updated contributing section for clarity (by Prerna Utage) (#2221)
- Fix typo in Russian language support (#2210)
- Build: Update CodeQL actions plugin to use v3 as v2 will be deprecated soon
- Build: Fix soon to be deprecated set-output command
- Build: Update build scripts to use non-deprecated actions tooling
- Fix linter issues (#2173)
- pylint fix raw_to_pronto_code.py (#2150)
- Document support for Comfee model (#2147)
- DAIKIN: ARC443A5 Remote supported note (#2138)
- library.json specifies libCompatMode strict (#2111)
- Added Electrolux EACM CL/N3 series remote to TCL protocol (#2100)
- Add AR-JW19 to supported devices (#2069)
- Remove unused constant `kRcmmExcess` (#2033)
- Panasonic AC: Document support for PV1122V remote (#2029)
- Document support for Panasonic CS-E12QKEW A/C (#2028)
@crankyoldgit crankyoldgit mentioned this pull request Jan 2, 2026
crankyoldgit added a commit that referenced this pull request Jan 2, 2026
**[Bug Fixes]**
- Bosch: Fixed the bug where the wind speed was always set to auto. (#2237)
- Update IRsend sendHaierAC to include SEND_HAIER_AC160 (#2172)
- Gree: Fix reporting vertical swing (#2125)
- Fix `decodeYork()` parameter names & defaults. (#2121)
- Fix the Coolix fan-only mode in IRac class. (#2104)
- Fix missing quiet parameter of haier176 (#2102)
- ESP32-C3: Fix compilation error when USB CDC on Boot is enabled (#2080)

**[Features]**
- Add Fahrenheit support for the BOSCH144 protocol (#2224)
- Build: Add compatibility with C++20 (#2040)
- Add initial detailed support for Kelon168 (Kelon/Hisense) (#1949)
- Add support for the Eurom A/C protocol (#2208)
- Add Fahrenheit support for Coolix (#2214)
- ESP32: Esp32 Core version 3 support (#2144)
- auto_analyse_raw_data: Add kXxMsbFirst to easy change MSBFirst for the full protocol (#2143)
- change kAirtonMaxTemp from 25C to 31C (#2124)
- Added support for Bluestar Heavy AC (#2120)
- Add support of Toshiba Remote Control B (#2094)
- Update haier160 & HaierYRWO2 to use quiet in the common class. (#2115)
- Internationalisation: Solvakian translation (#2091)
- Daikin: Support setting temperature in 0.5 C unit (#2036)
- Quiet/Silent Mode for Electra_AC (#1990)

**[Misc]**
- Document Fischer R51L1/BGE remote support (#2231)
- CI: pin python v3.13
- CI: Attempt to fix intelhex failures
- IRMQTTServer: Fixes for ArduinoJson v7 to remove depreicated calls
- docs: updated contributing section for clarity (by Prerna Utage) (#2221)
- Fix typo in Russian language support (#2210)
- Build: Update CodeQL actions plugin to use v3 as v2 will be deprecated soon
- Build: Fix soon to be deprecated set-output command
- Build: Update build scripts to use non-deprecated actions tooling
- Fix linter issues (#2173)
- pylint fix raw_to_pronto_code.py (#2150)
- Document support for Comfee model (#2147)
- DAIKIN: ARC443A5 Remote supported note (#2138)
- library.json specifies libCompatMode strict (#2111)
- Added Electrolux EACM CL/N3 series remote to TCL protocol (#2100)
- Add AR-JW19 to supported devices (#2069)
- Remove unused constant `kRcmmExcess` (#2033)
- Panasonic AC: Document support for PV1122V remote (#2029)
- Document support for Panasonic CS-E12QKEW A/C (#2028)
@crankyoldgit crankyoldgit mentioned this pull request Jan 2, 2026
crankyoldgit added a commit that referenced this pull request Jan 2, 2026
_v2.9.0 (20260103)_ release

**[Bug Fixes]**
- Bosch: Fixed the bug where the wind speed was always set to auto. (#2237)
- Update IRsend sendHaierAC to include SEND_HAIER_AC160 (#2172)
- Gree: Fix reporting vertical swing (#2125)
- Fix `decodeYork()` parameter names & defaults. (#2121)
- Fix the Coolix fan-only mode in IRac class. (#2104)
- Fix missing quiet parameter of haier176 (#2102)
- ESP32-C3: Fix compilation error when USB CDC on Boot is enabled (#2080)

**[Features]**
- Add Fahrenheit support for the BOSCH144 protocol (#2224)
- Build: Add compatibility with C++20 (#2040)
- Add initial detailed support for Kelon168 (Kelon/Hisense) (#1949)
- Add support for the Eurom A/C protocol (#2208)
- Add Fahrenheit support for Coolix (#2214)
- ESP32: Esp32 Core version 3 support (#2144)
- auto_analyse_raw_data: Add kXxMsbFirst to easy change MSBFirst for the full protocol (#2143)
- change kAirtonMaxTemp from 25C to 31C (#2124)
- Added support for Bluestar Heavy AC (#2120)
- Add support of Toshiba Remote Control B (#2094)
- Update haier160 & HaierYRWO2 to use quiet in the common class. (#2115)
- Internationalisation: Solvakian translation (#2091)
- Daikin: Support setting temperature in 0.5 C unit (#2036)
- Quiet/Silent Mode for Electra_AC (#1990)

**[Misc]**
- Document Fischer R51L1/BGE remote support (#2231)
- CI: pin python v3.13
- CI: Attempt to fix intelhex failures
- IRMQTTServer: Fixes for ArduinoJson v7 to remove depreicated calls
- docs: updated contributing section for clarity (by Prerna Utage) (#2221)
- Fix typo in Russian language support (#2210)
- Build: Update CodeQL actions plugin to use v3 as v2 will be deprecated soon
- Build: Fix soon to be deprecated set-output command
- Build: Update build scripts to use non-deprecated actions tooling
- Fix linter issues (#2173)
- pylint fix raw_to_pronto_code.py (#2150)
- Document support for Comfee model (#2147)
- DAIKIN: ARC443A5 Remote supported note (#2138)
- library.json specifies libCompatMode strict (#2111)
- Added Electrolux EACM CL/N3 series remote to TCL protocol (#2100)
- Add AR-JW19 to supported devices (#2069)
- Remove unused constant `kRcmmExcess` (#2033)
- Panasonic AC: Document support for PV1122V remote (#2029)
- Document support for Panasonic CS-E12QKEW A/C (#2028)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Support for esp32 Arduino 3.0.0