Developer Portal Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    SendDataOverMQTT can not connect to MQTT server

    mainul
    Member

    SendDataOverMQTT can not connect to MQTT server

    I am using the given example project (SendDataOverMQTT) with the XDK workbench 3.7.0.  I just added my wifi credentials and for MQTT broker 

    static MQTT_Connect_T MqttConnectInfo =

    {

            .ClientId = "XDK_FS",

            .BrokerURL = "broker.hivemq.com",

            .BrokerPort = 1883,

            .CleanSession = true,

            .KeepAliveInterval = 100,

    };/**< MQTT connect parameters */

     

    Wifi connection is okay but problem occurs before MQTT connection. 

    Here is the console output: 

     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: Successfully set IP using DHCP

     INFO | XDK DEVICE 1: Trying to connect with WiFi network...

     INFO | XDK DEVICE 1: Successfully removed obsolete profiles

     INFO | XDK DEVICE 1: Added new WLAN profile

     INFO | XDK DEVICE 1: Successfully reset obsolete connection policy

     INFO | XDK DEVICE 1: Successfully set new connection policy

     INFO | XDK DEVICE 1: Started collecting WLAN Rx Statistic

     INFO | XDK DEVICE 1: IP address of device  192.168.43.19

     INFO | XDK DEVICE 1:               Mask    255.255.255.0

     INFO | XDK DEVICE 1:               Gateway 192.168.43.1

     INFO | XDK DEVICE 1:               DNS     192.168.43.1

     INFO | XDK DEVICE 1: Connected to WPA network successfully

     INFO | XDK DEVICE 1: asserted at Filename ./../Libraries/ServalStack/3rd-party/ServalStack/api/Serval_StringDescr.h , line no  180

    Tags (1)
    2 REPLIES 2
    Mahalingam
    Occasional Contributor

    Re: SendDataOverMQTT can not connect to MQTT server

    Hello mainul,

    I am able to send data to mqtt server successfully with the below configuration.

    static MQTT_Connect_T MqttConnectInfo =
    {
    .ClientId = "XDS_FS",
    .Username = APP_MQTT_USERNAME,
    .Password = APP_MQTT_PASSWORD,
    .BrokerURL = "broker.hivemq.com",
    .BrokerPort = 1883,
    .CleanSession = true,
    .KeepAliveInterval = 100,
    };/**< MQTT connect parameters */

    Attached Workbench log for reference,

    INFO | XDK DEVICE 1: Successfully set IP using DHCP
    INFO | XDK DEVICE 1: Trying to connect with WiFi network...
    INFO | XDK DEVICE 1: Successfully removed obsolete profiles
    INFO | XDK DEVICE 1: Added new WLAN profile
    INFO | XDK DEVICE 1: Successfully reset obsolete connection policy
    INFO | XDK DEVICE 1: Successfully set new connection policy
    INFO | XDK DEVICE 1: Started collecting WLAN Rx Statistic
    INFO | XDK DEVICE 1: IP address of device 192.168.43.50
    INFO | XDK DEVICE 1: Mask 255.255.255.0
    INFO | XDK DEVICE 1: Gateway 192.168.43.1
    INFO | XDK DEVICE 1: DNS 192.168.43.1
    INFO | XDK DEVICE 1: Connected to WPA network successfully
    INFO | XDK DEVICE 1: MqttEventHandler : Event - 0
    INFO | XDK DEVICE 1: ServalMqttAgent:SubscribeToTopic - Subscribing to topic: BCDS/XDK110/example/out, Qos: 1
    INFO | XDK DEVICE 1: MqttEventHandler : Event - 8
    INFO | XDK DEVICE 1: MqttEventHandler : Event - 14
    INFO | XDK DEVICE 1: AppMQTTSubscribeCB : #1, Incoming Message:
    INFO | XDK DEVICE 1: Topic: BCDS/XDK110/example/out
    INFO | XDK DEVICE 1: Payload:
    INFO | XDK DEVICE 1: """
    INFO | XDK DEVICE 1: Environmental Data -
    INFO | XDK DEVICE 1: Humidity : 54
    INFO | XDK DEVICE 1: Pressure : 96257
    INFO | XDK DEVICE 1: Temperature : 30.181000ø
    INFO | XDK DEVICE 1: """
    INFO | XDK DEVICE 1: MqttEventHandler : Event - 15
    INFO | XDK DEVICE 1: MqttEventHandler : Event - 14

    Reason why you were getting  "asserted at Filename ./../Libraries/ServalStack/3rd-party/ServalStack/api/Serval_StringDescr.h , line no 180 " error was,

    You have removed below 2 parameter from the mqtt structure,

    .Username = APP_MQTT_USERNAME,
    .Password = APP_MQTT_PASSWORD,

    Could you please include back those parameter and Could you Clean the application and Build and Flash the application into XDK. XDK will be connected to mqtt server. I Hope this will solve your problem.

    mainul
    Member

    Re: SendDataOverMQTT can not connect to MQTT server

    It is working with dummy mqtt user name and password but it is bit weird that we need that to connect even that is dummy. Also, in there simple example they did not use those, I  just copies that into their example project. 

    static MQTT_Connect_T MqttConnectInfo = { .ClientId = "XDK_FS", .BrokerURL = "broker.hivemq.com", .BrokerPort = 1883, .CleanSession = true, .KeepAliveInterval = 100, };/**< MQTT connect parameters */

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist