Azure / azure-iot-arduino

Azure IoT library for the Arduino
Other
168 stars 95 forks source link

Question: Is it possible to extract the while(1) {} in a separate function? #57

Closed astaykov closed 7 years ago

astaykov commented 7 years ago

Hi,

this is a general question. I was wondering whether is it possible to extract the main while(){} loop into a separate function (without endless loop). The idea is to have that separate function being called from the main Arduinos loop.

End goal is to have Arduino doing more in its loop. By doing so I will avoid placing more Arduinos logic into the Azure IoT Hub related functions. For example - reading from various external sensors and sending real data. I am having hard time putting that loop into its own function. Seems like the serializer has some issues - I cannot serialize data when in another function.

The very simple sample I would like to achieve is - having my Arduinos loop in which I read sensor data and send these values to the IoT Hub. I am unable to extract such logic in its own function. Of course everything while maintaining integrity (the state of my already created model).

All of the C samples do have this XXX_run() function which contains the endless loop. Is it possible at all to achieve what I am asking?