MQTT Connection failed
Risposta
27/05/19 13.59

 

Hello everybody,

i am new with the xdk device  and i have some problems by using it .                         I'm using the SendDataOverMqtt Template (Workbench 3.6.0) to send data from the xdk to a mqtt server. I have just changed the network-Informations in AppController.h with my own network-informations (virtual network with an ACL Connection between XDK and MQTT Server) and my AppController.h looks now as following:

#ifndef APPCONTROLLER_H_
#define APPCONTROLLER_H_

#include "XDK_Utils.h"
#define WLAN_SSID                           "xxxxxxxxx"
#define WLAN_USERNAME                       "xxxxxxxxxxx"
#define WLAN_PSK                            "xxxxxxxxxxx"
#define WLAN_STATIC_IP                      true
#define WLAN_IP_ADDR                        XDK_NETWORK_IPV4(10, 16, 194, 233)
#define WLAN_GW_ADDR                        XDK_NETWORK_IPV4(10, 16, 64, 1)
#define WLAN_DNS_ADDR                       XDK_NETWORK_IPV4(0, 0, 0, 0)
#define WLAN_MASK                           XDK_NETWORK_IPV4(255, 255, 254, 0)
#define SNTP_SERVER_URL                     "SntpServerUrl"
#define SNTP_SERVER_PORT                    UINT16_C(123)
#define APP_MQTT_BROKER_HOST_URL            "mqtt://10.16.119.110:1883"
#define APP_MQTT_BROKER_HOST_PORT           UINT16_C(1883)
#define APP_MQTT_CLIENT_ID                  "10.16.64.140"
#define APP_MQTT_TOPIC                      "BCDS/XDK110/GetSensorData"
#define APP_MQTT_SECURE_ENABLE              0
#define APP_MQTT_DATA_PUBLISH_PERIODICITY   UINT32_C(1000)

void AppController_Init(void * cmdProcessorHandle, uint32_t param2);

#endif /* APPCONTROLLER_H_ */

 

 

 

But when i flash the code into the xdk i get the following error:

 

 INFO | Port 'COM4' has been disconnected
 INFO | Connecting to XDK device 'XDK Device 1' in port 'COM4'...
 INFO | Connection to port 'COM4' established
 INFO | XDK DEVICE 1: This is a CC3100R device
 INFO | XDK DEVICE 1: CHIP 0x4000000
 INFO | XDK DEVICE 1: MAC 31.1.2.0.2
 INFO | XDK DEVICE 1: PHY 1.0.3.23
 INFO | XDK DEVICE 1: NWP 2.2.0.1
 INFO | XDK DEVICE 1: ROM 0x3333
 INFO | XDK DEVICE 1: HOST 1.0.1.11
 INFO | XDK DEVICE 1: WLANPersonalWPA2Connect : Static IP is set to : 10.16.194.233
 INFO | XDK DEVICE 1: AppControllerEnable : Failed
 INFO | XDK DEVICE 1: Error in XDK110 Application package.
 INFO | XDK DEVICE 1:     Package ID: 153
 INFO | XDK DEVICE 1:     Module ID: 53
 INFO | XDK DEVICE 1:     Severity code: 2
 INFO | XDK DEVICE 1:     Error code: 168
 INFO | XDK DEVICE 1: asserted at Filename C:/Users/franck/XDK-Workspace/SendDataOverMQTT/source/AppController.c , line no  448

 

Why is this error occurring and how can i fix it?

Thank you in advance

Regards

Franck

0 (0 Voti)
RE: MQTT Connection failed
Risposta
28/05/19 5.57 come risposta a Franck Voufo.

Hi Franck

From your configurations I can see that you are using your personal connection and defined static IP

#define WLAN_STATIC_IP                      true

Please do the following changes in AppController.h :

/**
 * WLAN_SSID is the WIFI network name where user wants connect the XDK device.
 * Make sure to update the WLAN_PSK constant according to your required WIFI network.
 */
#define WLAN_SSID                           "xxxx"

/**
 * WLAN_PSK is the WIFI router WPA/WPA2 password used at the Wifi network connection.
 * Make sure to update the WLAN_PSK constant according to your router password.
 */
#define WLAN_PSK                            "xxx"

/**
 * WLAN_STATIC_IP is a boolean. If "true" then static IP will be assigned and if "false" then DHCP is used.
 */
#define WLAN_STATIC_IP                      false

/**
 * WLAN_IP_ADDR is the WIFI router WPA/WPA2 static IPv4 IP address (unused if WLAN_STATIC_IP is false)
 * Make sure to update the WLAN_IP_ADDR constant according to your required WIFI network,
 * if WLAN_STATIC_IP is "true".
 */
#define WLAN_IP_ADDR                        XDK_NETWORK_IPV4(0, 0, 0, 0)

/**
 * WLAN_GW_ADDR is the WIFI router WPA/WPA2 static IPv4 gateway address (unused if WLAN_STATIC_IP is false)
 * Make sure to update the WLAN_GW_ADDR constant according to your required WIFI network,
 * if WLAN_STATIC_IP is "true".
 */
#define WLAN_GW_ADDR                        XDK_NETWORK_IPV4(0, 0, 0, 0)

/**
 * WLAN_DNS_ADDR is the WIFI router WPA/WPA2 static IPv4 DNS address (unused if WLAN_STATIC_IP is false)
 * Make sure to update the WLAN_DNS_ADDR constant according to your required WIFI network,
 * if WLAN_STATIC_IP is "true".
 */
#define WLAN_DNS_ADDR                       XDK_NETWORK_IPV4(0, 0, 0, 0)

/**
 * WLAN_MASK is the WIFI router WPA/WPA2 static IPv4 mask address (unused if WLAN_STATIC_IP is false)
 * Make sure to update the WLAN_MASK constant according to your required WIFI network,
 * if WLAN_STATIC_IP is "true".
 */
#define WLAN_MASK                           XDK_NETWORK_IPV4(0, 0, 0, 0)

/* SNTP configurations ****************************************************** */

/**
 * SNTP_SERVER_URL is the SNTP server URL.
 */
#define SNTP_SERVER_URL                     "time.nist.gov"

/**
 * SNTP_SERVER_PORT is the SNTP server port number.
 */
#define SNTP_SERVER_PORT                    UINT16_C(123)

/* MQTT server configurations *********************************************** */

/**
 * APP_MQTT_BROKER_HOST_URL is the MQTT broker host address URL.
 */
#define APP_MQTT_BROKER_HOST_URL            "broker.hivemq.com"

/**
 * APP_MQTT_BROKER_HOST_PORT is the MQTT broker host port.
 */
#define APP_MQTT_BROKER_HOST_PORT           UINT16_C(1883)

/**
 * APP_MQTT_CLIENT_ID is the device name
 */
#define APP_MQTT_CLIENT_ID                  "XDK_MQTT_EXAMPLE"

/**
 * APP_MQTT_TOPIC is the topic to subscribe and publish
 */
#define APP_MQTT_TOPIC                      "BCDS/XDK110/example/out"

Thanks

Priyashi

0 (0 Voti)
RE: MQTT Connection failed
Risposta
28/05/19 6.33 come risposta a Priyashi Yadav.

Hi Priyashi,

thanks for your quick reply.

I'm actually using an enterprise network of a company.

The network is a virtual network and i have given in this network a static IP-address to the xdk and i've created an ACL connection between the IP-address of the xdk and that of the mqtt server.

Should then the configurations in AppController.h look different?

Thanks in advance!
Franck

 
0 (0 Voti)
RE: MQTT Connection failed
Risposta
29/05/19 8.23 come risposta a Franck Voufo.

Hello Franck,

if you want to connect the XDK with an enterprise WiFi, you have to use an other function like you do at the moment.

Instead of the function "WlanConnect_WPA" you need to use the function "WlanConnect_EnterpriseWPA". You can find the function also in the header file: BCDS_WlanConnect.h under the following path:

yourProject/SDK/xdk110/Platform/Wlan/include/BCDS_WlanConnect.h

If you have any further questions please do not hesitate to ask.

Best regards,

Christian

 

0 (0 Voti)
RE: MQTT Connection failed
Risposta
29/05/19 9.47 come risposta a Christian Köhler.

Hello Christian ,

thank you for your fast response.

I have used the function WlanConnect_EnterpriseWPA as you mentioned and i have also disabled the DHCP in BCDS_WlanNetworkConfig.h because i used a static IP and that's the way I did it :

 ******************************************************************************/
connectSSID = (WlanNetworkConnect_SSID_T)"..........";
connectUsername = (WlanNetworkConnect_Username_T)".............";
connectPassPhrase = (WlanNetworkConnect_PassPhrase_T)"..........";

Retcode_T WlanNetworkConnect_EnterpriseWPA(WlanNetworkConnect_SSID_T connectSSID, WlanNetworkConnect_Username_T connectUsername,
        WlanNetworkConnect_PassPhrase_T connectPassPhrase);

/******************************************************************************/

Retcode_T WlanNetworkConfig_SetIpStatic(WlanNetworkConfig_IpSettings_T myIpSettings){
        WlanNetworkConfig_IpSettings_T myIpSet;
        Retcode_T retStatus;
        myIpSet.isDHCP = (uint8_t) NETWORKCONFIG_DHCP_DISABLED;
        myIpSet.ipV4 = NetworkConfig_Ipv4Value(10, 16, 64, 140);
        myIpSet.ipV4DnsServer = NetworkConfig_Ipv4Value(10, 58, 194, 16);
        myIpSet.ipV4Gateway = NetworkConfig_Ipv4Value(10, 16, 64, 1);
        myIpSet.ipV4Mask = NetworkConfig_Ipv4Value(255, 255, 254, 0);

        retStatus = WlanNetworkConfig_SetIpStatic(myIpSet);
         if (retStatus == RETCODE_OK)
         {
           printf("The static IP was set successfully");
         }
        else {
           printf("Set IP static failed");
         }
        return 0;
}

But when i run the code into the XDK i get another error:

Makefile:59: recipe for target 'debug' failed
mingw32-make: *** [debug] Error 2

 

and NETWORKCONFIG_DHCP_DISABLED ist marked as undeclared.  I really do not know how I can configure the static ip well.

Thank you in advance for any help

Kind regards

Franck

0 (0 Voti)
RE: MQTT Connection failed
Risposta
29/05/19 13.25 come risposta a Franck Voufo.

Hello Franck,

i am not really sure what causes the error you are facing right now.

But maybe it will help you and also solve the error if you are start using the XDK_WLAN.h interface. Its a pretty abstracted an easy to use interface for WiFi interaction with the XDK.

To use the Interface in your case you should just need the following code:

#include "XDK_WLAN.h"

void someFunc(void){

   WLAN_Setup_T wlan = {
      .IsEnterprise = true,
      .IsHostPgmEnabled = false,
      .SSID = "your SSID",
      .Username = "your Username",
      .Password = "your Password",
      .IsStatic = true,
      .IpAddr = NetworkConfig_Ipv4Value(...),
      // DNS Gateway and so on
      };

      WLAN_Setup(&wlan);
      WLAN_Enable();
}

I hope this will solve your problem.

Best regards,

Christian

 

0 (0 Voti)
RE: MQTT Connection failed
Risposta
07/06/19 10.00 come risposta a Christian Köhler.

Hi,

i still have a connection issue with the xdk-device.

I tried the example "WlanNetworkManagement" just to see why the connection does not work.

I use the DHCP in this case and my AppController.h looks like this:

#ifndef APPCONTROLLER_H_
#define APPCONTROLLER_H_
#include "XDK_Utils.h"

#define NCI_DHCP_MODE                       (1)
#define SCAN_INTERVAL                       (5)

#define WLAN_SSID                           "xxxxxx"
#define WLAN_USERNAME                           "xxxxxx"
#define WLAN_PSK                            "xxxxxxxx"
#define WLAN_STATIC_IP                      false
#define WLAN_IP_ADDR        XDK_NETWORK_IPV4(0,0,0,0)

#define WLAN_GW_ADDR      XDK_NETWORK_IPV4(0,0,0,0)

#define WLAN_MASK              XDK_NETWORK_IPV4(0,0,0,0)
#define WLAN_DNS_ADDR     XDK_NETWORK_IPV4(0,0,0,0)

void AppController_Init(void * cmdProcessorHandle, uint32_t param2);

#endif /* APPCONTROLLER_H_ */

 

 

After flashing the code into the xdk , it scans properly all networks and shows these messages on the console:

Hey User! XDK found the following networks:

- found SSID number 0 is : network1

- found SSID number 1 is : network2

 - found SSID number 2 is : network3    ...........to network5

Finished scan successfully

DHCP is set

IP will be set using DHCP with callback. Waiting for IP ...

Connection failed.

 

 

 

I found a post that I need firmware 2.6.0.5 to connect Enterprise WPA2 Network.  can that be a solution to my problem or am I doing something wrong?

 

Thanks in advance

Best regards,

Franck

0 (0 Voti)