BriscoeTech / Arduino-FreeRTOS-SAMD21

A port of FreeRTOS that runs on Arduino Samd21 boards
64 stars 19 forks source link

Having Problems with MQTT #22

Closed Dorokun192 closed 2 years ago

Dorokun192 commented 4 years ago

I've written my code for Arduino MKR WiFi 1010 for sending data to Azure IoT. So far, the program works right until I've added the mqtt connection. I can't post the whole code but here is a snippet from it:

static void blueBlink(void *pvParameters)
{
  while(1)
  {
    if (mqttClient.connected())
    {
      WiFiDrv::digitalWrite(WBLUE, HIGH);
      myDelayMs(50);
      WiFiDrv::digitalWrite(WBLUE, LOW);
      myDelayMs(50);
      WiFiDrv::digitalWrite(WBLUE, HIGH);
      myDelayMs(50);
      WiFiDrv::digitalWrite(WBLUE, LOW);
      myDelayMs(1000);
    }
  } 
}

xTaskCreate(blueBlink, "Blue Blink", 64,NULL,tskIDLE_PRIORITY+4, &Handle_blueBlink);

If I remove the if(mqttClient.connected()) option it returns back to normal. I also changed the stack heap size to 9*1024 because of memory issues

BriscoeTech commented 4 years ago

Hello Dorokun192,

What exactly happens when you call the mqttClient.connected() command, does the rtos crash? Not working right is kind of a vague issue to diagnose.

I have added some new serial debugging features to the rtos to help diagnose crashing issues. If you are having crashing issues I would download the new version and take a look at the new examples. You will be interested in adding vSetErrorSerial to your project and see what prints on the terminal when you call your problematic function.