Skip to content

Hanging on Cayenne.begin on Arduino MKR WiFi 1010 #29

Open
@max-mayorov

Description

@max-mayorov

Hi.

I'm trying to use Cayenne with on Arduino MKR WiFi 1010 but it hangs on Cayenne.begin...

Here's the code for library version 1.3.1


#define CAYENNE_DEBUG       // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneMQTTMKR1010.h>

const char ssid[] = "WiFi-2.4-C9FC"; // WiFI ssid
const char wifiPassword[] = "wifiPassword"; //WiFI password

char username[] = "0000000-0000-0000-0000-000000000";
char password[] = "0000000-0000-0000-0000-000000000";
char clientID[] = "0000000-0000-0000-0000-000000000";


void setup() {
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID, ssid, wifiPassword);
  // Blink 3 times when back from begin
  for(int i=0; i<3; ++i)
  {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(500);
    digitalWrite(LED_BUILTIN, LOW);
    delay(200);
  }   
}

void loop() {
  Cayenne.loop();
}

CAYENNE_CONNECTED()
{
    for(int i=0; i<10; ++i){
    digitalWrite(LED_BUILTIN, HIGH);
    delay(50);
    digitalWrite(LED_BUILTIN, LOW);
    delay(200);   
  }
}

bool ledStatus = HIGH;
// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_OUT_DEFAULT()
{
  digitalWrite(LED_BUILTIN, ledStatus);
  if(ledStatus == HIGH)
    ledStatus = LOW;
  else 
    ledStatus = HIGH;

  // Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
  Cayenne.virtualWrite(0, millis());

  // Some examples of other functions you can use to send data.
  //Cayenne.celsiusWrite(1, 22.0);
  //Cayenne.luxWrite(2, 700);
  //Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
}

// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
  CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  //Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");
}

The debug log from Cayenne says that WiFi is connected and MQTT client is connected and built-in led blinks as expected. But it never gets back from Cayenne.begin and never blinks 3 times.

I did some print-debug ;) and found that it hangs when subscribing, line 68 in CayenneArduinoMQTTClient.h:

CayenneMQTTSubscribe(&_mqttClient, NULL, COMMAND_TOPIC, CAYENNE_ALL_CHANNELS, NULL);

I tried to print debug deeper, but couldn't make CAYENNE_LOG work in CayenneMQTTClient.c ...

Can you have a look?
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions