http.c
int m2x_create_stream ( const char *device_id_ptr, const char *api_key_ptr, const char *stream_name_ptr )
{
    int ret =0;
    if( doM2X ) {
	http_info_t put_req;
	char tmp_buff[64];
	char tmp_buff2[64];
	char url[256];

	memset(&put_req, 0, sizeof(http_info_t));
	memset(tmp_buff, 0, sizeof(tmp_buff));
	memset(tmp_buff2, 0, sizeof(tmp_buff2));
	memset(url, 0, sizeof(url));

	http_init(&put_req, 0);

	sprintf(url, "http://api-m2x.att.com/v2/devices/%s/streams/%s", device_id_ptr, stream_name_ptr );
	sprintf(tmp_buff, "X-M2X-KEY:%s", api_key_ptr);

	put_req.header = http_add_field(put_req.header, tmp_buff);
	put_req.header = http_add_field(put_req.header, "Content-Type: application/json");

        if( dbg_flag & DBG_M2X ) {
            printf("\n\n\ncreate_stream\n");
            printf("JIM: %s\n", url);
            printf("JIM: %s\n",tmp_buff);
            }

        ret=http_put(&put_req, url);
        if( put_req.rx_msglen >0) {
            if( strcmp(put_req.rx_msg,"{\"status\":\"accepted\"}") &&  dbg_flag & DBG_M2X ) 
                printf("\nUNEXPECTED REPLY WAS: %s\n",put_req.rx_msg);
            }
	http_deinit(&put_req);
        }
    return ret;
}
//
// This function creates a M2X Stream if it doesn't currently exist.  
//
This function creates a M2X Stream if it doesn't currently exist.
This function creates a M2X Stream if it doesn ' t currently exist .
int m2x_create_stream ( const char *device_id_ptr, const char *api_key_ptr, const char *stream_name_ptr )
{
    int ret =0;
    if( doM2X ) {
	http_info_t put_req;
	char tmp_buff[64];
	char tmp_buff2[64];
	char url[256];
	memset(&put_req, 0, sizeof(http_info_t));
	memset(tmp_buff, 0, sizeof(tmp_buff));
	memset(tmp_buff2, 0, sizeof(tmp_buff2));
	memset(url, 0, sizeof(url));
	http_init(&put_req, 0);
	sprintf(url, "http://api-m2x.att.com/v2/devices/%s/streams/%s", device_id_ptr, stream_name_ptr );
	sprintf(tmp_buff, "X-M2X-KEY:%s", api_key_ptr);
	put_req.header = http_add_field(put_req.header, tmp_buff);
	put_req.header = http_add_field(put_req.header, "Content-Type: application/json");
        if( dbg_flag & DBG_M2X ) {
            printf("\n\n\ncreate_stream\n");
            printf("JIM: %s\n", url);
            printf("JIM: %s\n",tmp_buff);
            }
        ret=http_put(&put_req, url);
        if( put_req.rx_msglen >0) {
            if( strcmp(put_req.rx_msg,"{\"status\":\"accepted\"}") &&  dbg_flag & DBG_M2X ) 
                printf("\nUNEXPECTED REPLY WAS: %s\n",put_req.rx_msg);
            }
	http_deinit(&put_req);
        }
    return ret;
}
int m2x_create_stream ( const char * device_id_ptr , const char * api_key_ptr , const char * stream_name_ptr ) { int ret = 0 ; if ( doM2X ) { http_info_t put_req ; char tmp_buff [ 64 ] ; char tmp_buff2 [ 64 ] ; char url [ 256 ] ; memset ( & put_req , 0 , sizeof ( http_info_t ) ) ; memset ( tmp_buff , 0 , sizeof ( tmp_buff ) ) ; memset ( tmp_buff2 , 0 , sizeof ( tmp_buff2 ) ) ; memset ( url , 0 , sizeof ( url ) ) ; http_init ( & put_req , 0 ) ; sprintf ( url , " " , device_id_ptr , stream_name_ptr ) ; sprintf ( tmp_buff , " " , api_key_ptr ) ; put_req . header = http_add_field ( put_req . header , tmp_buff ) ; put_req . header = http_add_field ( put_req . header , " " ) ; if ( dbg_flag & DBG_M2X ) { printf ( " \n \n \n \n " ) ; printf ( " \n " , url ) ; printf ( " \n " , tmp_buff ) ; } ret = http_put ( & put_req , url ) ; if ( put_req . rx_msglen > 0 ) { if ( strcmp ( put_req . rx_msg , " \" \" \" \" " ) && dbg_flag & DBG_M2X ) printf ( " \n \n " , put_req . rx_msg ) ; } http_deinit ( & put_req ) ; } return ret ; }
This function creates a M2X Stream if it doesn't currently exist.
This function creates a M2X Stream if it doesn ' t currently exist .