cancel
Showing results for 
Search instead for 
Did you mean: 

Reading data from Socket Client

damien_lobb
Associate III

Hi,

I am using the IDW04A1 with an STM F401RE MCU. On my program I want to be able to read data from a socket client, so I can essentially tell my MCU to run certain tasks over Wi-Fi.

The problem is, all the Socket Read API just return the status of the module (Success or fail, etc).

When the Socket Read function is run, it does print out the message the client sends it on the terminal, but I can't find a way to actually save that data in a variable somewhere so the MCU can decide what to do when it receives that message.

Thanks,

Damien

1 ACCEPTED SOLUTION

Accepted Solutions
Elio Cometti
Senior II

​Hello Damien,

when compiling for the Nucleo F4 board, the USARTx_IRQHandler() is "attached" to USART1_IRQHandler in the BSP.

When new data is received and +WIND:55: is printed by IDW04A1, then the incoming data is collected and given to the user by a call to ind_wifi_socket_data_received(), so you just need to implement and link your own implementation of ind_wifi_socket_data_recieved() (a default empty (weak) implementation of ind_wifi_socket_data_recieved() is linked when the user implementation is not found in the code).

I've just tried the Client_Socket example with my nucleo F401 + IDW04A1, it prints on the nucleo serial interface whatever I type from the remote socket server.

In the Keil project I used, the following macros are defined as compilation option: USE_HAL_DRIVER, STM32F401xE, USE_STM32F4XX_NUCLEO, USART_PRINT_MSG, SPWF04, CONSOLE_UART_ENABLED.

Hope I answered your question.

Elio

View solution in original post

7 REPLIES 7
damien_lobb
Associate III

Still haven't figured it out but I have found the function "ind_wifi_socket_data_received" which I cant seem to implement correctly.

Any guidance would still be useful.

Elio Cometti
Senior II

​Hello Damien,

I think you're going in the right direction.

You can find a sample implementation of "ind_wifi_socket_data_received" in Client_Socket example application.

Regards,

Elio

Thanks for your Reply Elio.

Quick question about that then. I found implementation of the function in a DMA read function.

That function is called in a UART Callback complete function.

For implementing this, should this run during an interrupt? And if so, what interrupt?

I tried adding breakpoints at the UART DMA interrupt handlers but when you see +WIND 55 the program doesn't stop there.

I​ tried a few different things. Do I need to run the AT command to read data in the socket and then run the ind_wifi_socket_data_recieved function?

I found it odd that if you run the AT command to read the data it will print to my terminal, which makes me think that a function somewhere in my program is already getting the data from the socket, but if so, where?

Sorry for the bombardment of questions.

Thanks​

Elio Cometti
Senior II

​Hello Damien,

when compiling for the Nucleo F4 board, the USARTx_IRQHandler() is "attached" to USART1_IRQHandler in the BSP.

When new data is received and +WIND:55: is printed by IDW04A1, then the incoming data is collected and given to the user by a call to ind_wifi_socket_data_received(), so you just need to implement and link your own implementation of ind_wifi_socket_data_recieved() (a default empty (weak) implementation of ind_wifi_socket_data_recieved() is linked when the user implementation is not found in the code).

I've just tried the Client_Socket example with my nucleo F401 + IDW04A1, it prints on the nucleo serial interface whatever I type from the remote socket server.

In the Keil project I used, the following macros are defined as compilation option: USE_HAL_DRIVER, STM32F401xE, USE_STM32F4XX_NUCLEO, USART_PRINT_MSG, SPWF04, CONSOLE_UART_ENABLED.

Hope I answered your question.

Elio

Hello Elio,

Excellent, thank you. I haven't fully implemented everything yet, but this makes a lot more sense.

I did notice one odd thing.

Original I used the VCOM example which sets up the baud rate at 921600, so when I tried editing it to the Socket server example I kept the configuration at 921600, and it would get stuck in the wifi_reset function as it couldn't change the Wifi_WIND_State IO_status_flag.

However when changing the baud rate to 115200 it got through it no problem.

Thanks for the help once again,

Damien

Elio Cometti
Senior II

​Hello Damien,

I'm not sure I got your point...

The VCOM example try to autodetect the actual baud rate on IDW04 side and then change it to the baud rate specified in the main.

In the Server and Client Socket examples the baud rate autodetect is not performed and the actual baud rate must be specified.

Regards,

Elio

Yes, this is true, and I can check when I'm back in the office, but I believe I was settling up the baud rate as 921600, which worked fine for just sending AT commands, but setting the baud rate as 921600 in other examples doesn't work.

I may have got something else wrong though.​