Receive messages via wifi with interrupt while executing main loop

BakeinBlue
Posts: 1
Joined: Mon Jun 29, 2020 12:13 pm

Receive messages via wifi with interrupt while executing main loop

Postby BakeinBlue » Mon Jun 29, 2020 1:19 pm

Good day!

Im using an ESP32 Wroom32 receiving messages and executing them. The use case needs the messages to be received while the main program is running.


Code as is now: (runs properly)
  1. //initial code
  2. setup()
  3. {
  4. //wifi, server settings
  5. }
  6. main(){
  7. WiFiClient client = server.available();
  8. byte msg_full[40];
  9. if (client)
  10.    {                            
  11.    Serial.println("Client connected");          
  12.    while (client.connected())
  13.       {
  14.       msg= client.read();
  15.       msg_full = process_msg(&msg, client);     //Returns a 0 array if msg is incorrect or has error. msg_full is full message
  16.       if (msg_full [0] != 0)            //Runs only if msg_full is not zero ie, valid
  17.       {
  18.        msg_run(msg_full);
  19.        //msg_full is set to zero again
  20.       }
  21.       }
  22.    }
  23. }
This above code has to be changed as follows. So that the messages are received while running the main loop. If I hard code msg_list, then the code works as expected.

  1. //initialisations
  2. /
  3. setup()
  4. {
  5. //wifi, server settings
  6. }
  7. main()
  8. {
  9.     WiFiClient client = server.available();
  10.     byte msg_full[40];
  11.     byte msg_list[50][40];
  12.     int count = 0;
  13.     if (count != 0)
  14.           {
  15.            msg_run(msg_list[0]);
  16.            //Decrement count
  17.            //Move msgs in msg_list by 1 row above
  18.           }
  19. }
  20.  
  21. def msg_rx_interrupt(int msg, WiFiClient& client_connected)
  22. {
  23.    If (client_connected.connected())
  24.       {
  25.       msg = client_connected.read();
  26.       msg_full = process_msg(&msg, client_connected); //Returns a 0 array if msg is incorrect or has error. msg_full is full message
  27.       //add new msg_full to msg_list
  28.       //count = count + 1
  29.       }
  30. }

Which Interrupt do I assign the function msg_rx_interrupt to?

https://docs.espressif.com/projects/esp ... /wifi.html does not list/document any receive/transmit events or interrupts

Who is online

Users browsing this forum: No registered users and 63 guests