azure-iot-sdk-c | C99 SDK for connecting devices | Azure library
kandi X-RAY | azure-iot-sdk-c Summary
kandi X-RAY | azure-iot-sdk-c Summary
The Azure IOT Hub Device SDK allows applications written in C99 or later or C++ to communicate easily with Azure IoT Hub, Azure IoT Central and to Azure IoT Device Provisioning. This repo includes the source code for the libraries, setup instructions, and samples demonstrating use scenarios. For constrained devices - where memory is measured in kilobytes and not megabytes - there are even lighter weight SDK options available. See Other Azure IoT SDKs for more.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of azure-iot-sdk-c
azure-iot-sdk-c Key Features
azure-iot-sdk-c Examples and Code Snippets
Community Discussions
Trending Discussions on azure-iot-sdk-c
QUESTION
I am able to successfully connect with a python example to my created IoT Edge. However, the same configuration does not work for my actual downstream device (ESP8266).
Downstream device (ESP8266) ConfigurationI am using the following example for the ESP8266: https://github.com/Azure/azure-iot-arduino/tree/master/examples/esp8266/iothub_ll_telemetry_sample
Added the certificate and connection string in the code:
...ANSWER
Answered 2021-Mar-24 at 14:24Finally it's working. Switched the hardware from ESP8266 to ESP32 and running (same code) without any issues.
QUESTION
Using the .Net SDK for IoT, is there a way to set the OPTION_SAS_TOKEN_LIFETIME (https://github.com/Azure/azure-iot-sdk-c/blob/master/iothub_client/inc/iothub_client_options.h#L36)?
I know I can generate the token and own the process using:
...ANSWER
Answered 2021-Mar-11 at 23:45See the related thread in github: https://github.com/Azure/azure-iot-sdk-csharp/issues/1818
"By default, if you initialize the device client using connection string, it will generate sas tokens that are valid for an hour. To override this behavior, you can implement the abstract class DeviceAuthenticationWithTokenRefresh
and pass it to the device client Create
method for initialization."
Thanks.
QUESTION
Describe the bug
DeviceClient SetMethodDefaultHandlerAsync handler is not triggered on internet disconnection instantly. It triggers after 15 to 20 minutes. Below are the logs
IoT Hub connection status Changed Status: Connected Reason: Connection_Ok Time: 3:09:15 PM +02 IoT Hub connection status Changed Status: Disconnected_Retrying Reason: Communication_Error Time: 3:26:29 PM +02
I disconnected the internet at 3:10:00 PM +02 and communication error was thrown after 16 minutes. I have created a sample code which reproduces the issue
Steps to reproduce
...ANSWER
Answered 2020-Aug-31 at 08:08As per the outcome of discussion in github: https://github.com/Azure/azure-iot-sdk-csharp/issues/1409
The SDK is relying on the OS TCP stack to inform that the disconnect has happened, and the OS can take a couple of retries before relaying this information. This might be what is causing the connection status change handler to get invoked with a 15min delay on Linux.
For Mqtt, the client does send a ping request every 75 seconds, but does not seem to be monitoring the ping response being received from the broker.
PS: This is not occurring when using Windows 10 OS
Update
Added a fix for the mqtt layer, where the sdk now monitors for a ping response and disconnects if the delay between sending a ping request and receiving a response is >30secs (this value is currently not configurable).
For the amqp implementation, the amqp library encapsulates this ping request-response logic from us; all that the device sdk does is set the IdleTimeout.
QUESTION
I am following the MS docs quickstart on creating an IoT Plug and Play device for Windows i.e Quickstart: Use a device capability model to create an IoT Plug and Play Preview device (Windows) and I'm having issues preparing the development environment.
When I get to installing the SDK with vcpkg (step 2 in preparing the dev environment section) running this command gives me an error:
...ANSWER
Answered 2020-Jul-02 at 07:54So here is the workaround...
Go to the Folder : C:\Users\satish\vcpkg\ports\azure-iot-sdk-c
- Edit the CONTROL file in any file editor, update use_prov_client as use-prov-client
- Edit the portfile.cmake file : update use_prov_client as use-prov-client
- run
.\bootstrap-vcpkg.bat
- run
.\vcpkg.exe install azure-iot-sdk-c[public-preview,use-prov-client]
Finally...
Please let us know if you need further help.
QUESTION
I have successfully managed to cross-compile the C Azure IoT SDK for a target device running embedded Linux. The instructions are here : https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/SDK_cross_compile_example.md
The next step is to get a basic application using the SDK running on the target device.
How would one go about doing this? Where are the generated libraries etc. to copy to the sysroot of the target device.
There seems to be only support for Rasberry Pi and generating a new firmware image.
...ANSWER
Answered 2020-Jun-16 at 16:43I would recommend that you use the -DCMAKE_INSTALL_PREFIX=[output path] when you generate your makefiles. Once you have run cmake and make you can then run make install which will copy the generated libraries to the location you chose. You do NOT want to install them into your host's library search path since (presumably) they are built for an incompatible architecture. Having done that the /lib directory will have the libraries that you need to use to build your application. These are static libraries (unless you chose otherwise) so they only need to be linked to your application. They do not need to be on the device. Obviously you will also need to cross compile your application.
There are a couple of things you need to look out for though. Your device will need to have the same version of OpenSSL and curl that you used when you built the SDK. These are dynamic libraries so your application would likely fail at run time if you don't take care of that since there would be a version mismatch.
There is another example of cross-compiling here: https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/Docker_SDK_Cross_Compile.md. This version also builds the prerequisite libraries and has suggestions about how you might also cross compile your application. It uses a Docker container to do this but, even if you don't want to use Docker, it may still help you with your process.
QUESTION
I am trying to cross-compile the Azure IoT SDK C for a Mips processor. Cross-compiling an older version of the same SDK using an older version of CMake (2.8.12.2) works just fine, so I doubt it's the code itself. I am guessing it's the Mips GCC compiler.
Error message:
...ANSWER
Answered 2020-Mar-30 at 18:21cmake
tries to compile an executable using "standard" (as per what cmake thinks is standard) compiler options and tries to run that executable, so to see if the compiler is working. The executable is simple, usually like int main(int argc) { return argc - 1; }
.
You can't do that when cross-compiling. Because usually you can't link a proper standard C library, you don't have printf
, or _start
or _exit
or similar, passing arguments to main
is implementation defined, or you need a linker script or you can't run cross-compiled source on host, etc... Simply: you usually can't run cross-compiled executable on host and most of the time even the compilation is hard enough to do.
The common solution is to set before project()
:
QUESTION
I'm running:
- Windows 10 Home version 1909.
- Visual Studio 2019 Pro 16.5.0. Azure
- IoT Edge Tools 1.7.0. azure-iot-sdk-c package.
- Latest version of Docker Toolbox - (it runs hello-world with no errors).
- Python, pip. iotedgehubdev 0.13.0
Did the following steps:
- Registered account on Azure
- Created free IoT hub
- Registered Edge Device
- (Not sure if it was needed) Created VM, installed Azure Runtime, registered it in IoT Hub as device from step 3.
- (Not sure if it was needed) Started registry in docker with command
docker run -d -p 5000:5000 --restart=always --name registry registry:2
- Created Win 64 Azure Module project in Visual Studio with default settings including the repository URL (localhost:5000/moduleName)
- Set up iotedgehubdev with device connection string taken from device from step 3.
- Set the module's project as startup project
- Trying to start debug
Module is built, but debugging does not start.
Output of IoT Hub in Visual Studio:
...ANSWER
Answered 2020-Apr-20 at 14:49I have reinstalled Windows to 10 Pro instead of Home which allowed me to use Docker Desktop instead of legacy Docker Toolbox solution. The issue is now fixed.
QUESTION
I am trying to use MQTT directly to connect to IOT central.
I just followed below documentation,
https://docs.microsoft.com/en-us/azure/iot-central/concepts-connectivity#connect-a-single-device
https://www.instructables.com/id/Azure-IoT-Hub-Set-Up-MQTTfx-Sigfox-Callback-and-Dr/
https://github.com/MediaTek-Labs/aws_mbedtls_mqtt/pull/9/files?short_path=04c6e90
https://docs.azure.cn/zh-cn/articles/azure-operations-guide/iot-hub/aog-iot-hub-howto-connect-with-tool-mqtt-fx (Translate to english)
Above documentation I used dps_cstr tool from github to generate connection string with SAS token from this link
https://docs.microsoft.com/en-us/azure/iot-central/tutorial-add-device#prepare-the-client-code
ANSWER
Answered 2018-Dec-19 at 21:41I have just finished a test using a MQTT.fx client connected to the Azure IoT Central. Based on the doc Using the MQTT protocol directly the password must be in the following format, see example:
QUESTION
I was facing an issue while building azure-iot-sdk-c sample code with below toolchain.cmake configuration.
...ANSWER
Answered 2019-Nov-15 at 23:30I think you need to include CMAKE_FIND_ROOT_PATH in your cross compile toolchain file. There is a working example of a cross compile of the SDK, albeit performed in a Docker container, here: https://github.com/Azure/azure-iot-sdk-c/blob/master/samples/dockerbuilds/RaspberryPi/Dockerfile. This example also builds all the prerequisites.
QUESTION
OS:Linux SDK Version : 2018-12-13 Description of the issue:
iothub_ll_telemetry_sample.c when i placed 60000 in the function ThreadAPI_Sleep(60000) works well but Tried with 120000 facing the timeout error.
cd ~/azure-iot-sdk-c/cmake/iothub_client/samples/iothub_ll_telemetry_sample $ ./iothub_ll_telemetry_sample
Console log of the issue:
Creating IoTHub Device handle Sending message 1 to IoTHub Sending message 2 to IoTHub Error: Time:Fri Dec 21 11:12:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK Sending message 3 to IoTHub Sending message 4 to IoTHub Error: Time:Fri Dec 21 11:16:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK Sending message 5 to IoTHub Error: Time:Fri Dec 21 11:18:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK Error: Time:Fri Dec 21 11:20:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK Error: Time:Fri Dec 21 11:22:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK Error: Time:Fri Dec 21 11:24:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK Error: Time:Fri Dec 21 11:26:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK
Note: In previous version you said it's resolved but here it's not working form me. Please Explain me where is the problem.
...ANSWER
Answered 2019-Jan-04 at 23:04The "LL" version of SDK functions are single threaded. When modify the code to sleep for two minutes the SDK is unable to service the socket and hence does not receive the CONNACK packet in time. The function call that services the socket is IoTHubDeviceClient_LL_DoWork
. This function should be called at a bare minimum every 100 ms and preferably more quickly than that. If you only want to send a message every two minutes the onus is upon you to keep track of the time and send your message every time it has been two minutes since your last message. You cannot simply put the thread to sleep for two minutes.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install azure-iot-sdk-c
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page