MQTT error

I've been trying to connect to a mqtt broker using the program called "mqtt_simple_sample" provided in the example files.Sadly I've been unable to get it to work.

I changed all the configurations needed, main.c and .config. I changed the password, user_name, topic, client id, hostname and port.

I get the following on the LTE Link Monitor.

According to this list of errors https://github.com/eblot/newlib/blob/master/newlib/libc/include/sys/errno.h#L161 I get this:  #define ENOMEM 12 /* Not enough core */

I'm not sure why is this happening or how to fix it.

Regards, Sandy.

Parents
  • Hi Sandra,

    How did you set username and password?

    Best regards,
    Dejan

  • I used the following code:

    /* MQTT client configuration */
        client->broker = &broker;
        client->evt_cb = mqtt_evt_handler;
        client->client_id.utf8 = client_id_get();
        client->client_id.size = strlen(client->client_id.utf8);
        client->password = "Liditek12345678912345";
        client->user_name = "Nordic1234567";
        client->protocol_version = MQTT_VERSION_3_1_1;

    The main change is on the client id and password.

  • Hi Sandra,

    You can specify your MQTT broker hostname which is given in Kconfig file to be test.mosquitto.org. On test.mosquitto.org, you can read that you would need to connect to port 1884 instead of 1883 to get authenticated access. On the same website, you can read that authenticated listeners require username to be set to "rw" and password to "readwrite". You would need to have 2 structs,  user_name and password, and set their utf8 values to "rw" and "readwrite". Additionally, you would need to define sizes the in each of the structs. You could do something like this

    static struct mqtt_utf8 user_name;
    static struct mqtt_utf8 password;
    
    client->user_name = &user_name;
    client->password = &password;
    
    user_name.utf8="rw";
    user_name.size=2;
    
    password.utf8="readwrite";
    password.size=9;


    Best regards,
    Dejan

Reply
  • Hi Sandra,

    You can specify your MQTT broker hostname which is given in Kconfig file to be test.mosquitto.org. On test.mosquitto.org, you can read that you would need to connect to port 1884 instead of 1883 to get authenticated access. On the same website, you can read that authenticated listeners require username to be set to "rw" and password to "readwrite". You would need to have 2 structs,  user_name and password, and set their utf8 values to "rw" and "readwrite". Additionally, you would need to define sizes the in each of the structs. You could do something like this

    static struct mqtt_utf8 user_name;
    static struct mqtt_utf8 password;
    
    client->user_name = &user_name;
    client->password = &password;
    
    user_name.utf8="rw";
    user_name.size=2;
    
    password.utf8="readwrite";
    password.size=9;


    Best regards,
    Dejan

Children
No Data
Related