azureeyemodule/app/iot/iot_interface.cpp
static void iot_loop(IOTHUB_MODULE_CLIENT_LL_HANDLE client_handle)
{
    while (true)
    {
        // Pull the next message from the mailbox queue
        IotMsg msg;
        const auto timeout_ms = 50;
        bool got_a_msg = mailbox.get_with_timeout(msg, timeout_ms);
        if (got_a_msg)
        {
            // Act on the message we just got
            switch (msg.type)
            {
                case IotMsgType::STOP_IOT:
                    stop_iot_loop(client_handle);
                    // Now return to let this thread join
                    return;
                case IotMsgType::SEND_MSG:
                    send_iot_msg(client_handle, std::move(msg.msg_channel), std::move(msg.msg_body));
                    break;
                default:
                    util::log_error("IoT loop got a type of message it does not understand.");
                    break;
            }
        }

        // The whole point of making this thread is that have to service the SDK
        // via this function every ~100ish ms.
        IoTHubModuleClient_LL_DoWork(client_handle);
    }
}
/**
 * This function runs as a forever loop, accepting messages from the API and acting on them.
 * The reason for this is that we need to call the do_work function at least once every 100ish ms,
 * and if we call it as part of our main loop, we may not meet timing, especially since the main
 * loop deals with neural network inference, which may take seconds at a time.
 */
This function runs as a forever loop, accepting messages from the API and acting on them.
The reason for this is that we need to call the do_work function at least once every 100ish ms,
and if we call it as part of our main loop, we may not meet timing, especially since the main
loop deals with neural network inference, which may take seconds at a time.
This function runs as a forever loop accepting messages from the API and acting on them . The reason for this is that we need to call the do_work function at least once every 100ish ms and if we call it as part of our main loop we may not meet timing especially since the main loop deals with neural network inference which may take seconds at a time .
static void iot_loop(IOTHUB_MODULE_CLIENT_LL_HANDLE client_handle)
{
    while (true)
    {
        IotMsg msg;
        const auto timeout_ms = 50;
        bool got_a_msg = mailbox.get_with_timeout(msg, timeout_ms);
        if (got_a_msg)
        {
            switch (msg.type)
            {
                case IotMsgType::STOP_IOT:
                    stop_iot_loop(client_handle);
                    return;
                case IotMsgType::SEND_MSG:
                    send_iot_msg(client_handle, std::move(msg.msg_channel), std::move(msg.msg_body));
                    break;
                default:
                    util::log_error("IoT loop got a type of message it does not understand.");
                    break;
            }
        }
        IoTHubModuleClient_LL_DoWork(client_handle);
    }
}
static void iot_loop ( IOTHUB_MODULE_CLIENT_LL_HANDLE client_handle ) { while ( true ) { IotMsg msg ; const auto timeout_ms = 50 ; bool got_a_msg = mailbox . get_with_timeout ( msg , timeout_ms ) ; if ( got_a_msg ) { switch ( msg . type ) { case IotMsgType :: STOP_IOT : stop_iot_loop ( client_handle ) ; return ; case IotMsgType :: SEND_MSG : send_iot_msg ( client_handle , std :: move ( msg . msg_channel ) , std :: move ( msg . msg_body ) ) ; break ; default : util :: log_error ( " " ) ; break ; } } IoTHubModuleClient_LL_DoWork ( client_handle ) ; } }
This function runs as a forever loop, accepting messages from the API and acting on them.
This function runs as a forever loop accepting messages from the API and acting on them .
// Pull the next message from the mailbox queue // Act on the message we just got // Now return to let this thread join // The whole point of making this thread is that have to service the SDK // via this function every ~100ish ms.