MQTT connection Failed
Answer
02/09/19 22:38

Newbie alert!!!

 

Today I am connecting my XDK via wifi to a mosquitto MQTT broker stablished on my laptop. The MQTT broker is listening on the 1883. 

The XDK connects to the wifi but no IP seems to be assigned to it. I go to my router homepage and took at look at this. Is this normal?

The laptop IP is 192.168.0.12.

at the end my main purpose is to send buffers of the accelerometer via MQTT. For the moment just to test the communication I want to send a simple hello world.

 INFO | XDK_DALOG1: [INFO, C:/Users/rafael_lainez/XDK-Workspace/apptest/src-gen/base/ConnectivityWLANWifi.c:98] init WlanNetworkConnect succeeded
 INFO | XDK_DALOG1: [INFO, C:/Users/rafael_lainez/XDK-Workspace/apptest/src-gen/base/ConnectivityWLANWifi.c:113] setting DHCP succeeded
 INFO | XDK_DALOG1: [INFO, C:/Users/rafael_lainez/XDK-Workspace/apptest/src-gen/base/ConnectivityWLANWifi.c:121] Connecting to personal network: KabelBox-CAC0
 INFO | XDK_DALOG1: [INFO, C:/Users/rafael_lainez/XDK-Workspace/apptest/src-gen/base/ConnectivityWLANWifi.c:155] Connected to WLAN. IP address of this device is: 0.0.0.0
 INFO | XDK_DALOG1: [INFO, C:/Users/rafael_lainez/XDK-Workspace/apptest/src-gen/main.c:182] enable ConnectivityWLANWifi succeeded
 INFO | XDK_DALOG1: Error in XDK110 Application package.
 INFO | XDK_DALOG1:     Package ID: 153
 INFO | XDK_DALOG1:     Module ID: 0
 INFO | XDK_DALOG1:     Severity code: 2
 INFO | XDK_DALOG1:     Error code: 12

 

package main;
import platforms.xdk110;


setup wifi: WLAN{
    authentication = Personal(psk = "xxxxxx" );
    ssid= "KabelBox-CAC0";
    ipConfiguration= Dhcp();
    
}

setup messaging: MQTT{
    transport=  wifi;
    url = "mqtt://192.168.0.12:1883";
    cleanSession = true;
    clientId = 'XDK_DALOG1';
    var Test = topic('hello/world');
    }

setup accelerometer{
    bandwidth= BW_1000Hz;
    range= Range_16G;
}

setup led : LED {
    var red = light_up(Red);
    var yellow = light_up(Yellow);
    var orange = light_up(Orange);
   
}

every 5 seconds{
    messaging.Test.write('{"hello": "world"}');
//    var myTemperature = environment.temperature.read();
//    messaging.Test.write(`Temp: ${myTemperature}`);
//    led.orange.write(true);
}

0 (0 Votes)
RE: MQTT connection Failed
Answer
03/09/19 08:30 as a reply to Rafael Lainez.

Hi Rafael,

The IP address 0.0.0.0 is an invalid address for your device. There seems to be an error with the DHCP negociation on the WLAN router.

As a first step, look if the router has DHCP enabled and see if the XDK appears as a DHCP client on the administrating interface

OR experiment first giving your XDK a static IP address in a valid range

Regards,

Francisco

+1 (1 Vote)
RE: MQTT connection Failed
Answer
03/09/19 08:41 as a reply to Francisco Llobet Blandino.

Dear Francisco, 

 

Thank you very much your confirmation on what I suspetected. 

I entered the administrating page of the router and saw the devie connected and the MAC adress of it but absolutely no IP. The router has most likely configured DHCP enabled but I will triple check. 

Yesterday the idea of giving it an static IP came to my mind too but it was really to late and my eyes were closing hahaha. 

Thanks a lot for the support I will be in further contact telling you my findings. 

0 (0 Votes)
RE: MQTT connection Failed
Answer
05/09/19 08:30 as a reply to Rafael Lainez.

Dear Francisco, 

 

I have carried out 2 tests. Creating a hotpost with my mobile and the 1st time I connected the DHCP worked perect and the IP adrees was assigned to the XDK. 

Next day I tested it back again and the connection was not stablished the IP came always 0.0.0.0. 

The second test was to give a fixed IP to the XDK. This way no problem came up. 
So in conclusion what I am able to determine by using 2 different devices to create a network is that XDK from time to time has issues with acquiring a dynamic IP adress. 

I will now work always by setting a fixed IP adress. 

0 (0 Votes)