How to see azure iot sdk C log trace prints on a serial monitor using TI CC3235SF?

Y MRUDULA 41 Reputation points
2024-08-01T20:40:40.08+00:00

I am using the TI CC3235SF MCU (custom board) and Azure IoT SDK C (C language) to provision my gateway to Azure DPS and connect it to Azure IoTHub.

I learnt that I can set "logtrace" ON which will output the log prints to stdout.

I print my logs onto a serial monitor (like Tera Term). After setting the "logtrace" option to ON, I was expecting some print statements such as shown below.

Info: IoT Hub SDK for C, version 1.1.28
IoTHubClient_LL_SetMessageCallback...successful.
IoTHubClient_LL_SendEventAsync accepted message [0] for transmission to IoT Hub.
IoTHubClient_LL_SendEventAsync accepted message [1] for transmission to IoT Hub.
IoTHubClient_LL_SendEventAsync accepted message [2] for transmission to IoT Hub.
IoTHubClient_LL_SendEventAsync accepted message [3] for transmission to IoT Hub.
IoTHubClient_LL_SendEventAsync accepted message [4] for transmission to IoT Hub.
-> 14:36:13 CONNECT | VER: 4 | KEEPALIVE: 240 | FLAGS: 192 | USERNAME: [...] | PWD: XXXX | CLEAN: 0
<- 14:36:13 CONNACK | SESSION_PRESENT: false | RETURN_CODE: 0x3
Error: Time:Wed Nov 29 14:36:13 2017 File:/home/ldallariva/Progetti/workspace_neon/VMU-C_EM/userapps/gpl/libs/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:mqtt_operation_complete_callback Line:1339 Connection Not Accepted: 0x3: Server Unavailable

But I am unfortunately not seeing any such data even when provisioning is successful and my device connects to the IoTHub. How do I see extensive log prints? Do I need to do anything else other than setting "logtrace" option to true?

This is the print function I am using to print out my personal logs to the serial monitor via UART.

void debug(const char *format, ...)
{
    char date[20];

    va_list args;
    va_start(args, format);

    while (pthread_mutex_trylock(&printfMutex))
    {
        usleep(5000);
    }

    struct timespec tspec;
    clock_gettime(CLOCK_REALTIME, &tspec);

    unsigned int hrs = tspec.tv_sec / (60*60);
    unsigned int min = (tspec.tv_sec - hrs*60*60) / 60;
    unsigned int sec = (tspec.tv_sec - hrs*60*60 - min*60);

    sprintf(date, "[%02d:%02d:%02d.%03d] ", hrs % 24, min, sec, tspec.tv_nsec / 1000000);
    fprintf(stderr, "%s", date);

    vfprintf(stderr, format, args);
    va_end(args);

    pthread_mutex_unlock(&printfMutex);
}

Azure IoT SDK
Azure IoT SDK
An Azure software development kit that facilitates building applications that connect to Azure IoT services.
224 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.