0

I completed this tutorial and can see data sent to Azure's cloud.

https://microsoft.github.io/azure-iot-developer-kit/docs/get-started/

But, looking at the serial monitor, I see it disconnecting and reconnecting over and over, between the successful sensor messages.

[...] hardware\stm32f4\1.6.0\cores\arduino\azure-iot-sdk-c\c-utility\adapters\socketio_mbed_os5.c Func:send_queued_data Line:213,
Socketio_Failure: encountered unknow connection issue, the connection will be restarted.
2019-03-27 00:35:28 INFO:  >>>Connection status: disconnected
2019-03-27 00:35:30 INFO:  >>>Re-connect.

My connection seems fine, judging by Google's speed test.

Fred B
  • 1
  • 1

2 Answers2

0

It's connection issue, the IoT DevKit only support 2.4GHz Wi-Fi, please make sure not connect with a 5GHz AP. If 2.4GHz, can you try another AP? Like set your cell phone as a Hotspot.

Arthur Ma
  • 21
  • 3
  • It was on a 2.4GHz that doesn't lag when I play online multiplayer games. I just tried with my mobile hotspot and had the same result, sadly. Both connections seem very reliable to me. I looked at the code http://sources.buildroot.org/azure-iot-sdk-c/git/umqtt/deps/c-utility/adapters/socketio_mbed_os5.c and indeed it seems like it's a connection issue, like you said. So I'm gonna try another connection, and maybe another USB cable and computer just to make sure. Thanks! – Fred B Mar 27 '19 at 01:48
0

Wasn't able to run the Get Started project on any connection, but I just created a new IotHub Project from scratch in Studio Code and it now stays connected.

Maybe I needed to update my firmware or something, I'll try it later, but if someone has the same issue and wants to get running, here's the simple working code that was generated:

#include "AZ3166WiFi.h"
#include "DevKitMQTTClient.h"

static bool hasWifi = false;
static bool hasIoTHub = false;

void setup() {
  // put your setup code here, to run once:
  if (WiFi.begin() == WL_CONNECTED)
  {
    hasWifi = true;
    Screen.print(1, "Running...");

    if (!DevKitMQTTClient_Init())
    {
      hasIoTHub = false;
      return;
    }
    hasIoTHub = true;
  }
  else
  {
    hasWifi = false;
    Screen.print(1, "No Wi-Fi");
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  if (hasIoTHub && hasWifi)
  {
    char buff[128];

    // replace the following line with your data sent to Azure IoTHub
    snprintf(buff, 128, "{\"topic\":\"iot\"}");

    if (DevKitMQTTClient_SendEvent(buff))
    {
      Screen.print(1, "Sending...");
    }
    else
    {
      Screen.print(1, "Failure...");
    }
    delay(2000);
  }
}
Fred B
  • 1
  • 1