Custom HTTP Endpoints


When a new device is provisioned with a device in AP mode, mDash creates an HTTP server with the /setup and /GetKey endpoints to interact with the user’s WebApp. This works, but we’d like to create additional endpoints to improve the provisioning process. This would enable us to convey additional data with the user.

Question: Is possible to add custom HTTP endpoints with mDash?

If we create an endpoint using conventional esp-idf HTTP libraries they don’t work as it appears mDash intercepts all HTTP traffic to the device.

Thank in advance!

The HTTP handler is defined in the guts of mdash library, it uses data structures that are not exported to the user. So the short answer is “no, not possible”.

Could you elaborate more on what do you intend to implement, please?

Our intention is to implement an HTTP SSE endpoint to report WiFi scanning details (SSID & RSSI) to improve the WiFi configuration process. We’ll also have an endpoint that declares the FW rev so that the WebApp can know the device capabilities.

Would something like this need to be integrated into mDash or is there a way for new endpoints external to mDash to coexist with the mDash library?


These things - WiFi scanning, and reporting some configurable value, sound like a generic features that belong to the mdash library.
We’ll implement that for the next release, expected in Q1 2021.

That would be a very welcome and valuable addition.

We might suggest implementing an SSE endpoint that includes SSID and RSSI values in a JSON object that represent a quasi-realtime view of the device’s WiFi scan results.

If we were to implement something like this external to mDash in the interim, is there a way to temporarily stop/restart the mDash library and/or start mDash w/o WiFi?


Why SSE, not a regular REST? The scanning might take a couple of seconds, is that a too high price to pay?

If you want to manage WiFi separately, take a look at mdash.h:

Specifically, the mdashInit() function assumes that WiFi is set by some external way. Do whatever discovery is required, join WiFi, and when IP address is obtained, call mDashInit() to connect to mDash.

Thanks for the advice regarding mDashInit() - we’ll take a look.

As for SSE vs. a REST endpoint, SSE seems like an elegant way to implement a quasi-realtime streaming of scan results (SSID + RSSI) without requiring the client to continually poll. If there is significant overhead or other negatives implementing SSE in the device FW that would be good to know.


The IDF API returns scanned network list in one go, not one by one. See ESP-IDF API reference
How do you see a quasi-realtime approach applied in that situation?

Yes, esp-idf does return scanned results in one go as you’ve noted.

So perhaps “quasi-realtime” is not the best terminology, but SSE gives us a way to push this streaming data to the client and it seems to work well enough.

I’m sure that polling a GET endpoint could achieve similar results. SSE does have new data for each update whereas that may not be the case for async client polling.