src/config_mqtt.c
IG_Status IG_Config_MQTT_get_topic(IG_Config * config, 
                              IG_Id id, 
                              IG_ConfigResponse * response) {

    unsigned char * topic_str = NULL;
    unsigned char xpath_str[100];

    //build xpath
    snprintf(xpath_str,100,IG_CONFIG_MQTT_TOPIC_FORMATSTRING,id);

    IG_Status rt;

    rt = IG_Config_get_node_attribute(config, xpath_str, IG_CONFIG_MQTT_TOPICNAME_VARNAME, &topic_str);
    if(rt != IG_STATUS_GOOD) {
        printf("could not get attribute '%s' from xpath '%s'",IG_CONFIG_MQTT_TOPICNAME_VARNAME, xpath_str);
        return IG_STATUS_BAD;
    }

    response->responseAmount = 1;
    response->data = (void*) topic_str;

    return IG_STATUS_GOOD;

}
//getting the appropriate topic for the id
getting the appropriate topic for the id
getting the appropriate topic for the id
IG_Status IG_Config_MQTT_get_topic(IG_Config * config, 
                              IG_Id id, 
                              IG_ConfigResponse * response) {
    unsigned char * topic_str = NULL;
    unsigned char xpath_str[100];
    snprintf(xpath_str,100,IG_CONFIG_MQTT_TOPIC_FORMATSTRING,id);
    IG_Status rt;
    rt = IG_Config_get_node_attribute(config, xpath_str, IG_CONFIG_MQTT_TOPICNAME_VARNAME, &topic_str);
    if(rt != IG_STATUS_GOOD) {
        printf("could not get attribute '%s' from xpath '%s'",IG_CONFIG_MQTT_TOPICNAME_VARNAME, xpath_str);
        return IG_STATUS_BAD;
    }
    response->responseAmount = 1;
    response->data = (void*) topic_str;
    return IG_STATUS_GOOD;
}
IG_Status IG_Config_MQTT_get_topic ( IG_Config * config , IG_Id id , IG_ConfigResponse * response ) { unsigned char * topic_str = NULL ; unsigned char xpath_str [ 100 ] ; snprintf ( xpath_str , 100 , IG_CONFIG_MQTT_TOPIC_FORMATSTRING , id ) ; IG_Status rt ; rt = IG_Config_get_node_attribute ( config , xpath_str , IG_CONFIG_MQTT_TOPICNAME_VARNAME , & topic_str ) ; if ( rt != IG_STATUS_GOOD ) { printf ( " " , IG_CONFIG_MQTT_TOPICNAME_VARNAME , xpath_str ) ; return IG_STATUS_BAD ; } response -> responseAmount = 1 ; response -> data = ( void * ) topic_str ; return IG_STATUS_GOOD ; }
getting the appropriate topic for the id
getting the appropriate topic for the id
//build xpath