C IoTHub 客户端的 Azure SDK 无法获取特定格式的设备 ID 的 clientID

问题描述 投票:0回答:0

我正在使用适用于 C 的 Azure SDK,我正在尝试将设备连接到 IoTHub。我注意到如果我使用像这样的设备 ID

"testDevice"
,我可以毫无问题地连接。但是如果我使用这样的东西
"11:11:11:11:11:11"
它无法通过mqtt连接。我已确保这两个设备都存在于 azure IoTHub 中,并且在更改它们时更新了它们的连接字符串。我得出的结论是,虽然 azure 允许我创建具有这些字符的设备,但 SDK 在连接到它时遇到了问题。这就是我正在做的......

String uuid = "11:11:11:11:11:11"; // this one fails
String uuid = "testingDevice"; // this one works
static const char* device_id = uuid.c_str();

客户端连接正常,但下面的块将失败的字符串返回到串行。虽然没有错误。

  char mqtt_username[128];
  // Get the MQTT user name used to connect to IoT Hub
  if (az_result_failed(az_iot_hub_client_get_user_name(
          &client, mqtt_username, sizeofarray(mqtt_username), NULL)))
  {
    printf("Failed to get MQTT clientId, return code\n");
    return 1;
  }

我对 device_id 使用这种格式的原因仅仅是因为这是一个设备唯一的 mac 地址。

azure mqtt azure-iot-hub azure-sdk
© www.soinside.com 2019 - 2024. All rights reserved.