http.c
char *flow_get ( const char *flow_base_url, const char *flow_input_name, 
                 const char *flow_device_name, const char *flow_server, 
                 const char *get_cmd, char *response, int resp_size)
{
    int r;
    http_info_t get_req;
    char tmp_buff1[256];
    char url[256];

    if( dbg_flag & DBG_FLOW )
        printf("-FLOW: BASE URL: %s\n-FLOW: INPUT NAME: %s\n-FLOW: DEVICE: %s\n-FLOW: COMMAND: %s\n",
                flow_base_url, flow_input_name, flow_device_name, get_cmd);

    memset(response, 0, resp_size);
    memset(&get_req, 0, sizeof(http_info_t));
    memset(tmp_buff1, 0, sizeof(tmp_buff1));
    memset(url, 0, sizeof(url));

    http_init(&get_req, 1);

    sprintf(url, "%s/%s?serial=%s%s", flow_base_url, flow_input_name, flow_device_name, get_cmd);
    get_req.header = http_add_field(get_req.header, tmp_buff1);

    sprintf(tmp_buff1, "Host:%s", flow_server);
    get_req.header = http_add_field(get_req.header, tmp_buff1);
    get_req.header = http_add_field(get_req.header, "HTTP/1.1");
    get_req.header = http_add_field(get_req.header, "Accept: */*");

    do {
        r=http_get(&get_req, url, response);
        if (r < 0) {
            if( dbg_flag & DBG_FLOW )
                printf("-FLOW: bad response %d, wait 30- seconds\n",r);
            sleep(30);
            }
        }
    while( r );

    http_deinit(&get_req);
    return response;
}
//
// This function is called to solicit an LED command from Flow based on accelerator and temp/humid data 
//
This function is called to solicit an LED command from Flow based on accelerator and temp/humid data
This function is called to solicit an LED command from Flow based on accelerator and temp / humid data
char *flow_get ( const char *flow_base_url, const char *flow_input_name, 
                 const char *flow_device_name, const char *flow_server, 
                 const char *get_cmd, char *response, int resp_size)
{
    int r;
    http_info_t get_req;
    char tmp_buff1[256];
    char url[256];
    if( dbg_flag & DBG_FLOW )
        printf("-FLOW: BASE URL: %s\n-FLOW: INPUT NAME: %s\n-FLOW: DEVICE: %s\n-FLOW: COMMAND: %s\n",
                flow_base_url, flow_input_name, flow_device_name, get_cmd);
    memset(response, 0, resp_size);
    memset(&get_req, 0, sizeof(http_info_t));
    memset(tmp_buff1, 0, sizeof(tmp_buff1));
    memset(url, 0, sizeof(url));
    http_init(&get_req, 1);
    sprintf(url, "%s/%s?serial=%s%s", flow_base_url, flow_input_name, flow_device_name, get_cmd);
    get_req.header = http_add_field(get_req.header, tmp_buff1);
    sprintf(tmp_buff1, "Host:%s", flow_server);
    get_req.header = http_add_field(get_req.header, tmp_buff1);
    get_req.header = http_add_field(get_req.header, "HTTP/1.1");
    get_req.header = http_add_field(get_req.header, "Accept: */*");
    do {
        r=http_get(&get_req, url, response);
        if (r < 0) {
            if( dbg_flag & DBG_FLOW )
                printf("-FLOW: bad response %d, wait 30- seconds\n",r);
            sleep(30);
            }
        }
    while( r );
    http_deinit(&get_req);
    return response;
}
char * flow_get ( const char * flow_base_url , const char * flow_input_name , const char * flow_device_name , const char * flow_server , const char * get_cmd , char * response , int resp_size ) { int r ; http_info_t get_req ; char tmp_buff1 [ 256 ] ; char url [ 256 ] ; if ( dbg_flag & DBG_FLOW ) printf ( " \n \n \n \n " , flow_base_url , flow_input_name , flow_device_name , get_cmd ) ; memset ( response , 0 , resp_size ) ; memset ( & get_req , 0 , sizeof ( http_info_t ) ) ; memset ( tmp_buff1 , 0 , sizeof ( tmp_buff1 ) ) ; memset ( url , 0 , sizeof ( url ) ) ; http_init ( & get_req , 1 ) ; sprintf ( url , " " , flow_base_url , flow_input_name , flow_device_name , get_cmd ) ; get_req . header = http_add_field ( get_req . header , tmp_buff1 ) ; sprintf ( tmp_buff1 , " " , flow_server ) ; get_req . header = http_add_field ( get_req . header , tmp_buff1 ) ; get_req . header = http_add_field ( get_req . header , " " ) ; get_req . header = http_add_field ( get_req . header , " " ) ; do { r = http_get ( & get_req , url , response ) ; if ( r < 0 ) { if ( dbg_flag & DBG_FLOW ) printf ( " \n " , r ) ; sleep ( 30 ) ; } } while ( r ) ; http_deinit ( & get_req ) ; return response ; }
This function is called to solicit an LED command from Flow based on accelerator and temp/humid data
This function is called to solicit an LED command from Flow based on accelerator and temp / humid data