Skip to content

Make Serial.onReceive() accept std::function #6302

Closed
@gonzabrusco

Description

@gonzabrusco

Related area

UART

Hardware specification

ESP32 DevKit

Is your feature request related to a problem?

Hello. It would be useful if you could make onReceive() on HardwareSerial accept std:function so I can point it to a class method with std:bind. You would need to include .

This request could be extended to other callbacks in the framework (like Wifi.onEvent() ).

If you don't want to include by default, could you at least provide us with a MACRO that enables or disables this?

Thanks

Describe the solution you'd like

Make callbacks use functional

Describe alternatives you've considered

Global function. But if I'm programming in pure C++ and I need to access privates variables of a class from the callback, it gets weird. I would prefer to be able to call a class method directly to avoid exposing data outside the class.

Additional context

No response

I have checked existing list of Feature requests and the Contribution Guide

  • I confirm I have checked existing list of Feature requests and Contribution Guide.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions