bool AiaMqttPublish()

in ports/IoT/src/aia_iot_config.c [23:63]


bool AiaMqttPublish( AiaMqttConnectionPointer_t connection, AiaMqttQos_t qos,
                     const char* topic, size_t topicLength, const void* message,
                     size_t messageLength )
{
    if( !connection )
    {
        AiaLogError( "Null connection." );
        return false;
    }
    if( !topic )
    {
        AiaLogError( "Null topic." );
        return false;
    }
    if( !topicLength )
    {
        topicLength = strlen( topic );
    }
    if( !message )
    {
        AiaLogError( "Null message." );
        return false;
    }
    if( !messageLength )
    {
        messageLength = strlen( message );
    }
    IotMqttPublishInfo_t topicPublish = { .qos = qos,
                                          .pTopicName = topic,
                                          .topicNameLength = topicLength,
                                          .pPayload = message,
                                          .payloadLength = messageLength,
                                          .retryMs = MQTT_RETRY_TIMEOUT_MS,
                                          .retryLimit = MQTT_RETRY_LIMIT };

    AiaLogDebug( "[AiaMqttPublish] %.*s", topicLength, topic );

    /** TODO: ADSER-1400 Use non-blocking MQTT publish. */
    return IOT_MQTT_SUCCESS == IotMqtt_TimedPublish( connection, &topicPublish,
                                                     0, MQTT_TIMEOUT_MS );
}