cancel
Showing results for 
Search instead for 
Did you mean: 

Implement WebSocket Protocol on STM32?

AS5
Associate II

Hello,

I am currently working on a project with an HTTP server, successfully implemented using FreeRTOS. In this setup, I handle client requests for opening and collecting data from the client side. However, since I need to display real-time data on a web page (for an IoT application), it has become necessary to implement the WebSocket protocol.

I am looking to implement a WebSocket server on my STM32f746G-DISCO. Unfortunately, I have not been able to find any working examples of WebSocket implementation on STM32.

Could you kindly point me in the direction of any relevant examples or provide some guidance on how to get started with this? Also, I would appreciate any insights regarding whether I need to modify my CubeMX configuration when implementing WebSocket, or if the standard initialization is sufficient — enabling ETH, activating lwIP (httpd) without DHCP, and activating FreeRTOS with the default task where the following initialization is done:

MX_LWIP_Init();
http_server_init();

Any help would be greatly appreciated.

Thank you in advance!

Best regards,

@AS5 

4 REPLIES 4
mbarg.1
Senior II

We did work out a websockets solution for H7 that work great but using AZRTOS as OS.

We had before a solution with FreeRtos but it was not rugged enough and we dropped a couple of years ago.

Our designs require a very resilient and robust performance, with true real time interaction with multiple clients.

Should you think to move to AZRTOS, let me know.

Intector
Senior

Hello @mbarg.1,

I'm working on a project for which I designed a board with an STM32H7R3L8H6H MCU, an APS256XXN-OBR-BG 256MBit PSRAM on HEXASPI, an MX25UW25645GXDI00-T 256MBit flash on OCTOSPI, and an EMMC08G-MV28-01J10 SDMMC, among other peripherals.

Here are some pictures of it:

20250118_131125.jpg

20250118_162939.jpg

TagID-DCU_01.jpg

TagID-DCU_02.jpg

 

I worked out all the major kinks, and the system runs pretty well. However, there's something that bothers me quite a bit. I'm running AZRTOS and have an HTTP server for the web interface for settings and manual operations of the device. I would like to optimize the system by getting rid of the long-running HTTP requests that I use to get feedback from the HTTP server to the web interface. Trust me, I tried almost every trick in the book, but nothing worked out better than what I have.

I tried SSE, but the HTTP server mixed up the requests. In the next step, I created a second HTTP server just for SSE, but the response headers to the client connection attempt have "Connection: Close" in them, which triggers the closing of the connection after the first event. 

The WebSocket runs on the server side and requires Node.js, and I couldn't get something like this running on my system. In one of my last attempts to find answers, I accidentally stumbled over this post in which you state that you've worked out a solution for that. 

I would be happy to try this on my system. Can you share your solution or at least some information on how you solved this issue?

 

 

Thank you, and to everyone else out there:

The secret is to keep banging the rocks together, guys.

 

Yes, I will be happy to share it with you BUT I am actually out of office for a business trip.

I will reply Monday, once back in office.

Thank you very much. Have a safe trip and a great weekend.