esp8266 / esp8266/Arduino

ESP8266WiFiMesh.h private typedefs prevent new'ing object

Open
#7,171 2 comments 0 reactions 1 assignee Claimed by @devyte View on GitHub
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

### Basic Infos

- [X] This issue complies with the [issue POLICY doc](https://github.com/esp8266/Arduino/blob/master/POLICY.md).
- [X] I have read the documentation at [readthedocs](https://arduino-esp8266.readthedocs.io/en/latest) and the issue is not addressed there.
- [X] I have tested that the issue is present in current master branch (aka latest git).
- [X] I have searched the issue tracker for a similar issue.
- [X] If there is a stack dump, I have decoded it.
- [X] I have filled out all fields below.

#### Platform

- Hardware: [ESP-12]
- Core Version: []
- Development Env: [Platformio]
- Operating System: [Windows]

### Settings in IDE

- Module: [Generic ESP8266 Module|Nodemcu]
- Flash Mode: [dio]
- Flash Size: [4MB]
- lwip Variant: [v1.4]
- Reset Method: [nodemcu]
- Flash Frequency: [40Mhz]
- CPU Frequency: [80Mhz]
- Upload Using: [SERIAL]
- Upload Speed: [115200] (serial upload only)

### Problem Description

Cannot instantiate ESP8266WiFiMesh via 'new' in a user-defined class because needed typedefs are private. If the typedefs are marked public, this then works.

### [MCVE](https://stackoverflow.com/help/mcve) Sketch

```h

#include
#include

class MyMeshWrapper
{
public:
MyMeshWrapper();
void networkFilter(int numberOfNetworks, ESP8266WiFiMesh &meshInstance);
String onRequestReceived(const String &request, ESP8266WiFiMesh &meshInstance);
transmission_status_t onResponseReceived(const String &response,
ESP8266WiFiMesh &meshInstance);
private:
ESP8266WiFiMesh * _pMesh;
}

```

```cpp
#include "MyMeshWrapper.h"

MyMeshWrapper::MyMeshWrapper()
{
ESP8266WiFiMesh::requestHandlerType rxType; /* = stuff */
ESP8266WiFiMesh::responseHandlerType rspType; /* = stuff */
ESP8266WiFiMesh::networkFilterType filterType; /* = stuff */

// doesn't compile. see error below
_pMesh = new ESP8266WiFiMesh(rxType, rspType, filterType, "password");
}
```

### Debug Messages

```
In file included from include/includes.h:2:0,
from src\MeshHelper.cpp:1:
C:\Users\\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFiMesh\src/ESP8266WiFiMesh.h: In constructor 'MeshHelper::MeshHelper()':
C:\Users\\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFiMesh\src/ESP8266WiFiMesh.h:64:68: error: 'typedef class std::function ESP8266WiFiMesh::requestHandlerType' is private
typedef std::function requestHandlerType;
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.