STATIC void stab_settest_serialGet_send(void)
{
	Wilddog_Return_T res = 0;
	int i;
	serialgetsend_cnt =0;
	for(i=0;i<10;i++)
	{
		if(stab_setdata[i].setfault)
			continue;
			
		res = wilddog_getValue(stab_setdata[i].client,\
					stab_settest_serialGetValueFunc,(void*)&stab_setdata[i]);
		stab_get_requestRes(res);
		if(res>=0)
		{
			serialgetsend_cnt++;
			while(1)
			{
				if(serialgetsend_cnt == 0)
					break;
				stab_trysync();
			}
		}

	}
}
void WD_SYSTEM perform_sync(void)
{
    if(SYS_ISIN(SYS_APPLICATIONSENDING))
    {
        int m;
        u8 request_num= 1;//REQ_NUMBER;
        os_timer_disarm(&test_timer2);

        performtest_timeReset();
        for(m=0; m < request_num; m++)
        {
            performtest_timeReset();
            int res = wilddog_getValue(wilddog, test_onQueryFunc, NULL);
            performtest_getSendTime();
            if(0 == res)
                perform_count++;
            else
                g_performtest.d_send_fault++;
        }
        performtest_timeReset();
        performtest_setSysState(SYS_APPLICATIONRECV);

      
        os_timer_disarm(&test_timer2);
        os_timer_setfn(&test_timer2, (os_timer_func_t *)perform_sync2, NULL);
        os_timer_arm(&test_timer2, 1000, 0); 
      //wilddog_destroy(&wilddog);
    }
    else
    {
        wilddog_trySync();
        os_timer_setfn(&test_timer2, (os_timer_func_t *)perform_sync, NULL);        
        os_timer_arm(&test_timer2, 1000, 0);            
    }
}
STATIC int multipletest_request(MULTIPLETEST_CMD_TYPE type,
                                Wilddog_T client,Multiple_client_T *p_mul_client)
{

    Wilddog_Node_T *p_head = NULL,*p_node = NULL;
    int res = 0;
    /*Create an node which type is an object*/
    p_head = wilddog_node_createObject(NULL);

    /*Create an node which type is UTF-8 Sring*/
    p_node = wilddog_node_createUString((Wilddog_Str_T *)MULTIPLETEST_KEY,(Wilddog_Str_T *)p_mul_client->p_host);

    /*Add p_node to p_head, then p_node is the p_head's child node*/
    wilddog_node_addChild(p_head, p_node);

    p_mul_client->d_cmd= type;
    p_mul_client->d_recvFlag = 0;
    p_mul_client->d_sendFault = 1;
    switch(type)
    {
    case MULTIPLETEST_CMD_GET:
        /*Send the query method*/
        res = wilddog_getValue(client, (onQueryFunc)multiple_getValueFunc, (void*)p_mul_client);
        break;
    case MULTIPLETEST_CMD_SET:
        /*Send the set method*/
        res = wilddog_setValue(client,p_head,multiple_setValueFunc,(void*)p_mul_client);
        break;
    case MULTIPLETEST_CMD_PUSH:
        /*Send the push method*/
        res = wilddog_push(client, p_head, multiple_pushFunc, (void *)p_mul_client);
        break;
    case MULTIPLETEST_CMD_DELE:
        /*Send the remove method*/
        res = wilddog_removeValue(client, multiple_removeValueFunc, (void*)p_mul_client);
        break;
    case MULTIPLETEST_CMD_ON:
        /*Observe on*/
        res = wilddog_addObserver(client, WD_ET_VALUECHANGE, multiple_addObserverFunc, (void*)p_mul_client);
        break;
    case MULTIPLETEST_CMD_OFF:
        res = wilddog_removeObserver(client, WD_ET_VALUECHANGE);
        break;
    case MULTIPLETEST_CMD_NON:
    default:
        break;
    }
    /*Delete the node*/
    wilddog_node_delete(p_head);
    /* fautl to request then do not getValue */
    if(res >= 0)
        p_mul_client->d_sendFault = 0;

    return res;
}
int stabtest_reques(STABTEST_CMD_TYPE type,Wilddog_T client,BOOL *p_finishFlag)
{

	Wilddog_Node_T *p_head = NULL,*p_node = NULL;
	int res = 0;
    /*Create an node which type is an object*/
    p_head = wilddog_node_createObject(NULL);
    
    /*Create an node which type is UTF-8 Sring*/
    p_node = wilddog_node_createUString((Wilddog_Str_T *)STABTEST_KEY,(Wilddog_Str_T *)STABTEST_VALUE);
    
    /*Add p_node to p_head, then p_node is the p_head's child node*/
    wilddog_node_addChild(p_head, p_node);
	
    
	stab_cmd = type;
    switch(type)
    {
        case STABTEST_CMD_GET:
            /*Send the query method*/
            res = wilddog_getValue(client, (onQueryFunc)stab_getValueFunc, (void*)p_finishFlag);
            break;
        case STABTEST_CMD_SET:  
            /*Send the set method*/
            res = wilddog_setValue(client,p_head,stab_setValueFunc,(void*)p_finishFlag);
            break;
        case STABTEST_CMD_PUSH:
            /*Send the push method*/
            res = wilddog_push(client, p_head, stab_pushFunc, (void *)p_finishFlag);  
            break;
        case STABTEST_CMD_DELE:
            /*Send the remove method*/
            res = wilddog_removeValue(client, stab_removeValueFunc, (void*)p_finishFlag);
            break;
        case STABTEST_CMD_ON:
            /*Observe on*/
            res = wilddog_addObserver(client, WD_ET_VALUECHANGE, stab_addObserverFunc, (void*)p_finishFlag);
            break;
		case STABTEST_CMD_OFF:
			res = wilddog_removeObserver(client, WD_ET_VALUECHANGE);
			break;
		case STABTEST_CMD_NON:
		default:
			break;
    }
    /*Delete the node*/
    wilddog_node_delete(p_head);
    return res;
}
Example #5
0
void ramtest_handle( u8 tree_num, u8 request_num)
{
	u8 m = 0;
	Wilddog_T wilddog = 0;
	
	u8 url[64]={0};

	ramtest_init(tree_num,request_num);
    sprintf((char*)url, "coaps://c_test.wilddogio.com/ramtest/tree_%d", tree2len[tree_num]);
	
	wilddog = wilddog_initWithUrl(url);
		
	if(0 == wilddog)
	{
		return;
	}
	count = 0;
	for(m=0; m < request_num; m++)
	{
		int res = wilddog_getValue(wilddog, test_onQueryFunc, NULL);
		if(0 == res)
			count++;
		else
			d_ramtest.d_sendfalt++;
	}
	ramtest_caculate_requestQueueRam();
	while(1)
	{
		if(count == 0)
		{
			
			ramtest_printf(&d_ramtest);
			break;
		}
		ramtest_getAveragesize();
		wilddog_trySync();
	}
	wilddog_destroy(&wilddog);
	return;
void WD_SYSTEM performtest_handle
	(
	u32 delay_tm,
	const u8 *p_url,
	u32 tree_num, 
	u8 request_num
	)
{
    u8 m = 0;
    Wilddog_T wilddog = 0;
        
    performtest_init(delay_tm,tree_num,request_num);
    performtest_setSysState(SYS_HSK);

    wilddog = wilddog_initWithUrl((Wilddog_Str_T*)p_url);
    if(0 == wilddog)
    {
        return;
    }
    perform_count = 0;
    performtest_setSysState(SYS_AUTHRECV);
    performtest_timeReset();
    while(1)
    {
        wilddog_trySync();
        if(SYS_ISIN(SYS_APPLICATIONSENDING))
            break;
    }
    performtest_timeReset();
    for(m=0; m < request_num; m++)
    {
        performtest_timeReset();
        /*printf("g_performtest.d_tm_star = %ul\n", g_performtest.d_tm_star);*/
        int res = wilddog_getValue(wilddog, test_onQueryFunc, NULL);
        performtest_getSendTime();
        /*printf("g_performtest.d_tm_send = %ul\n", g_performtest.d_tm_send);*/
        if(0 == res)
            perform_count++;
        else
            g_performtest.d_send_fault++;
        /*printf("send =%d;res =%d \n",perform_count,res);*/
    }
    performtest_timeReset();
    performtest_setSysState(SYS_APPLICATIONRECV);
    while(1)
    {
        if(perform_count == 0)
        {
            //printf("break\n");
            performtest_printf(&g_performtest);
            break;
        }
#ifdef WILDDOG_PORT_TYPE_WICED
        wiced_rtos_delay_milliseconds(g_performtest.d_tm_trysync_delay);
#else
#if defined WILDDOG_PORT_TYPE_ESP
        os_delay_us(1000 * g_performtest.d_tm_trysync_delay);
#else
        usleep(g_performtest.d_tm_trysync_delay);
#endif
#endif
        wilddog_increaseTime(g_performtest.d_tm_trysync_delay);
        wilddog_trySync();
    }
    wilddog_destroy(&wilddog);
    return;
}
Example #7
0
int main(int argc, char **argv) 
{
    char url[1024];
    char value[1024];
    char keys[256];
    char host[512];    
    char authData[512];
    BOOL authFlag = FALSE;
    
    memset(url,0,sizeof(url));  
    memset(value,0,sizeof(value));
    memset(keys,0,sizeof(keys));
    memset(host,0,sizeof(host));
    memset(authData,0,sizeof(authData));
    
    int type = 0;
    int opt,i,res = 0,cnt=0,cntmax=0;
    int option_index = 0;
    BOOL isFinish = FALSE,authFinish;
    Wilddog_T wilddog = 0;
    Wilddog_Node_T * p_node = NULL,*p_head = NULL;

    static struct option long_options[] = 
    {
    
        {"auth",    required_argument, 0,  0 },
        {"value",   required_argument, 0,  0 },
        {"key",     required_argument, 0,  0 },
        {0,         0,                 0,  0 }
    };

    while((opt=getopt_long(argc,argv,"hl:",long_options,&option_index)) != -1)
    {
        switch (opt) 
        {
        case 0:
            //printf("option %s", long_options[option_index].name);
            if (optarg)
            {
                if(strcmp(long_options[option_index].name,"key")==0)
                    memcpy(keys, optarg,strlen(optarg));
                if(strcmp(long_options[option_index].name,"value")==0)
                    memcpy(value, optarg,strlen(optarg));
                if(strcmp(long_options[option_index].name,"auth")==0)
                {
                    authFlag = TRUE;
                    memcpy(authData, optarg,strlen(optarg));
                 }
            }
            break;

        case 'h':
            fprintf(stderr, \
                 "Usage: %s setAuth|getValue|setValue|push|removeValue|addObser\n"
                "\t|disSetValue|disPush|disRemove|cacelDis|offLine|onLine\n"
                "\tver -l coap://<your appid>.wilddogio.com/ [ --auth=<auth data> "
                "--key=<key>  --value=<value>]\n",
                    argv[0]);
            return 0;
        
        case 'l':
            strcpy(url, (const char*)optarg);
            getHostFromAppid(host,url);
            sprintf(&host[strlen(host)],".wilddogio.com");
            break;          
        default: /* '?' */
            fprintf(stderr, \
               "Usage: %s setAuth|getValue|setValue|push|removeValue|addObser\n"
               "\t|disSetValue|disPush|disRemove|cacelDis|offLine|onLine\n"
               "\tver -l coap://<your appid>.wilddogio.com/ [ --auth=<auth data> "
               "--key=<key>  --value=<value>]\n",
                    argv[0]);
            return 0;
        }
    }

    for (i = 0; optind < argc; i++, optind++) 
    {
        if(i == 0)
        {
            if(strcmp(argv[optind],"getValue")==0)
            {
                type= TEST_CMD_GET;
                cntmax = 0;
            }
            else if(strcmp(argv[optind],"setValue")==0)
            {
                type= TEST_CMD_SET;
                cntmax = 0;
            }
            else if(strcmp(argv[optind],"push")==0)
            {
                type=TEST_CMD_PUSH;
                cntmax = 0;
            }
            else if(strcmp(argv[optind],"removeValue")==0)
            {
                type=TEST_CMD_DELE;
                cnt =0;
            }
            else if(strcmp(argv[optind],"addObserver")==0)
            {
                type= TEST_CMD_ON;
                cntmax = 10;
            }
            else if(strcmp(argv[optind],"setAuth")==0)
            {
                type= TEST_CMD_SETAUTH;
                cntmax = 0;
            }
            else if(strcmp(argv[optind],"disSetValue")==0)
            {
                type= TEST_CMD_ONDISSET;
                cntmax = 0;
            }
            else if(strcmp(argv[optind],"disPush")==0)
            {
                type= TEST_CMD_ONDISPUSH;
                cntmax = 0;
            }
            else if(strcmp(argv[optind],"disRemove")==0)
            {
                type= TEST_CMD_ONDISREMOVE;
                cntmax = 0;
            }
            else if(strcmp(argv[optind],"cacelDis")==0)
            {
                type= TEST_CMD_CANCELDIS;
                cntmax = 0;
            }
            else if(strcmp(argv[optind],"offLine")==0)
            {
                type= TEST_CMD_OFFLINE;
                cntmax = 0;
            }
            else if(strcmp(argv[optind],"onLine")==0)
            {
                type= TEST_CMD_ONLINE;
                cntmax = 0;
            }
        }
    }
    if( !type)
    {
        printf("Usage: %s setAuth|getValue|setValue|push|removeValue|addObser\n"
                "\t|disSetValue|disPush|disRemove|cacelDis|offLine|onLine\n"
               "\tver -l coap://<your appid>.wilddogio.com/ [ --auth=<auth data> "
               "--key=<key>  --value=<value>]\n", 
               argv[0]);
        return 0;
    }

    /*Create an node which type is an object*/
    p_head = wilddog_node_createObject(NULL);
    
    /*Create an node which type is UTF-8 Sring*/
    p_node = wilddog_node_createUString((Wilddog_Str_T *)keys, \
                                        (Wilddog_Str_T *)value);
    
    /*Add p_node to p_head, then p_node is the p_head's child node*/
    wilddog_node_addChild(p_head, p_node);

    /*Init a wilddog client*/
    wilddog = wilddog_initWithUrl((Wilddog_Str_T *)url);
    if(authFlag == TRUE)
        res = wilddog_auth((u8*)host,(u8*)authData, \
                               strlen((const char *)authData),
                               auth_callback,(void*)&authFinish);
    switch(type)
    {
        case TEST_CMD_GET:
            /*Send the query method*/
            res = wilddog_getValue(wilddog, (onQueryFunc)getValue_callback, \
                                   (void*)&isFinish);
            break;
        case TEST_CMD_SET:  
            /*Send the set method*/
            res = wilddog_setValue(wilddog,p_head,setValue_callback, \
                                   (void*)&isFinish);
            break;
        case TEST_CMD_PUSH:
            /*Send the push method*/
            res = wilddog_push(wilddog, p_head, push_callback, \
                               (void *)&isFinish);  
            break;
        case TEST_CMD_DELE:
            /*Send the remove method*/
            res = wilddog_removeValue(wilddog, removeValue_callback, \
                                      (void*)&isFinish);
            break;
        case TEST_CMD_ON:
            /*Observe on*/
            res = wilddog_addObserver(wilddog, WD_ET_VALUECHANGE,\
                                      addObserver_callback, \
                                      (void*)&isFinish);
            break;
        case TEST_CMD_SETAUTH:
            wilddog_debug("TEST_CMD_SETAUTH token = %s",value);
            res = wilddog_auth((u8*)host,(u8*)value, \
                               strlen((const char *)value),
                               auth_callback,(void*)&isFinish);
        case TEST_CMD_ONDISSET:
            /*Send the remove method*/
            res = wilddog_onDisconnectSetValue(wilddog,p_head,onDis_callback, \
                                      (void*)&isFinish);
            break;
        case TEST_CMD_ONDISPUSH:
            /*Send the remove method*/
            res = wilddog_onDisconnectPush(wilddog,p_head,onDis_callback, \
                                      (void*)&isFinish);
            break;

       case TEST_CMD_ONDISREMOVE:
            /*Send the remove method*/
            res = wilddog_onDisconnectRemoveValue(wilddog, onDis_callback, \
                                      (void*)&isFinish);
            break;
        case TEST_CMD_CANCELDIS:
            /*Send the remove method*/
            res = wilddog_cancelDisconnectOperations(wilddog, onDis_callback, \
                                      (void*)&isFinish);
            break;

         case TEST_CMD_OFFLINE:
            /*Send the remove method*/
            res = wilddog_goOffline();
            break;
        case TEST_CMD_ONLINE:
            /*Send the remove method*/
            res = wilddog_goOnline();
            break;
    }
    /*Delete the node*/
    wilddog_node_delete(p_head);
    while(1)
    {
        if(TRUE == isFinish)
        {
            if(type ==  TEST_CMD_ON)
                wilddog_debug("get new data %d times! after %d times, will " \
                              "remove Observer.", cnt, cntmax);
            cnt++;
            isFinish = FALSE;
            if(cnt > cntmax)/*force break when received new data.*/
            {
                if(type ==  TEST_CMD_ON)
                {
                    wilddog_debug("off the data!");
                    /*Observe off*/
                    wilddog_removeObserver(wilddog, WD_ET_VALUECHANGE);
                }
                break;
            }
        }
        /*
         * Handle the event and callback function, it must be called in a 
         * special frequency
        */
        wilddog_trySync();
    }
    /*Destroy the wilddog clent and release the memory*/
    wilddog_destroy(&wilddog);

    return res;
}
void performtest_handle( u32 delay_tm,u8 tree_num, u8 request_num)
{
	u8 m = 0;
	Wilddog_T wilddog = 0;
    u8 url[64]={0};
	
    sprintf((char*)url, "coaps://c_test.wilddogio.com/performtest/tree_%d", tree2len[tree_num]);
	
	performtest_init(delay_tm,tree_num,request_num);
	performtest_setSysState(SYS_HSK);

	wilddog = wilddog_initWithUrl(url);
		  
	if(0 == wilddog)
	{
		return;
	}
	perform_count = 0;
	performtest_setSysState(SYS_AUTHRECV);
	performtest_star_tm();
	while(1)
	{
		wilddog_trySync();
		if(SYS_ISIN(SYS_APPLICATIONSENDING))
			break;
	}
	performtest_star_tm();
	for(m=0; m < request_num; m++)
	{
		performtest_star_tm();
		/*printf("g_performtest.d_tm_star = %ul\n", g_performtest.d_tm_star);*/
		int res = wilddog_getValue(wilddog, test_onQueryFunc, NULL);
		performtest_tm_getSend();
		/*printf("g_performtest.d_tm_send = %ul\n", g_performtest.d_tm_send);*/
				if(0 == res)
			perform_count++;
		else
			g_performtest.d_send_fault++;
		/*printf("send =%d;res =%d \n",perform_count,res);*/
	}
	performtest_star_tm();
	performtest_setSysState(SYS_APPLICATIONRECV);
	while(1)
	{
		if(perform_count == 0)
		{
			//printf("break\n");
			performtest_printf(&g_performtest);
			break;
		}
#ifdef WILDDOG_PORT_TYPE_WICED
		wiced_rtos_delay_milliseconds(g_performtest.d_tm_trysync_delay);
#else 
		usleep(g_performtest.d_tm_trysync_delay);
#endif
		wilddog_increaseTime(g_performtest.d_tm_trysync_delay);
		wilddog_trySync();
	}
	wilddog_destroy(&wilddog);
	return;
}
int demo(char* url, int* isUnConnected)
{
    BOOL isFinish = FALSE;
    Wilddog_T wilddog = 0;
    Wilddog_Node_T * p_node = NULL, *p_head = NULL, *p_node_query = NULL;

    

    p_head = wilddog_node_createObject(NULL);
    /* create a new child to "wilddog" , key is "1", value is "1" */
    p_node = wilddog_node_createUString((Wilddog_Str_T*)"led1",(Wilddog_Str_T*)"1");
    /*p_node was p_head's child  */
    wilddog_node_addChild(p_head, p_node);
    
    /*creat new a client*/
    wilddog = wilddog_initWithUrl((Wilddog_Str_T*)url);
    
    if(0 == wilddog)
    {
        wilddog_debug("new wilddog error");
        return 0;
    }
    printf("\n\t seting led1=1 to %s\n",url);
    /* expect <appId>.wilddogio.com/ has a new node "1"
     * test_onSetFunc : handle recv data while response
     * */
    wilddog_setValue(wilddog,p_head,test_onSetFunc,(void*)&isFinish);
    /* dele node */
    wilddog_node_delete(p_head);
    while(1)
    {
		if(*isUnConnected)
		{
			wilddog_debug("wlan off!");
			break;
		}
        if(TRUE == isFinish)
        {
            wilddog_debug("\tset led1=1 success!");
            break;
        }
        /*retransmitĀ”Ā¢ received and handle response
         * */
        wilddog_trySync();
    }
    
    printf("\n\t send query to %s \n",url);
    /* send query */
    wilddog_getValue(wilddog, test_onQueryFunc, (void*)(&p_node_query));
    while(1)
    {
        if(p_node_query)
        {

            printf("\t get %s data: \n",url);
            /* printf recv node as json */
            wilddog_debug_printnode(p_node_query);
            /* free p_node_query */
            wilddog_node_delete(p_node_query);
            printf("\n");
            break;
        }
        wilddog_trySync();
    }
    /* free wilddog*/
    wilddog_destroy(&wilddog);

    return 0;
}
Example #10
0
int test(char *uid)
{
	char url[1024];

	char en_key = 0;
	BOOL isFinished = FALSE;
	Wilddog_T wilddog;
	Wilddog_Handle_T s_handle;
	Wilddog_Node_T *p_head = NULL, *p_node = NULL/*, *p_snapshot = NULL*/;
	u8 value1[5] = {246,12,0,0,6};
	/*u8 value2[4] = {23,67,98,1};*/
	wFloat f = 2.3;

	Wilddog_Node_T *root;
	Wilddog_Node_T *L1c1,*L1c2;
	Wilddog_Node_T *L2c1,*L2c2,*L2c3;
	Wilddog_Node_T *L3c1,*L3c2,*L3c3,*L3c4,*L3c5;
	Wilddog_Node_T *L4c1,*L4c2,*L4c3,*L4c4,*L4c5;

	int count = 0;	
	sprintf(url,"%s%s%s",TEST_URL_HEAD,uid,TEST_URL_END);

	memset(&s_handle, 0, sizeof(s_handle));
	s_handle.isFinished = FALSE;

	printf("*******************************************\n");
	printf("First Step: Build the data tree \n");
	printf("Please press enter key to continue!\n");
	printf("*******************************************\n");
	printf("*******************************************\n");
	printf("\n\n");
	
#ifndef WILDDOG_PORT_TYPE_WICED
	while(1)
	{
		en_key= getchar();
		if(en_key == '\n')
			break;
	}
	en_key = 0;
#endif

	root = wilddog_node_createNum((Wilddog_Str_T *)"root",9999);
	L1c1 = wilddog_node_createFalse((Wilddog_Str_T *)"L1c1");
	L1c2 = wilddog_node_createTrue((Wilddog_Str_T *)"L1c2");
	L2c1 = wilddog_node_createNum((Wilddog_Str_T *)"L2c1",-10000);
	L2c2 = wilddog_node_createFloat((Wilddog_Str_T *)"L2c2",f);
	L2c3 = wilddog_node_createTrue((Wilddog_Str_T *)"L2c3");          //true
	L3c1 = wilddog_node_createBString((Wilddog_Str_T *)"L3c1",value1,sizeof(value1)/sizeof(u8));    //BString
	L3c2 = wilddog_node_createTrue((Wilddog_Str_T *)"L3c2");
	L3c3 = wilddog_node_createTrue((Wilddog_Str_T *)"L3c3");
	L3c4 = wilddog_node_createNull((Wilddog_Str_T *)"L3c4");   //NULL
	L3c5 = wilddog_node_createTrue((Wilddog_Str_T *)"L3c5");
	L4c1 = wilddog_node_createNum((Wilddog_Str_T *)"L4c1",875);//    +Num
	L4c2 = wilddog_node_createNum((Wilddog_Str_T *)"L4c2",-5693);    //   -Num
	L4c3 = wilddog_node_createFloat((Wilddog_Str_T *)"L4c3",f);     //float
	L4c4 = wilddog_node_createFalse((Wilddog_Str_T *)"L4c4");        //false
	L4c5 = wilddog_node_createUString((Wilddog_Str_T *)"L4c5",(Wilddog_Str_T *)"string");      //UString
	
	if(WILDDOG_ERR_NOERR != wilddog_node_addChild(root,L1c1))
	{
		wilddog_debug_level(WD_DEBUG_ERROR,"node add error");
	}
	if(WILDDOG_ERR_NOERR != wilddog_node_addChild(root,L1c2))
	{
		wilddog_debug_level(WD_DEBUG_ERROR,"node add error");
	}
	if(WILDDOG_ERR_NOERR != wilddog_node_addChild(L1c1,L2c1))
	{
		wilddog_debug_level(WD_DEBUG_ERROR,"node add error");
	}
	if(WILDDOG_ERR_NOERR != wilddog_node_addChild(L1c1,L2c2))
	{
		wilddog_debug_level(WD_DEBUG_ERROR,"node add error");
	}
	if(WILDDOG_ERR_NOERR != wilddog_node_addChild(L1c2,L2c3))
	{
		wilddog_debug_level(WD_DEBUG_ERROR,"node add error");
	}
	if(WILDDOG_ERR_NOERR != wilddog_node_addChild(L2c1,L3c1))
	{
		wilddog_debug_level(WD_DEBUG_ERROR,"node add error");
	}
	if(WILDDOG_ERR_NOERR != wilddog_node_addChild(L2c1,L3c2))
	{
		wilddog_debug_level(WD_DEBUG_ERROR,"node add error");
	}
	if(WILDDOG_ERR_NOERR != wilddog_node_addChild(L2c2,L3c3))
	{
		wilddog_debug_level(WD_DEBUG_ERROR,"node add error");
	}
	if(WILDDOG_ERR_NOERR != wilddog_node_addChild(L2c2,L3c4))
	{
		wilddog_debug_level(WD_DEBUG_ERROR,"node add error");
	}
	if(WILDDOG_ERR_NOERR != wilddog_node_addChild(L2c2,L3c5))
	{
		wilddog_debug_level(WD_DEBUG_ERROR,"node add error");
	}
	if(WILDDOG_ERR_NOERR != wilddog_node_addChild(L3c2,L4c1))
	{
		wilddog_debug_level(WD_DEBUG_ERROR,"node add error");
	}
	if(WILDDOG_ERR_NOERR != wilddog_node_addChild(L3c3,L4c2))
	{
		wilddog_debug_level(WD_DEBUG_ERROR,"node add error");
	}
	if(WILDDOG_ERR_NOERR != wilddog_node_addChild(L3c3,L4c3))
	{
		wilddog_debug_level(WD_DEBUG_ERROR,"node add error");
	}
	if(WILDDOG_ERR_NOERR != wilddog_node_addChild(L3c5,L4c4))
	{
		wilddog_debug_level(WD_DEBUG_ERROR,"node add error");
	}
	if(WILDDOG_ERR_NOERR != wilddog_node_addChild(L3c5,L4c5))
	{
		wilddog_debug_level(WD_DEBUG_ERROR,"node add error");
	}
	

	printf("*******************************************\n");
	printf("The data is built as below:\n");
	wilddog_debug_printnode(root);
	printf("\n");
	printf("*******************************************\n");
	printf("\n\n");


/*
	printf("*******************************************\n");
	printf("Second Step: Use the Node API to change the data tree\n");
	printf("Change the L1c1 node's key from \"L1c1\" to \"L1c1New\" \n");
	wilddog_node_setKey(L1c1,(Wilddog_Str_T *)"L1c1New");
	printf("Change the L3c1 node's value from Bytestring \"{0xf6,0x0c,0x00,0x00,0x06}\" to Bytestring \"{0x17,0x43,0x62,0x01}\"\n ");
	wilddog_node_setValue(L3c1,value2,sizeof(value2)/sizeof(u8));
	printf("Please press enter key to continue!\n");
	printf("*******************************************\n");
	printf("\n\n");

#ifndef WILDDOG_PORT_TYPE_WICED

	while(1)
	{
		en_key= getchar();
		if(en_key == '\n')
			break;
	}
	en_key = 0;
#endif

	printf("*******************************************\n");
	printf("The data tree had changed as below:\n");
	wilddog_debug_printnode(root);
	printf("\n");
	printf("*******************************************\n");
	printf("\n\n");
*/
/*
	printf("*******************************************\n");
	printf("Clone the data tree from L2c2 node\n");
	printf("Print the L2c2 data tree\n");
	p_snapshot = wilddog_node_clone(L2c2);
	wilddog_debug_printnode(p_snapshot);
	wilddog_node_delete(p_snapshot);
	printf("\n");
	printf("*******************************************\n");
	printf("\n\n");
*/

	
	/*************************************************************/
	
	wilddog = wilddog_initWithUrl((Wilddog_Str_T *)url);

	printf("*******************************************\n");
	printf("Third step: Remove the %s's data\n",uid);
	printf("Please press enter key to continue!\n");
	printf("*******************************************\n");
	printf("\n\n");
	
#ifndef WILDDOG_PORT_TYPE_WICED

	while(1)
	{
		en_key= getchar();
		if(en_key == '\n')
			break;
	}
	en_key = 0;
#endif

	wilddog_removeValue(wilddog, test_onDeleteFunc, (void*)&isFinished);
	while(1)
	{
		if(TRUE == isFinished)
		{
			wilddog_debug("remove success!");
			break;
		}
		wilddog_trySync();
	}
	isFinished = FALSE;
	/*************************************************************/

	printf("*******************************************\n");
	printf("It has removed all data in %s!\n",uid);
	printf("Please check the data on %s page\n",url);
	printf("*******************************************\n");
	printf("\n\n");


	printf("*******************************************\n");
	printf("Fourth step: Set the root node to the %s's data tree\n",uid);
	printf("Please press enter key to continue!\n");
	printf("*******************************************\n");
	printf("\n\n");

#ifndef WILDDOG_PORT_TYPE_WICED
	
	while(1)
	{
		en_key= getchar();
		if(en_key == '\n')
			break;
	}
	en_key = 0;
#endif

	wilddog_setValue(wilddog,root,test_onSetFunc,(void*)&isFinished);
	wilddog_node_delete(root);
	
	while(1)
	{
		if(TRUE == isFinished)
		{
			wilddog_debug("set success!");
			break;
		}
		wilddog_trySync();
	}

	isFinished = FALSE;
	
	printf("*******************************************\n");
	printf("It has set the data in %s!\n",uid);
	printf("Please check the data tree on %s page\n",url);
	printf("*******************************************\n");
	printf("\n\n");




/*****************************************************************/
	printf("*******************************************\n");
	printf("Fifth step: Get the %s's data\n",uid);
	printf("Please press enter key to continue!\n");
	printf("*******************************************\n");
	printf("\n\n");

#ifndef WILDDOG_PORT_TYPE_WICED

	while(1)
	{
		en_key= getchar();
		if(en_key == '\n')
			break;
	}
	en_key = 0;
#endif

	s_handle.p_node = NULL;	
	wilddog_getValue(wilddog, test_onQueryFunc, (void*)(&s_handle));
	
	while(1)
	{
		if(s_handle.isFinished)
		{
			if(s_handle.p_node)
			{
				wilddog_debug("print node:");
				wilddog_debug_printnode(s_handle.p_node);
				wilddog_node_delete(s_handle.p_node);
				s_handle.p_node= NULL;
				printf("\n");
				break;
			}
		}
		wilddog_trySync();
	}
	
	isFinished = FALSE;
	printf("*******************************************\n");
	printf("It has get the data in %s!\n",uid);
	printf("Please check the data tree!\n");
	printf("*******************************************\n");
	printf("\n\n");




/*****************************************************************/
	p_head = wilddog_node_createObject((Wilddog_Str_T *)"3");
	p_node = wilddog_node_createNum((Wilddog_Str_T *)"2",1234);
	wilddog_node_addChild(p_head, p_node);
	
	printf("*******************************************\n");
	printf("Sixth step: Build a node as \"{\"2\":1234}\"\n");
	printf("Push the new node to the %s's data tree's root node\n",uid);
	printf("Please press enter key to continue!\n");
	printf("*******************************************\n");
	printf("\n\n");

#ifndef WILDDOG_PORT_TYPE_WICED
	
	while(1)
	{
		en_key= getchar();
		if(en_key == '\n')
			break;
	}
	en_key = 0;
#endif
	
	wilddog_push(wilddog, p_head, test_onPushFunc, (void *)&isFinished);	
	wilddog_node_delete(p_head);
	
	while(1)
	{
		if(isFinished)
		{
			wilddog_debug("push success!");
			break;
		}
		wilddog_trySync();
	}

	printf("*******************************************\n");
	printf("It has pushed the data in %s!\n",uid);
	printf("Please check the data tree on %s page\n",url);
	printf("\{\"2\":1234}\" will have a parent which have a long number\n");