Giter VIP home page Giter VIP logo

Comments (12)

asbarnes avatar asbarnes commented on June 22, 2024

Hi,

I'm doing something similar.

My cmake arguments for Azure-IoT-SDK-C are:
-Duse_amqp:BOOL=ON -Duse_http:BOOL=ON -Duse_mqtt:BOOL=ON -Dskip_samples:BOOL=OFF -Duse_prov_client:BOOL=ON -Duse_prov_client_core:BOOL=ON -Dhsm_type_sastoken:BOOL=ON

And for the device update agent I added the following libraries:

+find_package (azure_macro_utils_c REQUIRED)

target_link_libraries (

+prov_device_client

+prov_device_ll_client

+prov_auth_client

+prov_amqp_transport

+umqtt

+prov_mqtt_ws_transport

+hsm_security_client

+utpm

Here is my main diff


--- a/src/agent/src/main.c
+++ b/src/agent/src/main.c
@@ -20,6 +20,8 @@
 #include <iothub.h>
 #include <iothub_client_options.h>
 #include <iothubtransportmqtt.h>
+#include <iothub_device_client_ll.h>
+#include <azure_prov_client/iothub_security_factory.h>
 
 #ifndef ADUC_PLATFORM_SIMULATOR // DO is not used in sim mode
 #    include <do_config.h>
@@ -485,8 +487,22 @@ static void ADUC_ConnectionStatus_Callback(
 _Bool ADUC_DeviceClient_Create(ADUC_ConnectionInfo* connInfo, const ADUC_LaunchArguments* launchArgs)
 {
     IOTHUB_CLIENT_RESULT iothubResult;
+    int iothubInitResult;
     bool result = true;
 
+    // Before invoking ANY IoT Hub or DPS functionality, IoTHub_Init must be invoked.
+    if ((iothubInitResult = IoTHub_Init()) != 0)
+    {
+        Log_Error("Failure to initialize client, error=%d", iothubInitResult);
+        result = false;
+    }
+
+    if (iothub_security_init(IOTHUB_SECURITY_TYPE_SAS) != 0)
+    {
+        Log_Error("iothub_security_init failed");
+        result = false;
+    }
+
     // Create a connection to IoTHub.
     if ((g_iotHubClientHandle =
              IoTHubDeviceClient_LL_CreateFromConnectionString(connInfo->connectionString, MQTT_Protocol))

With these changes I am able to use ADU agent with DPS.
Note that the connection string format should be
HostName=<hub_name>;DeviceId=<registartion_id>;UseProvisioning=true

from iot-hub-device-update.

GauravChoube avatar GauravChoube commented on June 22, 2024

Hi asbarnes,
Thanks for reply
I will try above one.
but i have one problem , i getting below error after running agent code

/usr/bin/AducIotAgent: error while loading shared libraries: libcpprest.so.2.10: cannot open shared object file: No such file or directory

I have build whole code of update sdk on pi 4 ,
Do you have any idea ?

from iot-hub-device-update.

asbarnes avatar asbarnes commented on June 22, 2024

Hi,

Please check scripts/install-deps.sh. It should install cpprest.
If you are using Yocto meta-azure-device-update it is installed as part of deliveryoptimization-sdk.bb

from iot-hub-device-update.

GauravChoube avatar GauravChoube commented on June 22, 2024

Hi i have solved linking issue by using cmd

sudo ldkconfig

Here is update about implementation and problem.
i have successfully change the code of device update with device provisioning using 0x509.
Device getting register and dps got successfully by merging and linking code from dps sample directory.
but not getting mqtt error in device code.

 [I] Agent (linux; 0.6.0-public-preview) starting. [main]
2021-11-28T06:26:33.1934Z [I] Git Info: main:743bb72 [main]
2021-11-28T06:26:33.1934Z [I] Agent built with handlers: microsoft/swupdate. [main]
inside AllocateDeviceClientHandle
Provisioning API Version: 1.7.0
Info: Initiating DPS client to retrieve IoT Hub connection information
Provisioning Status: 0
Provisioning Status: 2
Registration Information received from service: devmgmtiothub.azure-devices.net!
Info: Provisioning callback indicates success.  iothubUri=devmgmtiothub.azure-devices.net, deviceId=dev_iot_001
Info: DPS successfully registered.  Continuing on to creation of IoTHub device client handle.
2021-11-28T06:26:43.5339Z [I] Initalizing PnP components. [ADUC_PnP_Components_Create]
2021-11-28T06:26:43.5339Z [I] ADUC agent started. Using IoT Hub Client SDK 1.7.0 [AzureDeviceUpdateCoreInterface_Create]
2021-11-28T06:26:43.5340Z [I] Calling ADUC_Register [ADUC_MethodCall_Register]
2021-11-28T06:26:43.5340Z [I] IoTHub Device Twin callback registered. [ADUC_DeviceClient_Create]
2021-11-28T06:26:43.5344Z [W] Failed to pass connection string to DO, error: -1 [StartupAgent]
2021-11-28T06:26:43.5344Z [I] Agent running. [main]
Error: Time:Sun Nov 28 06:26:44 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:26:44 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:26:45 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:26:47 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:26:51 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:26:59 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:27:15 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:27:45 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:28:15 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized





Error: Time:Sun Nov 28 06:28:45 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:29:16 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:29:47 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:30:18 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:30:49 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:31:19 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:31:50 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:32:19 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:32:49 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:33:19 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:33:50 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:34:21 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:34:52 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Sun Nov 28 06:35:22 2021 File:/tmp/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqttOperationCompleteCallback Line:2075 Connection Not Accepted: 0x5: Not Authorized
2021-11-28T06:35:27.2550Z [I] Agent exited with code 0 [main]
2021-11-28T06:35:27.2551Z [I] Agent is shutting down with signal 2. [ShutdownAgent]
2021-11-28T06:35:27.2551Z [I] ADUC agent stopping [AzureDeviceUpdateCoreInterface_Destroy]
2021-11-28T06:35:27.2552Z [I] Calling ADUC_Unregister [ADUC_MethodCall_Unregister]

can anyone tell me what is reason for it ?
what am i missing here ?

from iot-hub-device-update.

GauravChoube avatar GauravChoube commented on June 22, 2024

Hey,
I was my mistake that i entered all credential in code. Now updated and seem like code get connected to iot hub.
But now facing new problem as code getting stuck after subscription in agent and nothing happening after that.
Please find the attach the logs

Nov 29 04:50:03 raspberrypi systemd[1]: Stopped Azure Device Update Agent daemon..
Nov 29 04:50:03 raspberrypi systemd[1]: Started Azure Device Update Agent daemon..
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Hi This is Gaurav from agentEnter into test function sucessfully2021-11-29T04:50:03.1160Z [I] Agent (linux; 0.6.0-public-preview) starting. [main]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:03.1160Z [I] Git Info: main:743bb72 [main]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:03.1160Z [I] Agent built with handlers: microsoft/swupdate. [main]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: inside AllocateDeviceClientHandle
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Provisioning API Version: 1.7.0
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Info: Initiating DPS client to retrieve IoT Hub connection information
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Provisioning Status: 0
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Provisioning Status: 2
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Registration Information received from service: devmgmtiothub.azure-devices.net!
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Info: Provisioning callback indicates success.  iothubUri=devmgmtiothub.azure-devices.net, deviceId=dev_iot_001
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Info: DPS successfully registered.  Continuing on to creation of IoTHub device client handle.
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:14.7812Z [I] Initalizing PnP components. [ADUC_PnP_Components_Create]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:14.7813Z [I] ADUC agent started. Using IoT Hub Client SDK 1.7.0 [AzureDeviceUpdateCoreInterface_Create]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:14.7813Z [I] Calling ADUC_Register [ADUC_MethodCall_Register]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:14.7814Z [I] IoTHub Device Twin callback registered. [ADUC_DeviceClient_Create]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:14.7819Z [W] Failed to pass connection string to DO, error: -1 [StartupAgent]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:14.7819Z [I] Agent running. [main]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: -> 04:50:15 CONNECT | VER: 4 | KEEPALIVE: 240 | FLAGS: 128 | USERNAME: devmgmtiothub.azure-devices.net/dev_iot_001/?api-version=2020-09-30&DeviceClientType=iothubclient%2f1.7.0%20(native%3b%20Linux%3b%20armv7l)&model-id=dtmi%3aAzureDeviceUpdate%3b1 | CLEAN: 0
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: <- 04:50:16 CONNACK | SESSION_PRESENT: true | RETURN_CODE: 0x0
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:16.2355Z [D] IotHub connection status: 0, reason:6 [ADUC_ConnectionStatus_Callback]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: -> 04:50:16 SUBSCRIBE | PACKET_ID: 2 | TOPIC_NAME: $iothub/twin/res/# | QOS: 0
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: <- 04:50:16 SUBACK | PACKET_ID: 2 | RETURN_CODE: 0
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: -> 04:50:16 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/GET/?$rid=3
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: <- 04:50:17 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/res/200/?$rid=3 | PAYLOAD_LEN: 537
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0376Z [I] Processing existing Device Twin data after agent started. [ADUC_PnPDeviceTwin_Callback]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0376Z [D] Notifies components that all callback are subscribed. [ADUC_PnPDeviceTwin_Callback]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0377Z [I] DeviceInformation component is ready - reporting properties [DeviceInfoInterface_Connected]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0379Z [I] Property manufacturer changed to Contoso [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0380Z [I] Property model changed to Virtual-Machine [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0380Z [I] Property osName changed to Linux [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0381Z [I] Property swVersion changed to 5.10.17-v7l- [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0382Z [I] Property processorArchitecture changed to armv7l [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0628Z [I] Property processorManufacturer changed to ARM [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0630Z [I] Property totalMemory changed to 3919128 [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0631Z [I] Property totalStorage changed to 2405632 [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0633Z [I] No update content. Reporting Idle state. [ADUC_Workflow_HandleStartupWorkflowData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0634Z [I] Setting UpdateState to Idle [ADUC_SetUpdateStateHelper]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0634Z [I] Reporting state: 0, Idle (0); HTTP 200; result 1, 0 [AzureDeviceUpdateCoreInterface_ReportStateAndResultAsync]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0635Z [I] UpdateAction: Idle. WorkflowId: 211129045017 [ADUC_MethodCall_Idle]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0636Z [I] Calling IdleCallback [ADUC_MethodCall_Idle]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0636Z [I] Now idle. workflowId: 211129045017 [Idle]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: -> 04:50:17 SUBSCRIBE | PACKET_ID: 4 | TOPIC_NAME: $iothub/twin/PATCH/properties/desired/# | QOS: 0


from iot-hub-device-update.

asbarnes avatar asbarnes commented on June 22, 2024

The log says Failed to pass connection string to DO - is your connection string formatted correctly?
Is UseProvisioning=true part of your connection string?

from iot-hub-device-update.

GauravChoube avatar GauravChoube commented on June 22, 2024

Hi asbarnes,
I am not using any connection string based.
I have found the same the error also coming in out of box pi image from azure

I have attached the logs from out-of-box image

Nov 29 05:48:47 raspberrypi3 systemd[1]: Stopped ADU Client service..
Nov 29 05:48:47 raspberrypi3 systemd[1]: Started ADU Client service..
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:47.8336Z [I] Agent (linux; 0.7.0-rc1-public-preview) starting. [main]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:47.8337Z [I] Agent built with handlers: microsoft/swupdate. [main]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:47.8341Z [I] Attempting to create connection to IotHub using type: ADUC_ConnType_Device  [ADUC_DeviceClient_Create]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:47.8343Z [I] Initalizing PnP components. [ADUC_PnP_Components_Create]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:47.8344Z [I] ADUC agent started. Using IoT Hub Client SDK 1.6.0 [AzureDeviceUpdateCoreInterface_Create]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:47.8345Z [I] Calling ADUC_Register [ADUC_MethodCall_Register]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:47.8345Z [I] IoTHub Device Twin callback registered. [ADUC_DeviceClient_Create]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:47.8350Z [W] Failed to pass connection string to DO, error: -1 [StartupAgent]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:47.8351Z [I] Agent running. [main]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: -> 05:48:49 CONNECT | VER: 4 | KEEPALIVE: 240 | FLAGS: 192 | USERNAME: devmgmtiothub.azure-devices.net/dev_iot_000/?api-version=2020-09-30&DeviceClientType=iothubclient%2f1.6.0%20(native%3b%20Linux%3b%20armv7l)&model-id=dtmi%3aAzureDeviceUpdate%3b1 | PWD: XXXX | CLEAN: 0
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: <- 05:48:49 CONNACK | SESSION_PRESENT: true | RETURN_CODE: 0x0
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:49.3560Z [D] IotHub connection status: 0, reason:6 [ADUC_ConnectionStatus_Callback]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: -> 05:48:49 SUBSCRIBE | PACKET_ID: 2 | TOPIC_NAME: $iothub/twin/res/# | QOS: 0
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: <- 05:48:49 SUBACK | PACKET_ID: 2 | RETURN_CODE: 0
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: -> 05:48:49 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/GET/?$rid=3
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: <- 05:48:50 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/res/200/?$rid=3 | PAYLOAD_LEN: 537
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1584Z [I] Processing existing Device Twin data after agent started. [ADUC_PnPDeviceTwin_Callback]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1585Z [D] Notifies components that all callback are subscribed. [ADUC_PnPDeviceTwin_Callback]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1585Z [I] DeviceInformation component is ready - reporting properties [DeviceInfoInterface_Connected]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1588Z [I] Property manufacturer changed to Contoso [RefreshDeviceInfoInterfaceData]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1589Z [I] Property model changed to Virtual-Machine [RefreshDeviceInfoInterfaceData]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1590Z [I] Property osName changed to Linux [RefreshDeviceInfoInterfaceData]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1590Z [I] Property swVersion changed to 4.19.88 [RefreshDeviceInfoInterfaceData]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1591Z [I] Property processorArchitecture changed to armv7l [RefreshDeviceInfoInterfaceData]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1832Z [I] Property processorManufacturer changed to ARM [RefreshDeviceInfoInterfaceData]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1834Z [I] Property totalMemory changed to 947776 [RefreshDeviceInfoInterfaceData]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1836Z [I] Property totalStorage changed to 372615 [RefreshDeviceInfoInterfaceData]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1839Z [I] No update content. Reporting Idle state. [ADUC_Workflow_HandleStartupWorkflowData]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1839Z [I] Setting UpdateState to Idle [ADUC_SetUpdateStateHelper]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1840Z [I] Reporting state: 0, Idle (0); HTTP 200; result 1, 0 [AzureDeviceUpdateCoreInterface_ReportStateAndResultAsync]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1842Z [I] UpdateAction: Idle. WorkflowId: 211129054850 [ADUC_MethodCall_Idle]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1842Z [I] Calling IdleCallback [ADUC_MethodCall_Idle]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: 2021-11-29T05:48:50.1842Z [I] Now idle. workflowId: 211129054850 [Idle]
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: -> 05:48:50 SUBSCRIBE | PACKET_ID: 4 | TOPIC_NAME: $iothub/twin/PATCH/properties/desired/# | QOS: 0
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: -> 05:48:50 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/PATCH/properties/reported/?$rid=5 | PAYLOAD_LEN: 229
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: -> 05:48:50 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/PATCH/properties/reported/?$rid=6 | PAYLOAD_LEN: 99
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: -> 05:48:50 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/PATCH/properties/reported/?$rid=7 | PAYLOAD_LEN: 231
Nov 29 05:48:51 raspberrypi3 AducIotAgent[300]: <- 05:48:50 SUBACK | PACKET_ID: 4 | RETURN_CODE: 0

from iot-hub-device-update.

asbarnes avatar asbarnes commented on June 22, 2024

As per my understanding connection string is mandatory.
You can read about my approach for this issue here - #87 (comment)

from iot-hub-device-update.

GauravChoube avatar GauravChoube commented on June 22, 2024

Yes , saw the post and but if suppose that was case how could i connect with iot hub in my implementation.
I simply add dps sample code part to get provision where i get the huburl and device id and
i used the IoTHubDeviceClient_LL_CreateFromDeviceAuth , then its done.

from iot-hub-device-update.

asbarnes avatar asbarnes commented on June 22, 2024

I explained it in other issue. My approach is to perform the provisioning in a different program (let's say, one of azure-iot-sdk-c examples) and then call adu-agent with minimal changes:

--- a/src/agent/src/main.c
+++ b/src/agent/src/main.c
@@ -20,6 +20,8 @@
 #include <iothub.h>
 #include <iothub_client_options.h>
 #include <iothubtransportmqtt.h>
+#include <iothub_device_client_ll.h>
+#include <azure_prov_client/iothub_security_factory.h>
 
 #ifndef ADUC_PLATFORM_SIMULATOR // DO is not used in sim mode
 #    include <do_config.h>
@@ -485,8 +487,22 @@ static void ADUC_ConnectionStatus_Callback(
 _Bool ADUC_DeviceClient_Create(ADUC_ConnectionInfo* connInfo, const ADUC_LaunchArguments* launchArgs)
 {
     IOTHUB_CLIENT_RESULT iothubResult;
+    int iothubInitResult;
     bool result = true;
 
+    // Before invoking ANY IoT Hub or DPS functionality, IoTHub_Init must be invoked.
+    if ((iothubInitResult = IoTHub_Init()) != 0)
+    {
+        Log_Error("Failure to initialize client, error=%d", iothubInitResult);
+        result = false;
+    }
+
+    if (iothub_security_init(IOTHUB_SECURITY_TYPE_SAS) != 0)
+    {
+        Log_Error("iothub_security_init failed");
+        result = false;
+    }
+
     // Create a connection to IoTHub.
     if ((g_iotHubClientHandle =
              IoTHubDeviceClient_LL_CreateFromConnectionString(connInfo->connectionString, MQTT_Protocol))

from iot-hub-device-update.

GauravChoube avatar GauravChoube commented on June 22, 2024

Okay you are saying its not possible without connection string.
Can you please confirm about can we do device provisioning for agent code with the help of 0x509 certificate.
As provisioning example explain in prov_client_ll_sample.

from iot-hub-device-update.

GauravChoube avatar GauravChoube commented on June 22, 2024

@asbarnes
Hi I have successfully implemented the dps provisioning with agent code by same i have explained without using connection string. Some dps code was present for symmetric keys. Used some part of code and mixed with x509 sample code.
finally integrated with agent code.
Thank you much for support

from iot-hub-device-update.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.